Create chat completion
post/v1/chat/completions
Create a model response from a conversation history. Streaming and non-streaming responses are both supported.
Compatible with the OpenAI Chat Completions API.
Authentication
Send your OLETOKEN API key as a Bearer token. Keys are created on the API Keys page of the console.
Authorization: Bearer $OLETOKEN_API_KEYRequest body
Content-Type:application/json
| Field | Type | Required | Description |
|---|---|---|---|
| model | string | Model ID | |
| messages | Message[] | The conversation messages | |
| role | stringsystemuserassistanttooldeveloper | Message role | |
| content | string | MessageContent[] | Message content | |
| type | stringtextimage_urlinput_audiofilevideo_url | — | — |
| text | string | — | — |
| image_url | object | — | — |
| url | string | — | Image URL or base64 data |
| detail | stringlowhighauto | — | — |
| input_audio | object | — | — |
| data | string | — | Base64-encoded audio data |
| format | stringwavmp3 | — | — |
| file | object | — | — |
| filename | string | — | — |
| file_data | string | — | — |
| file_id | string | — | — |
| video_url | object | — | — |
| url | string | — | — |
| name | string | — | Sender name |
| tool_calls | ToolCall[] | — | — |
| id | string | — | — |
| type | string | — | — |
| function | object | — | — |
| name | string | — | — |
| arguments | string | — | — |
| tool_call_id | string | — | Tool call ID (for messages with the tool role) |
| reasoning_content | string | — | Reasoning content |
| temperature | number0–2default: 1 | — | Sampling temperature |
| top_p | number0–1default: 1 | — | Nucleus sampling parameter |
| n | integer≥ 1default: 1 | — | Number of completions to generate |
| stream | booleandefault: false | — | Whether to stream the response |
| stream_options | object | — | — |
| include_usage | boolean | — | — |
| stop | string | string[] | — | Stop sequences |
| max_tokens | integer | — | Maximum number of tokens to generate |
| max_completion_tokens | integer | — | Maximum number of completion tokens |
| presence_penalty | number-2–2default: 0 | — | — |
| frequency_penalty | number-2–2default: 0 | — | — |
| logit_bias | object | — | — |
| user | string | — | — |
| tools | Tool[] | — | — |
| type | string | — | — |
| function | object | — | — |
| name | string | — | — |
| description | string | — | — |
| parameters | object | — | Parameter definitions in JSON Schema format |
| tool_choice | string | objectnoneautorequired | — | — |
| type | string | — | — |
| function | object | — | — |
| name | string | — | — |
| response_format | ResponseFormat | — | — |
| type | stringtextjson_objectjson_schema | — | — |
| json_schema | object | — | JSON Schema definition |
| seed | integer | — | — |
| reasoning_effort | stringlowmediumhigh | — | Reasoning effort (for models that support reasoning) |
| modalities | string[] | — | — |
| audio | object | — | — |
| voice | string | — | — |
| format | string | — | — |
Responses
200Response created
| Field | Type | Required | Description |
|---|---|---|---|
| id | string | — | — |
| object | string | — | — |
| created | integer | — | — |
| model | string | — | — |
| choices | object[] | — | — |
| index | integer | — | — |
| message | Message | — | — |
| role | stringsystemuserassistanttooldeveloper | Message role | |
| content | string | MessageContent[] | Message content | |
| type | stringtextimage_urlinput_audiofilevideo_url | — | — |
| text | string | — | — |
| image_url | object | — | — |
| url | string | — | Image URL or base64 data |
| detail | stringlowhighauto | — | — |
| input_audio | object | — | — |
| data | string | — | Base64-encoded audio data |
| format | stringwavmp3 | — | — |
| file | object | — | — |
| filename | string | — | — |
| file_data | string | — | — |
| file_id | string | — | — |
| video_url | object | — | — |
| url | string | — | — |
| name | string | — | Sender name |
| tool_calls | ToolCall[] | — | — |
| id | string | — | — |
| type | string | — | — |
| function | object | — | — |
| name | string | — | — |
| arguments | string | — | — |
| tool_call_id | string | — | Tool call ID (for messages with the tool role) |
| reasoning_content | string | — | Reasoning content |
| finish_reason | stringstoplengthtool_callscontent_filter | — | — |
| usage | Usage | — | — |
| prompt_tokens | integer | — | Number of prompt tokens |
| completion_tokens | integer | — | Number of completion tokens |
| total_tokens | integer | — | Total number of tokens |
| prompt_tokens_details | object | — | — |
| cached_tokens | integer | — | — |
| text_tokens | integer | — | — |
| audio_tokens | integer | — | — |
| image_tokens | integer | — | — |
| completion_tokens_details | object | — | — |
| text_tokens | integer | — | — |
| audio_tokens | integer | — | — |
| reasoning_tokens | integer | — | — |
| system_fingerprint | string | — | — |
400Invalid request parameters
| Field | Type | Required | Description |
|---|---|---|---|
| error | object | — | — |
| message | string | — | Error message |
| type | string | — | Error type |
| param | string | null | — | The parameter involved |
| code | string | null | — | Error code |
429Rate limit exceeded
| Field | Type | Required | Description |
|---|---|---|---|
| error | object | — | — |
| message | string | — | Error message |
| type | string | — | Error type |
| param | string | null | — | The parameter involved |
| code | string | null | — | Error code |
Example request
curl -X POST 'https://api.oletoken.ai/v1/chat/completions' \
-H "Authorization: Bearer $OLETOKEN_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "gpt-4",
"messages": []
}'
