Overview
The Cloud API (https://api.allternit.com, cmd/allternit-cloud-api) serves open-lane models next to the normal catalog. They answer far fewer requests with a refusal, and every request to them passes a hard-line filter first. Users can also opt in to handoff: a refused completion from any other model is re-run on an open model.
User guide: Open models.
Models
Open-lane models carry"lane": "open" in GET /v1/models (every other model has "lane": "standard") and "open": { "access": "plan" | "research" }:
Each row has an upstream with a provider prefix, and a row can fail over to another upstream before the first byte is sent. The row that served the request is the one billed. Rows marked
research are listed only for accounts with Open Research. They are listed only while an open-lane upstream is configured (see Environment).
Entitlement
GET /api/v1/billing/credits and GET /api/v1/me/usage return an open_models object:
Open spend draws the plan allowance first, then bought credits. A request that runs past the allowance finishes; the next one is blocked. Free and unknown plans get no Cloud open models, even with bought credits. If the field is missing, clients treat open models as unlocked.
Gate
A chat completion whosemodel is an open-lane model is checked in this order. The base credits gate (credits_required, credits_exhausted) runs first.
Errors are JSON, sent before any stream starts, in the standard Chat Completions error shape:
Platform API-key projects, the OAuth app path and artifacts never run open models; those requests are refused as before.
Hard-line filter
Categories:csam, mass_casualty_weapons, real_person_sexual, sexual_content. The filter (services/hard_line.rs) runs a keyword pre-check for unmistakable phrasing, then a moderation model through an existing upstream (OPEN_LANE_MODERATION_MODEL). It reads the system and user messages (latest 8,000 characters). A block writes one open_lane_blocks row with the category only; prompt text is never stored.
Every other /v1/chat/completions request, BYOK included, runs the keyword pre-check alone (hard_line::standard_check, no model call) and answers the same 400 content_policy_hard_line when it fires.
Settings routes
Clerk session or an API token with theaccount scope.
PUT body (every field optional):
Handoff
Handoff runs when all of these hold: the user turned it on (with both gates passed), the account is entitled to open models (see Entitlement), the requested model is not an open-lane model, and an open-lane upstream is configured. A completion counts as refused when the provider signals it (finish_reason content_filter, a non-empty refusal field, or a content-policy error instead of a completion) or when a refusal phrase opens a short answer (services/refusal.rs). Answers that call tools are never refused. The refused request then passes the hard-line filter and is sent unchanged to the open model. If the filter blocks it, the moderation model is down, or the open model fails, the original refusal is returned.
Request field
The
allternit object is removed before the request reaches any upstream.
Response header and field
The rest of a handed-off response comes from the open model, so its
model field names the open model.
Streaming
With handoff on, the gateway holds a stream until the answer has 400 characters, calls a tool, finishes, or 20 seconds pass, and only then flushes. If the held part reads as a refusal, the frontier stream is dropped and the open model’s stream is sent in its place. With handoff off, streams are not held.Billing
Each model is billed for its own tokens, as twoinference_usage rows. The frontier row uses the provider’s usage report when the refusal finished inside the hold; otherwise it is the marked estimate (prompt and streamed characters divided by 4). Moderation calls are not billed to the user.
Handoff in the chat app
The chat app reaches models through gizzi (cmd/gizzi-code), and gizzi reaches Allternit Cloud models through this API.
- Allternit Cloud models. gizzi strips the handoff chunk from the stream before the AI SDK sees it, or reads the
x-allternit-handoffheader on a non-streamed reply. It then setshandoff: { from, to }on the assistant message. The code is insrc/runtime/providers/handoff.tsandretry-hint.ts. - Other brains (CLI subscriptions, your own API keys). When a finished step has no tool calls and reads as a refusal, gizzi re-runs the turn once on
allternit/<default_handoff_model>. It uses the same rules asservices/refusal.rs, and it checksGET /api/v1/open-lanefirst:available,terms_acceptedandhandoff_enabledmust all be true. The refused message is left out of the open model’s context. The new assistant message carrieshandoff. Sub-agent sessions are skipped.GIZZI_DISABLE_OPEN_LANE_HANDOFF=1turns this off on a runtime. - The bridge (allternit-api
v1_routes.rs) sends{ "type": "handoff", "messageId", "handoff": { from, to } }once per handed-off message. History responses carry the same object asmetadata.telemetry.handoff, so the note is still there after a reload.
Admin: Open Research
Admin only. Not part of the public API; it needs an admin session.PUT /api/v1/admin/open-lane/:user_id/research with body:
open_research: { enabled, contract_ref, set_at }. Open Research is by agreement only; there is no self-serve path.
Tables
Migration105_open_lane.sql:
user_open_lane:user_id(key),aup_accepted_at,age_confirmed_at,handoff_enabled(default false),updated_at, plus the Open Research columnsresearch_enabled_at,research_set_by,research_ref.user_open_allowance: per user, the period allowance and what is used. Reset when a plan grant lands.user_credits.bought_usd: the part of the balance that was bought. Plan grants never clip it.open_lane_blocks:id,user_id,category,created_at.
Environment
Each upstream is a provider prefix with its own variables, named
OPEN_ plus the provider. Setup is in the operations runbook.
| OPEN_LANE_MODERATION_MODEL | provider:upstream-id of the moderation model, through a configured provider. Default: the gpt-oss-safeguard 20B model through OpenRouter (DEFAULT_MODERATION_MODEL in services/hard_line.rs). Llama Guard style answers are understood too. |