Provider API
What a provider hosts — batch work via the OpenAI Batch API, extended for deadlines, pay and acceptance; direct requests via chat completions.
This page is the full specification of the API your server hosts to receive work from Batchrouter. There are two kinds of work, and each has its own endpoint:
- Batch work arrives through the OpenAI Batch API, hosted by you, with a few Batchrouter extensions. You get the whole batch and its deadline, so you can hold the jobs and run them in spare capacity. This is where most of the volume is.
- Direct requests arrive through
POST /v1/chat/completions. Batchrouter calls it only when a customer sends a single request and wants the answer right away, never for batch work.
Which of the two a lane receives depends on its integration:
| Integration | integration at registration, api_protocol on the lane | Batch work | Direct requests |
|---|---|---|---|
| OpenAI Batch API (recommended) | openai_batch | Yes | Yes, at the lane's direct price |
| Chat completions only | openai_compat | No | Yes, at the lane's price |
A chat-only lane gets no batch work. To receive batch work, host the batch endpoints below and switch
the lane to openai_batch.
Integrations built on Batchrouter's earlier batch contract keep working and will be migrated to this API. New providers can't choose that contract.
Endpoints
Host these endpoints at your base URL. The base URL is the https:// URL you enter in the portal
after you register (a default for the provider, optionally one per model), without a trailing /v1.
| Endpoint | Standard or extension | What Batchrouter uses it for |
|---|---|---|
GET /v1/models | Standard | Go-live check and the regular re-check. Must list the Model ID of every model on the lane |
GET /v1/batches?limit=1 | Standard | Go-live check that the batch API exists. Creates no work |
POST /v1/files | Standard | Upload the batch input (purpose=batch, multipart, JSONL; see Input file) |
POST /v1/batches | Standard, with extension keys in metadata | Create the batch. The response is your acceptance or decline |
GET /v1/batches/{batch_id} | Standard | Status, output_file_id and error_file_id |
GET /v1/files/{file_id}/content | Standard | Output and error files at the end |
POST /v1/batches/{batch_id}/cancel | Standard | Cancel |
POST /v1/chat/completions | Standard | Direct customer requests only |
A chat-only (openai_compat) lane needs GET /v1/models and POST /v1/chat/completions only.
Authentication
Batchrouter sends Authorization: Bearer <your API key> on every call. It's the key you store in the
provider portal, where it's encrypted. Use a dedicated key
you can revoke without affecting your other customers.
Model IDs
The model Batchrouter sends is your Model ID for that model, exactly as you entered it in the
portal and exactly as GET /v1/models lists it. See
Add your models.
Batch work
A batch takes four steps: Batchrouter uploads the input file, creates the batch, polls it and reads the results. The shapes are the OpenAI Batch API's, so a server that already speaks it needs only the extensions on this page.
Input file
Batchrouter uploads one JSONL file per batch with POST /v1/files (purpose=batch, multipart). All
requests in a file are for one model and one endpoint, /v1/chat/completions,
and every request is a standard OpenAI Batch request. The file comes in one of two shapes:
| Shape | metadata.batchrouter_input_format on the create | When |
|---|---|---|
Sectioned JSONL (batchrouter.sectioned.v1) | "sectioned.v1" | Every batch lane, once Batchrouter switches it on. Registered providers are told the date in advance |
| Standard OpenAI Batch lines | Not sent | Until then |
Batch input is moving to sectioned files
Batchrouter is moving every batch lane to sectioned input files. There is no per-lane opt-in and no
standard-lines fallback after the switch: if your server reads only standard OpenAI Batch lines, turn
each sectioned file back into standard lines on your side before you run it. One fixed rule does
that, and the reference expander implements it.
Until the switch reaches your lane, accept both shapes. Tell them apart by
metadata.batchrouter_input_format on the create, or by the first line of the file.
Whatever the shape:
custom_idis Batchrouter's item ID. It is opaque, at most 64 characters and unique within the batch. Echo it exactly in the result for that request — a result whosecustom_idis anything else is ignored and flags the lane. See Identity rules.bodynever containsstreamorstream_options.- Results are not sectioned: you return one standard output line per request. See Results.
Sectioned files
Requests that share the same model, endpoint and tools, and the same opening messages, sit under one section line that carries the shared part once. Each request line carries only what is its own. Every section is one prompt prefix, so a prefix cache (vLLM's automatic prefix caching, for example) computes it once for all the section's requests.
{"type":"header","format":"batchrouter.sectioned.v1","section_count":2,"request_count":3}
{"type":"section","id":"s1","model":"llama-3.1-8b-instruct","url":"/v1/chat/completions","cache_key":"pfx_64ef9c7d3cf9d2cfb268f4f10e5ab04a","prefix":[{"role":"system","content":"You triage support tickets. Answer with one label."}],"body":{"temperature":0,"max_tokens":16}}
{"type":"request","section":"s1","custom_id":"item_7d2f8a1c4b9e40d3a6c5e8f1b2d4a090","body":{"messages":[{"role":"user","content":"Classify this ticket: refund not received"}]}}
{"type":"request","section":"s1","custom_id":"item_0b5e3c7a9d1f42e8b6a4c2e0f8d6b4a2","body":{"messages":[{"role":"user","content":"Classify this ticket: parcel arrived damaged"}]}}
{"type":"section","id":"s2","model":"llama-3.1-8b-instruct","url":"/v1/chat/completions","cache_key":"pfx_9c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f","prefix":[],"body":{"temperature":0.7,"max_tokens":300}}
{"type":"request","section":"s2","custom_id":"item_5f1a9c3e7b2d48a0c6e4a2f8d0b6c4e2","body":{"messages":[{"role":"user","content":"Write a friendly reply to a customer whose order is late"}]}}| Line | Fields |
|---|---|
| Header, always the first line | type: "header", format: "batchrouter.sectioned.v1", section_count, request_count. Reject a file whose format you don't support |
| Section | type: "section", id (unique in the file), model (your Model ID), url, cache_key, prefix (the opening messages every request in the section starts with; may be empty) and body (the request fields every request in the section shares, such as temperature, max_tokens, response_format, tools). A section body never contains model, messages or stream |
| Request | type: "request", section (the id of its section), custom_id, and body: the messages that follow the prefix, plus any field whose value is the request's own |
Rules every file follows:
- The header's counts match the file.
- A section line comes before its requests, and its requests follow it directly. A section
idappears once. Two sections may carry the samecache_key, for example when requests with the same prefix differ in which fields they set, or when a large group is cut into two pieces. - Every section has at least one request.
- One model and one endpoint per file.
- UTF-8, one JSON object per line,
\nline endings, a newline after the last line.
Turn a sectioned file back into standard lines
Every request line becomes exactly one standard OpenAI Batch line. This rule is the whole conversion:
| Standard field | Comes from |
|---|---|
custom_id | The request's custom_id |
method | Always "POST" |
url | The section's url |
body.model | The section's model |
body.messages | The section's prefix, followed by the request's body.messages. Present when either has messages |
Every other body field | Every field of the section's body, then every field of the request's body except messages. A request field replaces a section field with the same name |
The first request above turns back into:
{"custom_id":"item_7d2f8a1c4b9e40d3a6c5e8f1b2d4a090","method":"POST","url":"/v1/chat/completions","body":{"model":"llama-3.1-8b-instruct","messages":[{"role":"system","content":"You triage support tickets. Answer with one label."},{"role":"user","content":"Classify this ticket: refund not received"}],"temperature":0,"max_tokens":16}}The reference expander, expand_sectioned.py, does this
in standard-library Python 3.8 or later. It reads the file as a stream, checks the rules above and
writes standard OpenAI Batch JSONL:
python expand_sectioned.py batch.sectioned.jsonl > batch.jsonlTo check your own reader, use the 100-request example in both shapes:
batch-100.sectioned.jsonl and
batch-100.openai-standard.jsonl. The
expander turns the first into the second byte for byte.
The cache key
cache_key is the same whenever the same Batchrouter customer sends the same prefix (model,
endpoint, tools and prefix messages) again, in any batch. Two customers never share one, even when
their prompts are identical. Use it to route a section to the server that already holds its prefix,
or as a per-request cache salt where your server supports one (vLLM's cache_salt), so one
customer's cached prefixes stay apart from another's.
To get the most from your prefix cache, run a section's requests close together, and with several
servers keep a section on one server. Report the prompt tokens served from your cache in
usage.prompt_tokens_details.cached_tokens; they are paid at the batch's cached input rate (see
How you are paid).
Standard lines
Until the switch reaches your lane, each line of the file is one complete request:
{"custom_id":"item_7d2f8a1c4b9e40d3a6c5e8f1b2d4a090","method":"POST","url":"/v1/chat/completions","body":{"model":"llama-3.1-8b-instruct","messages":[{"role":"user","content":"Classify this ticket: refund not received"}],"max_tokens":512}}body is a standard request body for the line's url.
Lines that share a prompt prefix arrive grouped: the same model and tools, then the same leading
messages, such as one system prompt or the same first turns. With automatic prefix caching (vLLM
has it) the shared prefix is computed once. Report the reused tokens in
usage.prompt_tokens_details.cached_tokens; they are paid at the batch's cached input rate (see
How you are paid). The line order means nothing else, so match results by
custom_id.
Batch limits
| Limit | Per batch |
|---|---|
| Lines | At most 5,000, or your lane's max_batch_items if that is lower |
| Input file | At most 20 MiB of JSONL, uncompressed |
| Each result file | Batchrouter reads at most 20 MiB |
A bigger job is cut into several batches. Each has its own input file, its own POST /v1/batches and
its own Idempotency-Key. Lines that share a prompt prefix stay in one batch unless they alone are
over a limit.
Create the batch
Batchrouter creates the batch with POST /v1/batches:
POST /v1/batches
Authorization: Bearer <your API key>
Content-Type: application/json
Idempotency-Key: wu_3e6c9b2d5a8f41e0b7d4c1a9f0e2b385:9f2c4e6a8b1d3f50
{
"input_file_id": "file-abc123",
"endpoint": "/v1/chat/completions",
"completion_window": "24h",
"metadata": {
"batchrouter_work_unit_id": "wu_3e6c9b2d5a8f41e0b7d4c1a9f0e2b385",
"batchrouter_deadline_at": "2026-10-08T14:30:00Z",
"batchrouter_window_seconds": "7200",
"batchrouter_tier": "standard",
"batchrouter_role": "standard",
"batchrouter_pay_input_per_1m": "0.04",
"batchrouter_pay_output_per_1m": "0.08",
"batchrouter_pay_cached_input_per_1m": "0.02"
}
}completion_window is always "24h", for compatibility. The real deadline is in metadata.
Idempotency-Key. The key is the work unit ID plus a short hash of the exact set of items being
sent, so a retry of the same create (for example after a network timeout) carries the same key, while
a later dispatch of a different item subset gets a new one. Treat it as opaque. If you receive a key
you have already seen, return the batch you already created for it. Never create a second batch for
the same key.
Metadata keys. The extensions are strings in metadata, so a stock OpenAI-compatible server
accepts them unchanged.
| Key | Meaning |
|---|---|
batchrouter_work_unit_id | Batchrouter's ID for this piece of work |
batchrouter_deadline_at | RFC 3339 time by which every line must be finished. Lines finished later are not paid |
batchrouter_window_seconds | Your processing window for this assignment, in seconds. It is the first-stage window of the batch's tier (about 10 hours on Standard) |
batchrouter_tier | The customer tier this batch was sold on: one of the SLA tiers your lane subscribes to. standard today, until the other tiers launch |
batchrouter_role | Why this lane got the work. standard today. backstop is reserved for rescue work — reassigned items Batchrouter needs finished quickly. Rescue work may also go to lanes with a direct price |
batchrouter_pay_input_per_1m | What Batchrouter pays for this batch's input tokens, in USD per 1 million tokens. It is your lane's declared price at the moment of the create (your price for the batch's tier, or your direct price when batchrouter_role is backstop), and it is locked for this batch |
batchrouter_pay_output_per_1m | The same for output tokens |
batchrouter_pay_cached_input_per_1m | The same for cached input tokens. Sent only when the lane has a cached input price |
batchrouter_input_format | sectioned.v1 when the input file is a sectioned file. Not sent with standard lines. Reject a value you don't support with a 4xx |
The three batchrouter_pay_* values are the price you declared, so what you are told is what you are
paid. They don't change after the create: Batchrouter pays every line of this batch at these rates,
even if you change your price while the batch is open. See How you are paid and
Changing your prices.
Accept or decline
Your response to the create request is your answer. There is no separate quote or accept step.
| Your response | What it means |
|---|---|
2xx with a batch object | Accepted. The window counts from when Batchrouter sent the request |
429 or 503, optionally with Retry-After, on the upload or the create | Declined for capacity. Batchrouter routes the batch to another lane. It counts as a decline, not a failure |
Any other 4xx | Rejected. The attempt fails and is recorded against your lane, and Batchrouter tries another lane |
Any other 5xx | Temporary error. Batchrouter retries and, if the errors continue, moves the work to another lane. Not a decline |
| No response within 10 seconds (60 seconds for the file upload), or the connection fails | Treated as a decline |
When another lane can take the batch, a decline moves it there. When none can, Batchrouter offers
the batch to you again after a short wait (your Retry-After if you sent one), until the customer's
deadline.
Decline when you can't finish the batch by batchrouter_deadline_at. Lines that finish after the
deadline are not paid.
Status
Batchrouter polls GET /v1/batches/{batch_id} and reads status, then output_file_id and
error_file_id once the batch ends.
Your status | What Batchrouter does |
|---|---|
validating, in_progress, finalizing | Keeps polling |
cancelling | Keeps polling until the batch reaches a terminal status |
completed | Reads output_file_id and error_file_id and applies every line. Batchrouter reads results only here: nothing is collected while the batch runs |
failed, expired, cancelled | Reads whatever output and error files exist, then fails every item that has no result |
Results
Each finished line has the OpenAI output-file shape, keyed by custom_id:
{"id":"batch_req_7f3a91","custom_id":"item_7d2f8a1c4b9e40d3a6c5e8f1b2d4a090","response":{"status_code":200,"request_id":"req_5c2e","body":{"id":"chatcmpl-91b","object":"chat.completion","created":1791460800,"model":"llama-3.1-8b-instruct","choices":[{"index":0,"message":{"role":"assistant","content":"billing"},"finish_reason":"stop"}],"usage":{"prompt_tokens":18,"completion_tokens":2,"total_tokens":20}}},"error":null}- A
2xxstatus_codewith anullerroris a success. - A non-2xx
status_codeor a non-nullerrorfails that item. Batchrouter may retry it on another lane. usageinbodyis required. Batchrouter pays on it. If it is missing, Batchrouter estimates the tokens and flags the lane.
Put successful lines in the output file and failed lines in the error file, as the OpenAI Batch API does. Results are the same whatever the shape of the input file: one line per request, never sectioned.
Large result files
Batchrouter is changing how it reads result files, in stages. Until the change is switched on for
your lane, Batchrouter reads at most 20 MiB per result file, and lines past that are never
applied: keep each file under it, for example by declaring a max_batch_items that keeps a batch's
output small enough.
After the change there is no 20 MiB limit. Batchrouter reads each file a slice at a time (up to
2,000 lines or 8 MiB per poll, whichever comes first), applies the slice, remembers how far it got,
and asks for the next one a few seconds later until the file ends. While it does, your batch stays
completed and nothing is lost if either side restarts: a slice that was read but not saved is
simply read again, and a line that was already applied is not applied twice. Batchrouter only fails
items that have no result (provider_missing_result) after the whole file has been read. A hard
ceiling of 2 GiB per file stays as a safety limit; a file past it is cut there.
What this asks of you:
- Support
RangeonGET /v1/files/{file_id}/content(recommended). Batchrouter resumes withRange: bytes=<offset>-and expects206 Partial Contentwith aContent-Rangethat starts at that offset. Return416for an offset at or past the end of the file. This is what stock object stores and most file servers already do. - If you do not support
Rangeand answer200with the whole file, it still works: Batchrouter reads the file from the start and skips the lines it already applied. That costs you more egress on a big file, soRangeis better. - Keep the file stable. Once a batch is
completed, the bytes of its output and error files must not change or be reordered, because Batchrouter resumes by position. Append-only while the batch runs is fine; the file Batchrouter reads is the one the batch ends with. - One JSON object per line, ending in a newline. A line that is not valid JSON is skipped, counted and flags the lane; the lines around it are still read.
Partial results (GET /v1/batches/{batch_id}/results) are switched off, so a result file is the only
way results reach Batchrouter. A batch that is cancelled or fails still has its output and error
files read the same way.
Identity rules
custom_idechoes the item ID Batchrouter sent, exactly. Any other value — a truncated, re-cased or self-assigned id — is ignored and flags the lane.- One result per
custom_id. - An exact duplicate of a line already read is ignored.
- A conflicting duplicate (same
custom_id, different content) keeps the first result and flags the lane. - When the batch reaches a terminal status (
completed,failed,expired,cancelled), every item without a result fails withprovider_missing_resultand can be reassigned to another lane. - A batch that is still open when its window runs out is cancelled by Batchrouter. Its unfinished items move to another lane while the customer's deadline allows, and fail as expired after it.
Cancel
Batchrouter cancels with POST /v1/batches/{batch_id}/cancel. Lines finished before the cancel are
still delivered and paid, at the same rates as the rest of the batch, so keep them in the output and
error files of the cancelled batch: Batchrouter reads those files once the batch reaches
cancelled.
How you are paid
For batch work, pay is tokens × rate. You report the tokens; the rates are the ones Batchrouter
sent in the batch's batchrouter_pay_* metadata when it created the batch.
- You report
usageon every result line. For chat completions that isprompt_tokensandcompletion_tokens, plus the cached input tokens inusage.prompt_tokens_details.cached_tokens. - Batchrouter multiplies the tokens by the batch's rates. Input tokens at
batchrouter_pay_input_per_1m, output tokens atbatchrouter_pay_output_per_1m, cached input tokens atbatchrouter_pay_cached_input_per_1m. All rates are USD per 1 million tokens. A batch with no cached input rate prices cached tokens at the input rate. - The rates are fixed for the batch. Batchrouter stores them when it creates the batch and uses them for every line, including a result file it reads again after a retry. Nothing in a result line sets or changes a rate; you never send one back.
- A backstop batch is paid at your direct price. When
batchrouter_roleisbackstop, thebatchrouter_pay_*values are your lane's direct price, not a tier price. - Cancelled batches. Lines finished before a cancel, and present in the cancelled batch's output or error file, are delivered, applied and paid at the same rates as the rest of the batch.
- Late and missing. Lines finished after
batchrouter_deadline_atare not paid. A line with nousageis paid on Batchrouter's token estimate, recorded as estimated, and flags the lane. - Counts are bounded by the request. A line cannot claim more tokens than the request allowed.
Output tokens are paid at most up to the request's
max_tokens(or your lane's declared maximum output, whichever is lower), input tokens up to your lane's declared maximum input, and cached tokens up to the input count. A count within a few percent of its limit is taken as reported. Beyond that the line is paid at the limit and the lane is flaggedprovider_usage_implausible.
For example, a line with 1,000 input tokens (200 of them cached) and 500 output tokens, in a batch created with the metadata shown above, is paid at 800 × $0.04 + 200 × $0.02 + 500 × $0.08 per million tokens.
A direct (non-batch) chat-completions request is paid at your direct price in effect when the request is made.
Earnings are settled monthly. See Earnings and payouts.
Direct requests
Batchrouter calls POST /v1/chat/completions only for a customer's direct request: one request
whose answer the customer is waiting for. It never sends batch work there.
The body is a standard chat completions body, with your Model ID as model.
- Customer doesn't stream: Batchrouter sends
"stream": falseand expects achat.completionobject withusage. - Customer streams: Batchrouter sends
"stream": truewith"stream_options": {"include_usage": true}and relays your chunks to the customer as they arrive. Answer withContent-Type: text/event-stream: onedata: {chat.completion.chunk}event per chunk, a final chunk that carriesusage, thendata: [DONE].
Streaming is server-sent events over a normal HTTP response.
Turn streaming on for a lane
In the provider portal, open the lane and tick Streams chat completions. Through the API, set
chat_streaming: true when you create or update the lane (POST and PATCH on
/v1/provider-portal/offerings). It applies to any lane that serves direct requests, whether
openai_compat or openai_batch.
When a customer streams, Batchrouter tries the lanes that have it on first. A lane that has not
turned it on still takes streamed requests, after those, so nothing breaks if you leave it off. Turn
it on once your server answers stream: true as described above. Without it, a streamed request that
reaches your lane costs a failover if you answer with a plain JSON body.
What to expect:
- If your endpoint gives a connection error, times out or returns a
5xxbefore the first byte, Batchrouter fails over to another lane. Once you have started streaming there is no failover, so an error mid-stream fails the customer's request. usageis required, as for batch work. If it is missing, Batchrouter estimates the tokens, records them as estimated, and pays and bills on the estimate. A lane that keeps answering withoutusagecan be put under review.
Prices
An openai_batch lane has no single batch price. It carries a price for each SLA
tier it takes, what you earn per 1 million tokens of batch work in that tier; see
Price per tier. The lane's own batch figures (input_per_1m and the like) are
derived from its reference tier: Standard, or the first tier it takes if it doesn't take Standard.
Every openai_batch lane also sets a direct price — direct_input_per_1m,
direct_output_per_1m and, optionally, direct_cached_input_per_1m. It is required, and it
does two jobs: it is what you earn for direct requests on the lane, and it is the lane's ceiling —
no tier price may be higher than its direct price.
On a chat-only (openai_compat) lane there are no separate direct fields: the lane's regular price
is its direct price.
Batchrouter adds its platform fee on top when it prices work for customers, so the price you set is what you earn.
The price you declare is the price Batchrouter routes on and the price it sends in
batchrouter_pay_* when it creates a batch. Once a batch is created, its pay is
locked.
SLA tiers
Batchrouter sells six SLA tiers to customers; see the customer tier list. A lane subscribes to the tiers whose work it takes. Your window is the first stage of each tier; the rest of the customer's time is for the backstop that runs if you miss it.
| Tier | Customer's deadline | Your window per assignment | How your lane gets it |
|---|---|---|---|
| Realtime | Best effort, no window | None | A direct request to your chat completions endpoint, at your direct price. Any lane with a direct price serves it; there is nothing to subscribe to |
| Priority | 4 hours | about 1.5 hours | Subscribe with sla_tiers. Not available on a native 24-hour batch lane |
| Standard | 24 hours | about 10 hours (24 hours on a native batch lane) | Subscribe with sla_tiers |
| Relaxed | 48 hours | about 20 hours | Subscribe with sla_tiers |
| Flex | 72 hours | about 44 hours | Subscribe with sla_tiers |
| Economy | 7 days | about 140 hours | Subscribe with sla_tiers |
Your window is not the customer's promise. The customer is promised the full deadline in the second column (see the customer tier table); you are held to your window, which is shorter, so the work can still be moved if you miss it. Example, a Standard batch: the customer sees 24 hours. Stage 1 goes to a lane with a 10-hour window; if that lane misses, stage 2 gets another 10 hours on a different lane, and the closing stage gets the rest. Read batchrouter_window_seconds on the create request for your own deadline, never the customer's.
Customers can buy Standard today; Priority, Relaxed, Flex and Economy open to customers when they
launch, all together. Subscribe now and your lane is in from the first day. Until then every batch
you receive carries batchrouter_tier: "standard", and batchrouter_window_seconds and
batchrouter_deadline_at on the create request are what you are held to.
Choose your tiers
In the provider portal, open the lane and tick the tiers under SLA tiers. Through the API,
send sla_tiers on the lane:
{ "sla_tiers": ["standard", "flex", "economy"] }- Joining a tier takes effect at once.
- Leaving a tier takes effect after 24 hours' notice. Your lane keeps receiving that tier's
work until the notice ends, and the response to your change says when that is
(
sla_tier_change.left[].takes_effect_at). The lane shows the tier as "leaving" meanwhile. - A batch already sent to you keeps its tier, its deadline and its pay, whatever you change.
GET /v1/provider-portal/offerings returns sla_tiers on every lane, plus sla_tier_exits, the
tiers the lane is leaving and when each notice ends.
Price per tier
Every tier a lane takes needs its own price. Set sla_tier_prices on the lane, in USD per
1 million tokens: input_per_1m and output_per_1m for each tier, and optionally cached_input_per_1m. A slower tier can carry a lower price:
{
"sla_tiers": ["standard", "flex", "economy"],
"sla_tier_prices": {
"standard": { "input_per_1m": 0.08, "output_per_1m": 0.24 },
"flex": { "input_per_1m": 0.05, "output_per_1m": 0.15 },
"economy": { "input_per_1m": 0.03, "output_per_1m": 0.09 }
}
}- A lane write that names
sla_tiersorsla_tier_pricesmust leave every tier the lane takes priced. Otherwise it is rejected with400 sla_tier_price_missing, anddetails.fieldnames the tier and key (for examplesla_tier_prices.flex.output_per_1m). Price that tier, or stop taking it. - Prices must fall from Realtime to Economy: your direct price is the ceiling, then Priority,
Standard, Relaxed, Flex and Economy, each no higher than the one before, for input, output and
cached input alike. A change that breaks the order is rejected with
400 sla_tier_price_order. - A tier price is a price like any other: a change reaches new work only, and the batch carries
the rate it was created with in
batchrouter_pay_*. See Changing your prices. - A model whose lanes are all priced per tier has no single batch price to change:
PATCH /v1/provider-portal/models/{modelId}naming one is rejected with400 priced_per_tier. Change the tier prices on its lanes instead. A direct price sent there must stay at or above every tier price (400 sla_tier_price_order). - A chat-only (
openai_compat) lane takes no batch work, so none of this applies: its one price is its direct price.
Changing your prices
A price change reaches new work only. When you change a price, the new price applies to work Batchrouter routes to you from then on, and to routing decisions straight away. It never changes the pay of a batch you already hold:
- Batches already created keep the rates in their own
batchrouter_pay_*metadata. Every line of such a batch is paid at those rates, even if you raise or lower your price while the batch is open. - Batches created after the change carry the new rates.
- Direct requests are paid at the direct price in effect when the request is made.
- Batches created before this rule took effect carry no lock and settle at your lane's current rate, as they did before.
A provider can't raise the price of work it already holds, and Batchrouter can't lower it under you. What you are told when a batch arrives is what you are paid for it.
The price-change notice
The provider portal calls that can change a price are:
PATCH /v1/provider-portal/models/{id}with a price field (input_per_1m,output_per_1m,cached_input_per_1mor adirect_*price)PATCH /v1/provider-portal/offerings/{id}POST /v1/provider-portal/offerings/{id}/versions
The deprecated /v1/provider/* aliases of the offering calls answer the same way. When a price
actually moved, the response carries the usual body plus a price_change object. A call that changes
no price has no price_change.
{
"offering": { "id": "po_8c1f3a", "version": 4, "...": "..." },
"price_change": {
"applies_to": "new_work_only",
"effective_at": "2026-10-09T09:12:44.000Z",
"changes": [
{
"provider_offering_id": "po_8c1f3a",
"model_slug": "llama-3.1-8b-instruct",
"task_type": "responses",
"field": "output_per_1m",
"from": 0.08,
"to": 0.1
}
],
"in_flight": { "work_units": 2, "items": 340 },
"message": "The new price applies to work routed to you from now on. 2 batches already sent to you (340 items still open) keep the prices they were sent with."
}
}| Field | Meaning |
|---|---|
applies_to | Always new_work_only |
effective_at | When the new price started to apply to newly routed work |
changes | One entry per price that moved, per lane: the lane (provider_offering_id, model_slug, task_type), the field (for example input_per_1m, output_per_1m, cached_input_per_1m, direct_output_per_1m), and its value from and to in USD per 1 million tokens (null when a price is unset) |
in_flight | The batches already sent to you that are still open (work_units) and their open items. They keep the prices they were sent with |
message | The same notice in words |
GET /v1/provider-portal/offerings returns price_change_policy next to the lanes: the same
applies_to: "new_work_only" and a short summary of the rule. The provider dashboard shows
the same notice.
Go-live checks
The portal's endpoint test and Go live call each endpoint (your default, and any per-model endpoint) with its key. Neither creates work or costs anything.
| Integration | Check | What passes |
|---|---|---|
openai_batch | GET {base URL}/v1/models | An OpenAI-style model list that includes the Model ID of every model on the lane |
openai_batch | GET {base URL}/v1/batches?limit=1 | An OpenAI-style list, {"object": "list", "data": [...]}. An empty data array passes |
openai_compat | GET {base URL}/v1/models | The same model list |
After you go live, Batchrouter re-checks your endpoint about once a week, and sooner when a check fails. See Test your endpoint for the usual failures and fixes.
Adding a lane to a provider that is already live. There is no second Go live, and adding a
lane does not run these checks by itself. Run the connection test from the provider page after you
add an openai_batch lane (POST /v1/provider-portal/connectivity-test), so that a missing batch
endpoint shows up before work reaches the lane.
Capacity and heartbeats
Declared capacity tells Batchrouter how much work a lane will accept. Batchrouter pushes jobs to
the lane within that declaration and does not read your queue depth. Every lane declares its own:
there is no provider-wide capacity and no default from your trust tier. A lane created through the
API takes available_queue_items and max_concurrent_batches (each at least 1) in its create
body, with sla_tiers (see One capacity per lane); a lane the portal's
Add model creates takes no work until you declare its capacity in the setup step. You can change
it in the portal, or from your own systems through the API:
| Endpoint | What it does |
|---|---|
GET https://api.batchrouter.com/v1/provider-portal/offerings | Lists your lanes and their IDs |
POST https://api.batchrouter.com/v1/provider-portal/offerings/{offering_id}/capacity | Sets the lane's standing capacity |
POST https://api.batchrouter.com/v1/provider-portal/offerings/{offering_id}/heartbeat | Updates capacity and keeps it open for a time-to-live |
Authenticate with a Batchrouter API key from the account that owns the provider, and name the provider in a header:
curl -X POST "https://api.batchrouter.com/v1/provider-portal/offerings/$OFFERING_ID/heartbeat" \
-H "Authorization: Bearer $BATCHROUTER_API_KEY" \
-H "x-batchrouter-provider-id: your-provider-slug" \
-H "Content-Type: application/json" \
-d '{"available_queue_items": 5000, "heartbeat_ttl_seconds": 300}'Listing lanes needs any access to the provider. Both writes need two permissions at once:
- The key's workspace role must be workspace owner or workspace admin. A key with the default
memberrole, or abillingorread_onlykey, can list lanes and gets403 forbiddenon both writes. - The account's access to that provider must be provider owner or provider admin. Provider
billingandviewercan read the portal and cannot change capacity. The owner shares those roles from the portal. See Roles and sharing.
A workspace owner whose provider share is viewer is refused, and so is a provider owner using a member key.
Both endpoints take the capacity fields from
Capacity, such as max_batch_items,
max_concurrent_batches, available_queue_items and available_queue_tokens. A heartbeat also
takes heartbeat_ttl_seconds, from 30 to 3600. Without it, the lane's configured time-to-live
applies.
One capacity per lane
A lane's capacity is one figure, shared by every tier the lane takes: sla_tiers of
["priority", "standard", "economy"] with available_queue_items of 100 is 100 items in all, not
100 for each tier. There is no per-tier capacity field (a body with one, such as
capacity_by_tier, is a 400 capacity_is_per_lane). When it is enforced for your environment,
POST /v1/provider-portal/offerings also needs the tiers and the capacity written out, so a new
lane has no silent default:
| Error | Meaning |
|---|---|
400 sla_tiers_required | Send sla_tiers: the tiers the lane takes (one, several or all) |
400 lane_capacity_required | Send available_queue_items and max_concurrent_batches, each at least 1. error.details.fields names what is missing |
400 capacity_is_per_lane | Capacity is the lane's, not a tier's and not the provider's |
409 lane_exists | The model already has a lane for this task and runtime profile. Change it with PATCH, or give the new lane its own runtime_profile_slug |
For capacity that belongs to one tier, make a lane per tier: the same model, a different
runtime_profile_slug, one tier each.
# Priority gets 40 items of its own; Standard gets 30. Prices per tier as in "Choose your tiers".
for lane in "tier-priority priority 40" "tier-standard standard 30"; do
set -- $lane
curl -X POST "https://api.batchrouter.com/v1/provider-portal/offerings" \
-H "Authorization: Bearer $BATCHROUTER_API_KEY" \
-H "x-batchrouter-provider-id: your-provider-slug" \
-H "Content-Type: application/json" \
-d "{\"provider_model_id\": \"$PROVIDER_MODEL_ID\", \"task_type\": \"responses\",
\"runtime_profile_slug\": \"$1\", \"sla_tiers\": [\"$2\"],
\"sla_tier_prices\": {\"$2\": {\"input_per_1m\": 0.4, \"output_per_1m\": 1.2}},
\"price\": {\"unit\": \"per_1m_tokens\", \"direct_input_per_1m\": 2, \"direct_output_per_1m\": 6},
\"available_queue_items\": $3, \"max_concurrent_batches\": 2}"
doneWork for a tier goes to the lane that takes it, and each lane holds only its own capacity.
Lane data handling
The same lane routes (POST /v1/provider-portal/offerings and PATCH .../offerings/{offering_id})
take the lane's own data handling, each optional and inheriting your provider profile when left
out: retention_days (days, 0 with supports_zdr: true is zero data retention),
supports_zdr, trains_on_customer_data (default false) and processing_countries (the countries
this lane runs inference in; its region tags are derived from them). Send null to go back to
your profile's value. GET /v1/provider-portal/offerings returns each lane's effective values as
data_handling, with the source of each (lane, provider or undeclared).
Standing capacity and heartbeats
Standing capacity is the default: the lane has no expiry (capacity_expires_at and
last_heartbeat_at are null), so it never times out and you don't need to send heartbeats. In the
catalog its capacity_freshness reads unknown. That is expected, and it costs the lane nothing in
eligibility or ranking.
Once you send heartbeats, keep sending them
Each heartbeat sets an expiry: the lane's capacity is open until the time-to-live runs out. If the
heartbeats stop, the lane stops taking batch work until the next one. Direct requests are not held
back by an expired heartbeat. To go back to standing capacity, call /capacity with
"capacity_expires_at": null and "last_heartbeat_at": null.
Standing commitment per lane
A standing commitment is the capacity a lane holds for Batchrouter until you change it. It is a long-term capacity window attached to the lane, and it is separate from the lane's declared capacity above: the declared capacity is how much the lane takes right now, the commitment is what you promise to keep available, and a batch is routed to the lane only when both have room.
| Endpoint | What it does |
|---|---|
POST https://api.batchrouter.com/v1/provider-portal/capacity-windows | Sets the lane's standing commitment |
POST .../capacity-windows/{window_id}/changes | Schedules a change to its work units, price or status |
POST .../capacity-windows/{window_id}/accepting | Stops (or resumes) new work at once |
curl -X POST "https://api.batchrouter.com/v1/provider-portal/capacity-windows" \
-H "Authorization: Bearer $BATCHROUTER_API_KEY" \
-H "x-batchrouter-provider-id: your-provider-slug" \
-H "Content-Type: application/json" \
-d '{"commitment_tier": "long_term", "provider_offering_id": "'"$OFFERING_ID"'", "starts_at": "2026-10-17T00:00:00Z", "max_work_units": 5000}'provider_offering_idis the lane's ID fromGET /v1/provider-portal/offerings. A lane has one standing commitment; a second request for the same lane answers409 lane_already_has_standing_commitment. Leaveends_atout: a standing commitment has no end.- The commitment follows the lane to its new ID when you publish a new version, so you set it once.
- A change that only raises
max_work_unitstakes effect at once. A lower figure, a price change, pausing or ending the commitment takes effect at least 24 hours after the request, and the response is202with the scheduled change. Stopping new work with/acceptingis always immediate. - Spot windows are the same endpoint with
"commitment_tier": "spot", ansla_bidsentry and at most 15 minutes betweenstarts_atandends_at. Naming the lane withprovider_offering_idis the way to scope them. - Windows that name a
modelinstead of a lane still work. A request cannot send both.
How Batchrouter uses the limits
These limits are the lane's declaration. They apply to batch work, not to direct requests:
max_batch_itemsandmax_batch_tokensare the largest batch Batchrouter sends you. Tokens are Batchrouter's estimate for the batch. A bigger job is cut into several batches that each fit, and work that can't fit on your lane at all goes to another lane. Whatever you declare, a batch stays within the batch limits: 5,000 lines and 20 MiB of input.available_queue_itemsandavailable_queue_tokensare the work you declared the lane will accept. Each batch is checked against them, less what Batchrouter is sending you at that moment. They are not reduced for batches you already hold, so declare the room you have left when it changes.tokens_per_minute, where your provider or lane declares it, is not a rate limit and Batchrouter does not meter you against it. It is the throughput Batchrouter assumes when it estimates whether a batch finishes inside its window, so a value that is too low makes your lane look too slow for short windows.max_concurrent_batchesis checked when work is routed, against the batches running at that moment. It is not a ceiling on how many batches can be in flight at once.
Running on vLLM
vLLM serves GET /v1/models and POST /v1/chat/completions, so it covers direct requests and the
model check as it is. For batch work you run a batch front end in front of it that hosts the batch
endpoints on this page. vllm run-batch reads standard OpenAI Batch lines and writes the same output
line format, which makes it a possible starting point for that front end. Put the
reference expander in front of it for sectioned
files. The expander keeps the order of the lines, so each section's requests stay together:
python expand_sectioned.py batch.sectioned.jsonl > batch.jsonl
python -m vllm.entrypoints.openai.run_batch -i batch.jsonl -o results.jsonl --model <your model>Keep prefix caching on (the default in current vLLM versions). vLLM fills in
usage.prompt_tokens_details only with --enable-prompt-tokens-details, so check a test batch for
cached_tokens.