https://ai.bijection.com. Use
getServiceUrl("ai-gateway") so the same code works against your installation
and local development. Gateway credentials stay inside actions; application
clients call your actions. Self-hosted deployments without a configured gateway
can call a model provider with their own key.
AI SDK
Install the AI SDK and Bijection provider:streamText, embed and embedMany. Use
bijectionGateway.embeddingModel("openai/text-embedding-3-small") for embeddings.
For endpoint-specific features, use bijectionGateway.messages(model) or
bijectionGateway.responses(model). Model construction can happen at module
scope; credentials and the service URL are obtained only when a request runs.
Pass the model as languageModel to an Agent. Conversation persistence and
reactive UI streaming belong to the Agent component.
OpenAI SDK
fetch with Authorization: Bearer <token>. The action runtime
caches and refreshes tokens. Never return them to clients or save them as
environment variables. Your action still authorizes the application’s user and
the data included in the prompt.
HTTP endpoints
Model IDs use
provider/model. JSON requests are limited to 16 MiB. The
gateway has a 30-minute maximum duration; your action’s runtime timeout may be
shorter. Responses are stateless: supply conversation context on each call.
Caller-supplied upstream credentials, arbitrary endpoints, plugins and model
fallback lists are refused. Upstream provider routing remains OpenRouter’s owner.
Image, voice, Decisions and video routes are experimental. Catalog entries may
include capabilities the gateway does not serve, such as reranking. Consult the
model’s supported interface before calling it.
Local development
Sign in, link your local deployment to a project on a paid team, and runbijection dev. The CLI renews a private capability for that local process.
Inference runs remotely and is billed to the linked team. Anonymous local
deployments cannot use the gateway.
Usage and limits
The team’s usage page shows AI costs by project and model, with a function breakdown. Costs use actual provider receipts, including cached and reasoning tokens, and appear on the team’s invoice at the provider rate. The gateway retains financial metadata without prompts or generated output. Missing costs remain pending until reconciled. A disconnected or cancelled request can still incur a charge. The gateway recovers existing generations’ costs without repeating inference; SDK retries can create additional generations. The gateway returns anX-Bijection-Inference-Id header for support correlation.
Team billing settings include AI-only daily and monthly budgets in USD cents,
daily/monthly warning thresholds, privacy requirements, allowed model IDs and maximum output tokens. Budgets use
UTC calendar periods and observed charges. Null disables a budget; zero stops new
inference. An AI-only budget does not stop database operations. Pending charges
can cause overshoot. Text requests default to at most 32,768 output tokens;
requests above the team’s limit or requesting multiple completions are refused.
The AI usage view separately shows settled charges, requests awaiting receipts,
and unknown outcomes. Unknown requests remain potentially billable. The
management API exposes GET/PUT /v1/ai-gateway/policy and
GET /v1/ai-gateway/usage?from=YYYY-MM-DD&to=YYYY-MM-DD on your management origin.
Policy updates require billing:spendingLimit:update; usage requires
team:usage:view. GET /v1/ai-gateway/requests accepts the same period and
project/deployment filters, a bounded limit and an opaque cursor. It exposes
execution IDs, outcomes, token details and settlement status. Hosted function
attribution additionally requires deployment usage permission; local attribution
is relayed only to the active linked process. The console’s AI usage section
includes these inference records.
Warning notifications use observed charges, are deduplicated within a policy
revision and UTC window, and follow existing administrator notification custody.
Warnings leave requests running. The independent AI-only disable threshold
refuses new AI requests; it does not disable the deployment.
Terminal usage is also available through the ai_gateway_usage log-stream topic.
Events contain execution and inference IDs, model and endpoint, reported token
counts and optional cost. Prompts, responses and raw provider errors are excluded.
Delivery is best effort and can duplicate events; deduplicate by deployment and
inference ID. The terminal snapshot is immutable: a receipt recovered later
updates billing and inference records rather than publishing another cost event.
Invoice closing waits for unresolved receipts. An installation operator can
explicitly waive an irrecoverable customer charge with an attributed reason and
evidence reference. This retains unknown provider cost and a separate customer
charge waiver; it does not record a free provider inference.
Team spending limits include AI usage. Hosted deployments also support daily and
monthly AI usage thresholds through the existing usage-limit settings. Their
disable threshold stops the deployment. Accounting and enforcement are
asynchronous, so in-flight requests can finish after a threshold is crossed.
Request-rate and concurrency limits additionally protect gateway capacity and
return HTTP 429 with Retry-After when reached.
Privacy preferences
UsebijectionGateway(model, { zdr: true }) or provider: { zdr: true } in a
supported HTTP request to require a zero-data-retention inference endpoint.
provider.data_collection: "deny", require_parameters and max_price are also
supported. Price preferences limit provider unit rates, not total request cost.
Team and installation policy may require stricter privacy or restrict model IDs.
Requests cannot relax either policy. If no eligible provider exists, the request fails. ZDR routing
does not control your application logs or third-party tools; usage and billing
metadata is retained.
Application budgets and agents
@bijectionhq/language-models supplies the managed gateway adapter and the
existing session meter. Declare bounded budgets alongside monthlyLimit:
subject, explicitly declared session action, and a named session tag.
Sessions accept at most eight tags; a catalog declares at most sixteen rules.
Every attempt reserves all applicable buckets in one component transaction before
provider dispatch. Unknown outcomes retain cost, token and concurrency commitments;
closing or expiring a session never makes uncertain inference free. Late
settlement updates the attempt’s original UTC windows once. Rate limits use UTC
calendar minutes. Monetary commitments use declared prices in integer picodollars
and are estimates, separate from the platform’s provider-charge ledger.
Managed sessions accept onBudgetWarning and onUsage mutation handles. A warning
callback receives a stable event ID; a usage callback receives a stable call ID
when a completed or proved-failed attempt settles. Handlers must be idempotent.
Read the named attempt with models.call(ctx, call); it includes measured usage,
the original declared price and the gateway inference ID when response headers
are available. Gateway
SDK metadata exposes reported cost for application usage tracking; it does not
establish a platform invoice amount.
Re-export models, usage, calls, budgets and creditBudget from
languageModelsApplication for the workspace page. Budget administration is off
by default. Supply canViewBudgets and authorizeBudgetAdjustment using your
application’s admin authorization before administrators can inspect user buckets
or add audited, idempotent credits. Credits increase a bucket’s application
allowance; they do not adjust provider costs or platform invoices. Raw gateway
calls receive platform controls and do not automatically receive managed
application budgets.