VAL Router is live — one key, one endpoint, every model we serve. Zero data retention, OpenAI & Anthropic compatible.

See plans

API reference

VAL Router API

A REST API in the OpenAI and Anthropic formats. Point your base URL at the gateway, send your val-router- key, and keep the rest of your code.

On this page
  1. Introduction
  2. Quick start
  3. Authentication
  4. Endpoint support
  5. Streaming (SSE)
  6. Error codes
  7. Rate limits

01 Introduction

VAL Router is a hosted REST gateway for large language models. It speaks both the OpenAI and Anthropic wire formats from a single base URL, so you keep the SDK you already use and change two values: the base URL and the API key.

One val-router- key works for every endpoint. Requests are routed to healthy upstream providers with automatic failover, and usage is metered per key.

Base URL
https://router.byvall.com/v1
Auth
Bearer val-router-... or X-API-Key
Formats
OpenAI + Anthropic compatible
Fair use
30 requests / min per key

New to the API? Start with the quick start, then read authentication and the endpoint reference.

02 Quick start

Three steps from zero to the first completion. If you already have a key, jump straight to step 3.

1

Get an API key

Register, open the dashboard and create a key. Keys look like val-router-... and work for both wire formats.

Open dashboard
2

Point your SDK here

Set the client base URL to https://router.byvall.com/v1 and export your key as an environment variable.

3

Make a request

Call chat completions with any model id from GET /v1/models. The first response proves the wiring end to end.

First request

import openaiclient = openai.OpenAI(    base_url="https://router.byvall.com/v1",    api_key="$VALROUTER_API_KEY",)resp = client.chat.completions.create(    model="deepseek/deepseek-v4.1-flash",    messages=[{"role": "user", "content": "Hello!"}],)print(resp.choices[0].message.content)

Model ids. Every key sees its own catalogue. Call GET /v1/models (see List models) and use an id from the response; the example above uses one that ships with every key.

03 Authentication

Every request is authenticated with your val-router- key. Send it as a Bearer token in the Authorization header (OpenAI convention) or in the X-API-Key header. Either works everywhere, on both wire formats.

http
GET https://router.byvall.com/v1/modelsAuthorization: Bearer val-router-...X-API-Key: val-router-...
Bearer token

Key management

  • Create, rotate and revoke keys from the dashboard.
  • Keys are bound to a plan, a token balance or a PAYG balance.
  • One key is enough: it authenticates OpenAI, Anthropic and the routing endpoints.

Keep the key secret. Treat val-router-... like a password. Anyone with the key spends your quota. Use environment variables, not client-side code, to store it.

04 Endpoint support

The gateway exposes one REST surface at https://router.byvall.com/v1. It passes the OpenAI and Anthropic formats through to healthy upstream providers, so your existing SDK code keeps working. All endpoints below require authentication.

OpenAI-compatible API

The OpenAI surface matches the official Clients. Point an OpenAI-style SDK at https://router.byvall.com/v1 and it works unchanged.

GET/v1/models

Lists the models available to your key: catalogue models, your combos and any Bansos public model. Each entry carries a context_window, USD pricing and a capabilities array.

curl
curl https://router.byvall.com/v1/models \  -H "Authorization: Bearer $VALROUTER_API_KEY"

Response sample

json
{  "object": "list",  "data": [    {      "id": "deepseek/deepseek-v4.1-flash",      "object": "model",      "created": 1763550000,      "owned_by": "deepseek",      "context_window": 1000000,      "pricing": { "input": 0.3, "output": 1.2 },      "capabilities": ["chat", "streaming", "vision"]    }  ]}
GET/v1/quota

Returns the key's entitlement: plan, expiry, RPM and parallel limits, token balance, allowed models and the last 30 days of usage. The same data you see in the dashboard.

curl
curl https://router.byvall.com/v1/quota \  -H "Authorization: Bearer $VALROUTER_API_KEY"

Response sample

json
{  "object": "quota",  "key": {    "id": 42,    "name": "my-key",    "kind": "subscription",    "status": "active",    "expires_at": 1795086000000,    "rpm_limit": 30,    "parallel_limit": 3,    "token_balance": 0,    "allowed_models": []  },  "plan": { "slug": "pro", "name": "Pro" },  "usage": {    "requests_30d": 412,    "tokens_30d": 1534821,    "charge_30d": 2.31  },  "balance": 5.5,  "bonus_tokens": 0,  "valid": true}

