01
Create an API key
Generate a PixelRouter key from your dashboard and keep it server-side. Public examples use placeholders only.
Developer documentation
Full API endpoint reference with request/response samples.
4
official endpoints
5
example formats
SSE
streaming ready
Start here
Use your PixelRouter deployment base URL, one PixelRouter key, and choose the endpoint shape that matches your existing client.
Integration path
01
Generate a PixelRouter key from your dashboard and keep it server-side. Public examples use placeholders only.
02
Point OpenAI-compatible clients at the PixelRouter base URL. Anthropic clients use the Messages endpoint with x-api-key.
03
Use Responses for new OpenAI-style text integrations, Chat Completions for legacy clients, or Messages for Anthropic-compatible apps.
Protocol map
/v1/modelsRetrieve the list of available public models. This request is free of charge and does not expose sensitive upstream details or model IDs.
/v1/chat/completionsFully 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`).
/v1/responsesOpenAI 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`).
/v1/messagesFully 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
OpenAI
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
Supports the Anthropic Messages API via a dedicated endpoint.
baseURL: "{PIXELROUTER_BASE_URL}"
x-api-key: "pxr_your_api_key"Live reference
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.
{PIXELROUTER_BASE_URL}OpenAI-compatible endpoints use Bearer token in Authorization header.
Authorization: Bearer pxr_your_api_keyAnthropic Messages API supports both x-api-key and Bearer token.
x-api-key: pxr_your_api_keySelect an endpoint to view usage details.
/v1/modelsRetrieve the list of available public models. This request is free of charge and does not expose sensitive upstream details or model IDs.
Authorization: Bearer pxr_your_api_keyAuthorization: Bearer pxr_your_api_key{
"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.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].textconst 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 || "");
}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.
Errors are returned in a standard format with clear error codes.