Send a conversation
curl "$CCSIO_BASE_URL/chat/completions" \
-H "Authorization: Bearer $CCSIO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.8-flash-next",
"messages": [{"role": "user", "content": "Say hello in one sentence."}]
}'The API keeps no conversation between calls: send the whole history in messages every time, oldest first, with the roles system, user, assistant and tool.
Parameters
| Parameter | Notes |
|---|---|
model, messages | Required. |
stream | true streams the answer as server-sent events; false or absent answers one JSON object. |
temperature, top_p, seed | Sampling, passed to the model. |
max_tokens, max_completion_tokens, stop | Where the answer ends, passed to the model. |
n, presence_penalty, frequency_penalty | Passed to the model. |
response_format | JSON output, when the model supports it. |
tools, tool_choice | Function calling, see below. |
user | Your own end-user label, passed to the model. |
A parameter the model does not support is refused by the model, and you receive its refusal as a 400.
Streaming
With "stream": true the answer is a text/event-stream. Each data: line carries one chat.completion.chunk; the stream ends with data: [DONE]. The platform always asks the model for the token counts, so the last chunk before [DONE] has empty choices and a usage object.
curl -N "$CCSIO_BASE_URL/chat/completions" \
-H "Authorization: Bearer $CCSIO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.8-flash-next",
"stream": true,
"messages": [{"role": "user", "content": "Write a haiku about the sea."}]
}'data: {"id":"chatcmpl-9b1c4e7f2a6d","object":"chat.completion.chunk","created":1792406148,"model":"qwen3.8-flash-next","choices":[{"index":0,"delta":{"role":"assistant","content":"Waves"},"finish_reason":null}]}
data: {"id":"chatcmpl-9b1c4e7f2a6d","object":"chat.completion.chunk","created":1792406148,"model":"qwen3.8-flash-next","choices":[{"index":0,"delta":{"content":" fold into foam"},"finish_reason":null}]}
data: {"id":"chatcmpl-9b1c4e7f2a6d","object":"chat.completion.chunk","created":1792406148,"model":"qwen3.8-flash-next","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: {"id":"chatcmpl-9b1c4e7f2a6d","object":"chat.completion.chunk","created":1792406148,"model":"qwen3.8-flash-next","choices":[],"usage":{"prompt_tokens":16,"completion_tokens":17,"total_tokens":33}}
data: [DONE]Tools (function calling)
Describe your functions in tools. When the model decides to call one, the answer carries the calls in choices[0].message.tool_calls; run them and send the results back as tool messages.
import os
from openai import OpenAI
client = OpenAI(
base_url=os.environ["CCSIO_BASE_URL"],
api_key=os.environ["CCSIO_API_KEY"],
)
tools = [{
"type": "function",
"function": {
"name": "get_weather",
"description": "The current weather of a city.",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
},
},
}]
completion = client.chat.completions.create(
model="qwen3.8-flash-next",
messages=[{"role": "user", "content": "What is the weather in Bogotá?"}],
tools=tools,
)
for call in completion.choices[0].message.tool_calls or []:
print(call.function.name, call.function.arguments) # get_weather {"city": "Bogotá"}Grouping requests
Send X-Session-Id with a label of your own (a conversation, a job, a ticket) to find all its requests together in the request log.