API relay: chat
Cette page est générée à partir de docs-site/openapi/relay.yaml. Son contenu est en anglais ; ne la modifiez pas à la main.
Text generation in four dialects.
POST /v1/chat/completions
Section intitulée « POST /v1/chat/completions »OpenAI Chat Completions
operationId relayChatCompletions · auth: bearerAuth
Streaming ("stream": true) answers with text/event-stream and always ends with a
chunk that carries usage (including usage.cost), then data: [DONE], whether or
not the client sets stream_options.include_usage.
Request body (required) application/json — ChatCompletionRequest
provider(RoutingPreferences) — Per-request routing wishes (OpenRouter-style). Use only the keys listed here: the Anthropic and Gemini dialects reject unknown keys with 400, and the others may ignore them. See docs/routing for the exact ranking.order(array of string) — Provider tags to try first, in this order. Matching is case-insensitive.only(array of string) — Use only these providers. 400provider_not_foundwhen none of them offers the model.ignore(array of string) — Never use these providers.sort(“price” | “latency” | “throughput”) — Rank the providers that are not named inorder. Providers with no measurement yet rank last.allow_fallbacks(boolean) —falsetogether withorder(or amodel:providerpin) restricts routing to those providers. Withoutorderor a pin it has no effect.
models(array of string) — Fallback list. The first entry that differs frommodelis tried after every provider ofmodelhas failed before the response started. One fallback model is used; further entries are ignored. The fallback is billed at its own price.usage(UsageSwitch) — Accepted and removed before the request reaches the provider. The cost is always returned; the switch exists so that clients written for other gateways keep working.include(boolean)
model(string, required) — A model slug or alias, optionally followed by:<provider tag>.messages(array of object, required)stream(boolean)max_tokens(integer)max_completion_tokens(integer)
| Status | Meaning | Body |
|---|---|---|
| 200 | A completion, or an SSE stream of chunks. | application/json OpenAIObject, text/event-stream string |
| default | Error in the OpenAI envelope (error.message, error.type, error.param, error.code). |
application/json OpenAIError |
Response 200 application/json — OpenAIObject
The provider-shaped response object of the dialect, with cost added inside its usage object.
Response 200 text/event-stream — string
POST /v1/responses
Section intitulée « POST /v1/responses »OpenAI Responses
operationId relayResponses · auth: bearerAuth
"background": true is rejected (400, param background): the gateway bills from the
response it relays. A previous_response_id is only accepted for a response that your
organisation created through the gateway (otherwise 404 previous_response_not_found),
and the follow-up request is routed to the same provider and upstream key.
Request body (required) application/json — ResponsesRequest
provider(RoutingPreferences) — Per-request routing wishes (OpenRouter-style). Use only the keys listed here: the Anthropic and Gemini dialects reject unknown keys with 400, and the others may ignore them. See docs/routing for the exact ranking.order(array of string) — Provider tags to try first, in this order. Matching is case-insensitive.only(array of string) — Use only these providers. 400provider_not_foundwhen none of them offers the model.ignore(array of string) — Never use these providers.sort(“price” | “latency” | “throughput”) — Rank the providers that are not named inorder. Providers with no measurement yet rank last.allow_fallbacks(boolean) —falsetogether withorder(or amodel:providerpin) restricts routing to those providers. Withoutorderor a pin it has no effect.
models(array of string) — Fallback list. The first entry that differs frommodelis tried after every provider ofmodelhas failed before the response started. One fallback model is used; further entries are ignored. The fallback is billed at its own price.usage(UsageSwitch) — Accepted and removed before the request reaches the provider. The cost is always returned; the switch exists so that clients written for other gateways keep working.include(boolean)
model(string, required)input(any)stream(boolean)previous_response_id(string)
| Status | Meaning | Body |
|---|---|---|
| 200 | A response object, or an SSE stream of Responses events. | application/json OpenAIObject, text/event-stream string |
| default | Error in the OpenAI envelope (error.message, error.type, error.param, error.code). |
application/json OpenAIError |
Response 200 application/json — OpenAIObject
The provider-shaped response object of the dialect, with cost added inside its usage object.
Response 200 text/event-stream — string
POST /v1/messages
Section intitulée « POST /v1/messages »Anthropic Messages
operationId relayMessages · auth: apiKeyHeader or bearerAuth
max_tokens is required, as at Anthropic. Errors use Anthropic’s envelope
({"type":"error","error":{...}}); insufficient balance is billing_error with HTTP 402,
an overloaded upstream is HTTP 529. There is no /v1/messages/count_tokens route.
Request body (required) application/json — MessagesRequest
provider(RoutingPreferences) — Per-request routing wishes (OpenRouter-style). Use only the keys listed here: the Anthropic and Gemini dialects reject unknown keys with 400, and the others may ignore them. See docs/routing for the exact ranking.order(array of string) — Provider tags to try first, in this order. Matching is case-insensitive.only(array of string) — Use only these providers. 400provider_not_foundwhen none of them offers the model.ignore(array of string) — Never use these providers.sort(“price” | “latency” | “throughput”) — Rank the providers that are not named inorder. Providers with no measurement yet rank last.allow_fallbacks(boolean) —falsetogether withorder(or amodel:providerpin) restricts routing to those providers. Withoutorderor a pin it has no effect.
models(array of string) — Fallback list. The first entry that differs frommodelis tried after every provider ofmodelhas failed before the response started. One fallback model is used; further entries are ignored. The fallback is billed at its own price.usage(UsageSwitch) — Accepted and removed before the request reaches the provider. The cost is always returned; the switch exists so that clients written for other gateways keep working.include(boolean)
model(string) — Required unlessmodelsis given, in which case its first entry is the model.max_tokens(integer, required, minimum: 1)messages(array of object, required)stream(boolean)
| Status | Meaning | Body |
|---|---|---|
| 200 | A message, or an SSE stream of Anthropic events. | application/json OpenAIObject, text/event-stream string |
| default | Error in the Anthropic envelope. | application/json AnthropicError |
Response 200 application/json — OpenAIObject
The provider-shaped response object of the dialect, with cost added inside its usage object.
Response 200 text/event-stream — string
POST /v1beta/models/{model}:generateContent
Section intitulée « POST /v1beta/models/{model}:generateContent »Gemini generateContent
operationId relayGenerateContent · auth: googApiKeyHeader or googApiKeyQuery or bearerAuth
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
model |
path | string | yes | The model, directly followed by the :method of the route. The gateway splits at the last colon, so gpt-4o-mini:azure:generateContent calls gpt-4o-mini pinned to the provider tagged azure. |
Request body (required) application/json — GenerateContentRequest
provider(RoutingPreferences) — Per-request routing wishes (OpenRouter-style). Use only the keys listed here: the Anthropic and Gemini dialects reject unknown keys with 400, and the others may ignore them. See docs/routing for the exact ranking.order(array of string) — Provider tags to try first, in this order. Matching is case-insensitive.only(array of string) — Use only these providers. 400provider_not_foundwhen none of them offers the model.ignore(array of string) — Never use these providers.sort(“price” | “latency” | “throughput”) — Rank the providers that are not named inorder. Providers with no measurement yet rank last.allow_fallbacks(boolean) —falsetogether withorder(or amodel:providerpin) restricts routing to those providers. Withoutorderor a pin it has no effect.
models(array of string) — Fallback list. The first entry that differs frommodelis tried after every provider ofmodelhas failed before the response started. One fallback model is used; further entries are ignored. The fallback is billed at its own price.usage(UsageSwitch) — Accepted and removed before the request reaches the provider. The cost is always returned; the switch exists so that clients written for other gateways keep working.include(boolean)
contents(array of object, required)
| Status | Meaning | Body |
|---|---|---|
| 200 | A GenerateContentResponse with usageMetadata.cost added. |
application/json OpenAIObject |
| default | Error in the Google envelope (error.code, error.message, error.status). |
application/json GeminiError |
Response 200 application/json — OpenAIObject
The provider-shaped response object of the dialect, with cost added inside its usage object.
POST /v1beta/models/{model}:streamGenerateContent
Section intitulée « POST /v1beta/models/{model}:streamGenerateContent »Gemini streamGenerateContent
operationId relayStreamGenerateContent · auth: googApiKeyHeader or googApiKeyQuery or bearerAuth
Without alt=sse the stream is one JSON array of GenerateContentResponse objects;
with ?alt=sse it is text/event-stream.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
model |
path | string | yes | The model, directly followed by the :method of the route. The gateway splits at the last colon, so gpt-4o-mini:azure:generateContent calls gpt-4o-mini pinned to the provider tagged azure. |
alt |
query | “sse” | no |
Request body (required) application/json — GenerateContentRequest
provider(RoutingPreferences) — Per-request routing wishes (OpenRouter-style). Use only the keys listed here: the Anthropic and Gemini dialects reject unknown keys with 400, and the others may ignore them. See docs/routing for the exact ranking.order(array of string) — Provider tags to try first, in this order. Matching is case-insensitive.only(array of string) — Use only these providers. 400provider_not_foundwhen none of them offers the model.ignore(array of string) — Never use these providers.sort(“price” | “latency” | “throughput”) — Rank the providers that are not named inorder. Providers with no measurement yet rank last.allow_fallbacks(boolean) —falsetogether withorder(or amodel:providerpin) restricts routing to those providers. Withoutorderor a pin it has no effect.
models(array of string) — Fallback list. The first entry that differs frommodelis tried after every provider ofmodelhas failed before the response started. One fallback model is used; further entries are ignored. The fallback is billed at its own price.usage(UsageSwitch) — Accepted and removed before the request reaches the provider. The cost is always returned; the switch exists so that clients written for other gateways keep working.include(boolean)
contents(array of object, required)
| Status | Meaning | Body |
|---|---|---|
| 200 | A stream of GenerateContentResponse objects. |
application/json array of OpenAIObject, text/event-stream string |
| default | Error in the Google envelope (error.code, error.message, error.status). |
application/json GeminiError |
Response 200 application/json — array of OpenAIObject
Response 200 text/event-stream — string