Chat Completions
OpenAI Chat Completions 协议:请求示例与主要参数。
endpoint
POST https://api.apiruna.ai/v1/chat/completions请求示例
同一把密钥、同一份余额,切协议只需换 Base URL 与 SDK。
cURL
curl https://api.apiruna.ai/v1/chat/completions \
-H "Authorization: Bearer $APIRUNA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-opus-5-5",
"messages": [
{ "role": "user", "content": "Explain vector databases in two sentences." }
],
"temperature": 0.7,
"max_tokens": 512
}'响应
200 OK
{
"id": "chatcmpl_9f3a21c7",
"object": "chat.completion",
"created": 1789113600,
"model": "claude-opus-5-5",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "A vector database stores embeddings and finds the nearest neighbours..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 1284,
"completion_tokens": 219,
"total_tokens": 1503
}
}请求参数
| 参数 | 类型 | 说明 |
|---|---|---|
model | string | 模型 ID,例如 gpt-6.2-sol |
messages | array | 对话历史:role 与 content |
temperature | number | 随机性,取值 0 到 2 |
max_tokens | integer | 响应最大 Token 数 |
stream | boolean | 通过 SSE 流式返回,见 流式输出 |
tools | array | 用于 tool calling 的函数定义 |
响应
200 OK
{
"id": "chatcmpl_9f3a21c7",
"object": "chat.completion",
"created": 1789113600,
"model": "claude-opus-5-5",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "A vector database stores embeddings and finds the nearest neighbours..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 1284,
"completion_tokens": 219,
"total_tokens": 1503
}
}更新于 2026 年 11 月 24 日