Skip to main content
POST
/
api
/
v1
/
chat
/
completions
Create chat completion
curl --request POST \
  --url https://api.myrouter.example/api/v1/chat/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "<string>",
  "messages": [
    {
      "content": "<string>",
      "name": "<string>",
      "tool_call_id": "<string>"
    }
  ],
  "stream": true,
  "max_tokens": 2,
  "temperature": 1,
  "top_p": 0.5,
  "tools": [
    {}
  ],
  "tool_choice": "<string>",
  "response_format": {},
  "user": "<string>"
}
'
{
  "id": "<string>",
  "object": "<string>",
  "created": 123,
  "model": "<string>",
  "choices": [
    {
      "index": 123,
      "message": {
        "content": "<string>",
        "name": "<string>",
        "tool_call_id": "<string>"
      },
      "finish_reason": "<string>"
    }
  ],
  "usage": {
    "input_tokens": 1,
    "output_tokens": 1,
    "total_tokens": 1,
    "cache_read_tokens": 1,
    "cache_write_tokens": 1,
    "reasoning_tokens": 1
  }
}

Authorizations

Authorization
string
header
required

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

Headers

x-request-id
string

Optional caller request id.

Body

application/json
model
string
required

Public MyRouter model id visible from /models.

messages
object[]
required

Ordered OpenAI-compatible messages.

Minimum array length: 1
stream
boolean

Whether to stream server-sent events.

max_tokens
integer

Maximum output tokens.

Required range: x >= 1
temperature
number

Sampling temperature.

Required range: 0 <= x <= 2
top_p
number

Nucleus sampling value.

Required range: 0 <= x <= 1
tools
object[]

OpenAI-compatible tool definitions.

tool_choice

Tool selection policy.

response_format
object

Structured response format options.

user
string

Customer end-user correlation id, not MyRouter principal.

Response

Create chat completion response.

id
string
required

Platform-generated completion id.

object
string
required

OpenAI-compatible object discriminator.

created
integer
required

Unix timestamp.

model
string
required

Model id used.

choices
object[]
required

Completion choices.

usage
object

Runtime usage facts, not invoice-grade charge evidence.