Text
Chat models from OpenAI, Google, xAI, DeepSeek, Moonshot and more.
See the full list and prices on the Models page. Text is charged per token after the reply.
Chat completions
curl https://pinerouter.ai/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" -H "Content-Type: application/json" \
-d '{
"model": "gpt-5-2",
"messages": [
{"role": "system", "content": "You are concise."},
{"role": "user", "content": "Explain DNS in one sentence."}
],
"max_tokens": 200
}'The answer is in choices[0].message.content, and usage has the token counts you are charged for. Full field list: Chat completions.
Set max_tokens: before a request runs it reserves its longest possible answer (max_tokens, or 8192 tokens if unset) at the output price, then you pay the real tokens.
Streaming
Add "stream": true to get the text as it is written, as server-sent events. Usage comes in the last chunk. See Streaming.
Model features
The fields below follow OpenAI's format and are passed to the model. Whether they work depends on the model; if a model does not support one, it may ignore it or return a 400. Test with the model you plan to use.
Tools (function calling)
{
"model": "gpt-5-5",
"messages": [{"role": "user", "content": "What is the weather in Paris?"}],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Current weather for a city",
"parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]}
}
}]
}If the model calls a tool, the answer has choices[0].message.tool_calls. Run the function yourself, then send its result back as a message with "role": "tool" and the matching tool_call_id. tool_choice works as in OpenAI's API.
JSON mode and structured output
"response_format": {"type": "json_object"} asks for valid JSON. "response_format": {"type": "json_schema", "json_schema": {...}} asks for JSON that matches your schema. Still validate the answer in your code.
Images in messages (vision)
Give the image as a public https:// link in a content part:
{
"model": "gemini-3-8-flash",
"messages": [{"role": "user", "content": [
{"type": "text", "text": "What is in this picture?"},
{"type": "image_url", "image_url": {"url": "https://example.com/photo.jpg"}}
]}]
}Reasoning models
Models that think before they answer use more output tokens, and those tokens are charged. reasoning_effort (chat completions) and reasoning (responses) are passed to the model where it has them. Leave room in max_tokens for the thinking.
Responses API
OpenAI's newer format also works: POST /v1/responses with {"model": "...", "input": "..."}. This is what Codex CLI uses. See Responses.
Claude format
Tools built for Anthropic's Messages API can call POST /v1/messages with any text model (base URL without /v1). See Claude messages. Claude models themselves are not on the list today.
List models
GET /v1/models returns every model your key may use.
More
- SDK setup for Python and Node.js: SDKs
- Coding agents, chat apps and frameworks: Integrations
- Status codes and retries: Errors
