ChatCompletions Format
Create a model response from conversation history. Supports streaming and non-streaming. Compatible with OpenAI Chat Completions API.
Note: Full path: POST /v1/chat/completions. OpenAI SDK base_url must include /v1.
Example model
Examples below use gpt-4 (GPT-4). Replace model and adjust size, quality, etc. per console docs when switching models.
Create chat completion
POST
https://token.easyapi.com/v1/chat/completionsCreate a model response from conversation history. Compatible with OpenAI Chat Completions API; supports streaming and non-streaming.
Request parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
Authorization | header | string | Yes | EasyAPI API Key. Format: Bearer `API_KEY` |
Content-Type | header | string | Yes | Request body format, always application/json |
Request body
| Name | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model ID |
messages | array<object> | Yes | Conversation message list |
temperature | number | No | Sampling temperature, default 1, range 0–2 |
top_p | number | No | Nucleus sampling, default 1, range 0–1 |
n | integer | No | Number of completions, default 1, must be ≥ 1 |
stream | boolean | No | Stream responses, default false |
stream_options | object | No | Extra options for streaming |
stop | string | array<string> | No | Stop sequence(s), string or string array |
max_tokens | integer | No | Max tokens to generate |
max_completion_tokens | integer | No | Max completion tokens |
presence_penalty | number | No | Presence penalty, default 0, range -2–2 |
frequency_penalty | number | No | Frequency penalty, default 0, range -2–2 |
logit_bias | object | No | Bias specific token probabilities |
user | string | No | End-user identifier for abuse monitoring |
tools | array<object> | No | Tool definitions the model may call |
tool_choice | string | object | No | Tool choice strategy, string or object |
response_format | object | No | Response format, e.g. JSON Schema |
seed | integer | No | Seed for best-effort reproducibility |
reasoning_effort | string | No | medium |
modalities | array<string> | No | Output modalities, e.g. text, audio |
audio | object | No | Audio output configuration |
Example
{
"model": "gpt-4",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello!"
}
],
"temperature": 0.7,
"stream": false
}Response example
{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1718452800,
"model": "gpt-4",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 20,
"completion_tokens": 12,
"total_tokens": 32,
"prompt_tokens_details": {
"cached_tokens": 0,
"text_tokens": 20,
"audio_tokens": 0,
"image_tokens": 0
},
"completion_tokens_details": {
"text_tokens": 12,
"audio_tokens": 0,
"reasoning_tokens": 0
}
},
"system_fingerprint": "fp_abc123"
}