Chat Completions

Creates a model response for a chat conversation. This endpoint accepts OpenAI-compatible chat payloads and adds JoyToken routing, policy, wallet, and usage metadata around the provider call.

身份验证

AuthorizationBearer

Use Authorization: Bearer $JOY_TOKEN_API_KEY.

请求头

X-API-Keystring可选
Compatibility API key header. Prefer Authorization Bearer for new integrations.

请求

This endpoint expects an object.
messageslist of objects必需

OpenAI-compatible chat messages.

modelstring可选

Model ID. Use auto or omit to let JoyToken route automatically.

tierenum可选
JoyToken model tier.
streamboolean可选默认为 false

Return an OpenAI-compatible SSE stream when true.

temperaturedouble可选0-2
Sampling temperature forwarded to the selected provider when supported.
top_pdouble可选0-1
Nucleus sampling value forwarded to the selected provider when supported.
max_tokensinteger可选>=1
Maximum output tokens. Also participates in JoyToken billing estimation.
userstring可选

Optional end-user identifier used as route session context.

toolslist of objects可选

OpenAI-compatible tool definitions.

响应头

X-DAOE-Used-Modelstring
The final model selected by JoyToken routing.
X-DAOE-Used-Providerstring
The provider that served the request.
X-DAOE-Failoverstring
Present on streaming responses when provider failover occurred.

响应

Successful chat completion response.
idstring
objectstring
choiceslist of objects
createdlong
modelstring
usageobject
metadataobject
JoyToken routing and billing metadata appended by the gateway when available.

错误

400
Bad Request Error
401
Unauthorized Error
402
Payment Required Error
403
Forbidden Error
429
Too Many Requests Error
500
Internal Server Error