Envía una conversación
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."}]
}'La API no guarda ninguna conversación entre llamadas: envía el historial completo en messages cada vez, del mensaje más antiguo al más reciente, con los roles system, user, assistant y tool.
Parámetros
| Parámetro | Notas |
|---|---|
model, messages | Obligatorios. |
stream | true transmite la respuesta como server-sent events; false o ausente devuelve un solo objeto JSON. |
temperature, top_p, seed | Muestreo; se pasan al modelo. |
max_tokens, max_completion_tokens, stop | Dónde termina la respuesta; se pasan al modelo. |
n, presence_penalty, frequency_penalty | Se pasan al modelo. |
response_format | Salida en JSON, cuando el modelo lo admite. |
tools, tool_choice | Function calling, ver más abajo. |
user | Tu propia etiqueta del usuario final, que se pasa al modelo. |
Un parámetro que el modelo no admite lo rechaza el propio modelo, y recibes ese rechazo como un 400.
Streaming
Con "stream": true la respuesta es un text/event-stream. Cada línea data: lleva un chat.completion.chunk; el stream termina con data: [DONE]. La plataforma siempre le pide al modelo el conteo de tokens, así que el último chunk antes de [DONE] trae choices vacío y un objeto usage.
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]Herramientas (function calling)
Describe tus funciones en tools. Cuando el modelo decide llamar a una, la respuesta trae las llamadas en choices[0].message.tool_calls; ejecútalas y envía los resultados de vuelta como mensajes tool.
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á"}Agrupar solicitudes
Envía X-Session-Id con una etiqueta tuya (una conversación, un trabajo, un ticket) para encontrar todas sus solicitudes juntas en el registro de solicitudes.