API Reference
ChatCompletions Format
Creates model responses based on chat history. Supports streaming and non-streaming responses.
Compatible with OpenAI Chat Completions API.
POST
/r1/chat/completionsAuthorization
BearerAuth
AuthorizationBearer <token>使用 Bearer Token 认证。 格式: Authorization: Bearer sk-xxxxxx
In: header
Request Body
application/json
model*string模型 ID
messages*对话消息列表
temperature?number采样温度
top_p?number核采样参数
n?integer生成数量
stream?boolean是否流式响应
stream_options?stop?string |停止序列
max_tokens?integer最大生成 Token 数
max_completion_tokens?integer最大补全 Token 数
presence_penalty?numberfrequency_penalty?numberlogit_bias?user?stringtools?tool_choice?string |response_format?seed?integerreasoning_effort?string推理强度 (用于支持推理的模型)
modalities?array<string>audio?Response Body
curl -X POST "https://ai-tokens.space/r1/chat/completions" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-4", "messages": [ { "role": "system", "content": "string" } ] }'{
"id": "string",
"object": "chat.completion",
"created": 0,
"model": "string",
"choices": [
{
"index": 0,
"message": {
"role": "system",
"content": "string",
"name": "string",
"tool_calls": [
{
"id": "string",
"type": "function",
"function": {
"name": "string",
"arguments": "string"
}
}
],
"tool_call_id": "string",
"reasoning_content": "string"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 0,
"prompt_tokens_details": {
"cached_tokens": 0,
"text_tokens": 0,
"audio_tokens": 0,
"image_tokens": 0
},
"completion_tokens_details": {
"text_tokens": 0,
"audio_tokens": 0,
"reasoning_tokens": 0
}
},
"system_fingerprint": "string"
}{
"error": {
"message": "string",
"type": "string",
"param": "string",
"code": "string"
}
}{
"error": {
"message": "string",
"type": "string",
"param": "string",
"code": "string"
}
}