API Reference

/v1/chat/completions

Endpoint principal de chat. Compatible con la API de OpenAI v1: mensajes, streaming, tools, response_format. Modelo por defecto: `Qwen/Qwen3.6-35B-A3B`.

Resumen

Crea un completion conversacional a partir de una lista de mensajes con roles (`system`, `user`, `assistant`, `tool`). Soporta streaming SSE, tool calling paralelo y `response_format=json_object` o `json_schema` para salidas estructuradas.

Endpoint y modelo

POST `https://api.tesseraai.cloud/v1/chat/completions`. El identificador de modelo en el campo `model` es el literal `Qwen/Qwen3.6-35B-A3B`.

  • Contexto: 32 K por defecto, hasta 128 K configurable en tier Scale, hasta 256 K nativo en Enterprise.
  • Modos `direct` y `thinking` disponibles. Conmutador real: campo `chat_template_kwargs.enable_thinking` en el body (vía `extra_body` con el SDK de OpenAI). El parámetro `reasoning_effort` de OpenAI no se traduce — pasa el flag explícitamente. Detalles en /docs/conceptos/direct-vs-thinking.
  • Streaming: añade `"stream": true`. Devuelve eventos SSE compatibles con OpenAI.

Request

POST /v1/chat/completions
curl https://api.tesseraai.cloud/v1/chat/completions \
  -H "Authorization: Bearer $TESSERA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "Qwen/Qwen3.6-35B-A3B",
    "messages": [
      {"role": "system", "content": "Eres un asistente conciso."},
      {"role": "user", "content": "Resume Cervantes en una frase."}
    ],
    "temperature": 0.3,
    "max_tokens": 200
  }'

Response

Estructura idéntica a OpenAI: `id`, `object`, `created`, `model`, `choices[].message.content`, `usage.prompt_tokens` / `completion_tokens` / `total_tokens`.

Respuesta (no-streaming)
{
  "id": "chatcmpl-...",
  "object": "chat.completion",
  "created": 1730812345,
  "model": "Qwen/Qwen3.6-35B-A3B",
  "choices": [{
    "index": 0,
    "message": {"role": "assistant", "content": "..."},
    "finish_reason": "stop"
  }],
  "usage": {"prompt_tokens": 24, "completion_tokens": 41, "total_tokens": 65}
}

Streaming, tools y JSON estructurado

  • `"stream": true` activa SSE; el cliente recibe `chat.completion.chunk` events hasta el `[DONE]` final.
  • `tools` y `tool_choice` siguen el formato OpenAI v1 — ver /docs/conceptos/tools-function-calling.
  • `response_format: {"type": "json_object"}` para JSON libre; `{"type": "json_schema", "json_schema": {...}}` para JSON estructurado validado.