API 参考
Chat Completions API
使用 Xenodia 的 OpenAI-compatible chat endpoint 进行服务端聊天、文本生成和 agent workflow。
使用 POST /v1/chat/completions 通过 Xenodia 进行 OpenAI-compatible 聊天和 text generation。
Endpoint
POST https://api.xenodia.xyz/v1/chat/completionsAuthentication
Authorization: Bearer YOUR_LONG_TERM_KEYMinimal request
{
"model": "openai/gpt-4o-mini",
"messages": [
{
"role": "user",
"content": "Reply with OK only."
}
]
}cURL
curl -X POST "https://api.xenodia.xyz/v1/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $XENODIA_API_KEY" \
-d '{
"model": "openai/gpt-4o-mini",
"messages": [
{ "role": "system", "content": "You are a precise test assistant." },
{ "role": "user", "content": "Reply with OK only." }
],
"temperature": 0
}'Success response
{
"id": "chatcmpl-xxx",
"choices": [
{
"message": {
"role": "assistant",
"content": "OK"
}
}
],
"usage": {
"prompt_tokens": 18,
"completion_tokens": 1,
"total_tokens": 19
}
}Compatibility
Request shape 遵循 OpenAI Chat Completions。迁移时通常只需要改 base URL、API key,并从 Model Discovery 选择 Xenodia model ID。
当前 gateway response 暴露从模型响应中持久化的标准字段:id、choices[].message 和 usage。不要强依赖 object、created、choices[].index 或 choices[].finish_reason,除非你的 adapter 自己补充这些字段。
Production guidance
- 调用前先查询
/v1/models,不要硬编码未经确认的模型 ID。 - 除非 capability data 暴露,否则把 model-specific parameter 当成 optional。
- 对非幂等 workflow 保持保守 retry。
- 日志记录 request ID 和 status code,不记录 raw prompt 或 API key。