Skip to content
Like what we’re building? Star on GitHub

The OpenAI-compatible gateway ​

Serving openai_compatible/<gateway model id> from the deployment's environment: the two variables, the verbatim wire id, the guarded dial and its escape hatch, the claw-only routing and its C186 warning, the catalog (ADR-122) and what an unknown answer costs, the env-funded accounting.

Read backends.md — the section is the reference; this page is the pointer.

Provider/model configuration lives in the DB ​

The database is the seat of provider/model configuration — context window, prices, capabilities, the per-credential default model (spec and tracking: #2906). Every provider/model record resolves through one cascade, global → org → team → bot → bot-in-team → bot binding, which extends the credential audience chain (OrderedAPIKeyCandidates, pkg/secrets/byok.go) and the model-override fold (model.ModelOverrides). A gateway model's capabilities — window, output cap, prices, accepted reasoning efforts — are facts of the gateway: their seat is the price feed below, at the platform, org and team levels only, never a bot, binding or credential (ADR-166). The env tables (OPENAI_COMPATIBLE_MODELS, OPENAI_COMPATIBLE_REASONING_EFFORTS, OPENAI_COMPATIBLE_CATALOG_PROVIDER) are runner-side fallbacks, not the seat of truth; a platform scaleway feed is CATALOG_PROVIDER's database seat.

The price feed (ADR-163, ADR-166) ​

The operator table has a database twin: platform, org and team feeds (price_feeds, documents platform, org:<id>, team:<id>), folded at every launch and resume into the run bundle and planted on the run's environment. Team over org over platform, per id: within a level the first answering feed that prices an id wins its price entry, which answers WHOLE — prices, window, output cap, cache price and flags from that one feed, never merged (ADR-122); a feed that prices a declared id restates its window, output cap and cache price, or they are lost, and the fold warns. Accepted efforts fold apart by the same precedence, so a priced entry never erases a declared effort list. A fetched feed (modelsdev, scaleway, litellm, exec) refreshes on one elected replica and answers while fresh; a stale one steps down to the operator table. A level the fold cannot read (a database error, or its own 2 s deadline) refuses the launch or resume, retryably (PRICE_FEED_UNREAD, ADR-166 §4). A declared feed is the operator's table stored in its config (params.entries): never fetched, never stale. Its entries answer whole as the operator-table rows they copy — priced or not, an unpriced one only where nothing prices the id (beside, below, or on the runner's env table) — and an entry stating only reasoning_efforts answers its efforts alone. The _gateway_spec record carries "feed:<name>" with its age.

Commands: iterion remote price-feeds list|set|delete|sync|declare [--platform|--org|--team] (the platform level is super-admin) and effective --team T [--model ID …], the table a run launched now for the team (naming those ids) seals, each answer with its feed and level. The full contract — precedence, sources, declarations, drift — is backends.md's price-feed section.

Accepted efforts ​

A gateway model accepts only some reasoning_effort values; the runner maps the requested effort onto that list (nearest named level, ties toward more effort). compatgw.AcceptedEfforts reads the run table's efforts map first (feed:<name>), then OPENAI_COMPATIBLE_REASONING_EFFORTS by exact wire id (env:…), else the effort passes. Efforts fold per field, separately from the price entries: a feed pricing an id never erases a declared list. The env table stays tolerant (invalid entries warn and drop individually; values normalize case/whitespace and accept integers 1–100), and old runners ignore the variable, so no deployment order is required. Delegation, interaction and cut-turn recovery share the mapping (TestEveryReasoningEffortWriterIsInventoried); the sandbox crossing writes the host's merged table under the env name, so an older sandbox image honours the database. reasoning_effort_adjusted names its source.

Only closed-list, typed provider parameter refusals park as PROVIDER_REQUEST_INVALID; model prose and tool stderr do not. A sandboxed node's refusal arrives typed only from a runner image of the same release: an older runner sends its text alone, which stays EXECUTION_FAILED. The gateway and correction contracts list the values, deployment example and Claude Code's untyped-error limitation.

A provider refusal is read from the typed error before its status (api.ClassifyRefusal). A budget is a spend ceiling: it parks as USAGE_LIMIT_BLOCKED, probed hourly. A model refusing an input kind, a grammar refusal or a refused request stops every retry layer, redelivery, automatic resume and gate relaunch (the table).

Images ​

A claw node reaches a vision model on the gateway through two channels: an image block in the user prompt ({{attachments.<name>}}), and the image a tool returns (read_image; screenshot and computer_use where a display exists). The chat wire (openaiwire.ConvertMessages, shared with foundry; the Responses API mirrors it) sends both as image_url parts, a base64 source as a data URL, and refuses an image block it cannot encode. A tool message is text only, so a tool's images ride in the next user message, announced by the tool text. The Mistral family's chat template refuses a user message right after a tool message (Unexpected role 'user' after role 'tool', text-only too), so an assistant message bridges them: tool → assistant → user is the one sequence every vision model measured on PLIAGE accepted (pixtral-12b, mistral-small-3.2, mistral-medium-3.5, gemma-4, qwen3.5, qwen3.6, deepseek-v4.1-flash, 24/11/2026). glm-5.3 is not multimodal: an image turn fails 400 … is not a multimodal model. A tool emits images only when its registration attests imageResult (tool.ImageResultContent decodes its output); every other tool output stays text. The held images wait for the end of the run of tool results on both wires, and a user message they join keeps its own content under its own caption (openaiwire.UserContentCaption), so a user image never reads as the tool's.

The bounds are the route's, one seam: tool.ImagePolicy, resolved from the spec once per generation (tool.RouteImagePolicy) and carried to the tool door and to buildRequest. The Anthropic family (anthropic, bedrock, vertex, or any route whose model id names a Claude model, a gateway's included) bounds an image at 5 MiB of base64 and 8000 pixels a side, a request's images at 24 MiB (its 32 MB cap, less the text) and 100 images, and every image of a request of more than 20 at 2000 pixels a side; every other route at 20 MiB per image and 40 MiB per request, nothing else. Escape hatches, 0 for no bound, read planted-as-unset like the watchdog knobs and crossed into the sandbox the same way (tool.ImagePolicyEnvVars): ITERION_IMAGE_MAX_BASE64_BYTES, ITERION_IMAGE_MAX_SIDE, ITERION_REQUEST_IMAGE_MAX_BYTES, ITERION_REQUEST_IMAGE_MAX_COUNT, ITERION_REQUEST_MANY_IMAGES_THRESHOLD, ITERION_REQUEST_MANY_IMAGES_MAX_SIDE, ITERION_IMAGE_MAX_DECODE_PIXELS (50 MP). An image is held to the smaller of the per-image and per-request byte bounds. Headers are read, never pixels (tool.ImageHeader: a PNG's IHDR, WebP's first chunk, a bounded JPEG stream, a GIF's screen and first frame); the header's format is the media type sent, and a known format of unreadable size counts as over any side bound. read_image bytes are never decoded: over a bound, a recoverable tool error advising to convert the file. Only a screenshot PNG is reduced (halved to the side, JPEG, halved to the bytes; transparency flattened onto white) with a note; computer_use is refused instead, naming screenshot (the model clicks in the capture's coordinates). Each request re-checks the per-image bounds and its budget: the oldest tool images are replaced, in that request only, by a marker (their reduction note dropped along); once over, down to 75% so the cut moves every few turns; a last-run image says calling again will not help only when it cannot fit beside the prompt's images, else to ask for fewer at a time. Over 20 images, the oldest tool images over 2000 px go first, then older ones whatever their side; the last run's go last, never promised a smaller image. Prompt images are never dropped — breaking a rule alone, the request is refused. Consecutive user messages join on the chat wire. A codemode program gets the description and the image-omitted marker, no bytes.

Whether a route takes images at all (image_input), what it does to an image tool and a prompt image, ITERION_IMAGE_ACCEPTANCE, and the rollout limits of stating it: image-acceptance.md.