Providers
A provider is how quorum reaches a model: an object that takes one request and returns the text of the reply. The CLI builds its providers from its config, each from a preset or a protocol (Configuration); a program builds its own, with one of the five shipped adapters or from scratch. This page covers the port, the deadline and the retries of a call, how replies are streamed, the adapters, the presets, the options the HTTP adapters share, the key header styles, the tool fields each of them refuses, the limits of a request, the body each sends and the replies it reads, the Claude Code adapter's command line, isolation and errors, the errors a provider raises, and writing a provider of your own.
The port
interface Provider {
readonly id: string
readonly model: string
readonly timeoutMs?: number
readonly stallTimeoutMs?: number
readonly retries?: number
readonly worstCase?: (request: CompletionRequest) => number
readonly room?: (request: CompletionRequest) => number
readonly window?: number
readonly maxTokens?: number
readonly thinking?: 'default' | 'low' | 'off'
readonly adapts?: { readonly thinking?: 'low' | 'off', readonly prompt?: true, readonly stream?: true }
readonly streams?: true
complete: (request: CompletionRequest) => Promise<CompletionResponse>
}
interface CompletionRequest {
system: string
messages: readonly ChatMessage[]
output: { name: string, schema: JsonSchema }
replyTokens?: number
thinking?: 'low' | 'off'
structuredOutput?: 'prompt'
stream?: false | 'bare'
onProgress?: (signal: StreamSignal) => void
signal?: AbortSignal
}
interface CompletionResponse {
text: string
model: string
usage?: Usage
reasoning?: boolean
whole?: true
rateLimit?: RateLimit
}
interface RateLimit {
readonly requests?: number
readonly tokens?: number
readonly tokensLimit?: number
readonly requestsResetMs?: number
readonly tokensResetMs?: number
}
type StreamSignal
= | { readonly kind: 'headers', readonly rateLimit?: RateLimit }
| { readonly kind: 'data', readonly outputTokens: number, readonly answer: boolean, readonly reasoning: boolean }
| { readonly kind: 'keep-alive' }- Text in, text out. A request carries the instructions in
system, the fenced data inmessages(oneusermessage), the shape of the reply inoutput(namedresearch_findingsorpanel_vote, with its JSON Schema), the tokens the core budgets for the reply inreplyTokenswhen the provider states what to size it by, and the attempt'ssignal. The request has no field for a tool, a function, a file or a network capability, and quorum offers none to a model. Each shipped adapter refuses the body fields of its protocol that would offer one, soextraBodycannot add them, but a model id can bring tools of its own, which only a preset's list refuses, andheadersare sent as given: The tool fields. - No secret in a request. No environment value, key or credential appears in a request: a key lives in the adapter that holds it.
- The core never trusts the reply. It extracts and validates the JSON in
textitself, whatever the provider did to get it, and readsusage(inputTokens,outputTokens, optionalcostUsd) only when its counts are finite numbers of at least 0. reasoningsays whether the reply showed reasoning:truewhen it did,falsewhen the adapter could tell it showed none, absent when the provider cannot tell, as a provider object of your own states none. The four HTTP adapters state it;claudeCodedoes not. It is a fact about the reply, never its text.thinking,structuredOutputandstreamare what the core changes by itself, for a provider that statesadapts: a lowered thinking level after a reply ran out of room while reasoning, prompt mode after an empty reply or a refused field, and a stream moved to a bare stream or to whole replies after a server refused one or answered it whole. An adapter honours each only when it states the matchingadapts, so a setting you set is never undone: What quorum adapts by itself.- A provider that streams says so with
streams: true, and reports each sign of life of a streamed reply through the request'sonProgress: its headers, each data event with the output tokens so far, a whole number, floored, and whether an answer or reasoning has shown, and each keep-alive.whole: trueon a response says the server answered a streamed request whole: Streaming. rateLimitsays what the reply's rate-limit headers stated, as numbers: the requests and tokens left, the tokens' limit and the wait until each count resets. A reply, a stream'sheaderssignal and a failure'sProviderErrorcarry it when the server sent any: The rate-limit headers.- A provider may state its
slots, how many calls its server serves at once, which its lane holds to: Lanes. idandmodelname the provider in events and inmeta, as they were when the quorum was created.- A provider may state its deadline,
timeoutMs, its stall window,stallTimeoutMs, and itsretries: Deadlines and retries. - A provider may state its worst case,
worstCase(request): the most tokens one attempt of the request may spend, which the review's token cap reserves before it is sent (The token cap): What a provider states. - A provider may state its window, its
maxTokensand its thinking, from which the core sizes each request's reply and the findings a research request asks for (Reply budgets), and an adapter countsreplyTokensin its size guard and sends it as the server's limit, at most itsmaxTokens: What a provider states. - A provider may state its room,
room(request): how many more tokens of text the request could hold and still fit its window, counted as its size guard counts, negative when it does not fit, which the review reads to split a large change into parts, and to size a vote's context, the hunks nearest the cited line when the voter's window does not hold the section (Research in parts): What a provider states.
Prompts shows what system and messages hold.
Deadlines and retries
The core runs each call's attempts inside the call's slot, which is its provider's lane (Lanes), and gives each a deadline of its own. A call that fails in passing is retried, as often as its provider states, after a growing wait.
The deadline of an attempt
- Each attempt has a deadline, its ceiling: the provider's
timeoutMswhen it states one, whatever the reply budget. Unset, the core derives it from the attempt's reply budget, the tokens its request is asked for (replyTokens, at mostmaxTokens, else 16000), by Anthropic's SDK rule of an hour for 128000 tokens:max(600000, ceil(3600000 × budget / 128000))ms, at most 86400000, a day. The ceiling is 600000 ms for a budget up to 21333 tokens, about 70 minutes (4218750 ms) for amaxTokensof 150000, and a day from a budget of 3072000 tokens. A reasoning reply can need far more than ten minutes: a larger reply budget, or atimeoutMs, gives it more. - The ceiling grows while a stream progresses. The derived ceiling assumes about 35 tokens a second, so a local model on a CPU, which streams at a few, would be cut while it still streams. With
timeoutMsunset, a streamed attempt that has shown its first data event is not failed as its ceiling's timer fires: the ceiling grows to the time its whole reply budget takes at the attempt's own pace,budget × time run / tokens streamed, its first wait included, and the timer is armed again for the rest. The growth stops at a floor of 2 tokens a second: below that pace the ceiling isbudget × 500ms, 10512000 ms for a budget of 21024 tokens, which bounds a trickle at its budget, and it is never more than 86400000 ms, a day, and never less than the derived one. It is checked again each time the grown ceiling is reached, so a stream that keeps its pace finishes, and one that slows below the floor is cut at the bound. AtimeoutMs, a request asked for a whole reply, and the wait for a first data event keep their ceilings exactly, and the review's own deadline ends a grown attempt as it ends any. Thecallevent of an attempt that grew reportsceilingMs, the CLI's summary names the largest, andtimeoutMspinned to it keeps a fixed ceiling. - At the ceiling the core aborts the attempt's signal and fails the attempt itself, as a
timeout,<id>: no reply within 4218750 ms, so a provider that ignores its signal cannot hold a review, and what it does after is ignored. Thecall:startevent gives the ceiling of the call's first request, and the retry line of atimeoutthat grew its ceiling names the one it reached:timeout after 2h55m12s. - The review's abort ends an attempt at once, without waiting for the provider.
- The review's own deadline is apart from it. At
reviewTimeoutMs, 30 minutes by default, every attempt and every wait of the review is stopped at once, whatever time its own deadline has left, and the call fails with the review's deadline, not atimeout: The review's deadline. - The runtimes' own timers are off on every request of the HTTP adapters: Bun's idle timer with
timeout: false, and Node's 300-second header and body timeouts through a dispatcher of each request that hands it to Node's global one with both off, so a proxy agent an operator set still carries it. A long reply of a thinking model is no longer cut at 300 s. - A proxy in front of a server can still cut one: Cloudflare answers 524 after 125 s with no response, an AWS load balancer closes a connection idle for 60 s, and nginx's
proxy_read_timeoutis 60 s: Local models.
The stall window
A streamed attempt is also watched for progress, since a dead stream would otherwise wait the whole ceiling. The attempt is streamed when its provider states streams and its request is not asked for a whole reply.
- A stream silent for its window stalls: the attempt fails as a
timeoutthat says it stalled,<id>: no reply progress within 300000 ms, at most the attempt's ceiling, which is the grown one once the ceiling has grown (The deadline of an attempt). The attempt's signal is aborted with it, as at the ceiling. When the ceiling grows, a stream already quiet for a whole window stalls at once. - Progress is its headers and each data event. A keep-alive, an SSE comment, a blank NDJSON line or an Anthropic
ping, shows the connection is open and is no progress, so a stream of keep-alives alone stalls. - The window is learned per provider, in the review, and never carried to the next: 600000 ms until the provider has answered a streamed attempt, then the larger of 300000 ms and three times the longest silence among its answered streamed attempts. A silence is the time between two signs of progress, from the attempt's send to its answer, the headers one of them.
- The wait for a first token is never cut before 600000 ms, though the learned window is shorter: before an attempt's first data event its window is the larger of 600000 ms and the learned one. A busy server queues a request before its first token with no sign, and a model whose reasoning is hidden is silent before its first visible token too. From its first data event on, the learned window applies.
- A gateway that holds a stream and sends it whole at its end after minutes is read as slow, not broken: the first window passes it, and the window it learns from it is above that silence.
stallTimeoutMssets the window, from 1000 to 86400000, exactly, before and after the first data event, with no learning. Set it above the longest silence in thecallevents'longestSilenceMsfor a slower gateway, and below the ceiling: a window at or above the ceiling never fires.- A stall is a timeout: it is retried once per call as a timeout is, counted as one when a provider is found down, and worded
stalled, no progress for 5m00sin the retry line. The fix israise stallTimeoutMs, or timeoutMs. A provider found down by stalls alone says so, with that fix. - A request for a whole reply is never watched, nor is a provider that does not state
streams.
What is retried
- A failure that passes: a dropped connection, a timeout, an HTTP 408, 409, 429 or 5xx, as the error's
retryablesays, within the provider'sretriesretries after the first attempt. - Never a
refusal,truncated,no-answer,invalid-response,unsupported,too-large,processorabortedfailure as a failure that passes, whateverretryablesays: planted text can cause each of them, so a retry would let it multiply the spend. The one more send of a bad reply, below, is the call's own and happens once. - A bad reply is sent once more, once per call: a reply of only reasoning, a vote cut off at its reply budget, or a reply quorum could not read (a research reply or a vote the stage refused, such as one that repeats a key). It is sent again as it is, within the provider's
retriesas the next retry of the call's last send, once the adaptations have had their try (a lowering of thinking, the prompt mode), with its retry line:part 12 of 44: its reply held only reasoning after 4m10s, retry 1 of 2 in 1s, orpart 117 of 131: its reply could not be read after 2m10s, retry 1 of 2 in 1s. A vote's retry writes no line. A second bad reply ends the call as it would have, a send whose retries are spent sends none, andretries: 0sends no call twice. An empty reply is never sent again (the prompt mode answers it), a research reply cut off is split by recovery, not sent again, and a vote cut on the way, at a length its provider learned, is not sent again either: the same request would be cut again after as long (A gateway that cuts long calls). A provider that states no retries,claude-codeincluded, gets none. Planted text that draws one out doubles each call it reaches, at most, under the token cap. - A timeout, the core's, a stall included, or a gateway's 504 or 524, once per call: a slow request is likely slow again, and may be billed each time. A second one ends the call, and a failure that passes after a timeout is retried as any other.
- Never a reply that says its credit, spend limit or quota is used up, whatever its status, and it finds its provider down at its first failure: the code decides, never the status, since a gateway forwards its upstream's body under a status of its own. The codes are each vendor's, matched and never quoted: OpenAI's
error.codeinsufficient_quota,billing_hard_limit_reached,credit_balance_exhausted,organization_usage_limit_exceededor any..._spend_limit_exceeded, and itserror.typeinsufficient_quota; Anthropic'serror.details.error_codeenforced_spend_limit_reached, and the usage limit its user set, a 400 ofinvalid_request_errorwhose message starts withYou have reached your specified API usage limitsorYou have reached your specified workspace API usage limits; OpenRouter's 402 whosemetadata.limit_sourceisopenrouter_creditsoropenrouter_key_limit; and Gemini's per-day quota, or anerror.codethat is the stringquota_exceededorpayment_required. Such a reply is theexhaustedfield of itsProviderError, and an exhausted error is never retryable.x-should-retry: falseis never retried either, but is no used-up quota. - A
generateContent402 with no such code is never retried, and not read as a used-up quota. Google's standard body names its status as a number inerror.code: the string codes are the Interactions API's, and match only a body a gateway forwards in that form. - A reply that says
x-should-retry: trueis retried, whatever its status, and so is an OpenRouter 402 of its in-flight budget (metadata.limit_sourceofopenrouter_in_flight_budget) that carries aRetry-After, the one 402 retried. A reply that says both to retry and never to is never retried. The ramp (Anthropic'sramp_limit_exceeded) and OpenAI'sslow_downare not a used-up quota: they are retried as any 429 is. - Nothing once the review is aborted or has reached its deadline. A failure that would have been retried, which the deadline prevents, is recorded as the deadline's failure, not its own.
The wait between attempts
- Before retry n, counting the first retry as 0, quorum waits a random time from 0 to the lesser of 8 s and 0.5 s times 2 to the n.
- A server's hint of the wait it asks for, the error's
retryAfterMs, replaces that when it is above 0 and up to 60 s, and quorum waits up to a second more. A hint over 60 s ends the call at once, and so does one longer than the time the review has left before its deadline (The review's deadline); one of 0 or less, or that is not a finite number, counts as none. - A hint comes from the reply. The HTTP adapters read
retry-after-msin milliseconds, thenretry-afterin seconds or as an HTTP date, andgeminialso the body'sRetryInfo.retryDelay, such as34s. A malformed one, 0 or a date in the past is none, and only the IMF date form,Sat, 14 Nov 2026 12:00:30 GMT, is read: the runtimes read other forms as local time, or1as a year. - The wait holds the call's slot, and an interrupt ends it at once.
A gateway that cuts long calls
A gateway or proxy between quorum and the server can cut a whole reply after a fixed time, however long the model still has to write: some answer with an HTTP/2 framing error and no status, which quorum reads as network, others with a 502, 504 or 524. quorum cannot tell it from a server that is down by the failure alone, so it reads how long the attempt ran.
- A call cut on the way is one whose attempt failed with
network, or an HTTP 502, 504 or 524, after at least a minute, the shortest idle limit of the common proxies (nginx's and an AWS load balancer's). A server that is refused or unreachable fails within seconds. - Each retry says how long its attempt ran:
part 7 of 51: network after 10m00s, retry 1 of 2 in 2s. Ten minutes, again and again, is a cut, and atimeoutline keeps its own words, the deadline. - A provider found down by cuts alone gets the cut fix in place of the server's:
each call was cut after about 10m00s, likely by a proxy or load balancer on the way: make replies shorter, with a lower maxTokens or partTokens, the shortest of the three calls' lengths. The summary's fix for its gaps is the same advice. A provider that failed any call of the streak quickly gets the fix of its kind, as before. A used-up quota keeps its own line, ahead of a cut. - Streaming passes such a cut, since the connection carries bytes all the while: every HTTP adapter streams every reply, Streaming. A gateway that ends any call at a fixed length, whatever bytes are flowing, still cuts one, and quorum learns that length.
- A cut is learned from two attempts. When two of a provider's cut attempts, of any calls, differ by at most the larger of 5 percent of the shorter and 5000 ms, the shorter is the provider's cut, for the rest of the review: a path's limit is a constant, and its cuts fall within a second of each other. A stream that ends before its last event is a cut attempt too. The first cut is retried as before, and nothing is learned from one.
- A call cut at the learned length is read as a reply cut off at its limit: every attempt that ends at the cut less that tolerance or later, the one that taught it included, is a
truncatedfailure that is never retried as it was, so a provider is no longer found down by calls that were cut. It lacks what its stream showed,thinkingwhen the stream showed reasoning and no answer, elsereply, and the path of Recovering a cut-off part takes it: the thinking probe once, where the provider may lower it (What quorum adapts by itself), then the split. A gateway that honours the lowered thinking answers the re-send well inside its cut, so no part splits. One that ignores it cuts the re-send again, the lowering is recorded, and every later cut part is split at once, which costs one more attempt of the cut's length per provider and review. A vote cut so is a failed vote of kindtruncated, a reject that no flag lifts, after the same probe, and it is not sent once more as a vote cut off at its reply budget is (What is retried): the same request would be cut again after as long, and the fix is a shorter reply. The line says it once per provider:api: its calls are cut after about 15m00s on the way: a call cut so is read as a reply cut off at its limit, and its replies are held to 36000 tokens for the rest of the review, and a part split for it readsreply cut on the way after about 15m00s (thinking). - A derived reply budget is held to what the cut lets through. The rate is the one the cut attempts streamed: the attempts that taught the cut, each one's streamed estimate of output tokens over its own length, the lowest of them scaled to the cut's length. An attempt that showed no count is left out, and an answered attempt teaches no rate, since a part that queued long before its first token and wrote little would hold the budget far under what the cut lets through. A cut attempt's length is the shape of a call a cut ends, its first wait included. The budget it holds is four fifths of the cut at that rate, never under 1024 tokens: a cut of 900 s that streamed 45000 tokens holds 36000. With
maxTokensunset, every later request of the provider is budgeted at most that, its findings asked recomputed from it, andadaptedrecordsreplyTokensmoved fromderivedto the tokens held (causecut-on-the-way). A provider whose derived budgets are all already under what the cut holds has nothing lowered: noadaptedis sent, and the line ends atat its limit. A fifth of the cut is left for a first token slower than any seen. With notimeoutMsset an attempt ends at its ceiling, 600000 ms at the default budget, so only a cut shorter than that can be learned from a derived budget: amaxTokensor atimeoutMsthat lifts the ceiling lets the core see a longer one. maxTokensis honoured exactly. A budget the owner set is never lowered: the line names the value to lower it to instead,lower maxTokens to about 36000 to keep each call under it. With no rate measured, the two attempts that taught the cut being whole replies, or streams that showed no count, the budgets stay as they are and the line gives the advicemake replies shorter, with a lower maxTokens or partTokens, which the summary'sreply-cut-offfix repeats once a cut was learned.--statekeeps a call cut on the way as a cut-off, as it keeps a reply cut off at its limit, so a rerun splits its part again at once, with no call: Saved state.- A rerun reuses the calls of a lowered budget only once it learns the cut again: a lowered budget changes the key of each request it touches, so a stored reply of the unlowered request is a different entry.
- Where a reply is not streamed, make replies shorter so that each call ends under the gateway's limit: set a lower
maxTokensor leave it unset, or a lowerpartTokens, which makes more, smaller parts: The reply's limit and Research in parts.
What a provider states
timeoutMsis a whole number of milliseconds from 1000 to 518400000, an own data field of the provider object, read when the quorum is created. A getter is never run and an inherited field states nothing, so a class sets it as a field. A provider that states none has each attempt's ceiling derived from its reply budget: The deadline of an attempt.stallTimeoutMsis a whole number of milliseconds from 1000 to 86400000, read astimeoutMsis: how long a streamed attempt may show no progress. A provider that states none has the window learned: The stall window. It matters only to a provider that statesstreams.retriesis a whole number from 0 to 5, read astimeoutMsis. A provider that states none gets no retry, since the core must not retry what may retry by itself.- The shipped adapters state them. The HTTP adapters from their options:
timeoutMsandstallTimeoutMsonly when their options set them, absent otherwise, andretries, 2 by default, so a call that fails in passing makes at most three attempts.claudeCodestates no retry, and one deadline for the whole run, which is not a sum of its attempts' limits: Stopping, nesting and the version. - A config sets them too: the
timeoutMs,stallTimeoutMsandretriesfields of a provider, and the role variablesQUORUM_RESEARCH_TIMEOUT_MS,QUORUM_RESEARCH_STALL_TIMEOUT_MS,QUORUM_RESEARCH_RETRIES,QUORUM_VOTER_TIMEOUT_MS,QUORUM_VOTER_STALL_TIMEOUT_MSandQUORUM_VOTER_RETRIES, as The environment variables says. worstCaseis the most tokens, input and output, that one attempt of a request may spend as the provider is billed for it, an own data function of the provider object, read when the quorum is created and called once per call with the request, synchronously: a promise states nothing, so anasyncfunction does not state a worst case. A result that is not a safe integer of at least 1, a whole number up to 9007199254740991, a promise, or a throw, states nothing, and the core then reserves its own count of the request with 512 and 16000, as it does for a provider that states none. A class states it as an arrow-function field, since a method is inherited.- The shipped adapters state it from what their size guard counts: the text they send, the template reserve and the reply budget, which The size of a request explains.
claudeCodecounts two model turns inschemamode: The size of a Claude Code request. roomis how many more tokens of text a request could hold and still fit the provider's window, counted as its size guard counts, an own data function of the provider object, read when the quorum is created and called synchronously with a request. A safe integer counts, a whole number up to 9007199254740991 either way, 0 and negative ones included: 0 is a request that fits exactly, and a negative number is one that does not fit. Anything else, a promise or a throw, states nothing, and a class states it as an arrow-function field, since a method is inherited.- The shipped adapters state the room from their size guard,
contextTokensless the text, the template reserve and the reply budget, so a request whose room is 0 is sent and one at -1 is refused, and text added to a request lowers it by exactly its count.claudeCodestates the lesser of that and what its stdin cap leaves, 10000000 less its message at one token per byte: The size of a Claude Code request. windowis the model's context window in tokens, prompt and reply together: a whole number of at least 1, an own data field of the provider object, read when the quorum is created. The core sizes each reply from it (Reply budgets). A provider that states none, and nomaxTokenseither, is reserved and asked as it always was: its research asks formaxFindingsfindings and its requests carry no budget.maxTokensis the most tokens a reply may hold, a whole number of at least 1, read aswindowis. It is the ceiling of every reply the core budgets: a research request is asked for it, and a vote for the lesser of it and the vote's own budget.thinkingis how much the provider thinks:default,loworoff, read aswindowis. The core leaves room for the thinking the level allows when it sizes a reply: 8192 tokens fordefault, 4096 forlowand none foroff. A provider that states none thinksdefault.- The shipped adapters state them:
windowis theircontextTokens,maxTokensis their option when it is set, andthinkingis theirthinkingoption,defaultwhen it is unset orextraBodysets the control (Thinking). adaptsis what the core may change by itself for the rest of a review, an own data object read when the quorum is created:thinking, the level a lowering sends,loworoff,prompt: true, the move from JSON mode to prompt mode, andstream: true, the two steps down from a stream, each optional. State each only when the setting is automatic. A provider that states none, as one whose settings are explicit does, is never moved: quorum adapts only what a provider says it may.streamsistruefor a provider that streams its replies, read asadaptsis. A provider that does not stream states none.slotsis how many calls the provider's server serves at once, a whole number of at least 1, read aswindowis, which the provider's lane starts and stays at: Lanes. No shipped adapter states it.- The shipped adapters state
adaptsfrom their options: athinkinglevel when thethinkingoption is unset andextraBodydoes not set the protocol's control (low,offonollama, andoffonopenaiCompatibleunder thevllmandllamacpppresets),promptwhenstructuredOutputis unset on a protocol whose default isjson(openaiCompatible,geminiandollama, notanthropic) andextraBodysets none of its fields, andstreamwhen the adapter streams and itsstreamoption is unset.claudeCodestates none. - The shipped adapters state
streamswhen they stream and theirstreamoption is notfalse: the four HTTP adapters. - A value out of range is refused where the provider is given, as the issue
ports.profiles.<id>.research.<field>orports.profiles.<id>.voters.<lens>.<field>,<field>beingtimeoutMs,stallTimeoutMs,retries,window,maxTokens,thinking,adapts,streamsorslots:must be a whole number of milliseconds from 1000 to 518400000(timeoutMs),must be a whole number of milliseconds from 1000 to 86400000(stallTimeoutMs),must be a whole number from 0 to 5,must be a whole number of tokens of at least 1(windowandmaxTokens),must be a whole number of at least 1(slots),must be default, low or offandmust be an object whose thinking is low or off and whose prompt and stream are true, each optional. AworstCaseor aroomthat is not a function is refused the same way:must be a function. The message never repeats the value.
Streaming
A whole reply waits in silence until it ends, and a proxy on the way can cut it, as a gateway did at 600 s. Every HTTP adapter streams every reply and assembles it into the whole reply its reader already checks, so every check of a reply, a cut-off, an empty one, a refusal or a tool the server ran included, runs unchanged on a streamed one. Each protocol has its own stream and its own assembler:
| Adapter | Sent | Complete at | Assembled | An error inside |
|---|---|---|---|---|
openaiCompatible | stream: true and stream_options: { "include_usage": true } | The finish_reason of choice index 0, the one read, or a top-level error, then [DONE] or the body's end | The model of the first chunk; of choice 0 alone, content joined, refusal joined, the annotation types and a non-empty executed_tools; the last finish reason that is not null; the usage of the last chunk that holds one | The chunk's error, read as a whole reply's is |
anthropic | stream: true | message_stop, after a message_delta that holds a stop_reason | The model of message_start; the content blocks by index, a text joined, a thinking or redacted_thinking block kept with no text, any other block by its type; the stop reason; message_start's usage, laid over by the last message_delta's | event: error, by its error.type: anthropic |
gemini | The model's streamGenerateContent, with alt=sse in the query | A candidate's finishReason, or a promptFeedback.blockReason, then the body's end | The modelVersion; the block reason; the last usageMetadata; the first candidate's parts in order, the text parts joined, a thought part kept with no text; its finish reason | A chunk's error, Google's standard body: gemini |
ollama | stream: true, read as NDJSON | The line that holds done: true | The model; message.content joined; message.thinking as the one word that says it showed; done, done_reason, prompt_eval_count and eval_count of the done line | A line's error, read as a whole reply's is |
The sections below hold for every adapter; what is the protocol's own is in its section.
What is streamed
- Every call streams: a request holds what the table says it sends, and an
openaiCompatibleone asks for its usage in a chunk of its own after the last choice. A whole request, whichstream: falsemakes, sends none of it, andollamasendsstream: false, since its server streams unless it is told not to. - The events are read as they arrive, as server-sent events, by the rules of the WHATWG, or as NDJSON for
ollama: a comment, or a blank NDJSON line, is a keep-alive, an event ends at a blank line, and an event the body leaves unclosed is dropped. The readers hold caps that fail closed: 16 MiB of body, 1,048,576 characters in a line, 4,194,304 characters and 1000 lines in an event, and 1,000,000 characters of answer. A body that passes one, or an event that is not JSON, is aninvalid-responsethat is never retried, and the body is cancelled first. - What is assembled is the table's column. A reasoning delta (
reasoning,reasoning_content, athinkingpart, athinking_delta, athoughtpart,message.thinking) is counted as it arrives and never kept or quoted: the reply only notes that it showed reasoning. - A stream is complete at its protocol's last event, the table's third column.
openaiCompatibleandgeminiare read on to the body's end, since the usage comes after the finish reason;anthropicandollamaend their read atmessage_stopand at the done line, with the body cancelled. A stream that ends before it is anetworkfailure,the reply stream ended before its last event, retried as a dropped connection is, and never an answer. An error inside a stream ends the read at once, with the body cancelled, and fails the call as the protocol's own failure does: anhttpfailure of its status, retried as that status is, or aninvalid-responsewhere it has none. - The usage is the last cumulative count, never a sum of deltas. A stream that reports none settles at the attempt's whole reservation, as a reply with no usage does: The token cap.
- The attempt's signal ends a stream at once: an abort in the middle of a body rejects the read, and the server sees its connection close. A read that rejects is
abortedwhen the attempt's signal is aborted, elsenetwork. - The adapter reports each sign of life through the request's
onProgress: oneheaderssignal when the reply is a stream, and none for a whole reply, adatasignal for each data event with the output tokens so far, a whole number: the larger of the server's own count, floored, and a quarter of the characters streamed, and whether an answer or reasoning has shown text, and akeep-alivesignal for each comment, each blank NDJSON line and eachpingofanthropic, which is no progress.
stream
stream | The provider | A refusal |
|---|---|---|
| Unset | Streams, and states streams and adapts.stream | Moved by itself, as below, and shown |
true | Streams, and states streams alone | Fails the call. A provider found down by it says set stream: false |
false | Asks for whole replies, as before streams, and states neither | None to refuse |
stream: false is the choice for a server or a gateway that cannot stream, or when you would rather have a whole reply. A config sets it with the stream field of a provider, and QUORUM_RESEARCH_STREAM and QUORUM_VOTER_STREAM set it for a role, as true or false exactly: The environment variables.
When a server refuses
A 400 or 422 whose body names a word of the request as a whole word is marked, as a code word and never a quote, and moves a provider whose stream is unset down two steps, each probed once per provider and review as What quorum adapts by itself describes:
stream_optionsmoves the provider to a bare stream, with no stream options. Each call then settles at its reservation, since the server sends no usage: the line says so.streammoves it to whole replies, withstream: falsesent. A server that refuses the bare stream as a stream steps on to whole replies in the same call.anthropicandollamatake this step alone, on a body that namesstream, andgeminion one that namesstreamGenerateContent, since its stream is a path and not a field.- A step moves only when its re-send answers. A refused or failed one moves nothing and ends the call with the failure that began it.
- A word counts only when a request sent it: a bare stream names no stream options, and a whole request names no stream.
streamingorstream_optionis another word. stream_optionsis refused inextraBody, since the adapter writes it:<id>.extraBody.stream_options: is written by the adapter and cannot be replaced.- A
geminigateway with no stream path answers 404, which is no refusal quorum probes, since only a 400 or a 422 is one: setstream: falsethere, and the adapter posts togenerateContent.
When a server answers whole
A server that answers a streamed request with a JSON body, not a stream, is read as a whole reply. The content type decides, by its media type alone, the text before any ;, trimmed and in lower case: text/event-stream; charset=utf-8 is a stream, and application/json, or no content type, is a whole reply. A provider whose stream is unset is then moved to whole replies for the rest of the review, with no probe, and the line says the server answered a streamed call whole. A provider with stream: true reads the whole reply and moves nothing. A request that asked for a whole reply, as one moved to stream: false does, is no such answer.
A whole reply is what a proxy can cut, as a gateway did in 0.7.0 at 600 s, so stream: false is a choice made knowing it.
What a gateway must pass
text/event-stream, unbuffered, with a content type whose media type is that: a charset after it is fine.ollamastreamsapplication/x-ndjson.- Every event as it is written: a gateway that holds the stream and sends it at the end gives an answer after the same wait as a whole reply, and passes no cut it was never going to pass.
- Comments (
: ping) are signs of life, and a keep-alive is no progress of its own.
The rate-limit headers
A server says in the headers of each reply how much of its limit is left, and a failed reply says it too. Every HTTP adapter reads them, from a stream's headers as they arrive, from a whole reply and from a failure, and states what it read as numbers in rateLimit: on the headers signal of a stream, on the response and on the ProviderError. A whole reply that fails as it is read, cut off at its limit or with no answer, keeps its headers on its error, and the lane reads them at its end. The names read, each field from the first that holds a well-formed value:
| Field | OpenAI's name | Anthropic's name |
|---|---|---|
requests, left | x-ratelimit-remaining-requests | anthropic-ratelimit-requests-remaining |
tokens, left | x-ratelimit-remaining-tokens | anthropic-ratelimit-tokens-remaining |
tokensLimit | x-ratelimit-limit-tokens | anthropic-ratelimit-tokens-limit |
requestsResetMs | x-ratelimit-reset-requests | anthropic-ratelimit-requests-reset |
tokensResetMs | x-ratelimit-reset-tokens | anthropic-ratelimit-tokens-reset |
- A count is decimal digits, at most 15. A sign, a fraction, an exponent or a longer number is read as nothing.
- OpenAI's resets are durations,
1s,6m0s,1h2m3.5s,20msor1.5s, in hours, minutes, seconds and milliseconds, read as milliseconds.0sis no wait left. - Anthropic's resets are RFC 3339 dates,
2026-11-22T10:00:30Z, matched by their shape before they are read and taken as the milliseconds from now. A date already past is read as nothing, since a clock that is off must not read as a reset that came. - The generic
x-ratelimit-limit,x-ratelimit-remainingandx-ratelimit-resetare not read: they name no window. - A malformed header is read as nothing, and one good header beside it is still read. A reply with none well formed carries no
rateLimit. - A value is read as a number and never copied: no header value reaches an error message, a line or a log.
Lanes
With the review's concurrency unset, each provider has a lane: a limit of its own on the calls it has in flight, inside a ceiling of 16 calls in flight over every provider. A review of several providers so never lets one gateway's throttling slow the others, and a provider with room is never held to four calls. The lane of a provider object is shared by every profile and role that uses it.
- A call waits in this order: its lane's slot, then its lane's pause and pacing waits, then a slot of the review's ceiling, and only then does it build its request and run (a request is built inside both slots, so the requests held at once stay as few as the calls). The queues are first come, first served. The pause and pacing waits end at once at the review's deadline or interrupt, as a wait between two attempts does, and a call waiting for them holds no slot of the ceiling, so it takes none from the other lanes.
- A lane starts at 4 calls at once. It is the limit of releases before lanes, and at quorum's rate, a few calls of a minute or more each, it is far below the ramp a hosted tier limits, so a lower start would only slow the first minutes of every review. A throttle that comes at once still cuts the lane.
- It grows by one after a window of clean answers, as many as the lane's limit since its last change, with no throttle signal among them, while the last reply's headers hold one more call. The ceiling is 16, four times the start: room for a hosted tier, and a bound on what a review holds at once. A lane that grew only on clean answers would ramp a local server or a gateway into queueing with no error, then into timeouts, so it grows only on the provider's own word.
- It halves on a throttle signal, at least to 1, and once per window: an
http429 that is not anexhaustedquota, a 503, 504, 524 or 529 (an overload inside a stream is one), atimeout, a stall included. A throttle from a call sent before the last change cuts nothing more, since it answers the load the lane has already shed. After a cut, a lane below its start grows back by one after each window of clean answers, with no header needed, up to its start. - A throttle's
Retry-Afterpauses the lane: its new calls wait until it passes, at most 60 seconds, the longest hint a retry waits for. The calls already in flight go on. A server can slow its own lane, never stop it. - The headers pace the lane. A call waits, before it starts, while the last reply said no request is left, or fewer tokens are left than the lane's calls since then reserve with this one's. It waits for the headers' reset, the tokens' when tokens run short and else the requests', at most 60 seconds, and then starts, and the server's answer decides from there: pacing only delays, never refuses, and a reset that says now, or none, waits for nothing.
- How the tokens are counted depends on the server. A server that counts a request as it arrives has it in the tokens left already, so the lane counts each call at its reservation, and only the calls it sent since the reply whose headers it reads. A server that counts a reply as it ends shows it as a stream starts, in the headers sent as the request is accepted, before the body: they state fewer tokens used than half the reply budget the request carried (the half absorbs a count rounded to the thousand). Only those headers decide it: a refusal's, which the server may never have counted, and a whole reply's at its end, on a window that may have given its count back, do not. The lane then counts every call in flight at its expected use, a third of its input and its reply at the lesser of its budget and 4096 tokens, and a lane grows past what the reservations alone would allow. Requests are counted as they arrive, in both. A streamed request a server answers whole is such a reply, with no stream start to read, whatever its headers say. A provider that asks for whole replies, with
stream: falseor once the core moved it to them, has no stream start to read either, so its lane counts every call at its reservation, whatever its server does. - A provider that sends no rate-limit headers never grows past 4: a lane without a header has nothing to tell it there is room. It is still cut by a throttle and grows back to 4. Set
concurrencyto run more, if its gateway has room: The calls at once. Gemini, Ollama and a Claude Code run send none of their own, but every HTTP adapter reads OpenAI's and Anthropic's names, so a gateway in front of any of them grows its lane. - A provider states its server's slots as
slots, a whole number of at least 1, which an adapter or a library program states of its server. The lane then starts and stays at the lesser ofslotsand 16, sends oneconcurrencyevent of causeslots, and a throttle still halves it. No adapter statesslotsyet; a local server's parallel requests are set withconcurrency: How many calls at once. concurrencyset keeps one limit shared by every provider, with no lane, no event and no pacing: The calls at once.- What it says: each change of a lane's limit, each pause and each pacing wait is a
concurrencyevent (Events), andmeta.concurrencyrecords, per provider, its lowest and highest limit, its cuts and whether it sent headers: The lanes.
The adapters
Quorum ships one adapter per wire protocol, and one that runs your installed Claude Code CLI:
| Adapter | For | Endpoint | Default auth | Default temperature | Default structuredOutput |
|---|---|---|---|---|---|
openaiCompatible | Any OpenAI-compatible endpoint: vLLM, TGI, llama.cpp, LM Studio or a hosted API. Ollama has ollama: its /v1 cannot be told the context size | POST {baseUrl}/chat/completions | 'bearer' | 0 | 'json' |
anthropic | The Anthropic Messages API, or a gateway that speaks it | POST {baseUrl}/v1/messages | 'bearer' | Left out | 'prompt' |
gemini | The Gemini API's generateContent | POST {baseUrl}/v1beta/models/{model}:streamGenerateContent?alt=sse, :generateContent for a whole reply | { header: 'x-goog-api-key' } | Left out | 'json' |
ollama | Ollama's native chat API, on a local server or Ollama's cloud: the CLI's built-in default | POST {baseUrl}/api/chat | 'bearer' | 0 | 'json' |
claudeCode | Your installed Claude Code CLI, run headless for each request | Spawns claude -p | 'inherit', of its own three modes: The auth modes | Not supported | 'schema' |
import { anthropic, claudeCode, gemini, ollama, openaiCompatible } from '@tobi-or-not/quorum'
const local = ollama({
id: 'local',
baseUrl: 'http://localhost:11434',
model: 'qwen3.6:27b',
contextTokens: 131072
})
const claude = anthropic({
id: 'claude',
baseUrl: 'https://api.anthropic.com',
model: 'claude-opus-5-5',
contextTokens: 200000,
apiKey: process.env.ANTHROPIC_API_KEY,
structuredOutput: 'schema'
})
const flash = gemini({
id: 'flash',
baseUrl: 'https://generativelanguage.googleapis.com',
model: 'gemini-3.8-flash',
contextTokens: 1000000,
apiKey: process.env.GEMINI_API_KEY
})
const hosted = openaiCompatible({
id: 'hosted',
baseUrl: 'https://api.openai.com/v1',
model: 'gpt-6-astra',
contextTokens: 400000,
apiKey: process.env.OPENAI_API_KEY,
temperature: null,
maxTokensField: 'max_completion_tokens'
})
const code = claudeCode({ id: 'code', model: 'sonnet', contextTokens: 1000000 })Every HTTP adapter sends one JSON POST per call through the same hardened path, The limits of a request, passes the request's signal to fetch with the runtime's own timers off: The deadline of an attempt, and reports in usage every prompt token the request carried, cached ones included, and every token the model generated, thinking included, from the counts its protocol sends: never a cost. The counts a protocol keeps apart, such as Anthropic's cache tokens or Gemini's thought tokens, are added in when they are numbers; a reply without both main counts as numbers reports no usage. A reply the adapter reads and then refuses, cut off at its token limit, with no answer, refused or unusable, carries the same counts in its ProviderError's usage, which the review counts: a status outside 2xx carries none. claudeCode sends no request of its own: it runs a process, claudeCode, and is the one adapter that reports a cost.
Presets
A preset is a row of data for a vendor's or a server's endpoint: the protocol it speaks, and the defaults it fills in for a provider, baseUrl, auth, structuredOutput, temperature and, for the openai-compatible protocol, maxTokensField. Any of them set on the provider wins. A field set to undefined counts as unset, so a spread of a value that was never given keeps the preset's; temperature: null is set, and leaves the temperature out.
| Preset | Protocol | Base URL | Key header | Key variable | structuredOutput | temperature | Token-limit field |
|---|---|---|---|---|---|---|---|
ollama | ollama | http://localhost:11434 | Authorization: Bearer | None | json | 0 | options.num_predict |
ollama-cloud | ollama | https://ollama.com | Authorization: Bearer | OLLAMA_API_KEY | json | 0 | options.num_predict |
lmstudio | openai-compatible | http://localhost:1234/v1 | Authorization: Bearer | None | schema | 0 | max_tokens |
llamacpp | openai-compatible | http://127.0.0.1:9931/v1 | Authorization: Bearer | None | json | 0 | max_tokens |
vllm | openai-compatible | http://localhost:8000/v1 | Authorization: Bearer | None | json | 0 | max_tokens |
openai | openai-compatible | https://api.openai.com/v1 | Authorization: Bearer | OPENAI_API_KEY | json | Left out | max_completion_tokens |
azure-openai | openai-compatible | None: the provider sets its own | api-key | AZURE_OPENAI_API_KEY | json | Left out | max_completion_tokens |
openrouter | openai-compatible | https://openrouter.ai/api/v1 | Authorization: Bearer | OPENROUTER_API_KEY | prompt | 0 | max_tokens |
groq | openai-compatible | https://api.groq.com/openai/v1 | Authorization: Bearer | GROQ_API_KEY | json | 0 | max_completion_tokens |
mistral | openai-compatible | https://api.mistral.ai/v1 | Authorization: Bearer | MISTRAL_API_KEY | json | 0 | max_tokens |
deepseek | openai-compatible | https://api.deepseek.com | Authorization: Bearer | DEEPSEEK_API_KEY | json | 0 | max_tokens |
together | openai-compatible | https://api.together.ai/v1 | Authorization: Bearer | TOGETHER_API_KEY | json | 0 | max_tokens |
fireworks | openai-compatible | https://api.fireworks.ai/inference/v1 | Authorization: Bearer | FIREWORKS_API_KEY | json | 0 | max_tokens |
xai | openai-compatible | https://api.x.ai/v1 | Authorization: Bearer | XAI_API_KEY | json | 0 | max_completion_tokens |
anthropic | anthropic | https://api.anthropic.com | Authorization: Bearer | ANTHROPIC_API_KEY | schema | Left out | max_tokens |
gemini | gemini | https://generativelanguage.googleapis.com | x-goog-api-key | GEMINI_API_KEY | json | Left out | generationConfig.maxOutputTokens |
- The key variable is the one the vendor documents for its key.
fromConfigandloadConfigread it, but only while the base URL keeps the preset's origin, and warn when it does not: a key is sent only to the endpoint it belongs to.AZURE_OPENAI_API_KEYis one variable for every Azure resource, since the preset has no base URL: it is read for anhttpshost underopenai.azure.com, so a voter whose own variables nameazure-openaion another Azure host sends that key there. A preset sends no key it is not given, and a local server needs none:vllm,llamacppandlmstudiotake one as a bearer token once the server is started with one. - The defaults follow the vendors.
temperatureis0unless the vendor rejects one, as OpenAI's and Azure's reasoning models and Anthropic do, or its current models ignore it, as Gemini's do.structuredOutputisjsonwhere the server documents a JSON mode,schemawhere it documents only a schema (LM Studio, and Anthropic, which has no JSON mode), andpromptfor OpenRouter, whose support depends on the model a request is routed to and which ignores a format the endpoint cannot honour.openai,azure-openai,groqandxaisendmax_completion_tokens, which their vendors document in place of a deprecatedmax_tokens. DeepSeek's base URL has no/v1. ollama-cloudis Ollama's cloud,https://ollama.com, reached through the same native/api/chatas a local server, with a key.azure-openaihas no base URL: set your resource's v1 endpoint,https://<resource>.openai.azure.com/openai/v1, and name your deployment as the model. Without a base URL it is a configuration error.
The model ids a preset refuses
A model id can bring tools of its own, which no body check sees. A preset lists the ids of its vendor that run a tool on the server by themselves, as patterns where * stands for any text, possibly empty, and every other character for itself. A provider built from the preset refuses a model that a pattern matches whole, in any letter case: <id>.model: runs tools on the server by itself, which quorum never allows. The patterns also apply to a provider whose base URL has a preset's origin (its scheme, host and port), whether or not it names a preset: a provider with only a protocol, pointed at Groq's endpoint, is held to Groq's patterns, and so is one built from another preset and pointed there. The host is read in lower case, a default port is dropped and so is one trailing dot, so HTTPS://API.GROQ.COM:443/v9 and https://api.groq.com./openai/v1 have Groq's origin; another port is another origin.
| Preset | Refused model ids | Why |
|---|---|---|
openai | *search*, *computer-use* | The search models, such as gpt-5-search-api, search the web before every answer, and the computer-use models drive a browser |
openrouter | *:online*, *@preset/*, openrouter/fusion*, openrouter/auto*, perplexity/*, *search* | :online adds a web search, a @preset/ slug can hold tools, openrouter/fusion runs with web search and web fetch, openrouter/auto routes to a pool of models OpenRouter does not publish, which may hold search models, and Perplexity's models and any search model search by themselves |
groq | openai/gpt-oss-*, groq/compound*, compound-beta* | gpt-oss runs Groq's built-in web search and code execution by itself, which no parameter turns off, and the compound models run tools by themselves |
xai | *multi-agent* | The multi-agent model works only on the Responses API, where xAI runs its server-side tools |
gemini | *deep-research*, *antigravity*, *computer-use* | Deep Research and Antigravity are agents that search, fetch URLs and run code, and the computer-use models drive a browser. A Gemini id is matched with its models/ prefix too |
The other presets know no such id: on azure-openai the model is a deployment name you choose. A model no pattern knows, or one reached through a gateway or a proxy at another origin, can still run a tool, and openaiCompatible then fails the reply that shows it, openaiCompatible.
Presets as data
presets is exported read-only: the table, each row, its auth and its toolModels are frozen, so a change throws a TypeError in strict-mode code, as every ES module is; elsewhere the write is ignored, and the values never change either way, so no program can alter the defaults another provider reads. A row has the fields protocol, baseUrl, auth, apiKeyEnv, structuredOutput, temperature, maxTokensField and toolModels, and apiKeyEnv is the "Key variable" column. Preset types a row, PresetName names one and Protocol names the four wire protocols. fromConfig builds each provider a config defines from its preset or its protocol, through the checks below and the model-id refusals: loadConfig and fromConfig. The CLI builds its providers through fromConfig, so its refusals are the same. A program that passes a preset's values to an adapter itself gets only the adapter's checks. Those already refuse, in every adapter, the body fields that offer a tool; the reply check of openaiCompatible is the one that covers a tool a model id brings, openaiCompatible, and it has limits. It runs after the server ran the tool: it keeps a review from being built on the tool's output, but what the tool sent has already left, and a search query can quote the diff. Groq reports executed_tools whatever the model does, while a url_citation appears only when the reply cites a source, so a search model that cites nothing can pass. So choose a model that runs no tool.
A provider built from a preset or a protocol is checked first for the problems below, then with its adapter's own checks, Configuration errors, and every problem comes in one ConfigError, these first. While the protocol, the base URL or the model is unusable, these come alone. The builder reads a spec's fields once each, and only its own: a field that only a prototype holds, such as one planted on Object.prototype, is unset, and a getter is called once, so the checks and the adapter see the same value. The auth object goes to the adapter as a copy of its own fields too. That is the builder's own read: the schema that checks a config before the builder has a limit of its own, loadConfig and fromConfig. No message repeats a value:
| Path | Message |
|---|---|
<id>.preset | must be one of ollama, ollama-cloud, lmstudio, llamacpp, vllm, openai, azure-openai, openrouter, groq, mistral, deepseek, together, fireworks, xai, anthropic or gemini |
<id>.protocol | is required without a preset |
<id>.protocol | must be openai-compatible, anthropic, gemini, ollama or claude-code |
<id>.protocol | must be <protocol>, the protocol of the <preset> preset, for a protocol other than the preset's |
<id>.baseUrl | is required without a preset, for a protocol other than claude-code, which has no base URL |
<id>.baseUrl | is required: the azure-openai preset has none |
<id>.baseUrl | must be a string, for a base URL that is set to anything else, null and a String object included |
<id>.maxTokensField | is only for the openai-compatible protocol |
<id>.args, <id>.command | is only for the claude-code protocol |
<id>.model | is required, for a model that is unset |
<id>.model | must be a model id of visible ASCII characters, with no space |
<id>.model | runs tools on the server by itself, which quorum never allows |
The shared options
These are the options of the four HTTP adapters. claudeCode takes id, model, contextTokens, maxTokens, apiKey, structuredOutput, timeoutMs and retries, with its own rules, refuses the rest (thinking among them: its effort is --effort in args), and has options of its own: Claude Code options.
Options
| Option | Type | Default | Does |
|---|---|---|---|
id | string | Required | Names the provider in events, meta and its error messages |
baseUrl | string | Required | An http:// or https:// URL with a host, and no user name, password, query or fragment. Requests go to it, its trailing slashes removed, followed by the adapter's path and the query |
model | string | Required | The model every request names: in the body, or in the URL for gemini |
contextTokens | number | Required | The model's context window in tokens, prompt and reply together. A request that may not fit it is refused before it is sent: The size of a request |
apiKey | string | None | Sent as auth says, and nowhere else. Without it, or with an empty one, no key header is sent |
auth | 'bearer' | 'x-api-key' | 'none' | { header, prefix? } | The adapter's | How the key is sent: The key header |
headers | Record<string, string> | None | Sent with every request, names lower-cased. They cannot replace content-type, content-length, host, the key header, or anthropic's anthropic-version. Their values are redacted from error messages, as the key is |
query | Record<string, string> | None | Added to every request URL. Not redacted from error messages: never put a key here. A value equal to apiKey is refused, and gemini refuses the names key and alt, in any letter case |
extraBody | Record<string, unknown> | None | JSON values deep-merged into the body last: objects merge key by key, anything else replaces. A top-level key cannot replace a field the adapter writes for the conversation, or set one that offers the model a tool: The tool fields. Nor can it set the reply limit, which maxTokens sets: The size of a request |
temperature | number | null | The adapter's | Sent where the protocol takes it; null leaves it out, for a model that rejects it |
maxTokens | number | Derived from the window | The most tokens a reply may hold, thinking included: the ceiling of every reply, sent as the server's limit in the protocol's own field. Unset, each request is sent the reply budget the core derives for it, else 16000: The reply's limit |
timeoutMs | number | Derived from the reply budget | The deadline of one attempt, in milliseconds, from 1000 to 86400000: The deadline of an attempt |
stallTimeoutMs | number | Learned | How long a streamed attempt may show no progress, in milliseconds, from 1000 to 86400000: The stall window |
retries | number | 2 | How many times a call that failed in passing is tried again, from 0 to 5: What is retried |
systemPrompt | 'native' | 'inline' | 'native' | native sends the system text in the protocol's own place; inline puts it at the head of the first user message, joined by a blank line, for a chat template that rejects a system role |
structuredOutput | 'prompt' | 'json' | 'schema' | The adapter's | How the reply's shape reaches the endpoint: Structured output |
thinking | 'low' | 'off' | The server's own | How much the model thinks, sent as the protocol's own control: Thinking |
stream | boolean | Unset: streamed | true pins the stream, so a refusal fails the call; false asks for whole replies. Unset, quorum steps down by itself when a server refuses a stream's options, refuses streaming or answers a stream whole: Streaming. Every HTTP adapter streams |
systemPrompt: 'inline' sends the instructions in the same user message as the fenced data, so they lose the role that sets them apart from it: a weaker separation than the one Prompts describes. When the conversation does not start with a user message, inline sends the system text as a user message of its own.
HttpProviderOptions types every option here. OpenAICompatibleOptions adds maxTokensField, and AnthropicOptions, GeminiOptions and OllamaOptions are HttpProviderOptions as it is.
The key header
auth names the header that carries apiKey, and the key goes nowhere else:
auth | Header |
|---|---|
'bearer' | Authorization: Bearer <key> |
'x-api-key' | x-api-key: <key> |
'none' | none; a key set as well is a configuration error |
{ header: 'api-key' } | api-key: <key> |
{ header: 'X-Token', prefix: 'Token ' } | x-token: Token <key> |
{ header: 'authorization', prefix: 'Basic ' } | authorization: Basic <key>: basic auth, with the base64 of user:password as the key |
A custom header name is lower-cased, and its prefix goes before the key. A request sends its headers in this order: the content type, the provider's own headers, then the key header; anthropic sends its version header last.
Structured output
| Mode | openaiCompatible | anthropic | gemini | ollama |
|---|---|---|---|---|
prompt | No response_format | No output_config | No responseMimeType | No format |
json | response_format: { "type": "json_object" } | Refused: the Messages API has no JSON mode | generationConfig.responseMimeType: "application/json" | format: "json" |
schema | response_format: { "type": "json_schema", "json_schema": { "name": <output.name>, "schema": <output.schema>, "strict": true } } | output_config: { "format": { "type": "json_schema", "schema": <output.schema> } } | generationConfig.responseMimeType: "application/json" and generationConfig.responseJsonSchema: <output.schema> | format: <output.schema> |
Unset, structuredOutput is automatic: the mode a preset gives, else the protocol's default, json on openaiCompatible, gemini and ollama and prompt on anthropic. A preset's json is that automatic start, and quorum moves a provider that starts there to prompt for the rest of a review when a reply comes back empty, or when the server answers a 400 or 422 that names the field (response_format, responseMimeType, responseJsonSchema or format): What quorum adapts by itself. It never moves from schema, which a preset such as lmstudio or anthropic sets, nor from a mode you set, json and prompt included, nor when extraBody sets the field. The provider states what it may move in adapts (What a provider states).
Every mode keeps the schema in the system message, and the core validates the reply the same way in each. schema asks the endpoint to enforce the shape; use it where the endpoint supports it, json where it supports only JSON mode, and prompt where it supports neither. An endpoint can drop the field without a word: Ollama's and DeepSeek's Anthropic-compatible endpoints ignore output_config.format, so schema is enforced only where the endpoint supports it, and Anthropic accepts it only on the models its structured-outputs page lists.
Thinking
A reasoning model can spend its whole reply on thinking, so thinking turns it down. Each protocol maps the two values to its documented control, and the adapter sends the control with every request, before extraBody is merged:
| Protocol | low | off |
|---|---|---|
openaiCompatible | reasoning_effort: "low" | reasoning_effort: "none" |
anthropic | output_config: { "effort": "low" }, merged beside the format of schema mode | Refused |
gemini | generationConfig.thinkingConfig.thinkingLevel: "LOW" | thinkingLevel: "MINIMAL", Gemini's "little to no thinking" |
ollama | think: "low", which a model without named levels reads as its default | think: false, the lowest level of a model that cannot turn thinking off |
claudeCode | Refused | Refused |
Unset, no control is sent: the server's own default holds. The provider states its thinking to the core as its option's level, default when it is unset, from which the core sizes the reply budget (Reply budgets). It states default too when extraBody sets the control, since quorum cannot read that level.
Three things are refused when the provider is built, each a configuration error at <id>.thinking:
thinking: offonanthropic:the anthropic protocol has no one setting that turns thinking off on every model: set thinking: low, or set thinking in extraBody for your model. Claude Opus 5.5 answers 400 todisabled, and Claude Sonnet 5.5 takesbetween_tools, so no one value turns it off.- Any
thinkingonclaudeCode:claude-code takes its effort from args: --effort low. thinkingbeside the same control inextraBody:is set, and extraBody sets <field> too: two settings for one control, so keep one,<field>beingreasoning_effort,output_config.effort,generationConfig.thinkingConfigorthink.extraBodyis merged last, so it would undo the setting.
A value that is neither low nor off is must be low or off. A server whose model or chat template does not know the value can answer a 400, and the call then fails with that status: set the control in extraBody for such a model, as Reasoning mode shows for the servers' own fields. The role variables QUORUM_RESEARCH_THINKING and QUORUM_VOTER_THINKING set it from the environment: Thinking.
The tool fields
Each adapter refuses, in extraBody, the body fields of its protocol that would offer the model a tool or a server-side capability. A tool the server runs, such as a web search, code execution, a URL fetch or an MCP server, could carry the data out, and quorum offers a model none:
| Adapter | Refused fields |
|---|---|
openaiCompatible | tools, tool_choice, parallel_tool_calls, functions, function_call and web_search_options, which OpenAI and others take; OpenRouter's plugins, deferred_tools, stop_server_tools_when, x_search_filter, preset and models, a fallback list whose ids can bring tools as :online does; xAI's search_parameters; Groq's compound_custom, search_settings, include_domains, exclude_domains, disable_tool_validation and documents; Azure's data_sources, which grounds the reply on an external search index (On Your Data) |
anthropic | tools, tool_choice, mcp_servers, which offers an MCP server's tools with no tools entry under a deprecated beta, container, which loads skills, and the beta's server-side fields thread, fallbacks, fallback_credit_token, context_management and compaction |
gemini | tools, toolConfig, and cachedContent, since a cached content can hold tools of its own |
ollama | tools, and _debug_render_only, which answers with the rendered template instead of a reply |
Each is a configuration error: <id>.extraBody.<key>: offers the model a tool, which quorum never does. A key matches in any letter case and with or without underscores, since Ollama's Go decoder reads a key in any letter case, U+017F matching s and U+212A matching k, and Gemini's proto JSON takes a field's snake_case name: Tools and tool_config are refused too, and so is a field the adapter writes, such as Messages. openaiCompatible lets chat_template_kwargs through: it sets chat-template variables, such as turning thinking off on vLLM or Together, and runs nothing on the server.
Two ways around these checks remain, and both are the program's to avoid:
- A model id can bring tools of its own, which no body check sees: OpenAI's search models search the web before every answer, and OpenRouter's
:onlinesuffix, itsopenrouter/fusionmodel and its@preset/ids add a web search or a stored preset's tools. A preset refuses the ids it knows, The model ids a preset refuses, andopenaiCompatiblefails a reply that shows a tool the server ran, but a model no list knows can still search before it answers. Choose a model that runs no tool. headersare sent as given.anthropicaccepts ananthropic-betaheader, which serves needs such as a longer context window: no documented beta header offers a tool by itself, and the body fields a beta would need are refused.
The limits of a request
Every request goes through one hardened path:
- A redirect is not followed. It is an
httperror that names it,HTTP 307 (redirects are not followed): "<body>", so a key in any header never reaches another endpoint. - A reply body over 16 MiB is refused, without reading the rest.
- At most 64 KiB of an error body is read, enough for the 500 characters a message quotes.
- A failed reply's hint and codes are read as numbers and words, never quoted: the message quotes the body as before.
- Server text in a message is redacted of the key, of the base URL's path and of the values of
headers, as written and trimmed, sincefetchsends a header value trimmed; a value that is blank once trimmed redacts nothing. Every occurrence is redacted, and values that overlap in the text become one[redacted]. It is redacted once escaped ASCII is decoded, each value matched as written and with its own escapes decoded, then cut to 500 characters: 200 for model text and for a server error in a 2xx reply, 40 for a stop or finish reason. A server echoes the path in a 404, and a gateway's own credential goes in a header, so both are redacted too.
The size of a request
Some endpoints cut a prompt that is too long for the model in silence and still answer 200, and a review of text the model never read is worse than none. So every adapter requires contextTokens, and checks every request, research and vote alike, after shaping it and before sending it, and refuses one that may not fit:
- The text is the system text and every message as the adapter sends them (
systemPrompt: 'inline'counts the blank line that joins them), at one token per UTF-8 byte, each code point at its longest form (as it is, decomposed with NFD, or compatibility-decomposed with NFKD), and the reply schema's JSON once more, since a server may add it to the prompt. - The chat template takes 512 tokens, for what a server adds around the messages.
claudeCodekeeps 4096 instead, for the context Claude Code adds itself: The size of a Claude Code request. - The reply takes the request's reply budget, which the core derives from the window (Reply budgets), at most
maxTokenswhen it is set; elsemaxTokens; else 16000. Every adapter sends that number as the server's limit, so the budget the guard keeps is the one the server enforces: The reply's limit.
A request is sent only when text + 512 + reply <= contextTokens. One token per byte bounds byte-level BPE and byte-fallback SentencePiece tokenizers. Counting each code point at its longest form bounds every normalized form of the text, so a tokenizer that normalizes with NFC, NFKC, NFD or NFKD first stays bounded: Qwen 2.5's NFC normalizer turns 300 bytes of U+0F81 into 500 tokens, which is why the count is not the raw bytes. Decomposition works one code point at a time and composing never lengthens UTF-8, so the sum is an upper bound, and the text is never normalized as a whole, which takes quadratic time on a long run of combining marks. Case folding is not proven covered, and no chat model's tokenizer is known to fold case. It costs room: accented letters count one more byte per accent, Hangul syllables up to three times their size, and code runs about three bytes to a token, so the guard accepts about a third of the diff that would really fit.
The core counts a request's text with the same bound, so the worst case a provider states and the core's own count never drift.
The room a provider states is this bound read the other way, contextTokens − (text + 512 + reply), with the request's own reply budget, from the same count, so the two never drift: What a provider states.
A request over the bound is not sent. The call fails with a ProviderError of kind too-large, which is not retryable, and its message holds the provider id and numbers only, never the text or the URL: <id>: may need <n> tokens, more than contextTokens (<c>): <t> for its text at one token per byte, 512 for the chat template and <r> for the reply. The review records it as a gap: ProviderError.
A provider with no contextTokens is refused when the adapter is called, before any request, whether or not a profile uses it: <id>.contextTokens: is required: the model's context window in tokens, which quorum checks every request against. No adapter is exempt, the hosted APIs that refuse an oversized prompt themselves included: that refusal is a research-failed gap, exit 4, or exit 3 when no research request of any profile answered, and on a vote it is a failed vote with no request-too-large gap, which only a refusal quorum makes itself records. The CLI's resolution names where to set one instead: Configuration.
A contextTokens that leaves no room for a request would refuse every request, so it is a configuration error when the adapter is called. With maxTokens unset the reply has no budget yet, since the core derives one for each request from the window, so the template reserve alone must fit: <id>.contextTokens: must be more than 512, the tokens kept for the chat template. With maxTokens set, it must hold that and the reply: <id>.contextTokens: must be more than 16512, the 16000 tokens of the reply budget and 512 for the chat template, for a maxTokens of 16000.
extraBody cannot set the reply limit. The guard reserves maxTokens for the reply, so a limit set there would send more than it reserved. Each adapter refuses these fields, in any letter case, and maxTokens sets the limit instead:
| Adapter | Refused fields |
|---|---|
openaiCompatible | Both max_tokens and max_completion_tokens, whatever maxTokensField names |
anthropic | max_tokens |
gemini | generationConfig.maxOutputTokens |
ollama | options.num_predict |
Each is a configuration error, <id>.extraBody.<key>: sets the reply limit: use maxTokens, where <key> is the field's path, such as generationConfig.maxOutputTokens. The key is matched as in The tool fields.
The guard does not count the text that extraBody adds to a request, such as a vLLM chat_template, and the 512 tokens do not cover what a server adds beyond them, such as an Ollama Modelfile's TEMPLATE or SYSTEM. It does not see a server-side switch that truncates a prompt either, which extraBody can turn on: vLLM's truncate_prompt_tokens, or OpenRouter's transforms with middle-out. Do not set one. It trusts the number it is given: a server that loads a smaller context than contextTokens can still cut a prompt in silence, which is why ollama is told the context it counts with, below.
The reply's limit
Planted text can draw a reply out to the model's whole window, so every request carries the reply's limit in the field of the last column of the presets table, and the server stops the reply there. The limit is the request's reply budget, which the core derives from the window and the request's kind (Reply budgets), at most maxTokens when that is set, which is a ceiling; with no budget on the request, maxTokens, else 16000. The size guard, the room and the worst case a provider states all read the same number, so the budget the guard keeps is the one the server enforces.
- Thinking counts inside it on Anthropic, OpenAI and Gemini, so a reasoning model needs more than a model that answers at once: OpenAI advises at least 25000 for its reasoning models. Raise
maxTokens, andcontextTokenswith it, since the guard keeps the whole limit as room for the reply. - A reply that reaches it fails as
truncated,reply was cut off at its limit of <l> tokens, and is never retried as a failure of the network is: a research reply cut so is split by recovery, a vote is sent once more as it is, once per call (What is retried), and any other call ends: What a reply lacked,ProviderError. A reply whose output tokens reach the limit fails so whatever its finish reason says. - A model whose own output limit is below the limit sent may refuse the request. An older model that an Azure deployment still serves is one: set
maxTokensto its limit, which is a ceiling of every reply. Every current model of the presets takes more than 16000, the most a request is sent without a budget. - A server that refuses the field does the same: an
openai-compatibleprovider with no preset sends the limit asmax_tokens, which the reasoning models of OpenAI and Azure refuse. SetmaxTokensField: max_completion_tokensfor them, as theopenaiandazure-openaipresets do. claudeCodesends it as Claude Code's own limit, inCLAUDE_CODE_MAX_OUTPUT_TOKENS: The size of a Claude Code request.
What a reply lacked
A reply can come back with no answer quorum can use. Each HTTP adapter reads which, by one rule, into a ProviderError whose noAnswer field and message say what the reply lacked, in code words and numbers, and never quote the reply or its reasoning:
| Kind | noAnswer | The reply |
|---|---|---|
truncated | reply | Its visible answer was cut off at the limit sent, or its output stopped below that limit: a server that caps replies lower than quorum asked |
truncated | thinking | It was cut off with reasoning and no visible answer: its reasoning used the limit |
truncated | window | The server's window ended it |
no-answer | thinking | It ended on its own with reasoning and no visible answer, as a server that puts its answer in a reasoning field does |
no-answer | empty | It ended on its own with no visible answer and no reasoning, as a server that mishandles its structured output does |
- A reply is cut off when its protocol says so, or when its reported output tokens reach the limit sent, whatever its flag: a server may fail to flag it. It is
windowwhen the protocol says the server's window ended it, or, foropenaiCompatibleandollama, when its output stays under the limit sent while its input and output reachcontextTokens: vLLM clamps the limit to what its window leaves. Else, with no visible answer and reasoning shown, it isthinking, and otherwisereply. - A reply that ended on its own with no visible answer is
no-answer:thinkingwhen it showed reasoning, elseempty. A visible answer is text that is not blank once trimmed. - Reasoning is never read as the answer. It is a fact the adapter reads (a field or part with text, or a reasoning token count above 0), never text it returns or quotes.
claudeCodereads its flags alone. Its usage sums every model turn of a run, so a count rule would misfire:api_errormax_output_tokensandstop_reasonmax_tokensarereply, a success with a blank or missingresultinpromptmode isempty, and it reports no reasoning. A missing structured output inschemamode staysinvalid-response: it is Claude Code's own failure to call its schema tool.
Each adapter reads these fields:
| Adapter | Cut off | Reasoning shown by | The window ended it | empty |
|---|---|---|---|---|
openaiCompatible | finish_reason length or model_length | message.reasoning (vLLM), message.reasoning_content (llama.cpp, DeepSeek), a thinking part (Mistral), or usage.completion_tokens_details.reasoning_tokens above 0 | A cut-off whose prompt_tokens and completion_tokens reach contextTokens while the output stays under the limit sent | stop or no reason, with no text and no reasoning |
anthropic | stop_reason max_tokens | A thinking or redacted_thinking block, or usage.output_tokens_details.thinking_tokens above 0 | stop_reason model_context_window_exceeded | end_turn with no text block and no thinking |
gemini | finishReason MAX_TOKENS or CONTINUATION; the candidates and thoughts count as output | A part flagged thought, or usageMetadata.thoughtsTokenCount above 0 | None documented | STOP with no text part and no thought |
ollama | done_reason length | message.thinking with text | length with eval_count under num_predict and the input and output at num_ctx | stop with no content and no thinking |
claudeCode | api_error max_output_tokens or stop_reason max_tokens | None | None | A success with a blank or missing result, in prompt mode |
Each adapter's reasoning is true for a reply that showed reasoning and false for one it could tell showed none. The messages, which the CLI's progress lines share:
| The reply | Message |
|---|---|
| Cut off below the limit sent | a reply was cut off at <o> tokens, below the <l> quorum asked for: the server caps replies near <o>: set maxTokens: <o> |
| Cut off at the limit | reply was cut off at its limit of <l> tokens, or reply was cut off at its limit when the limit is not known |
| Cut off while reasoning | reply was cut off at its limit of <l> tokens while reasoning, before any answer |
Ended at the server's window, its input and output below contextTokens | a reply ended at the server's window after <i> input and <o> output tokens, below contextTokens <c>: set contextTokens to at most <i + o> |
| Ended at the server's window, any other | a reply ended at the server's window, which is smaller than contextTokens: lower contextTokens |
| Only reasoning | reply has no answer, only reasoning: the server may put its answer in its reasoning field: set thinking: off, or structuredOutput: prompt |
| Nothing | reply has no answer and no reasoning: the server may mishandle its structured output: set structuredOutput: prompt |
Each message names the setting to change. Turning thinking off is the thinking option, off or low: Thinking, and Reasoning mode for a server's own field. A reply with no answer and no reasoning is never sent again, and one of only reasoning is sent once more as it is, once the thinking lowering has had its try (What is retried), its reply-lacked line said only when that second reply also held only reasoning, or with the first reply when there is no second, with retries: 0 or the retries spent. Three calls in a row that end with no answer find the provider down, each counted once after its retry, in words that say what they lacked: <id>: 3 calls in a row had no answer, only reasoning: ... or had no answer and no reasoning: ...; a truncated reply never counts. A server that caps replies below quorum's limit, or loads a window smaller than contextTokens, is named once per provider in a review, with its numbers, as the reply-lacked event: Events.
Configuration errors
Each adapter checks its options when it is called, before any request, and throws one ConfigError with each problem, in this order. No message repeats a value:
| Path | Message |
|---|---|
<id>.baseUrl | must be an http:// or https:// URL with a host |
<id>.baseUrl | must not hold a user name or password: send a key with apiKey |
<id>.baseUrl | must not hold a query or a fragment |
<id>.apiKey | must only contain visible ASCII characters, which an HTTP header can carry |
<id>.apiKey | is set, but auth is none, so it would never be sent |
<id>.auth | must be bearer, x-api-key, none or { header, prefix } |
<id>.auth.header | must be an HTTP header name |
<id>.auth.header | must not be content-type, content-length or host |
<id>.auth.header | is set by the adapter and cannot be replaced |
<id>.auth.prefix | must only contain printable ASCII characters |
<id>.headers | must map names to strings |
<id>.headers.<name> | must be an HTTP header name |
<id>.headers.<name> | must not be content-type, content-length or host |
<id>.headers.<name> | is the header that carries the key: set apiKey instead |
<id>.headers.<name> | is set by the adapter and cannot be replaced |
<id>.headers.<name> | repeats a header name in another letter case |
<id>.headers.<name> | must be a string of printable ASCII characters |
<id>.query | must map names to strings |
<id>.query.<name> | holds the key, which travels only in the header auth names |
<id>.extraBody | must be an object of JSON values, with no __proto__ key |
<id>.extraBody.<key> | is written by the adapter and cannot be replaced |
<id>.extraBody.<key> | offers the model a tool, which quorum never does |
<id>.extraBody.<key> | sets the reply limit: use maxTokens |
<id>.temperature | must be a finite number, or null to leave it out |
<id>.maxTokens | must be a whole number of at least 1 |
<id>.contextTokens | is required: the model's context window in tokens, which quorum checks every request against |
<id>.contextTokens | must be a whole number of at least 1 |
<id>.contextTokens | must be more than 512, the tokens kept for the chat template, with maxTokens unset, else must be more than <n>, the <r> tokens of the reply budget and 512 for the chat template |
<id>.systemPrompt | must be native or inline |
<id>.structuredOutput | must be prompt, json or schema |
<id>.structuredOutput | must be prompt or schema |
<id>.stream | must be true or false |
<id>.timeoutMs | must be a whole number of milliseconds from 1000 to 86400000 |
<id>.retries | must be a whole number from 0 to 5 |
<id>.stallTimeoutMs | must be a whole number of milliseconds from 1000 to 86400000 |
<id>.maxTokensField | must be max_tokens or max_completion_tokens |
<id>.query.<name> | would carry a key in the URL: set apiKey instead |
<id>.query.alt | is set by the adapter and cannot be replaced |
<id>.extraBody.generationConfig | must be written generationConfig |
<id>.extraBody.generationConfig | must be an object |
<id>.model | must be a Gemini model id, such as gemini-3.8-flash |
<id>.extraBody.options | must be written options |
<id>.extraBody.options.<key> | is set from contextTokens: set contextTokens instead |
<id>.extraBody.options | must be an object |
headers and query must be plain objects, an object literal or one with no prototype: a Headers or a Map is refused with must map names to strings, since its entries are not its own fields. A header name that repeats an earlier one in another letter case is refused at the later one, since one request cannot send both.
is set by the adapter and cannot be replaced names anthropic's anthropic-version, in any letter case, as a header or as a custom auth header, and gemini's alt, in any letter case, as a query name, since the adapter sets it for a stream. must be prompt or schema is anthropic's, whose protocol has no JSON mode, and claudeCode's. maxTokensField is checked by openaiCompatible only, model, a key query parameter and an extraBody.generationConfig that is no object or is not spelled generationConfig, by gemini only, and options.num_ctx in extraBody, with an extraBody.options that is no object or is not spelled options, by ollama only. Both servers read the key in any letter case, and Gemini as generation_config too, so a second spelling would send two keys for the field the adapter merges into: must be written <name> names the one spelling, never the key it was given. A key that is no object has the one issue, must be an object. sets the reply limit: use maxTokens names a field by its path, <id>.extraBody.generationConfig.maxOutputTokens for one that is nested. is required: ... is the one issue of a contextTokens that is unset, and the two after it are the issues of one that is set. must be more than <n>, ... is checked against a valid maxTokens only, with <r> its value, and <n> that and 512; with maxTokens unset, the issue reads must be more than <n>, the tokens kept for the chat template, <n> being 512 (4096 for claudeCode).
These are the checks of the four HTTP adapters; claudeCode's are its own: Claude Code configuration errors. A config file's schema reads auth for every protocol, so its message for a value no protocol takes is <path>.auth: must be bearer, x-api-key, none, inherit, login, api-key or { header, prefix }, where an HTTP adapter given inherit, login or api-key by the builder says the <id>.auth message above.
A header name, an extraBody key or a query name is printed in a path only when it is a safe name, at most 64 ASCII letters, digits, _, $ and -. Any other prints as *, since a secret pasted as a name would otherwise show.
openaiCompatible
For any OpenAI-compatible /chat/completions endpoint. Ollama's /v1 is one, and it cuts an oversized prompt in silence, which the size guard cannot see: for Ollama use ollama, which tells it the context size. The hosted provider of The adapters sets temperature: null and maxTokensField: 'max_completion_tokens', as the openai preset does, because OpenAI's reasoning models reject a temperature, and OpenAI deprecates max_tokens for every model.
| Option | Type | Default | Does |
|---|---|---|---|
maxTokensField | 'max_tokens' | 'max_completion_tokens' | 'max_tokens' | The body field of the reply's limit. OpenAI's reasoning models need max_completion_tokens |
The body of every request holds, in this order:
modelandmessages: the request's messages, with the system text first as asystemmessage, or inline at the head of the first user message;response_format, unlessstructuredOutputisprompt;temperature, unless it isnull;- the reply's limit under
maxTokensField, the request's reply budget at mostmaxTokens, elsemaxTokens, else 16000; reasoning_effort,lowornone, whenthinkingis set;stream: trueandstream_options: { "include_usage": true }, unlessstreamisfalseor the core moved the provider to whole replies, which send neither, andstream_optionsis left out for a bare stream: Streaming;- then
extraBody, merged. It cannot replacemodel,messages,streamorstream_options, or setmax_tokensormax_completion_tokens, whichmaxTokenssets.
The reply is read as a whole reply: a streamed one is assembled into it first (Streaming), and a server that answers a streamed request whole is read as it is. The text is the first choice's message.content: a string, or an array of parts whose text parts are joined, as Mistral sends it. Every other part is skipped, thinking parts included, and so is message.reasoning or message.reasoning_content: reasoning is never read as the answer, only noted: What a reply lacked. model is the one the reply names, or the configured one when it names none. usage is read from usage.prompt_tokens and usage.completion_tokens.
A top-level error in the reply fails the call before the choices are read, since some servers answer a failure with status 200 (OpenRouter does, for a failure during generation). The error is { message, code } or a string. An error of null beside the choices is a success. A message that shows a tool the server ran fails next, before a refusal or a finish reason is read: a model or a gateway that ran a tool by itself leaves a review that cannot be trusted. An empty executed_tools, and annotations without a url_citation, are not one.
| The reply | Kind | Message |
|---|---|---|
A server error, its code an error status (400 to 599) | http, retryable as that status would be | server error 502: "<message>" |
A server error with no error status as its code | invalid-response | server error: "<message>", and server error: "" for { "error": "" }; the quote is left out only when error is an object without a string message, as in { "error": {} } |
| A stream that ends before choice index 0 shows or finishes, whatever another choice shows | network | the reply stream ended before its last event |
| No first choice | invalid-response | reply has no choices |
A non-empty executed_tools array in the message (Groq's built-in tools), or a url_citation entry in its annotations (OpenAI's search models, OpenRouter's web plugin) | invalid-response | the server ran a tool for this reply, which quorum never allows |
message.refusal set | refusal | model refused: "<up to 200 characters>", or model refused when it is not a string |
The finish reason content_filter | refusal | reply was stopped by the content filter |
The finish reason length or model_length, or completion_tokens at or above the reply's limit | truncated, reply, thinking or window | What it lacked: What a reply lacked |
The finish reason error, insufficient_system_resource or aborted | invalid-response | reply ended early: "<finish reason>" |
| No text, and a reasoning field or part, or a reasoning token count above 0 | no-answer, thinking | reply has no answer, only reasoning: ... |
| No text, and no reasoning | no-answer, empty | reply has no answer and no reasoning: ... |
anthropic
For the Anthropic Messages API, or a gateway that speaks it, such as Ollama's or DeepSeek's Anthropic-compatible endpoint:
- Every request names the API version in
anthropic-version: 2026-10-21, the current one, which Anthropic's TypeScript SDK sends since its 1.0.0. Noheadersentry can replace it; ananthropic-betaheader goes through. - The key goes as
Authorization: Bearer <key>by default: Anthropic documents it as its primary key header,x-api-keyas a legacy fallback it still accepts, and the gateways take bearer.auth: 'x-api-key'sends the legacy header. - No temperature is sent unless one is set. Under
2026-10-21, Anthropic answers 400 to anytemperature,top_portop_k, even at its default value; a gateway may accept one. max_tokensis always sent, the request's reply budget at mostmaxTokens, elsemaxTokens, else 16000: the Messages API requires it, and thinking counts toward it.- No assistant prefill, and no
thinkingfield. Current models reject a prefill, and Claude Opus 5.5 answers 400 to a request that turns thinking off.thinking: lowis sent asoutput_config.effort, andoffis refused: Thinking.
The body of every request holds, in this order:
model;max_tokens;system: the system text, unlesssystemPromptisinline;messages: the request's messages, each{ role, content }with its text;temperature, when set;output_config:format: { type: 'json_schema', schema: <output.schema> }inschemamode, andeffort: 'low'whenthinkingislow, in one object;stream: true, unlessstreamisfalseor the core moved the provider to whole replies, which send none: Streaming;- then
extraBody, merged:{ output_config: { effort: 'low' } }goes beside the format inschemamode. It cannot replacemodel,messages,systemorstream, or setmax_tokens, whichmaxTokenssets.
A reply is read as a whole reply: a streamed one is assembled into it first (Streaming), and a server that answers a streamed request whole is read as it is. It succeeds with the stop reason end_turn or stop_sequence and a text block. The stop reason is read first, since a refused or cut-off reply can still hold some text. The text is the text of the type: 'text' blocks, joined: thinking and redacted_thinking blocks are skipped, never read as the answer, as is every block of another type. model is the one the reply names, or the configured one. The input count is usage.input_tokens, plus usage.cache_creation_input_tokens and usage.cache_read_input_tokens when they are numbers; the output count is usage.output_tokens. A status outside 2xx is an http error that quotes Anthropic's { "type": "error", "error": { "type", "message" } } body.
| The reply | Kind | Message |
|---|---|---|
An event: error whose error.type is invalid_request_error, authentication_error, billing_error, permission_error, not_found_error, request_too_large, rate_limit_error, api_error or overloaded_error | http, status 400, 401, 402, 403, 404, 413, 429, 500 or 529 in that order, retried as the status is | server error <status>: "<message>" |
An event: error of another type, or of none | invalid-response | server error: "<message>" |
A stream that ends before message_stop, or at one that follows no stop reason | network | the reply stream ended before its last event |
stop_reason refusal | refusal | model refused |
stop_reason max_tokens, or output_tokens at or above the reply's limit | truncated, reply or thinking | What it lacked: What a reply lacked |
stop_reason model_context_window_exceeded | truncated, window | a reply ended at the server's window after <i> input and <o> output tokens, below contextTokens <c>: set contextTokens to at most <i + o>, or, when the counts are not all known or reach contextTokens, a reply ended at the server's window, which is smaller than contextTokens: lower contextTokens |
Any other stop_reason, tool_use and pause_turn included | invalid-response | reply ended early: "<stop reason>", or reply ended early when it is not a string |
| No text block, and a thinking block or a thinking token count above 0 | no-answer, thinking | reply has no answer, only reasoning: ... |
| No text block, and no thinking | no-answer, empty | reply has no answer and no reasoning: ... |
gemini
For the Gemini API's generateContent, which Google now calls a legacy API, still supported:
- The model goes in the URL,
/v1beta/models/<model>:streamGenerateContent, withalt=sseadded after the options'query, or:generateContentfor a whole reply. It is written with or without a leadingmodels/, which is stripped, and the id that remains must match[a-z0-9][a-z0-9.-]*in any letter case, asgemini-3.8-flashdoes: that keeps a/, a?or a:out of the path. Another is a configuration error,<id>.model: must be a Gemini model id, such as gemini-3.8-flash. A tuned model (tunedModels/...) is not supported. - The key goes in
x-goog-api-keyby default, never in thekeyquery parameter: aqueryentry namedkey, in any letter case, is a configuration error, since URLs get logged and error messages would not redact it. Aqueryentry namedaltis one too,<id>.query.alt: is set by the adapter and cannot be replaced, since the adapter writes it. - No temperature is sent unless one is set. Current models ignore it, and Google says a future model will answer 400 to it.
The body of every request holds, in this order:
contents: each message as{ role, parts: [{ text }] }, anassistantmessage with the rolemodel;systemInstruction: { parts: [{ text: <system text> }] }, unlesssystemPromptisinline;generationConfig:temperaturewhen set,maxOutputTokens, the request's reply budget at mostmaxTokens, elsemaxTokens, else 16000,responseMimeType: 'application/json'injsonandschemamode,responseJsonSchema: <output.schema>inschemamode, as Google's JavaScript SDK sends it (responseSchemais deprecated), andthinkingConfig: { thinkingLevel }whenthinkingis set: Thinking;- then
extraBody, merged:{ generationConfig: { thinkingConfig: { thinkingLevel: 'low' } } }goes beside the rest. It cannot replacecontentsorsystemInstruction, or setgenerationConfig.maxOutputTokens, whichmaxTokenssets. ItsgenerationConfigmust be an object, writtengenerationConfig: another spelling, such asgeneration_config, would send a second key, so it is refused.
A reply is read as a whole reply: a streamed one is assembled into it first (Streaming), and a server that answers a streamed request whole is read as it is. It succeeds with a first candidate whose finishReason is STOP and whose parts hold text. The text is the text of the first candidate's content.parts, joined, without the parts flagged as thoughts, which are never read as the answer. model is the reply's modelVersion, or the configured model. The input count is usageMetadata.promptTokenCount; the output count is usageMetadata.candidatesTokenCount, plus usageMetadata.thoughtsTokenCount when it is a number. Gemini leaves a zero count out of its JSON, so a candidates count the reply leaves out reads as 0: a thinking model cut off while it thinks reports only its prompt and thought counts. A reply without promptTokenCount, or with a prompt or candidates count that is not a number, reports no usage. A status outside 2xx is an http error that quotes Google's { "error": { "code", "message", "status", "details" } } body; a 402, which Google sends for a depleted prepay balance, is not retryable, unlike a 429, and a 429 of a per-day quota is not either.
| The reply | Kind | Message |
|---|---|---|
A chunk's error, whose code is an error status (400 to 599) | http, retried as that status is, a RetryInfo and a per-day quota read as they are on a failed reply | server error <status>: "<message>" |
A chunk's error with no such code | invalid-response | server error: "<message>" |
| A stream that ends with no finish reason and no block reason | network | the reply stream ended before its last event |
promptFeedback.blockReason set | refusal | prompt was blocked: "<reason>" for a reason of 1 to 64 capital letters and underscores, such as PROHIBITED_CONTENT, and prompt was blocked for any other |
| No first candidate | invalid-response | reply has no candidates |
finishReason MAX_TOKENS or CONTINUATION, or candidate and thought tokens at or above the reply's limit | truncated, reply or thinking | What it lacked: What a reply lacked |
finishReason SAFETY, RECITATION, BLOCKLIST, PROHIBITED_CONTENT, SPII or IMAGE_SAFETY | refusal | reply was stopped by the safety filter |
No finishReason, or null | invalid-response | reply has not finished |
Any other finishReason | invalid-response | reply ended early: "<finish reason>", or reply ended early when it is not a string |
No text part, and a part flagged thought or a thoughtsTokenCount above 0 | no-answer, thinking | reply has no answer, only reasoning: ... |
| No text part, and no thought | no-answer, empty | reply has no answer and no reasoning: ... |
ollama
For Ollama's native chat API, on a local server or Ollama's cloud, https://ollama.com, which needs a key. Its base URL is the server's root, such as http://localhost:11434, without the /v1 that openaiCompatible takes there:
- It is the CLI's built-in default. With no provider configured and no base URL, preset or protocol variable for a role, that role talks to the Ollama on this machine through this adapter, at
http://localhost:11434, which Ollama listens on, on127.0.0.1, by default; a role whose variables set a base URL without a preset or a protocol speaksopenai-compatibleto that URL, as before: Layering. A panel with no voter variables shares the finder's provider: The voter's fallback. truncate: falsekeeps a prompt whole. A prompt past the model's context is then a 400,request (N tokens) exceeds the available context size (M tokens), try increasing it, instead of its oldest messages dropped in silence. It needs Ollama 0.12.6 or later; an older server ignores the field and drops them.shift: falsekeeps it whole as the reply is written. A reply that fills the model's context then stops, as a truncation, instead of part of the prompt dropped so the reply can go on. It needs the same versions, and a server that loaded the model with context shift on loads it again, as it does each time a client asks for the other setting.num_ctxfromcontextTokens. The adapter sendsoptions.num_ctx, so the server loads the context the size guard counts with; a larger value than the model's own maximum is cut to it, so keepcontextTokensat most whatollama show <model>reports, and read the context a running model loaded in theCONTEXTcolumn ofollama ps.extraBodycannot setoptions.num_ctx, in any letter case, or replaceoptionswith anything but an object, which would drop it. Itsoptionsmust be writtenoptions: another spelling, such asOptions, would send a second key, so it is refused.- The key goes as
Authorization: Bearer <key>, only when one is set: a local server needs none. - No
thinkfield unlessthinkingis set. A thinking model thinks as it does by default, and its thinking comes back apart, inmessage.thinking, which the adapter never reads as the answer: it notes that the reply showed reasoning.thinking: lowsendsthink: "low"andoffsendsthink: false: Thinking.
The body of every request holds, in this order:
modelandmessages: the request's messages, with the system text first as asystemmessage, or inline at the head of the first user message;stream: true,falsefor a whole reply, thentruncate: falseandshift: false;options:temperature, unless it isnull,num_predict, the request's reply budget at mostmaxTokens, elsemaxTokens, else 16000, andnum_ctx, always, fromcontextTokens;format:'json'injsonmode,<output.schema>inschemamode;think:'low'orfalse, whenthinkingis set;- then
extraBody, merged:{ options: { seed: 7 } }goes beside the temperature. It cannot replacemodel,messages,stream,truncateorshift, or setoptions.num_ctx, whichcontextTokenssets, oroptions.num_predict, whichmaxTokenssets. Itsoptionsmust be an object.
A reply is read as a whole reply: a streamed one is assembled into it first (Streaming), and a server that answers a streamed request whole, with a content type that is not application/x-ndjson, is read as it is. It succeeds with done: true, the done_reason stop and a string message.content. The text is message.content, as it came: a <think> block left in it, by a model or a template Ollama cannot split, is for the core's reply parser to drop. model is the one the reply names, or the configured one; usage is read from prompt_eval_count and eval_count. A status outside 2xx is an http error that quotes Ollama's { "error": "<message>" } body.
| The reply | Kind | Message |
|---|---|---|
A string error, in a stream a line that holds one | invalid-response | server error: "<message>" |
A stream that ends before the line that holds done: true | network | the reply stream ended before its last event |
done: true and done_reason length, or eval_count at or above the reply's limit | truncated, reply, thinking or window | What it lacked: What a reply lacked. With shift: false, a reply that fills the context ends as length too, and is the window's when its input and output reach num_ctx |
No done: true, or a done_reason other than stop or length | invalid-response | reply has not finished |
No message.content text, and a message.thinking with text | no-answer, thinking | reply has no answer, only reasoning: ... |
No message.content text, and no thinking | no-answer, empty | reply has no answer and no reasoning: ... |
claudeCode
For your installed Claude Code CLI, which it runs once per request, headless and isolated, as a pure completion: no tool but the one that captures the reply, nothing loaded from your setup or from the checkout it runs in, the message on stdin, and in the default modes no key that quorum picks, holds or sets: it hands its environment to your own CLI, less the variables it removes. It needs a model, an alias or an id, and a context size, and it finds claude on PATH:
import { claudeCode } from '@tobi-or-not/quorum'
const code = claudeCode({ id: 'code', model: 'sonnet', contextTokens: 1000000 })From the CLI, QUORUM_RESEARCH_PROTOCOL=claude-code builds it: Claude Code. It requires Claude Code 2.1.311 or newer: Stopping, nesting and the version.
What it runs
One process per request:
claude -p \
--output-format=json \
--model=<model> \
--system-prompt-file=<run>/system.txt \
--tools '' --setting-sources '' --strict-mcp-config --no-session-persistence --disable-slash-commands \
--json-schema=<the reply schema as JSON> \
--bare \
--effort=high- The order is fixed, and nothing is optional but the last three lines:
--json-schemaonly inschemamode,--bareonly inapi-keymode, then the allowlistedargs, here--effort high. - Every value quorum or the config supplies is written
--flag=value, so no value is read as a flag, whatever it starts with. The two isolation flags with an empty value keep the two-argument form,--tools ''and--setting-sources '', which is the one verified with Claude Code 2.1.311. - The system text goes in a file, the message on stdin and the key in the environment. Linux caps one argument at 128 KiB, Windows a command line at 32,767 characters, and
psshows a command line to every user: nothing secret, and nothing long, is on it. - Each request has a directory of its own,
quorum-claude-<random>under the system's temporary directory, made at an absolute path thoughTMPDIRis relative:cwd/, the child's empty working directory,tmp/, where Claude Code keeps its scratch files, andsystem.txt, mode0600. It is removed onceclaudehas exited, on every path, before the call settles, and when quorum itself exits while a run is live. - It is never run through a shell. A
.cmdor.batfile, which runs only through one, is refused; any other executable is run as it is.
The isolation
Each measure of the command line and of the environment, and what it stops:
| Measure | What it stops |
|---|---|
--tools '' | Every built-in tool: no shell, file or web tool. --json-schema adds one, which only captures the reply as structured output, and structuredOutput: 'prompt' leaves it out |
--setting-sources '' | The user's, the project's and the local settings: their hooks, plugins, agents, CLAUDE.md files, permission rules and configured credentials |
--strict-mcp-config | Every MCP server that is not named on the command line, which is none |
--no-session-persistence | A transcript written to disk |
--disable-slash-commands | Slash commands, as Claude Code documents the flag: its effect was not observed live. A message that starts with /, after white space, is refused before claude starts, since -p expands one as a slash command, and that refusal is the guard that is tested |
| An empty working directory | A CLAUDE.md, a .claude/ directory or a .mcp.json of the pull request's checkout: claude never runs there |
CLAUDE_CODE_DISABLE_AUTO_MEMORY=1 | Auto memory, which would load what an earlier run wrote |
DISABLE_COMPACT=1 | Summarizing a long prompt, which would shorten what the model reads (from Claude Code's documentation, not observed live) |
CLAUDE_CODE_TMPDIR=<run>/tmp | Claude Code's scratch files outside the request's directory |
CLAUDE_CODE_AUTO_CONNECT_IDE=false, ENABLE_CLAUDEAI_MCP_SERVERS=false | An IDE connection and the claude.ai MCP connectors, which are on by default |
CLAUDE_CODE_DISABLE_ATTACHMENTS=1, CLAUDE_CODE_DISABLE_FILE_MENTIONS=1 | A file named in the message. A line such as @/path/to/file in the diff makes Claude Code attach that file for the model to read, with every tool off, and the model repeated a canary file's content that way (observed live with 2.1.311). With both set the model saw none. They are why an older Claude Code is refused: Stopping, nesting and the version |
CLAUDE_CODE_DISABLE_CLAUDE_MDS=1 | Every CLAUDE.md file, the managed one included (from Claude Code's documentation, not observed live) |
CLAUDE_CODE_DISABLE_BUNDLED_SKILLS=1, CLAUDE_CODE_DISABLE_POLICY_SKILLS=1 | The skills Claude Code bundles and the ones an organization's managed policy brings (from Claude Code's documentation, not observed live) |
API_TIMEOUT_MS=<timeoutMs>, CLAUDE_CODE_MAX_RETRIES=<retries> | How long Claude Code waits for the headers of each attempt's response, and its own retries. The provider's timeoutMs and retries replace the environment's two variables, which are removed in any letter case: 2 retries by default, where Claude Code alone makes 10 |
CLAUDE_CODE_MAX_OUTPUT_TOKENS=<maxTokens> | Claude Code's limit on each reply, over the environment's: each run is given the reply budget of its request, at most maxTokens, else maxTokens, else 16000, where Claude Code asks for up to 128000 by itself |
| The parent session's variables, removed in every mode | CLAUDE_CODE_MESSAGING_TOKEN, CLAUDE_CODE_MESSAGING_SOCKET, CLAUDE_CODE_ENTRYPOINT, CLAUDE_CODE_EMIT_STARTUP_TIMING and CLAUDE_CODE_STARTUP_FAILURE_RESULTS: a run nested in a Claude Code session does not inherit its messaging token or socket |
| The capability variables, removed in every mode | CLAUDE_CODE_PLUGIN_DIRS, CLAUDE_CODE_PLUGIN_SEED_DIR, CLAUDE_CODE_PLUGIN_CACHE_DIR, CLAUDE_CODE_SYNC_PLUGINS, CLAUDE_CODE_SYNC_SKILLS, CLAUDE_CODE_PROCESS_WRAPPER, CLAUDE_CODE_ENABLE_CFC, CLAUDE_CODE_ENABLE_TODO_TOOLS, CLAUDE_CODE_ENABLE_TASKS, CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS, CLAUDE_CODE_USE_POWERSHELL_TOOL, CLAUDE_CODE_EXTRA_BODY and CLAUDE_CODE_FORCE_SESSION_PERSISTENCE: they load plugins and skills, start every process through a wrapper, enable a tool, merge a JSON object into every request body or keep the session --no-session-persistence drops, and no flag governs them |
| A process group of its own | What claude starts: an abort stops the whole group, and so does quorum's exit, process.exit or a second interrupt included (not on Windows, which has none) |
| The request's directory removed | Its working directory, its scratch files and the system text. Claude Code may still write its own session files under ~/.claude and to ~/.claude.json, and a SIGKILL of quorum can leave the directory, with the inbox socket that CLAUDE_CODE_TMPDIR puts in it (unverified): Claude Code, isolated |
Variable names are matched in any letter case, as Windows reads them. The credentials and endpoints that a mode removes are in The auth modes.
Not everything is off, and no flag of this list turns the rest off: an organization's managed settings, hooks and MCP servers may still load (its CLAUDE.md and skills, and the bundled skills, have variables that turn them off, unverified live on a managed machine), Claude Code adds its own context to every request, a run binds an inbox socket, in its own directory, and keeps registry files under ~/.claude, and inherit applies no credential that a settings file configures. Claude Code, isolated states each of them.
Claude Code options
| Option | Type | Default | Does |
|---|---|---|---|
id | string | Required | Names the provider in events, meta and its error messages |
model | string | Required | What claude --model takes: an alias, sonnet, opus, haiku or fable, or a full model id, with [1m] after it (opus[1m]) for a 1M window on a 4.6 model. Visible ASCII, no space, and not starting with - |
contextTokens | number | Required | The model's context window in tokens, prompt and reply together. It must be more than 4096 when maxTokens is unset, and more than maxTokens and 4096 when it is set: The size of a Claude Code request |
maxTokens | number | Derived from the window | The most tokens each reply may hold, thinking included: the ceiling of Claude Code's own limit on each reply, CLAUDE_CODE_MAX_OUTPUT_TOKENS, which is the request's reply budget, else this, else 16000: Claude Code caps a value above the model's own limit, and a model that thinks with a budget needs more than 1024 |
auth | 'inherit' | 'login' | 'api-key' | 'inherit' | Whose credentials claude uses: The auth modes |
apiKey | string | None | api-key only: the key handed to claude as ANTHROPIC_API_KEY, in its environment and nowhere else. Without one, api-key keeps the environment's own ANTHROPIC_API_KEY. Refused under another mode |
structuredOutput | 'prompt' | 'schema' | 'schema' | schema has claude enforce the reply schema with --json-schema, and reads the reply from its structured output; prompt leaves the shape to the prompt, adds no tool, and reads the result's text |
args | readonly string[] | None | Flags passed to claude: --effort (low, medium, high, xhigh or max), --fallback-model, --max-budget-usd (a positive decimal) and --betas (api-key only), each followed by its value or written --flag=value, each at most once. A value is visible ASCII that does not start with -. Any other element is refused by its index, and never repeated, so no option loosens the isolation |
command | string | 'claude' | The executable: an absolute path, or a bare name that spawn finds on PATH. A path with a separator that is not absolute is refused, since it would resolve inside the working directory, and so is a .cmd or .bat file, which runs only through a shell |
env | Record<string, string | undefined> | process.env | The environment claude inherits, less what its mode removes. Read once, when the provider is made |
timeoutMs | number | 600000 | How long Claude Code waits for the response headers of each attempt at its API call, in milliseconds, from 1000 to 86400000, set as API_TIMEOUT_MS in place of any the environment sets. It bounds that wait only, so raise it for a long run: the provider states timeoutMs times retries plus one as the deadline of the whole run: Stopping, nesting and the version |
retries | number | 2 | Claude Code's own retries of an API call that failed in passing, from 0 to 5, set as CLAUDE_CODE_MAX_RETRIES, where Claude Code alone makes 10, and replacing a CLAUDE_CODE_MAX_RETRIES of the environment. The provider states no retry to the core |
ClaudeCodeOptions types them and ClaudeCodeAuth types auth. The options of an HTTP endpoint (baseUrl, headers, query, extraBody, temperature and systemPrompt) are refused: there is no endpoint.
The auth modes
| Mode | The child's environment | Use |
|---|---|---|
inherit | The environment as it is, less the variables every mode removes | Whatever claude -p finds on its own, from the environment: a cloud provider (Bedrock, Vertex or Foundry), a gateway, a key or a login. The default. Quorum hands the environment to claude, less the variables it removes, and reads the credential variables' values only to redact them from a quoted error: it stores and logs none, and sends them nowhere but the child |
login | inherit's, less ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN, ANTHROPIC_BASE_URL, ANTHROPIC_PROFILE, ANTHROPIC_FEDERATION_RULE_ID, ANTHROPIC_ORGANIZATION_ID, ANTHROPIC_CUSTOM_HEADERS, ANTHROPIC_UNIX_SOCKET and every variable whose name starts with CLAUDE_CODE_USE_ | The Claude Code login, /login, or the CLAUDE_CODE_OAUTH_TOKEN of claude setup-token, which stays in the environment. It reaches Anthropic's own API unless a managed setting says otherwise |
api-key | login's, then ANTHROPIC_API_KEY set to the key, and --bare on the command line | An API key. Under --bare, Claude Code is documented to read no login, keychain or CLAUDE_CODE_OAUTH_TOKEN, even when one is in the environment, so the key is the credential, and to drop some of the context Claude Code adds; neither was observed live |
ANTHROPIC_BASE_URLgoes underloginandapi-key, since a login or a key sent through another host is what the threat model rules out. A gateway stays reachable throughinherit.ANTHROPIC_CUSTOM_HEADERSgoes because a header can carry another credential, andANTHROPIC_UNIX_SOCKETbecause it sends every request through a local socket, as a base URL would. ACLAUDE_CODE_USE_prefix catches a cloud provider added later.- The key of
api-keyisapiKey, else the environment'sANTHROPIC_API_KEY, trimmed. With neither, Claude Code has no credential and the call fails: the CLI's resolution refuses it earlier, Claude Code. - A text that quotes
claude's output is redacted of the values of the credential variables the child holds, as written and trimmed:ANTHROPIC_API_KEY,ANTHROPIC_AUTH_TOKEN,CLAUDE_CODE_OAUTH_TOKEN,CLAUDE_CODE_OAUTH_REFRESH_TOKEN,CLAUDE_CODE_CLIENT_KEY_PASSPHRASE,ANTHROPIC_CUSTOM_HEADERS,AWS_BEARER_TOKEN_BEDROCK,AWS_SECRET_ACCESS_KEY,AWS_SESSION_TOKEN,ANTHROPIC_AWS_API_KEY,ANTHROPIC_FOUNDRY_API_KEYandANTHROPIC_FOUNDRY_AUTH_TOKEN. A reply fromclaudecan echo any of them.
The size of a Claude Code request
The guard of The size of a request, with two differences. Claude Code adds its own context to every request, which 512 tokens do not cover: 953 tokens for a one-line prompt and 1463 with the schema tool's second turn, measured, so the reserve is 4096. And the reply budget is the request's, at most maxTokens, else maxTokens, else 16000, which is also the limit the run sets on Claude Code's replies. A request is sent only when text + 4096 + reply <= contextTokens, so contextTokens must be more than 4096 when maxTokens is unset, or the provider is refused: <id>.contextTokens: must be more than 4096, the tokens kept for the chat template; with maxTokens set it must be more than that and maxTokens: <id>.contextTokens: must be more than 20096, the 16000 tokens of the reply budget and 4096 for the chat template, for a maxTokens of 16000. The text is counted as for an HTTP adapter, the reply schema's JSON included. A request that may not fit fails with may need <n> tokens, more than contextTokens (<c>): <t> for its text at one token per byte, 4096 for the chat template and <r> for the reply.
- The message is at most 10,000,000 bytes, the smaller reading of the 10 MB that Claude Code reads on stdin, checked first: a larger one is
too-largetoo. - Claude Code's own refusal of a prompt is
too-largeas well. When it reportsterminal_reason: "prompt_too_long", or an error result (is_error) whose text startsPrompt is too long, a prompt the guard let through and Claude refused is the samerequest-too-largegap, which--allow-incompletedoes not lift. - A long prompt is not summarized.
DISABLE_COMPACT=1is meant to keep Claude Code from compacting it, so that what the model reads is the prompt the guard counted; that is from Claude Code's documentation, and was not observed live. - It states its worst case over the model turns of a run. In
schemamode there are two, the second carrying the first reply:2 * (text + 4096) + 3 * maxTokens. Inpromptmode there is one:text + 4096 + maxTokens. The cap does not reserve a reply Claude Code continues after its limit (up to three times a turn), nor its own retries: they count once the run reports its usage, so the runs in flight can pass the cap by what they spend beyond their reservation, and the cap then refuses what no longer fits (The token cap). - It states its room as the lesser of what its guard leaves and what the stdin cap leaves, the message counted at one token per byte, which a byte count never passes: a request whose room is not negative passes both checks, and text added to the message lowers the room by exactly its count.
Claude Code replies and errors
claude -p --output-format=json prints one JSON object. Only the unknown-model error and two success runs were observed live: the shapes of a refusal, a reply cut off by the token limit, a prompt too long and an auth failure follow Claude Code's documentation, and the max_output_tokens result below was read in the embedded code of Claude Code 2.1.311, never run. Claude Code reports an API error as exit 1 with that object on stdout, subtype: "success" and is_error: true, so the object is read before the exit code, in this order:
| The result | Kind | Message |
|---|---|---|
terminal_reason prompt_too_long, or an error result that starts Prompt is too long | too-large | Claude Code refused the prompt as too long for the model's context |
stop_reason refusal | refusal | model refused |
An error result whose api_error is max_output_tokens: Claude Code continued a reply cut at its limit three times, then gave up | truncated, reply | reply was cut off at its limit |
An error (is_error is not false, or subtype is not success) with an api_error_status from 400 to 599 | http, retryable as that status would be, so 429 and 5xx are | HTTP 404 from the model API: "<up to 200 characters>" |
| Any other error | process, with the exit code as status | claude failed (error_max_structured_output_retries): "<up to 200 characters>", the subtype, or the terminal_reason of a success one, left out when it is not a short word |
A signal ended claude after a success result | process | claude was stopped by SIGTERM after its result |
| A non-zero exit after a success result | process | claude exited 1 after its result |
A tool the server ran: usage.server_tool_use or a model's webSearchRequests above 0 | invalid-response | the server ran a tool for this reply, which quorum never allows |
A success result with stop_reason max_tokens, checked before the text | truncated, reply | reply was cut off at its limit |
schema mode and no structured output, though no error is reported | invalid-response | reply has no structured output, or reply structured output could not be serialized |
prompt mode and a result that is blank or missing | no-answer, empty | reply has no answer and no reasoning: the server may mishandle its structured output: set structuredOutput: prompt |
Without a JSON result, a signal, a non-zero exit and an exit 0 with nothing are each a failure:
| What happened | Kind | Message |
|---|---|---|
A signal ended claude | process | claude was stopped by SIGKILL |
| A non-zero exit | process | claude exited 2: "<up to 500 characters of stderr>" |
Exit 0, and no JSON result object on stdout | invalid-response | claude printed no JSON result |
| More than 16 MiB on stdout | invalid-response | reply is over 16 MiB |
Before claude starts, and around it:
| What happened | Kind | Message |
|---|---|---|
| A request that is not exactly one user message | unsupported | takes a request of exactly one user message |
A message that starts with / after white space | unsupported | a message that starts with / would run as a Claude Code command |
| A message over 10,000,000 bytes | too-large | the message is <n> bytes, more than the 10000000 Claude Code reads on stdin |
| A request that may not fit the context | too-large | may need <n> tokens, ...: The size of a Claude Code request |
| The signal aborted | aborted | request aborted |
| A directory that cannot be made | process | could not prepare a directory for claude (EACCES), the code left out when there is none |
A claude that cannot start | process | could not start the claude CLI (ENOENT) |
claude --version names a version below 2.1.311, or none | process | Claude Code 2.1.311 or newer is required, found 2.1.310, or found an unknown version when the version is not plain numbers: Stopping, nesting and the version |
claude --version does not answer within 10 seconds | process | claude --version did not answer within 10 s |
Every message starts with the provider id. A quoted text is cut, written as a JSON string and redacted, as an HTTP adapter's is, and stdout is read to 16 MiB and stderr to 64 KiB, the rest dropped.
usageis the sum over every model the result reports inmodelUsage: the input is every prompt token, cached ones included (inputTokens,cacheReadInputTokensandcacheCreationInputTokens), and the output every token generated. The result's ownusagecovers the last turn only, 2 input tokens against 1199 in a schema run, so its token counts are not read. A result the adapter refuses, cut off, refused or failed after it, carries the same sum in itsProviderError'susage; one with nomodelUsageentry carries none.costUsdistotal_cost_usd, Claude Code's own estimate, when it is a number of at least 0.modelis the one that answered: the single key ofmodelUsage, since--fallback-modelcan change it, else the configured one.- The text is
structured_outputserialized inschemamode, andresultinpromptmode. It reports noreasoning, and reads no count of output tokens as a cut-off: What a reply lacked.
Stopping, nesting and the version
- An abort sends SIGTERM to
claude's process group, then SIGKILL2000ms later if it has not closed, and the call rejects asabortedonce the directory is removed. Stdout past 16 MiB stops it the same way. Whenclaudeexits, SIGKILL goes to what is left of its group, since a helper that still holds its pipes would keep the call from settling, and2000ms after the exit its stdout and stderr are closed, so a helper that left the group (it calledsetsid) and holds them cannot keep the call from settling either: it is beyond quorum's reach and is left running. While a run is live, quorum's own exit sends SIGKILL to the group and removes the directory, which coversprocess.exitand a second interrupt but not a SIGKILL of quorum. Windows has no process groups, so there onlyclaudeis signalled, and the adapter is not tested there yet. - It runs inside a Claude Code session too.
CLAUDECODE=1in the environment does no harm, which was checked live, and the parent session's own variables are removed: The isolation. - One process per call. The provider's lane, 4 calls at once, since a Claude Code run sends no rate-limit header to grow it, or the review's
concurrencywhen it is set, bounds the calls in flight, so it bounds theclaudeprocesses too. - The provider states no retry to the core, since Claude Code retries by itself, and one deadline for the whole run:
timeoutMstimesretriesplus one, 1800000 ms by default and at most 518400000. It bounds every one of Claude Code's own attempts and the waits between them,claude's start and the version check, and the time each reply takes after its headers.API_TIMEOUT_MS, which the run sets totimeoutMs, limits only each attempt's wait for its response headers, so the stated deadline is not the sum of those limits. At the deadline the call fails as atimeoutand the child's group is stopped as an abort stops it: a voter's vote fails, and a research call is that part'sresearch-failedgap, or, once three calls in a row fail so, a provider found down. - Raise
maxTokensat a high--effort, andtimeoutMswith it. A reply at a high effort thinks longer, and its thinking counts inside the reply's limit, whichmaxTokenscaps: Claude Code continues a reply cut at its limit up to three times, then the call fails astruncated. A longer reply takes longer, so raisetimeoutMstoo: by default it bounds the whole run at 30 minutes.reviewTimeoutMs, 30 minutes by default, ends the whole review whatevertimeoutMssays, so a long run raises it as well: The review's deadline. - The provider's settings replace the environment's. The run sets
API_TIMEOUT_MStotimeoutMs,CLAUDE_CODE_MAX_RETRIEStoretriesandCLAUDE_CODE_MAX_OUTPUT_TOKENStomaxTokensover whatever the environment held, in any letter case, so exporting any of them has no effect: settimeoutMs,retriesandmaxTokensin the config, ortimeoutMsandretrieswithQUORUM_<ROLE>_TIMEOUT_MSandQUORUM_<ROLE>_RETRIES, instead. The default takes Claude Code from its own 10 retries to 2, andretriesstops at 5. - The version: 2.1.311 or newer. The isolation rests on environment variables that an older Claude Code does not know, and one it ignores is a file mention that is not turned off. So before its first request a provider runs
claude --version, with the request's environment, from the request's empty directory and with the request's signal, and the result is kept for the life of the process, once per command. A version below 2.1.311, or an output that does not start with<major>.<minor>.<patch>, fails the request asprocess:Claude Code 2.1.311 or newer is required, found 2.1.310. The version is quoted only when each of its parts is at most four digits, else the message readsfound an unknown version, so nothing elseclaudeprinted comes with it. It has 10 seconds to answer: past them its process group is stopped as an abort stops one (SIGTERM, then SIGKILL2000ms later), the request's directory is removed and the request fails withclaude --version did not answer within 10 s. A check that failed is run again by the next request, and a request that waits for a check another request started aborts on its own signal, without stopping that check. A Claude Code that lacks one of the flags fails the run too, closed.bun run live:claude-codechecks the adapter against the realclaude. You run it by hand, with Claude Code installed and logged in, and neitherbun run testnor CI does: it makes four calls onhaiku, each capped by--max-budget-usd 0.05: structured output from a directory that holds a plantedCLAUDE.md, which shows the child runs in an empty directory of its own and not in that one, one inpromptmode, one whose message names a canary file with a random token as@<its absolute path>, which fails if the token comes back, and one that names a model that does not exist. It passed against Claude Code 2.1.311, at under a tenth of a cent.
Claude Code configuration errors
claudeCode checks its options when it is called, before any request, and throws one ConfigError with each problem, in this order. No message repeats a value: a key, a model id or an argument can be a secret.
| Path | Message |
|---|---|
<id>.baseUrl, <id>.headers, <id>.query, <id>.extraBody, <id>.temperature, <id>.systemPrompt | is not an option of the claude-code protocol |
<id>.model | must be a model id of visible ASCII characters, with no space, that does not start with - |
<id>.maxTokens | must be a whole number of at least 1 |
<id>.contextTokens | is required: the model's context window in tokens, which quorum checks every request against |
<id>.contextTokens | must be a whole number of at least 1 |
<id>.contextTokens | must be more than 4096, the tokens kept for the chat template, with maxTokens unset, else must be more than <n>, the <r> tokens of the reply budget and 4096 for the chat template |
<id>.auth | must be inherit, login or api-key |
<id>.apiKey | is set, but auth is not api-key, so it would never be sent |
<id>.apiKey | must only contain visible ASCII characters |
<id>.structuredOutput | must be prompt or schema |
<id>.args | must be a list of strings |
<id>.args.<index> | must be a string |
<id>.args.<index> | is not a flag quorum passes to claude: use --effort, --fallback-model, --max-budget-usd or --betas |
<id>.args.<index> | needs a value, for a flag that ends the list |
<id>.args.<index> | repeats a flag |
<id>.args.<index> | is only for auth: api-key, for --betas |
<id>.args.<index> | must be low, medium, high, xhigh or max, for --effort |
<id>.args.<index> | must be a positive number of dollars, such as 0.50, for --max-budget-usd |
<id>.args.<index> | must be visible ASCII characters that do not start with -, for --fallback-model and --betas |
<id>.command | must name an executable |
<id>.command | is a Windows script, which runs only through a shell: name claude.exe instead |
<id>.command | must be an absolute path, or a name to find on PATH |
<id>.timeoutMs | must be a whole number of milliseconds from 1000 to 86400000 |
<id>.retries | must be a whole number from 0 to 5 |
<index> is the index of the element in args, or of the value after a flag when the value is the problem. --tools, --mcp-config, --settings, --add-dir and --dangerously-skip-permissions are refused as any element outside the allowlist is, and --effort=high --tools=Bash in one element is refused as an --effort value: no args element loosens the isolation.
ProviderError
Every failure of a shipped adapter's call is a ProviderError, the error class the core exports for any provider to use. Its message starts with the provider id, and the adapter never puts a request header, a key or the runtime's own error text in it: text a server or a model sent is quoted as a JSON string and cut short, and a key the server echoes, the base URL's path or a value of headers is replaced by [redacted] first. claudeCode quotes the text of claude the same way, redacted of the credentials its child holds.
| Field | Holds |
|---|---|
providerId | The provider's id |
kind | What went wrong, below |
status | The HTTP status, for http. For a server error in an openaiCompatible 2xx reply, it is the status the body's code names. For a claudeCode process error that follows an exit of claude (a reported error, or claude exited 2), it is that exit code. A signal, a version that is too old, a start failure and a directory failure carry none |
retryable | true for network and timeout, and for http with status 408, 409, 429 or 5xx: a caller may try the call again. A provider may set it, and the core retries only network, timeout and http failures, whatever it says |
exhausted | true when the reply says the account's credit, quota or spend limit is used up, else false: What is retried. Such an error is never retryable, whatever the adapter set, and finds its provider down at once |
retryAfterMs | The wait the server asked for at least, in milliseconds, or undefined. The HTTP adapters set it from the reply's headers, and gemini from its body |
noAnswer | What a truncated or no-answer reply lacked: reply, thinking, window or empty, as What a reply lacked says; undefined for any other failure |
rateLimit | What the failed reply's rate-limit headers stated, { requests?, tokens?, tokensLimit?, requestsResetMs?, tokensResetMs? }, or undefined: The rate-limit headers. Numbers only |
usage | The counts of the reply the call failed on, { inputTokens, outputTokens, costUsd? }, when the provider read one that reports them; undefined otherwise. The review counts them as the failed call's usage, in its call event and in meta.usage, and the token cap settles the attempt at them (The token cap). The shipped adapters set it on every failure that follows a reply they read and that reports its counts |
| Kind | Raised when |
|---|---|
http | The endpoint answers with a status outside 2xx: HTTP 503: "model is loading", quoting up to 500 characters of the body. A 3xx adds (redirects are not followed): HTTP 307 (redirects are not followed): "moved". Also an openaiCompatible server error in a 2xx reply whose code is an error status, and a claudeCode result that reports an API error with a status from 400 to 599: HTTP 429 from the model API: "..." |
network | The request fails, request to http://localhost:11434 failed (ECONNREFUSED), or reading the reply does, reading the reply from <origin> failed |
aborted | The request's signal stopped it, a claude run included: request aborted. A request carries its attempt's signal, which the review's abort, the review's deadline and the attempt's own deadline all abort, so inside a review an aborted failure never surfaces: the attempt's timeout, the review's deadline or the abort's reason wins |
refusal | The model refused, or a filter stopped the reply or the prompt: each adapter's reply table names its messages, and claudeCode's is Claude Code replies and errors |
truncated | The token limit, the server's window or a lower cap of the server cut the reply off: reply was cut off at its limit of <l> tokens, a reply was cut off at 8192 tokens, below the <l> quorum asked for: ... or a reply ended at the server's window ..., each with its noAnswer (reply, thinking or window): What a reply lacked |
no-answer | The reply ended on its own with no visible answer: reply has no answer, only reasoning: ... (noAnswer thinking) or reply has no answer and no reasoning: ... (noAnswer empty). Only a reply of only reasoning is sent once more, once per call, after the thinking lowering has had its try (What is retried); three calls in a row find the provider down: What a reply lacked |
invalid-response | The body is not JSON (response body is not JSON), is over 16 MiB (reply body is over 16 MiB) or is not an object (reply is not a JSON object), for every HTTP adapter. Or the reply holds an error, has not finished or ended early, as each adapter's reply table words it. For claudeCode: a claude that printed no JSON result, a schema result with no structured output or one that shows a tool the server ran, or more than 16 MiB on stdout (reply is over 16 MiB) |
too-large | A request may not fit the model's context, and the provider refused it before sending it: <id>: may need <n> tokens, more than contextTokens (<c>): ..., with the numbers The size of a request explains. Not retryable. The review records it as a request-too-large gap, on research and on a vote alike, and never fails on it. claudeCode adds a message over its 10,000,000-byte stdin cap, and Claude Code's own refusal of a prompt as too long, which are gaps too: The size of a Claude Code request |
process | A claude that failed, exited or could not start: claude exited 2: "...", claude failed (...): "...", could not start the claude CLI (ENOENT). Only claudeCode raises it |
unsupported | claudeCode refuses a request that is not exactly one user message, or whose message starts with /. Only claudeCode raises it |
timeout | The core raises it at an attempt's deadline: <id>: no reply within 600000 ms, the id the provider had when the quorum was created |
The core raises one more itself: a provider whose reply has no string text fails that call with <id>: returned no reply text, of kind invalid-response.
The core retries a call as Deadlines and retries says. A failed research call is its profile's research-failed gap, a gating profile's too, unless it is a too-large refusal, which is a request-too-large gap: the other parts and profiles go on. A provider whose calls fail three times in a row for a reason of its own, a reply with no answer included, is found down and called no more, its unsent parts and votes are provider-down gaps, and only when no research call answered does review reject, with a ProviderDownError, which the CLI writes as exit 3: When the research call fails. A failed vote is recorded in the vote's error and counts as a reject: Failed votes.
Writing a provider
Any object of the port's shape is a provider. It must:
- return the model's raw text in
text, without parsing it: the core extracts and validates the JSON itself, and a reply it cannot use is a failed vote, or, for research, aresearch-failedgap; - honour
request.signal, settling soon after it aborts: the core settles the call at its deadline or at the review's abort without waiting, and a provider that ignores the signal works on, outside the review, until it ends; - throw when the call fails, a
ProviderErrorwith the closestkindfor preference. A vote records the message of anyError, and the text of anything else thrown. A reply that held no usable answer istruncated, with anoAnswerofreply,thinkingorwindow, orno-answer, withthinkingorempty: the review reads the error's own datakindandnoAnswer, never its message, to say so once and to count a provider that is down. AProviderErrorof an HTTP adapter says the account's credit, quota or spend limit is used up withexhausted: true, which only the vendor's own codes set (What is retried); a provider object of your own may set it on anhttpfailure to stop its provider at once, and it is read as own data, for anhttpkind alone; - report
usageonly when it knows it:inputTokensandoutputTokens, andcostUsdwhen it knows the price. It reports it on a reply it returns, and in theusageof theProviderErrorit throws for a reply it read but cannot use, which the review counts as the failed call's; - check the size of its own requests: quorum states no context size for a provider object. The review's token cap reserves the provider's stated
worstCase, else the core's own count of the request with 512 and 16000, which bounds the spend and is no size guard: the provider's own check still refuses what may not fit its window. A provider that refuses a request as too large throws aProviderErrorof kindtoo-large, which the review records as arequest-too-largegap, on research and on a vote alike, instead of a failure:ProviderError. The review recognises the refusal by an ownkindproperty of'too-large', not by class, so one raised by a second copy of quorum counts too.
A provider object of your own states timeoutMs, retries, worstCase and room as plain fields: What a provider states. An object that already has an own timeoutMs or retries field, for a purpose of its own, now states it to the core: in range, the value becomes the core's deadline or its retries, so a provider that retries by itself and exposes retries is retried on top; out of range, createQuorum refuses it. An own worstCase or room that is not a function is refused the same way. The core reads a thrown value's kind, status, retryable, retryAfterMs and noAnswer as own data properties too, so a plain Error, or an error whose fields are getters, is never retried: throw a ProviderError with the closest kind to be retried. A shipped adapter takes both as options, and states them itself:
import { ollama } from '@tobi-or-not/quorum'
const voter = ollama({
id: 'voter',
baseUrl: 'http://localhost:11434',
model: 'qwen3.6:27b',
contextTokens: 131072,
timeoutMs: 120_000
})A vote with no reply within two minutes is a timeout, which is tried again once, and a second silence of two minutes fails the vote, voter: no reply within 120000 ms: retries: 0 fails it at the first. A review aborted by its own signal still rejects with that signal's reason.
Next
Profiles — what a review looks for, the security profile, writing one of your own, gating and guidelines.