Quota vs balance. balance is your PAYG credit, bonus_tokens the prepaid token pool and usage the rolling 30-day history. A subscription key spends none of them until the plan expires.

POST/v1/chat/completions

The workhorse endpoint: a standard chat completion in the OpenAI format. Use any model id from List models.

resp = client.chat.completions.create(    model="deepseek/deepseek-v4-pro",    messages=[        {"role": "system", "content": "You are a concise assistant."},        {"role": "user", "content": "Explain SSE in two sentences."},    ],    temperature=0.7,    max_tokens=512,)print(resp.choices[0].message.content)

Request parameters

FieldTypeDescription
modelstring · requiredModel id, e.g. deepseek/deepseek-v4-pro.
messagesarray · requiredConversation turns with role and content.
temperaturenumberSampling temperature. Default 1.
max_tokensintegerUpper bound for the completion.
streambooleanStream the response over SSE. See Streaming.

Response sample

json
{  "id": "chatcmpl-9f2c",  "object": "chat.completion",  "created": 1763550000,  "model": "deepseek/deepseek-v4-pro",  "choices": [    {      "index": 0,      "message": {        "role": "assistant",        "content": "Server-Sent Events push text to the client ..."      },      "finish_reason": "stop"    }  ],  "usage": {    "prompt_tokens": 24,    "completion_tokens": 41,    "total_tokens": 65  }}
POST/v1/responses

The OpenAI Responses API. Use input instead of messages; the response carries output and output_text. Streaming is supported with stream: true.

resp = client.responses.create(    model="z-ai/glm-5.2",    input="Summarise the SSE spec in one line.",)print(resp.output_text)

Response sample

json
{  "id": "resp_4b1e",  "object": "response",  "created": 1763550120,  "model": "z-ai/glm-5.2",  "output": [    {      "type": "message",      "role": "assistant",      "content": [{ "type": "output_text", "text": "SSE is a ..." }]    }  ],  "usage": {    "input_tokens": 18,    "output_tokens": 27,    "total_tokens": 45  }}

Anthropic-compatible API

The Anthropic surface matches the Messages API. Use the Anthropic SDK, set the base URL and key, and add the anthropic-version header.

POST/v1/messages

A standard Anthropic Messages request. Required header: anthropic-version: 2023-06-01. The gateway bridges the response back into the native Anthropic shape, including SSE events when streaming.

import anthropicclient = anthropic.Anthropic(    base_url="https://router.byvall.com/v1",    api_key="$VALROUTER_API_KEY",)message = client.messages.create(    model="anthropic/claude-sonnet-5",    max_tokens=512,    messages=[{"role": "user", "content": "Hello!"}],)print(message.content[0].text)

Request parameters

FieldTypeDescription
modelstring · requiredModel id, e.g. anthropic/claude-sonnet-5.
max_tokensinteger · requiredUpper bound for the completion.
messagesarray · requiredConversation turns with role and content.
systemstringSystem prompt, passed separately from the turns.

Response sample

json
{  "id": "msg_01XFDUDYJgAACzvnptvVoaTre",  "type": "message",  "role": "assistant",  "model": "anthropic/claude-sonnet-5",  "content": [    { "type": "text", "text": "Hello! How can I help you today?" }  ],  "stop_reason": "end_turn",  "usage": {    "input_tokens": 12,    "output_tokens": 19  }}

Pass-through, not passthrough limits. The gateway proxies the OpenAI /v1/completions, embedding, moderation and image endpoints when the provider supports them. The four above are the ones every key can rely on.

05 Streaming (SSE)

Add "stream": true to any chat, responses or messages request and the gateway answers with Content-Type: text/event-stream. Tokens arrive as Server-Sent Events as the upstream produces them.

OpenAI-shaped stream

Chunks follow the chat.completion.chunk object. Each data: line carries one delta; the stream ends with data: [DONE].

