Skip to main content
POST

Request body

string
required
Model ID to use. See available models.
array
required
Array of message objects with role and content, forwarded to the model as sent.
  • role: "system", "user", "assistant", or "tool" (a tool result)
  • content: the message text, or an array of content parts (for example image_url parts on a vision model). See Tool calling.
number
Sampling temperature (0-2). Lower = more focused, higher = more creative. Kyma sets no default: when omitted, the model’s own default applies.
number
Maximum tokens to generate in the response. When omitted, the model’s own default applies. If your balance cannot pay for all of them, Kyma lowers the value and says so in the x-kyma-max-tokens-clamped response header (see Response headers).
boolean
default:"false"
Stream response tokens as server-sent events.
number
Nucleus sampling parameter (0-1). When omitted, the model’s own default applies.
array
Tool definitions, OpenAI format. On models with supports_tools: true in GET /v1/models. Pair with tool_choice.
object
{"type": "json_object"} or a json_schema, on models with supports_structured_outputs: true. See Structured outputs.
Other OpenAI parameters (stop, seed, stream_options, …) are forwarded to the model as sent. Kyma drops store and metadata. reasoning_effort and reasoning reach some models and are dropped for others.

Response

usage.cost is what the call cost you in USD; usage.cache_discount is what prompt caching saved on it.

Response headers

Status codes

Every error body has a string error.code, a category in error.type, error.retryable and error.request_id (same as the x-request-id header). Branch on error.code; each code links to its entry on Errors. A 402 is always about money or catalog access, never a problem on our side. Every 402 body carries need_usd and have_usd (on insufficient_credits), balance, required, topup_url, details and topup next to error. GET /v1/models publishes free_tier on every model, so a never-funded key can tell in advance which models it may call. Full bodies: Error Handling. When all routes for a model are exhausted, you get 503 with Retry-After and:
Retry the same request, or send it to another model; the catalog is at GET /v1/models. If a stream fails after it started, the HTTP status is already 200: the last chunk has finish_reason: "error" and error.code: "stream_interrupted". Retry the whole request. See Errors while streaming.