Developer documentation

API Documentation

Full API endpoint reference with request/response samples.

4

official endpoints

5

example formats

SSE

streaming ready

Request console
$curl {PIXELROUTER_BASE_URL}/v1/responses
$-H Authorization: Bearer pxr_your_api_key
$-d '{ model, input, stream }'

Start here

Use your PixelRouter deployment base URL, one PixelRouter key, and choose the endpoint shape that matches your existing client.

Integration path

Three decisions before your first request

01

Create an API key

Generate a PixelRouter key from your dashboard and keep it server-side. Public examples use placeholders only.

02

Set the base URL

Point OpenAI-compatible clients at the PixelRouter base URL. Anthropic clients use the Messages endpoint with x-api-key.

03

Pick the response shape

Use Responses for new OpenAI-style text integrations, Chat Completions for legacy clients, or Messages for Anthropic-compatible apps.

Protocol map

Official API Endpoints

GET/v1/models

GET /v1/models

Retrieve the list of available public models. This request is free of charge and does not expose sensitive upstream details or model IDs.

POST/v1/chat/completions

POST /v1/chat/completions

Fully compatible with OpenAI Chat Completions. Uses the `messages` array in the request body. The response contains `choices` with the generated message. Supports Server-Sent Events streaming (`stream: true`).

POST/v1/responses

POST /v1/responses

OpenAI Responses-compatible API, highly recommended for new text generation integrations. Uses `input` as the main request parameter. The response contains `output` and `output_text` fields. Supports streaming (`stream: true`).

POST/v1/messages

POST /v1/messages

Fully compatible with Anthropic Messages API. Uses the `messages` array and returns responses in Anthropic's message layout. Supports SSE streaming (`stream: true`). PixelRouter accepts omitted `max_tokens` as a compatibility extension (defaults to 4,096, capped by the model max output tokens). The official Anthropic API still requires `max_tokens`; clients are encouraged to send it explicitly for predictable output.

Client setup

Use the SDK you already know

OpenAI

Using the OpenAI SDK

Fully compatible with the OpenAI SDK. Just change the base URL and API key.

baseURL: "{PIXELROUTER_BASE_URL}/v1"
apiKey: "pxr_your_api_key"

Anthropic

Using the Anthropic SDK

Supports the Anthropic Messages API via a dedicated endpoint.

baseURL: "{PIXELROUTER_BASE_URL}"
x-api-key: "pxr_your_api_key"

Live reference

API Documentation

Full API endpoint reference with request/response samples.

Never use your API key in frontend or browser code.

Your API key gives full access to your account balance. Only use it server-side. Exposing it in client-side JavaScript, mobile apps, or public repositories will allow anyone to use your credits.

Base URL

{PIXELROUTER_BASE_URL}

Authentication

OpenAI-compatible endpoints use Bearer token in Authorization header.

Authorization: Bearer pxr_your_api_key

Anthropic Messages API supports both x-api-key and Bearer token.

x-api-key: pxr_your_api_key

Endpoints

Select an endpoint to view usage details.

Endpoint details

GET/v1/models

GET /v1/models — List Models

Retrieve the list of available public models. This request is free of charge and does not expose sensitive upstream details or model IDs.

Authentication

Authorization: Bearer pxr_your_api_key

Headers

Authorization: Bearer pxr_your_api_key

Response

{
  "object": "list",
  "data": [
    {
      "id": "your-model-id",
      "object": "model",
      "created": 0,
      "owned_by": "openai"
    }
  ]
}
Method: GET
URL: {PIXELROUTER_BASE_URL}/v1/models

Authorization:
  Type: Bearer Token
  Token: pxr_your_api_key

Headers:
  Content-Type: application/json

Click Send.

Response text paths

How to extract the assistant text from each endpoint response:

// /v1/chat/completions
response.choices[0].message.content

// /v1/messages
response.content[0].text

// /v1/responses
response.output[0].content[0].text

Streaming

const stream = await client.chat.completions.create({
  model: "your-model-id",
  messages: [{ role: "user", content: "Tell me a story" }],
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content || "");
}

Billing

You are charged per token at the rates listed on the pricing page. Your prepaid balance is deducted in real-time. If your balance reaches zero, requests will be rejected with a 402 Payment Required error.

Common Errors

Errors are returned in a standard format with clear error codes.