Skip to main content
POST
Generate chat completion (deprecated)

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
model
string
required

OpenRouter model identifier

Example:

"openai/gpt-4"

messages
object[]
required

Array of messages for conversation (supports text, images, audio, and files/PDFs)

stream
boolean
default:false

Enable streaming response via Server-Sent Events

temperature
number

Controls randomness in generation

Required range: 0 <= x <= 2
maxTokens
integer

Maximum number of tokens to generate

topP
number

Nucleus sampling parameter

Required range: 0 <= x <= 1
fileParser
object
thinking
boolean

Enable extended reasoning capabilities (appends :thinking to model ID if not already present). Not every model supports this, only works with Anthropic models with the :thinking suffix.

tools
object[]

Tool definitions for function calling

toolChoice

Controls tool usage: auto, none, required, or a specific function

Available options:
auto,
none,
required
parallelToolCalls
boolean

Allow the model to call multiple tools in parallel

Response

Chat completion response

text
string

AI model response content

tool_calls
object[]

Tool calls requested by the model (present when the model invokes tools)

annotations
object[]

URL citations from web search results (present when webSearch is enabled)

metadata
object