
Gateway
How it works
A request authenticates with a gateway key or a supported client’s organization
sign-in. Forge resolves the caller’s identity and access profile, validates the requested model and API surface, applies the
relevant policy and budget controls, selects an eligible route, and records the
result.
With a supported network integration or Forge for devices, Forge can
automatically route supported model API traffic through the LLM Gateway. Teams
get one governed path without reconfiguring every application.
Traffic entry
Traffic reaches the LLM Gateway through three supported paths:
Native web and desktop sessions use a separate inspection path that preserves
the provider login. Routing those sessions does not switch them to a managed
model provider or apply an explicit gateway access profile. See
Architecture for the two paths.
Network routing gives organizations agentless coverage from an existing
network control point. Forge for devices extends the same experience to
managed endpoints wherever they work. Direct configuration remains available
for teams that want to connect an application or service explicitly.
Providers
Forge maintains a catalog of supported providers and the API surfaces available for each one. The provider picker includes OpenAI, Anthropic, Azure OpenAI, Microsoft Foundry Models, Amazon Bedrock, Amazon Bedrock Mantle, Vertex AI, Gemini, Mistral, Cohere, xAI, Databricks, OpenRouter, Cerebras, DeepSeek, Fireworks AI, Groq, Nebius AI Studio, Perplexity, Forge Router, and custom OpenAI-compatible and Anthropic-compatible connections. Microsoft Foundry Models and Bedrock Mantle accept a configured regional base URL and provider API key for Chat Completions and Responses, including streams. For Bedrock Mantle, expand Advanced authentication to use AWS access keys instead. Enter the access key ID, secret access key, region, and any session token. Forge stores them securely and signs requests for the selected region. These are separate connections from Azure OpenAI and Bedrock Converse. Provider credentials can use a Forge-managed secret reference, a customer-managed credential, or no credential when the upstream connection does not require one. Plaintext credentials are accepted only when a provider is configured and are never returned by the API. Forge reports each provider’s configuration state and health separately. Configuration states includeconfigured, disabled, error, and deleted;
health can be healthy, degraded, unhealthy, down, or unknown.
The provider and model picker uses a versioned Forge catalog. It shows models
eligible for the selected provider and still accepts a custom model ID when
your provider offers a model that is not yet listed. Forge reviews model
capabilities and prices before publishing catalog changes. The Terraform
catalog data source exposes model entries and a digest so plans can detect a
catalog update without pinning a model list in configuration.
API surfaces
Routes are scoped to an API surface so a caller cannot use an upstream capability merely because it can reach the provider.
The provider catalog is the source of truth for which surfaces a specific
provider supports.
For configured OpenAI-compatible destinations, native media routes include
image generation, edits, and variations; audio speech, transcription, and
translation; and video creation, status, and content download. Forge applies
access, routing, and budget controls to these routes and passes the media
content through without content inspection. Video downloads stream to the
caller and are limited to 1 GiB.
On native Anthropic Messages routes, Forge forwards syntactically valid
Anthropic-Beta feature headers and preserves output_config.effort in the
request body. Forge replaces caller credential headers with the credential
assigned to the selected provider. Provider beta features still require that
the selected Anthropic model supports them.
OpenAI Chat Completions can also use an Anthropic provider through Forge’s
Chat-to-Messages bridge. That bridge currently supports text turns and
function-tool history, including streaming and provider-reported usage. It
uses a 4096 output-token limit if max_tokens is omitted and rejects
unsupported request fields or provider blocks before releasing a translated
response. OpenAI Responses calls can use the same Anthropic Messages route
for text and function calls in unary or streaming mode. The bridge returns provider-
reported token usage and rejects unsupported input before contacting Anthropic.
Anthropic Messages calls can also use an OpenAI Chat route for text and
function calls in unary or streaming mode. Forge translates the Chat response
and provider usage back to the Messages format.
Gemini, Vertex and Bedrock Converse routes can serve Chat, Responses,
Messages, GenerateContent and Converse clients. The bridges accept a documented
text and function-tool subset, reject unsupported fields, and use provider-
reported usage when available. GenerateContent requests to OpenAI Chat or
Anthropic Messages routes support text turns, system instructions and common
generation settings in unary mode. Tool, multimodal and thought fields that
cannot be preserved are rejected before a provider call. The gateway returns
an error if the chosen provider operation cannot support a streaming request.
When policy enforcement is enabled, OpenAI Responses requests must include the
complete provider-visible context in
input. Forge rejects
previous_response_id continuations because the referenced provider-side
history cannot be evaluated or transformed by the gateway. Monitor and
simulate modes may observe these continuations without claiming full-context
enforcement.Access profiles
An access profile is the reusable control plane for a class of gateway traffic. It defines what a caller assigned to the profile may request and what controls Forge applies. Access profiles configure:- Model selectors and provider selectors.
- Allowed client networks.
- Data classes used by policy evaluation.
- Prompt, pre-tool-use, and post-tool-use policy checkpoints.
- Privacy mode for retained gateway data.
- Enforcement mode and lifecycle state.
Profiles are versioned so changes to model access and enforcement can be
tracked. Organization sign-in makes every currently assigned profile available,
including profiles granted through overlapping groups. Grants combine the set
of available profiles; they do not combine model permissions or provider pools.
Each request uses exactly one profile. Gateway keys have an explicit allowed
profile set and a default profile within that set; existing keys keep their
single-profile scope.
Restrict client networks
In LLM Gateway > Access profiles, open a profile and enter IPv4 or IPv6 addresses or CIDR ranges in Allowed client networks under Profile details. For public connections, use the IP addresses Forge sees at its ingress, such as your company’s public egress ranges. The caller still needs a valid grant for the selected profile. Forge denies a request if it cannot verify an allowed client address. An empty list accepts any client network. If Terraform manages the profile, setallowed_client_networks in forge_llm_gateway_access_profile.
Select a profile per request
Use profiles for use cases such as engineering, legal analysis, or confidential work. Send the profile’s immutable routing key or canonical ID inX-Forge-Gateway-Profile on inference and model-discovery requests:
GET /v1/access-profiles on the gateway base URL with the same credential
to discover eligible profiles and the default. Standard model discovery shows
only the models available within the selected profile. A selector never grants
access: unknown and unauthorized profiles are denied, and a failed selection
does not fall back to another profile.
Without a header, a gateway key uses its configured default. Organization
sign-in uses the most specific marked direct-request default (person, then group, then
organization), or the sole eligible profile if no default is marked. Conflicting
defaults require an explicit selector; a configured but unavailable default
fails closed. Adding a second group therefore does not make explicit selection
ambiguous.
A sensitivity profile expresses the caller’s intent. Mandatory organization
controls still inspect and constrain the request; selecting a general profile
cannot relax those controls. Organization, identity, key and applicable group
budget limits continue across profile switches. Profile budgets account for
the selected use case.
Send the intended profile header on each request, including follow-up provider
resource calls. Provider resource and idempotency behavior remains unchanged.
The gateway consumes the selector and returns the selected canonical profile
ID in its response headers.
Applications that support fixed custom headers can configure the same header
once. For example, a supported Claude Desktop managed configuration uses:
Connect an app
In Gateway, select Connect an app and choose your application. Forge shows the available connection methods and setup instructions.
Use Access settings to assign profiles to people or departments. Budgets are
optional and configured separately in Gateway → Budgets.
Organization sign-in requires an active organization membership, a linked
directory identity, and a managed-access assignment.
Choose automatic network access
In each profile assignment, set Network traffic to Use automatically for the profile Forge should apply to supported traffic from connected devices. Choose Direct requests only to keep that profile available for direct Gateway requests without making it an automatic network choice. If a person or group already has an automatic network assignment, additional assignments default to direct requests only. Budget changes do not alter these access choices. An assignment limited to direct requests is skipped for automatic selection. Other eligible assignments can still apply, including the organization default. For example, give a Leadership group Leadership Team for automatic network access and keep General Use for direct requests only. People retain both profiles for direct Gateway requests and can select General Use withX-Forge-Gateway-Profile.
Under Direct requests, Use by default controls requests without that
header; it does not choose the automatic network profile.
Automatic network selection uses an explicit person or workload assignment
before a matching group assignment, then the organization default. More than
one eligible assignment at the winning level blocks automatic network access,
including overlapping groups. A missing or unavailable winning profile does
not fall back to a less specific one. To repair an overlap, edit the assignment
you want to keep for direct requests and choose Direct requests only; do not
delete the assignment unless you also intend to remove its direct access.
An administrator cannot explicitly enable a second automatic assignment for
the same target. Assignments on different groups can still overlap through
membership, so review the person’s current groups. An explicit person
assignment can provide the intended higher-priority network choice. Existing
authentication, model restrictions and shared budgets still apply.
Use the OAuth access token and public client settings shown for the selected
application. A customer IdP token supplied directly as a bearer credential is
not interchangeable with Forge organization sign-in.
See Gateway authentication for token validation,
directory linkage, and assignment precedence.
For Claude Desktop, download the setup file for your operating system or use
Connection details and manual setup for one device. Follow
Claude Desktop with Forge.
For other applications, follow Connect apps to Forge.
For Codex CLI or the desktop app, follow Codex with Forge.
Send a first request and check Usage to confirm the connection.
Routing
A route matches an access profile and requested model, then directs the request to a provider. A route can preserve the requested model name or rewrite it to a different upstream model. Forge selects the compatible provider operation and translates supported client formats; the Console does not ask you to choose a protocol route.Tiers and strategies
Routes with the same priority form a tier. Forge tries lower priority numbers first and moves to later tiers only when the earlier tiers have no eligible destination or their attempts fail. Later tiers are therefore the fallback path;fallback is not a strategy you select.
The strategy controls selection among eligible destinations within one tier:
Forge excludes degraded or unhealthy destinations during their cooldown and
uses eligible destinations in the same tier before moving to the next tier. A
successful later probe restores a destination to healthy. Buffered request
surfaces can fail over before a response is returned; Forge does not replay a
stream after its response has begun.
Routes can also set same-destination retries, cooldown periods, and
provider-specific request overrides. Provider-owned and secret-bearing fields
cannot be supplied through request overrides.
Route rollout states are
draft, monitor, simulate, enforce, paused,
and archived. Tool denials can use hard_block or rewrite_refusal.
Gateway keys
Gateway keys authenticate callers and connect each caller to an access profile. A key binds one subject of typeuser, group, app, agent,
service_account, or customer_tenant.
Token classes include personal, group, service_account, app, agent,
customer_tenant, and exchanged. Keys can expire and can be rotated,
transferred, revoked, disabled, re-enabled, or deleted. Their runtime state is
active, revoked, or expired.
Use Filter in Gateway keys to search keys and narrow the table by
access profile, assignment type, assignee, state, management, activity, or expiration. Filters
can be combined and cleared together.
Service accounts
Service accounts give non-human workloads a durable identity rather than sharing a person’s key. They can represent applications, agents, bots, and integrations. A service account records its owner, environment, rotation policy, and state. The owner can be a directory user, directory group, or app integration. States areactive, disabled, and archived.
Budgets
Configure optional limits in Gateway → Budgets. Access settings grant access to models; they do not create or edit budgets. Creating a gateway key or assigning an access profile does not require a budget. Removing an access assignment does not remove a budget or its recorded usage. Budgets can be attached to an access profile, gateway key, or subject. A budget can enforce any combination of:- Spend in USD.
- Input tokens.
- Output tokens.
- Total tokens.
daily, weekly, monthly, rolling_24h,
rolling_7d, and rolling_30d. Calendar windows reset in UTC; rolling windows
move continuously. When either a configured spend or token limit is reached,
Forge blocks subsequent requests in that budget window.
In the Budgets editor, expand Alerts and cost accounting to set an optional
Notify at percentage. Forge sends an administrator notification when recorded usage first
reaches that share of any configured limit. The hard stop remains at 100%.
Calendar windows notify once per window; rolling windows notify again only
after usage has fallen below the threshold and later crosses it. The API accepts
metadata.warningThresholds: [80] on budget creation. Access assignments do not configure budgets.
The Console also offers a Spend alert in USD with optional email recipients.
It can be used without a hard limit, or set below a hard spend limit. Crossing
this threshold creates an alert without blocking requests. This is separate
from the percentage-based Notify at setting.
Open Gateway → Budgets and choose Add budget to set a user, group, service-account, or gateway-key limit.
Budgets apply across all access profiles by default; expand Access profile to
limit a budget to one profile. Existing key and managed-access budgets appear in
the same table. Editing a limit preserves usage; changing its target or period
requires a new budget.
Budgets migrated from managed access keep their previous fallback rule: a matching
managed override budget replaces the legacy Default user budget. Other
independent budgets still apply together.
For a department, choose its directory group and expand Member limits to set
a per-member default and named exceptions. For example, a group can have $100 in
total, $10 per member, and a $20 exception for Amelia. Shared group keys cannot
identify an individual member; use user keys or organization sign-in when member
limits apply. Every matching user, group, member, profile, and key cap applies.
Choose Add allowance for this period to add temporary spending to a budget or
member. The allowance ends at the next UTC day, week, or month reset without
changing the normal limit or clearing usage. Open the same action to remove an
allowance early. The dialog previews the normal limit, current limit, new limit,
and exact UTC expiry before confirmation. This is an administrator-granted
current-period allowance, not an approval-request or arbitrary-duration workflow.
Allowances do not bypass other budgets and are unavailable for
rolling periods. The table shows Applying changes while a saved change is
propagating; the previous limits can remain active until that finishes.
Dollar budgets stop new paid calls when recorded spend reaches the limit.
Maximum request estimates and unresolved charges from earlier calls do not
exhaust a dollar budget while recorded spend is below the limit. Calls already
in flight can finish above the threshold; Forge records their full actual cost
and stops subsequent paid calls. Verified free calls remain available.
Token caps reserve capacity before sending a request and reconcile it with
reported usage afterward. Multiple output candidates reserve tokens for every
candidate. Pending or unsettled token reservations can block a call even when
recorded token usage is below its cap.
Canceling a request does not prove that the provider incurred no charge. Unknown
billing remains unresolved until provider evidence is available. Forge preserves
those facts without counting the maximum possible output bill as recorded spend.
Open a blocked request in Gateway → Usage to see its budget explanation.
New requests show the applicable scope and period, limit, and recorded usage
from the admission decision. Token budget explanations also show reserved and
required capacity. Older requests may not have these saved details. A budget service availability error
does not mean that you exhausted a limit.
Cost comes from provider-reported usage, configured route pricing, or Forge’s
model pricing catalog. Missing rates or unsupported billing modifiers produce
unknown cost. Use models with known pricing when enforcing dollar budgets;
requests without usable pricing are unavailable when a matching dollar budget
applies. This includes provider-hosted tools with unpriced fees and media whose
cost cannot be bounded by the token quote. Client-executed function tools remain
supported. Token limits remain available independently of dollar pricing.
For custom OpenAI- or Anthropic-compatible endpoints, configure both
cost_per_1k_input_tokens and cost_per_1k_output_tokens in the route’s config
when enforcing dollar budgets on generation. A familiar model name alone does
not establish the custom endpoint’s prices. Known input-only operations require
only the input rate.
Enforcement across providers and replicas
Budgets apply to the Forge identity and selected access profile before provider execution. Switching providers, changing keys for the same user, or switching between supported client API formats does not create a separate user allowance. An access-profile filter intentionally restricts that budget to the selected profile. All other matching limits still apply. Gateway replicas share committed usage and token reservations. Admission checks all matching spending thresholds and token caps atomically. If shared accounting cannot be read or safely recovered, affected requests are unavailable rather than admitted using an independent local counter. Usage displayed in the Console can lag admission because recorded request history updates separately. Budgets govern traffic sent through Forge. They do not cap direct calls made with a provider credential outside Forge, or unpriced external services such as Tavily search credits. Provider usage and pricing determine the accuracy of USD accounting; a dollar limit is not a guarantee about the provider’s final invoice. Token admission reserves conservative input bytes where an exact provider count is unavailable. Output and total-token caps require an explicit output limit or a reviewed model maximum; remaining quota is never used as a guessed provider maximum. Known input-only operations such as embeddings do not reserve output capacity. Hard limits block operations whose consumption cannot be bounded before dispatch, including open-ended realtime sessions, asynchronous batch/training submissions, and unpriced hosted tools or media. Read-only retrieval of models, files, or existing jobs and token-count previews do not reserve generation quota. These operations remain available when no matching hard limit requires an unsupported bound. A pricing failure returnsforge_budget_pricing_unavailable; an unavailable
token bound returns forge_budget_exposure_unavailable.
The gateway rechecks the final provider payload after route parameters, policy
rewrites, and protocol translation. Earlier billable attempts remain counted
when a request retries or falls back to another provider. Each request uses its
original admission time for calendar and rolling limits,
including retries and later usage updates. A request crossing a UTC reset retains
the period in which it was admitted.
In-flight exposure remains reserved while a request runs. A long stream does not
regain capacity merely because five minutes elapsed. If a client disconnects or
a provider omits final usage, the gateway records only the usage it actually
observed and retains the unused admitted bound for each unknown dimension.
Missing billing is not treated as free usage. A later complete observation
releases the remaining hold without counting the request twice.
The Console shows Pending usage when a provider has not supplied complete
billing. Reserved token exposure still counts toward token limits. Unconfirmed
cost estimates do not exhaust a dollar budget. An allowance increases
the applicable cap; it does not
resolve unknown billing or bypass another matching limit.
A calendar reset starts a new budget period. For rolling limits, both observed
usage and uncertain holds leave the active window according to the request’s
original admission time, using minute buckets. A crash does not retain current
rolling headroom for the full accounting-history retention period. Aging out of
a window does not mean the provider’s final bill became known.
Already-admitted requests can finish across a calendar reset. Their final payload
checks and usage stay in the original period; new requests use the new period.
The old period’s accounting remains available until its live requests finish.
Reporting history can lag a provider request or its final payload adjustment.
Forge therefore repairs derived counters from its replicated accounting journal.
Budgeted requests also require all configured eligible replica acknowledgements.
In the deployed three-node topology, either missing replica makes budgeted
requests temporarily unavailable, including during node maintenance. This keeps
a stale promoted replica from opening capacity that was already reserved.
If authoritative accounting is missing, affected budgets remain unavailable;
reporting history alone is not proof that no billable work occurred.
Administrators must restore validated accounting rather than reset usage.
API and Terraform coverage
The public API exposes budget operations under/api/headless/v1/organizations/{organizationId}/llm-gateway. The Console uses
the same validation and accounting through its organization endpoints:
Budget writes reject unknown
metadata keys instead of ignoring misspelled
settings. Supported settings include memberLimitUsd, memberLimitsUsd,
softBudgetUsd, softBudgetAlertEmails, warningThresholds,
negotiatedDiscountPercent, and costMultiplier. Server-owned allowance and
membership fields may be sent back unchanged on update; change allowances through
allowanceUsd. Read responses can contain additional metadata.
Authenticate public API calls with a Forge service-account bearer token. Reads
require policies:read and organization telemetry-read permission. Writes require
policies:write and policy-management permission, plus X-Forge-Reason,
X-Forge-Confirm: true, and a unique Idempotency-Key. Reusing the same key and
request body returns the original result without adding the allowance twice.
Use a new key for a new action. Console session mutations also require CSRF
protection.
For a temporary allowance, send an update such as:
allowanceUserId to target the budget
total. To bind a grant to the period you previewed, send allowanceWindowStart
from the list response’s periodStarts for that budget’s window. A reset returns
409 without granting allowance. Omission uses the period at processing time;
zero-value removal ignores this precondition. Positive amounts add to the current-period allowance; zero removes that
target’s entire allowance. Other budget edits in the same allowance request are
ignored. metadata.allowance and metadata.memberAllowances are server-owned
response fields; change them through this action. For ordinary updates, send the
complete editable budget settings; the server preserves omitted allowance and
member-linkage fields. Expired allowances are removed during ordinary edits and
do not block clearing a member default. Current and scheduled allowances remain
protected. Target and period
changes require a new budget. A 202 response means the save succeeded but runtime
propagation is pending; it does not mean every gateway already enforces the change.
Poll GET /budgets and inspect X-Forge-Gateway-Authority-Propagation; wait for
ready before treating the new configuration as effective across serving replicas.
The Terraform provider’s forge_llm_gateway_managed_access_override manages
access assignments only. Use forge_llm_gateway_budget
for normal spending, token, and group member limits. Terraform preserves
administrator-granted temporary allowances during refresh and updates. Destroy
disables a budget without deleting its usage history. Existing
Terraform configurations must remove budget_window, amount_usd,
total_token_limit, and alert_threshold_percent from access assignments. The
state upgrade removes those fields without deleting the remote budgets.
Switch an app
Point the existing SDK at the Forge endpoint and replace the provider credential with a scoped gateway key.Session continuity
To group multiple model requests from one logical agent interaction, generate a high-entropy session hint and send the same value unchanged on every request in that interaction:X-Forge-Session-Id response
header contains Forge’s canonical session ID for observability. Treat that
response value as read-only: continue sending your original hint rather than
using the returned canonical ID as the next request’s hint.
This continuity is required for Allow retry once approvals. Send the stable
client hint on the request that receives 403 with
X-Forge-Policy-Outcome: approval_required, approve the request in
Responses, and retry the identical model request with the same client hint.
The approved retry returns X-Forge-Policy-Outcome: allowed. A
single-invocation grant is consumed by that retry; another matching invocation
requires a new approval.
Do not replace the client hint with the canonical sess_lgw_... value returned
by Forge. Sending that canonical value as a new hint starts a different scoped
session and the approved grant will not match.
User attribution
The gateway key authenticates the application or service account. When the application acts for an end user, it can also pass a verified identity token:Policy checkpoints
Profiles and routes can invoke policies at three points:
The profile and route enforcement modes determine whether a matching policy is
observed, simulated, enforced, or processed under break-glass behavior. Tool
denials can stop execution or return a rewritten refusal when that behavior is
configured on the route.
Observability
Forge records the requested and served model, selected provider and route, identity, policy outcomes, tokens, cost, latency, retries, fallbacks, errors, cache hits, and denied tool calls for routed traffic. Gateway analytics include:- Request and session volume.
- Input, output, and total tokens.
- Provider-reported or Forge-estimated cost.
- Policy hits and denied tool calls.
- Route health, errors, retries, fallback rate, and cache hits.
- Bypass findings for observed traffic that did not use the gateway.
Streaming response headers
For a successful SSE response, Forge sends the policy result known before the stream starts inX-Forge-Gateway-Initial-Policy-Outcome (and its
X-Forge-Initial-Policy-Outcome alias). This is an immutable snapshot: HTTP
response headers have already been committed when later tool calls and tool
results are evaluated.
The final controlling result is therefore sent after the stream in the
X-Forge-Gateway-Policy-Outcome and X-Forge-Policy-Outcome HTTP trailers.
Clients that need the final result must use an HTTP stack that exposes response
trailers, or read the persisted request/session evidence in Forge. A client
that does not expose trailers can still use the initial outcome header without
mistaking it for the final tool-adjusted decision.
X-Forge-Phase-Timing-Scope: pre_stream_headers identifies streaming timing
headers as the phases completed before Forge commits the SSE headers. They do
not include subsequent stream consumption, tool-output evaluation, or final
persistence. Unary timing headers continue to describe the completed unary
request and do not carry this scope marker.