Skip to main content
Endpoint: 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, send content as an array of blocks. Use a text block for the instruction and an image_url block for the image.
For private images, use a base64 data URL:

PDF File Input

If the target model and upstream provider support OpenAI-compatible file content blocks, you can pass a PDF in messages[].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.
See the Multimodal guide for more examples, including Gemini-native and Claude-native formats.

Response

Successful responses follow the OpenAI Chat Completions shape.
Read the assistant text from:

Provider Routing

Automatic routing is the default:
Pin a provider with vendor:

Streaming

Set stream to true to receive incremental server-sent events.

Common Errors

For model IDs and provider pinning examples, see Models and the Router guide.