Create Chat Completion
Creates a model response from conversation history with streaming, tools, and usage accounting.
application/json
gpt-4o, gpt-4.1, gpt-5, o3, o4-mini
curl -X POST https://api.routekey.ai/v1/chat/completions \
-H "Authorization: Bearer sk-your-key" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [
{
"role": "user",
"content": "Hello from Route Key"
}
],
"stream": false
}'{
"id": "chatcmpl_xxx",
"object": "chat.completion",
"created": 0,
"model": "gpt-4o",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello!"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 8,
"completion_tokens": 3,
"total_tokens": 11
}
}curl -X POST 'https://api.routekey.ai/v1/chat/completions' \
-H 'Add Authorization: Bearer sk-your-key to the request headers.'
-H 'Content-Type: application/json'
-d '{
"model": "gpt-4o",
"messages": [
{
"role": "user",
"content": "Hello from Route Key"
}
],
"stream": false
}'Parameters
| Name | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Target model name from the Models page or model-list response. |
messages | array<object> | Yes | OpenAI-compatible chat messages for text endpoints. |
temperature | number | No | Sampling temperature. |
top_p | number | No | Nucleus sampling value. |
stream | boolean | No | Enable server-sent streaming responses when supported. |
max_tokens | integer | No | Maximum tokens for completion output. |
tools | array<object> | No | Tool definitions or function schemas supported by the selected model. |
response_format | object | No | Optional output format or response encoding. |
Response
| Name | Type | Required | Description |
|---|---|---|---|
id | string | - | Response, task, or resource ID. |
object | string | - | Response object type. |
created | integer | - | Creation timestamp. |
model | string | - | Model used for the request. |
choices | array<object> | - | Candidate model outputs. |
usage | object | - | Token usage statistics. |
Notes
- OpenAI Chat Completions
- Use the same request shape as the matching provider API when the backend channel is enabled.