"OpenAI-compatible" covers a wide range. At one end is a faithful reimplementation where existing code moves unchanged. At the other is a URL that accepts a similar JSON body and returns a similar one. Both get described the same way.
The part everyone gets right
The request body: model, messages, temperature, max tokens, and a response with choices plus usage. That the base URL is the only change is the entire commercial proposition.
from openai import OpenAI
client = OpenAI(
base_url="https://api.supesonic.com/v1",
api_key="sk-...",
)
resp = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "hi"}],
)Streaming, where implementations diverge
A faithful implementation forwards server-sent events as they arrive. A lazy one waits for the whole upstream response, then replays it as a burst of chunks. If your interface streams, test time-to-first-token and whether usage arrives on the final chunk.
Errors, which almost nobody gets right
The OpenAI error contract is specific: an HTTP status and a body with error type, code and message. Send a nonexistent model and a malformed body. You want typed errors — not HTTP 200 with a business failure in the body.
A ten-minute compatibility check
- GET /v1/models — does it list what you expect?
- A plain completion, non-streaming. Reconcile usage against the charge.
- The same request streaming. Time the first chunk.
- A nonexistent model name — expect a typed 404-class error.
- A malformed body — expect a typed 400-class error.
- A tool call if you use them — arguments parse as JSON.
- Abort a streaming request halfway and confirm the charge stops.
Our base URL is https://api.supesonic.com/v1. See the API docs.