OpenAI Compatibility

Point your existing OpenAI client at SingularityAPI

The contract

/v1/chat/completions, /v1/responses, and /v1/images/generations speak the same request and response wire format as the OpenAI API. If your code already uses the official openai SDK, it keeps working — change the base_url and the API key, nothing else.

client = OpenAI(
base_url="https://api.singularityapi.dev/v1",
api_key="YOUR_API_KEY",
)

What differs from OpenAI

  • Unsupported parameters fail loudly. Unknown or reserved fields are rejected with a 400 invalid_request error, never silently dropped. What you send is exactly what runs.
  • max_tokens and max_completion_tokens are interchangeable on chat completions. Every chat model accepts either spelling; the gateway normalizes to the model’s canonical field and records the rewrite in the receipt’s transformed_fields. Sending both in one request is a 400. The responses surface accepts only max_output_tokens. Omit the field and the per-model default applies — see the table on Models & Pricing.
  • model must be a catalog slug or contract/{slug}. See Contracts for how contract slugs resolve to a served model.
  • Duplicate JSON keys and NaN/Infinity literals are rejected with a 400.
  • Context overflow is rejected before any tokens are spent. If your estimated input plus the requested output limit exceeds the model’s context window, the request fails with a 400.
  • Three extra response headers appear on every response: x-singularity-request-id, x-singularity-receipt-id, and — on contract calls — x-singularity-contract-revision.

Everything else in the OpenAI request schema passes through unmodified to the model.