Status: AVAILABLE (internal, admin only). cloud-api (api.allternit.com) watches the prepaid balance Allternit holds at each model provider, compares it with what customers hold in their wallets, alerts the team when a provider runs short, and routes around a provider that falls under its floor. Code: cmd/allternit-cloud-api/src/services/upstream_funding.rs (poller, math, router cache), src/routes/admin_funding.rs (admin routes), migration migrations_pg/104_upstream_funding.sql. Admin page: platform.allternit.com/admin/funding.

How the money flows

  1. The customer pays Allternit through Stripe. Credit packs and plans go through Stripe Checkout; the webhook grants credits to the customer’s cloud wallet (user_credits). Each model call is charged to that wallet at retail price.
  2. Allternit pays each model provider from a prepaid balance. OpenRouter, Together, Fireworks, DeepInfra and Groq each hold a prepaid balance that our production keys spend.
  3. Each provider refills itself. None of them has an API to buy credits. Each one has an auto-recharge setting in its own dashboard: when the balance drops under a threshold, it charges Allternit’s business card for a set amount. Eoj sets this up once per provider, by hand (checklist below).
  4. Timing works in our favour. The business card bill is due about 30 days after the charge. Stripe pays customer money out to the bank in about 2 days. Customer money is in the bank before the card bill is due, so Allternit never floats money it does not have.
  5. cloud-api checks the numbers. Every 10 minutes it refreshes each provider’s balance and its last 24 hours of spend. When a provider has fewer days left than its reserve, or less money than its floor, the team gets an email (at most once per provider every 6 hours). A provider under its floor is skipped for any model another provider also serves.

What is measured

Routing around a short provider

A catalog model is tied to one provider. When that provider’s balance is under its floor, the router looks for another catalog entry of the same model on a different provider (same upstream model name, ignoring case, dashes and the vendor prefix) whose provider is configured and not under its floor. If it finds one, the request runs there, and the price, pool and usage row follow that provider. If no other provider serves the model, the request goes to the original provider anyway: funding never refuses a request by itself. BYOK requests are never rerouted.

Model availability and provider request options

