Provider notes
What the SDK sends to each provider and how it reads the answer. You never need this to use the SDK. Read it when a provider behaves in a way that surprises you.
The SDK talks to every provider with plain fetch. Your code is the same for all of them. These notes list what the adapters do underneath. How a model string is routed is in Models and providers. The cache and thinking options are in Reasoning and caching.
Google
The adapter uses the Interactions API (POST {baseUrl}/interactions, streaming with ?alt=sse).
- History is chained on Google's side with
previous_interaction_id. If the conversation switches to another provider or model, or the chain has expired, the SDK sends the full history again. Each assistant turn keeps Google's raw output steps, so a resent history is identical to what Google produced, thought signatures included. That keeps the reasoning and the cache prefix intact. - Thinking is sent as
thinking_level(minimal,low,mediumorhigh).xhighandmaxbecomehigh,noneanddynamicare left out. Reasoning summaries are switched on whenever thinking is on. - Stream endings. Only
interaction.completedends a stream. A stream that stops before it with nothing in it, or while a tool call is still being written (itsstep.stopnever came), fails as a retryableincomplete_stream, and its tool calls never run. A cut text answer keeps its text, but the next turn sends the full history instead of continuing the unfinished interaction. A call cut off by the output limit never runs, and its saved step holds{}. - Errors in a stream or a failed interaction are retryable when their code names a temporary failure:
gateway_timeout,UNAVAILABLE,RESOURCE_EXHAUSTED,INTERNALorDEADLINE_EXCEEDED. Other codes, such asINVALID_ARGUMENT, fail for good. - Caching is implicit only. Another
cachevalue warns and falls back. - Tool schemas are converted to the OpenAPI 3.0 subset that Google accepts.
- Long answers on Gemini 4. Google allows 65,536 output tokens per request. A
gemini-4*model with a highermaxOutputTokensruns as a background interaction, with no extra option.run()polls (after 2 seconds, then every 5 seconds).stream()reconnects withlast_event_idafter a dropped connection, and 15 minutes of silence counts as dropped. Cancelling cancels the interaction on Google's side, so billing stops.limits.requestTimeoutMstimes each HTTP request, not the whole run. Any other Google model above 65,536 fails with aConfigErrorbefore the network.
OpenAI
The adapter uses the Responses API (POST {baseUrl}/responses).
- Every turn is stateless. The full history is sent with
store: false.previous_response_id,backgroundand conversations are never used. - Thinking is sent as
reasoning.effort, with the level as you wrote it.dynamicis left out. - Reasoning is kept across a tool loop. A reasoning model returns encrypted reasoning items. The SDK asks for them (
reasoning.encrypted_content), saves them with the turn and sends them back, unchanged, with the tool results of the same run. Reasoning of finished turns is not sent again. - Cache.
prompt_cache_key(at most 64 characters) pins requests to one cache. Cache reads and, from GPT-5.6, cache writes are reported inusage. A write is priced at the catalog'scache_writeprice, which is the30mrate, so a12hwrite costs about twice as much and the estimate is low. - Service tier
flexorpriorityis passed asservice_tier. - Stream endings are read as they come:
response.incomplete(finish reasonlength, orrefusalwhen the content filter cut it),response.failedanderror. The codesserver_errorandrate_limit_exceededare retryable and the others are not. Reasoning summaries arrive asthinking. The finalresponse.completedcarries the whole reply: its text and its function calls fill what an unreadable stream event lost (the app gets a missing end of the text as one moretext_delta), and a streamed call is never dropped. - Tool call ids from other providers are made valid (letters, digits,
_and-, at most 64 characters, a hash when cut), the same way on the call and on its result. - Not sent:
temperature,top_p, and anything that chains conversations.max_output_tokensis sent when you set it. Avideopart is rejected before the network.
Anthropic
The adapter uses the Messages API (POST {baseUrl}/messages) for the Claude 5 family. The API version is 2026-10-21. A headers entry named anthropic-version overrides it. No anthropic-beta header is ever sent.
- Every turn is stateless. Roles alternate, and the tool results of a turn travel together in one user message, before any text.
- Thinking. Claude 5 models think adaptively. A level other than
dynamicsendsoutput_config.effort(minimalbecomeslow) and a summarized thinking display, sothinking_deltaevents carry readable text.noneuses the model's own off switch where it has one (between_toolson Sonnet 5.5,disabledon Haiku 5.5, Opus 5 and Sonnet 5). Otherwise it warns and uses effortlow. The signed thinking blocks of the current tool loop are saved asproviderStepsand sent back unchanged, because the API rejects an edited block. Blocks of finished turns are not sent again. - Caching.
implicit(and unset) puts an automaticcache_controlmark on the last block.5mand1hset its lifetime.30mand12hwarn and fall back. Anthropic reports cache reads and writes outsideinput_tokens. The SDK adds them back, socacheReadTokensandcacheWriteTokensare parts ofinputTokens, as everywhere else. A write is priced at the catalog's single cache-write price (the 5 minute rate), so a1hwrite is under-estimated. - Tool choice.
requiredand a pinned tool map toanyandtool. Opus 5.5, Sonnet 5.5 and the Fable and Mythos 5.1 and 5.2 models answer forced tool use with a 400. For them the SDK warns once and lets the model decide.validatedis Google only. - Structured output uses
output_config.format. The schema is cleaned to the subset Anthropic accepts (closed objects, numeric and length limits moved into the description). The answer is still checked against your own schema. Strict tools get the same cleaning. - Input. Text, images (JPEG, PNG, GIF, WebP) and PDF or plain-text documents. See Media input.
- Output limits.
max_tokensis required, so it defaults to the model's output limit, capped at 64,000. SetmaxOutputTokensto change it.temperature,top_pandtop_kare never sent, because this API version answers them with a 400.serviceTier: "priority"sendsservice_tier: "auto", andflexwarns. - Errors are one line with the status, Anthropic's error type and the
request_id. 429, 5xx, 504 and 529 (overloaded) are retryable, and so is anerrorevent inside a stream. The monthly spend-limit 429 (enforced_spend_limit_reached) is never retried. A stream that ends withoutmessage_stopfails as a retryableincomplete_stream. A call cut off bymax_tokensnever runs its tool calls. - Not supported: server tools (web search, web fetch, code execution), the Batches, Files and token-counting endpoints, citations and prefill.
OpenRouter
The adapter uses Chat Completions (POST {baseUrl}/chat/completions).
- Every turn is stateless. The whole
messageslist is sent. - Session affinity is the body field
session_id, plus thex-session-idheader. The body wins. - Thinking is sent as
reasoning.effort, like OpenAI.dynamicis left out. The thinking text you get comes from thereasoning_detailsblocks (a block'stext, or thesummaryof a summary block, which is how OpenAI models arrive), else fromreasoning. Encrypted blocks have no text, so they never hidereasoning. - Tool choice.
autois left out.none,requiredand a pinned tool are sent.validatedis Google only and is dropped with one warning. - Errors inside a stream. OpenRouter can send an error chunk in a stream that answered 200. The SDK reads it like an HTTP error. The status comes from the chunk's numeric
code, else from itserror_type(rate_limit_exceededis 429,provider_overloaded503,provider_unavailable502,timeout504 andserver500), else from the name incode(as in Retries).finish_reason: "error"is a retryable 502.runRetriesretries the retryable ones. - Reasoning and PDFs. A turn's
reasoning_detailsblocks and parsed-PDF annotations are saved and sent back exactly as OpenRouter returned them. - Cost. The provider's own
costis used when it is reported. A reported0(a free model, a cache hit) stays a known zero. - Cache.
anthropic/...and~anthropic/...models accept the5mand1hsettings. - Files, audio and video are described in Media input. No plugin is ever added. OpenRouter reads a file natively or with its own parser.
- Routing options (
order,only,sort,data_collectionand the rest) come from theopenroutersetting, never fromAgentConfig. Nothing is sent for a key you did not set. See Settings.
OpenAI-compatible services
Groq, Together, Ollama, vLLM and any other service with Chat Completions use one adapter. Name them with a prefix: groq/llama-3.3-70b-versatile.
import { ensureCustomProvider, getProvider } from "agent-accelerator";
const groq = ensureCustomProvider("groq", {
baseUrl: "https://api.groq.com/openai/v1",
});
console.log(groq.id, getProvider("groq") === groq);- The adapter is created once per prefix. A second
ensureCustomProviderwith anotherbaseUrlthrows aConfigError. - It sends no
session_idorprompt_cache_key, because strict services reject unknown fields. Affinity goes in headers only. - Thinking text is read from
reasoning_detailsblocks (textorsummary), elsereasoning_content(DeepSeek, vLLM, Qwen), elsereasoning, the same way onrun()andstream(). It is shown only, never sent back. - Streamed tool calls are placed by their
index. A piece without one continues the current call, unless it carries a new id: then it is the next call, so parallel calls from a server that sends no index stay apart. - An error sent with HTTP 200 or inside a stream is retried when its
codeis a status number (429) or names a temporary failure (overloaded,rate_limit_exceeded...).finish_reason: "error"is a retryable 502, in a stream and in a whole reply. - Its price and abilities are unknown unless you describe the model with
registerModel. See Models and providers. ensureCustomProviderthrows aConfigErrorif you pass abaseUrlorapiKeyfor a first-class prefix (google,openai,anthropic,openrouter). Pass those to theAgentinstead.
Tips
- Pin one provider per agent with
ModelProvider.*when several run in one process. - When an answer surprises you, check
res.provider,res.finishReasonandres.raw. See Errors and telemetry.