/api/v1/chat/completionsRequests use GlobalRouter authentication and model relations. When openrouter is selected, the provider object is forwarded to upstream OpenRouter.
Back to Chat / Text endpoint listRequest parameters
| Field | Type | Required | Description |
|---|---|---|---|
model | OpenRouterPublicModelId | Yes | GR public model ids used in request bodies. |
messages | ChatMessage[] | Yes | See the OpenAPI schema for field details. |
messages[].role | string | Yes | Allowed values: system, user, assistant, tool. |
messages[].content | string | object[] | Yes | See the OpenAPI schema for field details. |
provider | string | OpenRouterProviderRouting | No | See the OpenAPI schema for field details. |
max_tokens | integer | No | See the OpenAPI schema for field details. |
temperature | number | No | See the OpenAPI schema for field details. |
stream | boolean | No | See the OpenAPI schema for field details. |
tools | object[] | No | See the OpenAPI schema for field details. |
response_format | object | No | See the OpenAPI schema for field details. |
openrouter_metadata | object | No | See the OpenAPI schema for field details. |
Response fields
| Field | Type | Required | Description |
|---|---|---|---|
id | string | No | See the OpenAPI schema for field details. |
object | string | No | See the OpenAPI schema for field details. |
model | string | No | See the OpenAPI schema for field details. |
provider | string | No | See the OpenAPI schema for field details. |
choices | object[] | No | See the OpenAPI schema for field details. |
usage | Usage | No | usage.cost is the upstream cost fact when present, including 0. GR billing may apply local discounts when writing final cost. |
usage.prompt_tokens | integer | No | See the OpenAPI schema for field details. |
usage.completion_tokens | integer | No | See the OpenAPI schema for field details. |
usage.total_tokens | integer | No | See the OpenAPI schema for field details. |
usage.cost | number | No | usage.cost |
usage.is_byok | boolean | No | See the OpenAPI schema for field details. |
usage.cost_details | object | No | See the OpenAPI schema for field details. |
usage.prompt_tokens_details | object | No | See the OpenAPI schema for field details. |
usage.completion_tokens_details | object | No | See the OpenAPI schema for field details. |
usage.server_tool_use | object | No | See the OpenAPI schema for field details. |
openrouter_metadata | OpenRouterMetadata | No | See the OpenRouterMetadata schema. |
openrouter_metadata.provider | string | No | See the OpenAPI schema for field details. |
openrouter_metadata.generation_id | string | No | See the OpenAPI schema for field details. |
Errors
401
UNAUTHORIZEDMissing or invalid Authorization Bearer token.
403
FORBIDDENThe current API key is not authorized for this scope, model, or management capability.
422
VALIDATION_ERRORThe request body, path parameters, or query parameters do not match the endpoint schema.
Notes
- Use a GlobalRouter API key; upstream OpenRouter API keys are never exposed to tenants.
- provider is optional; an object must follow OpenRouter's native provider routing object format.
- If upstream returns usage.cost, it is the actual upstream charge; GR billing applies local discount rules to that value.