curl --request POST \
--url https://api.omnirelay.ai/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-6-luna",
"messages": [
{
"role": "system",
"content": "Answer concisely."
},
{
"role": "user",
"content": "Hello OmniRelay"
}
]
}
'{
"id": "chatcmpl-example",
"object": "chat.completion",
"created": 1790985600,
"model": "gpt-6-luna",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 5,
"total_tokens": 15
},
"cost_microusd": 30
}{
"error": {
"code": "unsupported_parameter"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "unauthorized"
}
}{
"error": {
"code": "insufficient_balance"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "model_not_allowed"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "model_unavailable"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "payload_too_large"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "rate_limited"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "model_unavailable",
"message": "The model does not exist or is disabled.",
"type": "not_found_error",
"param": "<string>"
},
"request_id": "<string>"
}{
"error": {
"code": "live_provider_not_configured"
},
"request_id": "2f6c1d0e9a"
}创建对话补全
调用已启用模型,通过 GET /v1/models 查询工具、JSON 格式、采样、推理及组合限制。能力审查覆盖全部可调用路由;新增组合依据文档,仍待逐项真实调用验证。预留费用并按可信用量结算,请关闭 SDK 自动重试。Responses 为无状态/store:false,不支持托管工具及存储引用。所有可调用路由采用参数透传(parameter_policy upstream-first);能力列表提供建议,普通 Schema 与扩展字段透传。保留原生响应与推理输出;模型服务方 400/422 拒绝释放预留,模型服务方故障、超时或断流需要对账。
curl --request POST \
--url https://api.omnirelay.ai/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-6-luna",
"messages": [
{
"role": "system",
"content": "Answer concisely."
},
{
"role": "user",
"content": "Hello OmniRelay"
}
]
}
'{
"id": "chatcmpl-example",
"object": "chat.completion",
"created": 1790985600,
"model": "gpt-6-luna",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 5,
"total_tokens": 15
},
"cost_microusd": 30
}{
"error": {
"code": "unsupported_parameter"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "unauthorized"
}
}{
"error": {
"code": "insufficient_balance"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "model_not_allowed"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "model_unavailable"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "payload_too_large"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "rate_limited"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "model_unavailable",
"message": "The model does not exist or is disabled.",
"type": "not_found_error",
"param": "<string>"
},
"request_id": "<string>"
}{
"error": {
"code": "live_provider_not_configured"
},
"request_id": "2f6c1d0e9a"
}授权
在 OmniRelay 控制台创建的 API Key。所有者确认身份后可在控制台再次查看。
请求头
本次调用的标签,以逗号分隔的 key=value,例如 client=acme,env=prod。与 API Key 的默认标签合并;同名 key 以请求体 tags 字段为准。X-OmniRelay-Tags 是同一个请求头的旧名,继续接受。
传 enabled 时,响应会附带 gateway_metadata,说明网关为本次调用做出的决定。其他值或不传此头,响应保持不变。X-OmniRelay-Metadata 是同一个请求头的旧名,继续接受。
enabled 请求体
参数透传:普通扩展字段透传,仍执行鉴权、文本/函数协议及预算结算边界。
来自 GET /v1/models 的已启用模型 ID。
"gpt-6-luna"
1 至 2000 条文本消息,遵守模型上下文约定。请求体上限 4 MiB(4194304 字节 UTF-8)。Provider-context-ceiling 分别预留输入与输出,由模型服务方验证实际上下文是否容纳。
1 - 2000 elementsShow child attributes
Show child attributes
以服务器发送事件的方式返回回复,而不是一次性返回 JSON。
仅在 stream 为 true 时生效。
Show child attributes
Show child attributes
本次调用的标签。与请求头和 Key 默认标签合并后最多 10 个。key 为 1 至 64 个字符,统一存为小写;value 为 1 至 128 个字符。两者只能包含字母、数字和 - _ . : /。以 gateway: 或 omnirelay: 开头的 key 为保留字。tags 不是对象时会被忽略。
Show child attributes
Show child attributes
{ "client": "acme", "project": "invoices" }
仅真实调用。正整数,两个输出限制字段只传一个;网关按模型要求转换字段。默认值及上限读取模型列表 limits.default_output_tokens 和 limits.output_tokens;GPT 5.4 Mini 为 64/256,多数其他已接入文本路由默认 32,000,最多 128,000(Gemini 3.1 Pro Preview 和 Gemini 3.6 Flash 为 65,536),DeepSeek V4 Pro、GLM 5.3 和 Kimi K3 为 4,096/4,096。
x >= 1仅真实调用。正整数,两个输出限制字段只传一个;网关按模型要求转换字段。默认值及上限读取模型列表 limits.default_output_tokens 和 limits.output_tokens;GPT 5.4 Mini 为 64/256,多数其他已接入文本路由默认 32,000,最多 128,000(Gemini 3.1 Pro Preview 和 Gemini 3.6 Flash 为 65,536),DeepSeek V4 Pro、GLM 5.3 和 Kimi K3 为 4,096/4,096。
x >= 1透传并由模型服务方判断,可能忽略不支持的取值;请查阅具体模型的文档建议。
0 <= x <= 2透传并由模型服务方判断,可能忽略不支持的取值;请查阅具体模型的文档建议。
0 <= x <= 1仅真实模式,且端点核验配置明确支持时可用。
-2 <= x <= 2仅真实模式,且端点核验配置明确支持时可用。
-2 <= x <= 2仅真实模式,且端点核验配置明确支持时可用。
仅真实模式,且端点核验配置明确支持时可用。
256仅真实模式。每次请求不支持生成多个补全。
1 仅真实模式且模型支持 tools 时可用。只支持 function 工具;严格工具和 JSON Schema 关键字另需支持。详见模型接入指南。
1 - 64 elementsShow child attributes
Show child attributes
模型声明 tool_choice 时可使用 auto、none 或 required。指定函数名选择还要求 capabilities.named_tool_choice。
auto, none, required 仅真实模式,且端点核验配置明确支持时可用。
透传并由模型服务方判断,可能忽略不支持的取值;请查阅具体模型的文档建议。
Show child attributes
Show child attributes
透传并由模型服务方判断,可能忽略不支持的取值;请查阅具体模型的文档建议。
文档通过 thinking_modes 声明支持;GLM 5.3 仅接受 enabled。
Show child attributes
Show child attributes
文档通过 tool_stream 声明支持;true 要求 stream:true。
响应
返回已结算用量和费用的补全,或 SSE 流。流式请求可能在 HTTP 200 后输出错误,此时不会以 [DONE] 结束。
"chatcmpl-2f6c1d0e9a"
chat.completion Unix 时间戳,单位为秒。
Show child attributes
Show child attributes
已验证模型服务方用量,缺失或不合法会阻止自动结算。Prompt 包含缓存分项,completion 包含推理。省略明细计数不会抹除 Token 用量。
Show child attributes
Show child attributes
按冻结价格、Token 分项、阶梯和折扣计算的已结算费用,单位微美元。整次费用取整后应用折扣,再向上取整。这是最终费用,不是最高预留。
仅在请求带有 X-Gateway-Metadata: enabled 时出现。同时以 gateway_metadata 和旧名 omnirelay_metadata 返回,内容相同。流式响应中随第一个数据块返回。
Show child attributes
Show child attributes
仅在请求带有 X-Gateway-Metadata: enabled 时出现。同时以 gateway_metadata 和旧名 omnirelay_metadata 返回,内容相同。流式响应中随第一个数据块返回。
Show child attributes
Show child attributes