Chat Completions API
POST /v1/chat/completions is the most commonly used endpoint for multi-turn conversations with language models.
Requestâ
POST https://real200.com/v1/chat/completions
Headersâ
| Header | Type | Required | Description |
|---|---|---|---|
Authorization | string | Yes | Bearer sk-real200-xxx |
Content-Type | string | Yes | application/json |
Body Parametersâ
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
model | string | Yes | - | Model name, e.g., gpt-4o, claude-sonnet-4 |
messages | array | Yes | - | Conversation message list |
temperature | number | No | 1.0 | Randomness, range 0â2 |
top_p | number | No | 1.0 | Nucleus sampling threshold |
max_tokens | integer | No | Model default | Maximum generation tokens |
stream | boolean | No | false | Enable streaming output |
Example Requestâ
curl https://real200.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $REAL200_API_KEY" \
-d '{
"model": "gpt-4o",
"messages": [
{"role": "user", "content": "Introduce yourself in three sentences."}
],
"temperature": 0.7,
"max_tokens": 200
}'
Responseâ
Non-Streaming Responseâ
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1716300000,
"model": "gpt-4o",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "I am an AI assistant..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 45,
"total_tokens": 57
}
}
Streaming Responseâ
When stream: true is enabled, responses are returned in text/event-stream format.
Error Codesâ
| HTTP Status | Error Type | Description |
|---|---|---|
| 400 | invalid_request_error | Request parameter error |
| 401 | invalid_api_key | Invalid API Key |
| 402 | insufficient_quota | Insufficient balance or quota |
| 429 | rate_limit_exceeded | Request rate limit exceeded |
| 500 | api_error | Server error |