Chat Completions
7/28/26About 1 min
Chat Completions
Create chat completions, fully compatible with OpenAI's Chat Completions API.
Endpoint
- URL:
/v1/chat/completions - Method: POST
- Auth: API Key required
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model ID, e.g., gpt-4o-mini |
messages | array | Yes | Message list |
temperature | number | No | Temperature, 0-2, default 1 |
max_tokens | integer | No | Max tokens to generate |
top_p | number | No | Nucleus sampling, 0-1 |
frequency_penalty | number | No | Frequency penalty, -2 to 2 |
presence_penalty | number | No | Presence penalty, -2 to 2 |
stream | boolean | No | Stream output, default false |
stop | array | No | Stop sequences |
n | integer | No | Number of completions, default 1 |
messages Format
{
"messages": [
{"role": "system", "content": "You are a helpful assistant"},
{"role": "user", "content": "Hello"},
{"role": "assistant", "content": "Hello! How can I help you?"},
{"role": "user", "content": "How is the weather today?"}
]
}Request Examples
Standard Request
curl https://api.quickapi.store/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "gpt-4o-mini",
"messages": [
{"role": "user", "content": "Hello"}
],
"temperature": 0.7,
"max_tokens": 1000
}'Streaming Request
curl https://api.quickapi.store/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "gpt-4o-mini",
"messages": [
{"role": "user", "content": "Hello"}
],
"stream": true
}'Response Examples
Standard Response
{
"id": "chatcmpl-xxx",
"object": "chat.completion",
"created": 1700000000,
"model": "gpt-4o-mini",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help you?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 20,
"total_tokens": 30
}
}Streaming Response
data: {"id":"chatcmpl-xxx","object":"chat.completion.chunk","created":1700000000,"model":"gpt-4o-mini","choices":[{"index":0,"delta":{"content":"Hello"},"finish_reason":null}]}
data: {"id":"chatcmpl-xxx","object":"chat.completion.chunk","created":1700000000,"model":"gpt-4o-mini","choices":[{"index":0,"delta":{"content":"!"},"finish_reason":null}]}
data: [DONE]Python Example
from openai import OpenAI
client = OpenAI(
base_url="https://api.quickapi.store/v1",
api_key="YOUR_API_KEY"
)
# Standard request
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Hello"}]
)
print(response.choices[0].message.content)
# Streaming request
for chunk in client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Hello"}],
stream=True
):
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")
