The OpenAI Chat Completions contract, for drop-in use with the OpenAI SDKs — point a stock client at the base URL https://gateway.roadie.paroaria.ai/openai/v1 with a Roadie key. Requests are translated to the unified contract and flow through the same routing, fallback, metering, and enforcement as the native POST /v1/chat; only the wire shape at the edge differs.

Authentication

Authenticated with a secret key (rd_sk_…) or a client token (carrying the ai.chat scope). A publishable key is rejected 403.

Request body

The standard OpenAI Chat Completions body. The gateway reads the fields below and safely ignores unknown ones.
Translation details: developersystem (message name is dropped); a string user becomes the end-user id; the platform-native fields metadata and provider_options are not part of this surface — use the native /v1/chat endpoint for those.

Model resolution

The model you send is resolved deterministically: a project alias (e.g. smart) passes through; a qualified provider/model (e.g. openai/gpt-4o) passes through; a bare OpenAI name (e.g. gpt-4o) resolves to openai/<name> when it is in your catalog, otherwise to a unique catalog entry with that native id. A bare name that matches more than one provider fails 400 (model_ambiguous) — send a qualified id instead.

Example

Response

200 OK — an OpenAI chat.completion:
model echoes the string you sent (never the internal provider/model). A tool-only turn carries content: null and a tool_calls array. usage may include prompt_tokens_details.cached_tokens and completion_tokens_details.reasoning_tokens. The gateway request id is available both as the X-Request-Id response header and inside the completion id (chatcmpl-<request_id>).

Streaming

With stream: true, the response is text/event-stream — a sequence of chat.completion.chunk frames terminated by data: [DONE]:
The first chunk is role-only; content and tool-call deltas map 1:1; the terminal chunk carries finish_reason with an empty delta. When stream_options.include_usage is set, a final chunk with choices: [] and a usage block precedes [DONE]. A mid-stream failure is delivered as a data: { "error": … } frame with no [DONE].

Idempotency

Send Idempotency-Key: <unique-id> on a non-streaming request; a retry with the same key and body replays the stored response without re-executing or re-metering (the OpenAI SDKs set this automatically).

Errors

Errors use the OpenAI envelope, which the OpenAI SDKs deserialize into their typed error classes:
The Roadie error taxonomy is mapped onto OpenAI’s type/code while keeping the HTTP status the SDK uses to pick its error class: Rate-limit, quota, and budget responses carry a Retry-After header.