GRGlobalRouter Docs
Console

Chat / POST

Create chat completion

Creates an OpenAI-style chat completion.

Endpoints

Mobile only shows the endpoint list. View parameter details and examples on desktop.

MethodEndpointDescription
POST/v1/chat/completionsCreates an OpenAI-style chat completion.
POST/v1/chat/completions

Useful for migrating projects that already use an OpenAI SDK. Requests use OpenAI-style messages, while model IDs come from the GlobalRouter catalog.

Back to Chat endpoint list

Request parameters

FieldTypeRequiredDescription
modelstringYesGlobalRouter model ID.
messagesarrayYesOpenAI-style message array containing role and content.
messages[]objectYes单条 OpenAI 风格消息。
messages[].rolestringYes消息角色,例如 system、user、assistant、tool。
messages[].contentstring | arrayNo消息文本或多模态内容片段。
messages[].namestringNo参与者名称。
messages[].tool_callsarrayNoassistant 消息中的工具调用列表。
messages[].tool_call_idstringNotool 消息对应的工具调用 ID。
providerstringNo指定 GlobalRouter Provider 偏好;这里是 GR 的 provider string,不是 OpenRouter 官方 provider object。
streambooleanNoWhen true, returns text/event-stream.
stream_optionsobjectNoStreaming options, such as include_usage.
temperaturenumberNoSampling temperature.
top_pnumberNoNucleus sampling probability.
max_completion_tokensintegerNoMaximum output token count.
max_tokensintegerNo最大输出 token 数,兼容旧请求;新请求优先使用 max_completion_tokens。
reasoningobjectNo推理models配置,例如 effort、summary 或 provider 支持的推理选项。
reasoning_effortstringNoreasoning.effort 的快捷字段;不能与 reasoning.effort 设置为不同值。
toolsarrayNoTool call definitions.
tool_choicestring | objectNoTool selection strategy, such as auto or a specific tool.
response_formatobjectNoStructured output constraints.
stopstring | string[]NoStop sequences.
userstringNoApplication-side user identifier.
_routerobjectNoGlobalRouter routing metadata, such as provider, route, or metadata.

Response fields

FieldTypeRequiredDescription
idstringYesGeneration record ID.
choicesarrayYesModel output; streaming responses include delta.
usageobjectNoToken and billing statistics.
modelstringYesActual model ID used.

Errors

401UNAUTHORIZED

Missing or invalid Authorization Bearer token.

403FORBIDDEN

The current API key is not allowed to call this scope or model.

429RATE_LIMITED

请求过快或异步任务队列已满,请降低并发或稍后重试。

Notes

  • `provider` 是 GlobalRouter 的 provider string;OpenRouter 官方 Chat Completion 文档中的同名字段是 object。