The public model list also honors inference_pools.enabled = FALSE. Disabling a shared pool removes its models from the app pickers as well as refusing shared-credit chat. Re-enabling the pool restores them without a code deploy. BYOK dispatch still runs before the shared-pool gate. For the 2026-11-05 review preparation, the shared Groq pool is disabled: its current account tier permits 8,000 tokens per minute, while a normal app turn sent about 41,000 tokens of instructions and tools. Short API probes passed but the app chat failed. Re-enable only after the account limit can serve a real app turn and that turn passes. No credits or billing settings were changed. Cloud omits providers that have no credits from /v1/models. When the catalog’s default model is on one of them, default: true moves to the first funded listed model, the same one a Platform agent on "allternit" uses. Clients that follow the flag (the console agent form, Gizzi’s “Keep going on Cloud”) move with it. A provider below its funding floor can still serve requests; the router first looks for a funded route to the same model. An HTTP 402 hides that provider’s models for 15 minutes before retrying. This applies to the shared catalog used by Desktop, the web workspace, the phone PWA and iPhone. Together’s dedicated-only Llama 3.3 70B Turbo and Qwen 2.5 72B routes are removed from the starter catalog. They cannot run on the shared serverless key. Removing those routes also keeps funding fallback from selecting them. The retired Groq Qwen 3.6, unlisted Together Qwen3.8 2.4T and undeployed Fireworks DeepSeek V4 Pro routes are also removed. Saved kimi-k3 chats use the same Kimi K3 model on Fireworks because Together’s endpoint repeatedly returned capacity errors. On 2026-11-10 the Cloud list was checked against the real provider accounts. Three rows were added, each checked with a real request first: claude-sonnet-5.5 and gpt-6.1-sol on OpenRouter, and kimi-k3.1-pro on Together (Fireworks does not serve it for chat). claude-sonnet-4.6 is now hidden. It still routes, and saved claude-sonnet and claude-sonnet-4 ids still use it at the same price. Fireworks rows now get the retail markup. Fireworks’ model list has no pricing, so these rows used to be billed at Fireworks’ own price. Now they are billed at the static catalog price × INFERENCE_MARKUP, and the static price is recorded as the wholesale cost. Rows on other providers are unchanged. Because the wholesale cost is now recorded, Fireworks requests also count toward the Fireworks pool’s monthly budget (inference_pools.monthly_budget_usd); before, they counted as 0. Groq does not accept the AI SDK’s prompt_cache_key. Cloud strips OpenAI-only cache and safety hints for non-OpenAI upstreams, for both streaming and buffered chat (#2119). Tool definitions and streaming usage options still pass through. Real OpenAI upstreams retain those hints.

Hide a provider that has no money

To hide every model on a provider until it is funded, enter a balance of 0 for it (PUT /api/v1/admin/funding/<provider> with {"balanceUsd": 0}). Within 10 minutes its rows leave /v1/models, requests for them get “model unavailable”, and the default moves to a funded model. Saved chats and bots on those models get the same “model unavailable” until the provider is back. Do not remove catalog rows for this. To bring the provider back, enter its real balance the same way. Its models return within 10 minutes. On 2026-11-13 Fireworks, Together, DeepInfra and Groq were set to 0 this way, leaving only the OpenRouter models listed.

Admin routes

Both routes need a Clerk session for a user listed in ALLTERNIT_ADMIN_USER_IDS; everyone else gets 403.

Read funding

Set a balance, reserve or floor

Every field is optional. balanceUsd is the balance the provider’s dashboard shows right now; from then on cloud-api subtracts our metered spend. reserveDays is 0 to 365, floorUsd is 0 or more. The provider is refreshed right away and its row returned. Known providers: openrouter, together, fireworks, deepinfra, groq; any other name gets 404. For OpenRouter, the balance comes from its API, so balanceUsd is only used when no OpenRouter key is set.

Who is not charged to the upstream balance

Two paths change who pays for a model call. An outside app that uses Sign in with Allternit spends the signed-in person’s own credits, under their monthly limit. A request to a linked/claude/* model is billed by Anthropic to the person’s linked Claude organization, and Allternit’s wallet is not debited. Each usage event records this in inference_usage.billed_to: allternit_credits, user_wallet or claude_org. Setup is in Claude organization linked billing.

Environment

Stripe go-live (Eoj, by hand)

  1. Stripe dashboard, Developers, Webhooks, the https://api.allternit.com/api/v1/webhooks/stripe endpoint: add payment_intent.succeeded, payment_intent.payment_failed, payment_intent.requires_action, charge.dispute.created and charge.dispute.closed, keeping the events already there.
  2. Then set AUTO_TOPUP_LIVE=1 on cloud-api. Until it is set, auto top-up charges no card (see Cloud billing).

Provider setup checklist (Eoj, by hand)

Do this once per provider. It moves money, so nothing here is automated. OpenRouter
  1. openrouter.ai, Settings, Credits: add the Allternit business card.
  2. Turn on auto top-up. Suggested: when the balance drops below $50, add $100. Pick numbers that cover at least reserveDays of the 24-hour burn on the Funding page.
  3. Confirm the production key cloud-api uses belongs to this account. If /credits does not answer with that key, create a key for balance reads and set OPENROUTER_CREDITS_KEY.
  4. On the Funding page, set the floor (for example $25) and reserve days.
Together AI
  1. api.together.ai, Settings, Billing: add the business card.
  2. Turn on auto-recharge with a threshold and amount.
  3. Enter today’s balance on the Funding page (Edit, balance), plus floor and reserve days.
Fireworks
  1. fireworks.ai, Account, Billing: add the business card.
  2. Turn on auto-recharge (or the prepaid top-up threshold) with a threshold and amount.
  3. Enter today’s balance, floor and reserve days on the Funding page.
DeepInfra
  1. deepinfra.com, Dashboard, Billing: add the business card.
  2. Turn on auto top-up with a threshold and amount.
  3. Enter today’s balance, floor and reserve days on the Funding page.
Groq
  1. console.groq.com, Settings, Billing: add the business card and choose the paid tier.
  2. If Groq bills after use instead of prepaid, enter a balance equal to the spend limit you set there, and re-enter it each billing cycle.
  3. Enter floor and reserve days on the Funding page.
Every provider, after setup
  • Re-enter the balance on the Funding page whenever a manual provider’s dashboard and the page disagree by more than a few dollars (our metered spend is an estimate).
  • Keep the business card limit above the sum of all auto-recharge amounts that could fire in one billing cycle.
  • Check the provider’s data settings and turn off any training on or retention of API data the dashboard allows. OpenRouter needs no setting: the Cloud API sends no-retention routing on every request (see Data retention). Record for each direct provider whether its terms say API data is not retained.