POST /chat/completions
Use this endpoint for most model API integrations. Send a model ID and an array of messages; YouRouter returns an OpenAI-compatible completion response. For models that support vision, this endpoint can also accept image inputs in messages[].content.
Request
OpenAI SDK
Headers
Body Parameters
string
required
The model ID to call, such as
gpt-4o, claude-sonnet-4-20250514, or gemini-2.5-flash.array
required
Ordered conversation messages. Each message includes a
role and content.boolean
default:"false"
If true, the response is returned as server-sent event chunks.
number
Controls randomness when supported by the selected model.
integer
Limits the number of output tokens when supported by the selected model.
array
Tool definitions for models that support function calling or tool use.
Multimodal Image Input
For vision models, sendcontent as an array of blocks. Use a text block for the instruction and an image_url block for the image.
PDF File Input
If the target model and upstream provider support OpenAI-compatible file content blocks, you can pass a PDF inmessages[].content. The file_data value should be the base64-encoded raw PDF bytes.
PDF input is not supported by every model. If you need Gemini-native or Claude-native PDF behavior, see the provider-native examples in the Multimodal guide.
Response
Successful responses follow the OpenAI Chat Completions shape.Provider Routing
Automatic routing is the default:vendor:
Streaming
Setstream to true to receive incremental server-sent events.
Common Errors
For model IDs and provider pinning examples, see Models and the Router guide.