Create a chat completion
Generate an OpenAI-compatible chat completion with messages, streaming, tools, vision, and JSON output.
POST
Creates a model response from an ordered list of conversation messages. This endpoint is the broadest compatibility choice for existing OpenAI SDK integrations.
Endpoint
Headers
API key using the format
Bearer $YELU_API_KEY.Must be
application/json.Request body
A model ID returned by
GET /v1/models.Ordered conversation messages. Each item has a
role (system, developer, user, assistant, or tool, as supported by the model) and content. Content can be text or a multimodal content array.Sampling temperature from
0 to 2. Prefer changing either temperature or top_p, not both.Nucleus sampling probability from
0 to 1.Maximum tokens the model may generate. Support and accounting of reasoning tokens are model-specific.
When
true, returns Server-Sent Events with incremental completion chunks.Streaming options. Set
include_usage to true to request a final usage chunk when supported.Up to the model’s supported number of sequences that stop generation.
Value from
-2 to 2 that adjusts reuse based on whether tokens appeared.Value from
-2 to 2 that adjusts reuse based on token frequency.Function definitions the model may call. Validate all generated arguments before execution.
Use
none, auto, required, or a named function choice when supported.Requests JSON object or JSON schema output on compatible models. See Structured output.
low, medium, or high on compatible reasoning models.A stable, non-sensitive identifier for your end user. Do not send direct personal information.
Response
Unique completion identifier.
chat.completion for non-streaming requests; streaming chunks use chat.completion.chunk.Unix timestamp for creation.
Model that produced the completion.
Generated alternatives. Each choice contains
index, an assistant message, and finish_reason such as stop, length, tool_calls, or content_filter.Token accounting, commonly
prompt_tokens, completion_tokens, and total_tokens. Additional fields can appear for supported models.Error codes
Streaming
Parse SSE completion chunks safely.
Function calling
Connect chat models to application tools.
Last modified on July 13, 2026