Skip to main content
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

Authorization
string
required
API key using the format Bearer $YELU_API_KEY.
Content-Type
string
required
Must be application/json.

Request body

model
string
required
A model ID returned by GET /v1/models.
messages
array
required
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.
temperature
number
default:"1"
Sampling temperature from 0 to 2. Prefer changing either temperature or top_p, not both.
top_p
number
default:"1"
Nucleus sampling probability from 0 to 1.
max_completion_tokens
integer
Maximum tokens the model may generate. Support and accounting of reasoning tokens are model-specific.
stream
boolean
default:"false"
When true, returns Server-Sent Events with incremental completion chunks.
stream_options
object
Streaming options. Set include_usage to true to request a final usage chunk when supported.
stop
string | string[]
Up to the model’s supported number of sequences that stop generation.
presence_penalty
number
default:"0"
Value from -2 to 2 that adjusts reuse based on whether tokens appeared.
frequency_penalty
number
default:"0"
Value from -2 to 2 that adjusts reuse based on token frequency.
tools
array
Function definitions the model may call. Validate all generated arguments before execution.
tool_choice
string | object
Use none, auto, required, or a named function choice when supported.
response_format
object
Requests JSON object or JSON schema output on compatible models. See Structured output.
reasoning_effort
string
low, medium, or high on compatible reasoning models.
user
string
A stable, non-sensitive identifier for your end user. Do not send direct personal information.

Response

id
string
required
Unique completion identifier.
object
string
required
chat.completion for non-streaming requests; streaming chunks use chat.completion.chunk.
created
integer
required
Unix timestamp for creation.
model
string
required
Model that produced the completion.
choices
array
required
Generated alternatives. Each choice contains index, an assistant message, and finish_reason such as stop, length, tool_calls, or content_filter.
usage
object
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