http
HTTP/1.1 200 OKContent-Type: text/event-streamCache-Control: no-cachedata: {"id":"chatcmpl-9f2c","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"role":"assistant"}}]}data: {"id":"chatcmpl-9f2c","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"1..."}}]}data: {"id":"chatcmpl-9f2c","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"2..."},"finish_reason":null}]}data: [DONE]
SSE frame
stream = client.chat.completions.create(    model="deepseek/deepseek-v4.1-flash",    messages=[{"role": "user", "content": "Count to five."}],    stream=True,)for chunk in stream:    delta = chunk.choices[0].delta.content    if delta:        print(delta, end="", flush=True)

Anthropic-shaped stream

On /v1/messages the gateway emits native Anthropic events: message_start, content_block_start, content_block_delta, content_block_stop and message_stop.

http
event: message_startdata: {"type":"message_start","message":{"id":"msg_01XFDUDYJgAC","role":"assistant","content":[]}}event: content_block_startdata: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}event: content_block_deltadata: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hello"}}event: message_stopdata: {"type":"message_stop"}
Anthropic SSE events

Clients handle the parsing. The official OpenAI and Anthropic SDKs parse these frames for you. Consume the stream object (for chunk in stream / for await (const chunk of stream)) instead of reading the raw socket.

Disconnects. If the client closes the connection mid-stream the gateway stops billing and records client_disconnect. Tokens already generated are still charged.

06 Error codes

Errors use the standard OpenAI envelope. On Anthropic-shaped endpoints the same failure is wrapped in the Anthropic { type: "error", error: {...} } shape instead.

{  "error": {    "message": "Incorrect API key provided...",    "type": "invalid_request_error",    "code": "invalid_api_key",    "param": null  }}
StatusCodeMeaning & how to fix
400invalid_json, missing_model, invalid_requestMalformed body, missing model, or a parameter the endpoint rejects. Fix the request and retry.
401missing_api_key, invalid_api_keyNo key, or the key is wrong, revoked or malformed. Check the dashboard value.
402insufficient_quotaToken balance or subscription quota is exhausted. Top up or renew.
403model_not_allowedThe model is not in your plan, or an IP-binding rule blocked the request.
404model_not_found, not_foundUnknown endpoint or model id. List models for valid ids.
429rate_limit_exceededHard cap hit. Fair use queues instead of refusing; see Rate limits.
499client_disconnectThe client closed the connection mid-request or mid-stream.
503overloaded, capacity_unavailable, no_healthy_keyUpstreams saturated or no healthy key available. Retry shortly; the response may carry Retry-After.
500 · 502upstream_errorAn upstream provider failed. Retry; the gateway itself keeps running.

Error messages may carry a shop hint. Quota refusals can include an operator-sentenced hint (for example a link to the shop) appended to the message. Treat it as guidance, not part of the error schema.

07 Rate limits

One fair-use limit protects every key: 30 requests per minute. When the window fills, the request is queued and served in turn — not refused — so a burst of traffic delays instead of failing.

How the queue works

  • Requests inside the rolling 60-second window are served immediately.
  • Once the window fills, the request waits for a free slot (queue depth is bounded).
  • If the queue is full or the wait times out, the request is refused with 429 and a Retry-After header telling you exactly how long to back off.

Hard caps

No hourly, weekly or monthly request caps exist. A plan's parallel sessions ceiling (how many requests can run at once) and the fair-use RPM are the only throughput limits. Admin-assigned per-key caps (per-minute, per-hour, per-day, tokens-per-minute) can tighten them further — GET /v1/quota reports the effective values.

http
HTTP/1.1 429 Too Many RequestsRetry-After: 8{  "error": {    "message": "Rate limit reached; the request is queued.",    "type": "rate_limit_exceeded",    "code": "rate_limit_exceeded",    "param": null  }}
429 with Retry-After

Best practices

  • Retry 429 and 503 with exponential backoff; honour Retry-After when present.
  • Prefer streaming for long generations — the connection stays busy and billing is fairer.
  • Check GET /v1/quota before large batches instead of probing with requests.

You are rarely refused. The design goal is a queued request, not a failed one. A client that retries on 429 and honours Retry-After will almost never see a hard failure under normal load.

ARMING ROTORS
0%
ALT: 0.0mVEL: 0.0 m/sRPM: 0LAT 6.2088 · LNG 106.8456
API Documentation — VAL Router