# LaoZhang API in production: budgets, failover and logs on your key

URL: https://infro.io/blog/laozhang-api-in-production-budgets-failover-and-logs-on-your-key
Author: INFRO Editorial (https://infro.io/blog/editorial)
Publisher: INFRO
Published: 2026-11-26
Last modified: 2026-11-26
Last reviewed: 2026-11-26 (next review due 2026-12-26)
Topic: Architecture and migration
Format: Guide

> LaoZhang API is a provider kind on INFRO: you paste your own LaoZhang key, LaoZhang keeps billing you directly, and INFRO adds routes, failover to a second connection, budgets and per-request logs around the same traffic.[^infro-connect-laozhang]

Key takeaways:
- LaoZhang API is one of the provider kinds you can connect; the key stays yours and LaoZhang bills you directly, with 0% markup from INFRO.
- Connecting means pasting a key you created at LaoZhang into INFRO, then swapping your application's base URL and key for an INFRO gateway key.
- Failover needs a second connection that serves the same model, such as the vendor's own API, plus a route that puts the two in the order you want.
- Budgets are checked before the provider call and a key's limit always blocks; the worst case counted includes the most expensive provider a request could fall back to.
- Each request's record names the model, connection, outcome, timings, usage, fallback attempts and estimated provider cost; the estimate is not an invoice.

## What "LaoZhang on INFRO" means

INFRO is a control plane that sits between your application and providers you already pay. LaoZhang API is one of the account types you can connect. INFRO's connect page puts the arrangement plainly: you keep your LaoZhang API contract and your key, and INFRO adds routing, budgets, failover and an audit trail around each request.[1]

Three facts about money and custody matter before anything else:

- **The key stays yours.** You create it in your LaoZhang account, paste it into INFRO, and it is sealed when saved and never shown again.[1] Your applications carry an INFRO gateway key instead, so the provider key is not in your app's environment.
- **LaoZhang bills you directly.** The bill for model usage stays with LaoZhang, under your own agreement and at your own rates. INFRO bills a separate software subscription with 0% markup on model spend.[1]
- **INFRO's cost figures are estimates.** The request log is operational evidence, not an invoice.[2] Reconcile against what LaoZhang bills you.

This guide is neutral about LaoZhang. It makes no price comparison and no claim about the service beyond what INFRO's own pages state. The work here is the part you control: how the key is held, what happens when a call fails, how much a key can spend, and where you look afterwards.

## Connect the key

INFRO's connect page lists three steps.[1]

1. **Create an INFRO workspace.** It starts as a 14-day trial.
2. **Connect your LaoZhang API key.** Setup opens on LaoZhang API. You paste a key you created in your LaoZhang account.
3. **Point your app at INFRO.** Swap in your INFRO gateway key and base URL, and name the model the way INFRO does, for example `openai/gpt-6-astra`.

The provider docs add the mechanics. You open Providers in the console and choose the provider kind, which decides the wire protocol, which models it can serve and what configuration it needs beyond a key. You paste the key, test it, then name and save it. The test calls the provider with the key and the connection's real base URL and auth, and shows what came back before anything is saved, so a typo is caught there and not by your first production request.[3]

Until something is connected, INFRO returns 503 with `code: "no_provider_connected"`, naming the provider to connect. The docs call that the expected first response, not a fault.[3]

The application change is the one the connect page shows, using the OpenAI SDK:

```python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["INFRO_API_KEY"],   # an INFRO gateway key, not the LaoZhang key
    base_url="https://api.infro.io/v1",
)

resp = client.chat.completions.create(
    model="openai/gpt-6-astra",            # the id as INFRO names it
    messages=[{"role": "user", "content": "Hello"}],
)
```

Model ids come from INFRO's catalog, not from whatever string you sent LaoZhang before. Each catalog model page gives the id to send, the vendor's list rate and the other providers that serve it.[1] That last item is what makes the next section possible.

## Add the vendor's own API as a second connection

A single connection means a single point of failure: the docs say that with one connection there is nothing to fail over to.[4] The fix is a second connection, on a different account, that serves the same model.

For a model such as `openai/gpt-6-astra`, that second connection can be your own OpenAI account, if you hold one. You connect it exactly as above. INFRO's connection failover is same-model: when you name a model directly, it tries every enabled, healthy connection in your organization that serves that model's vendor and matches the key's environment, in the order you connected the providers.[4]

If you want the order to be a decision and not an accident of connection history, use a route. A route is a stable name your application sends as `model`, resolved to an ordered list of your own connections and the model each should serve.[5] The strategies:

| Strategy | Behaviour | Use it for |
| --- | --- | --- |
| priority | Walks enabled targets in order, uses the first that answers | A primary with a fallback |
| weighted | Picks the first target at random in proportion to weight, then falls through the rest | A canary or a gradual migration |

Table: route strategies, from INFRO's routes documentation.[5]

A target with weight 0 on a weighted route is a standby that never takes a first attempt, and a weighted route still fails over if its pick fails.[5] Your application then calls the route name:

```bash
curl https://api.infro.io/v1/chat/completions \
  -H "Authorization: Bearer $INFRO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "support-agent",
    "messages": [{"role": "user", "content": "Where is my order?"}]
  }'
```

`support-agent` is the docs' own example name.[5] Put LaoZhang first and the vendor's API second, or the reverse; INFRO does not decide that for you.

### What triggers a move, and what does not

Every upstream failure before the first token moves to the next connection: a provider 5xx, a timeout, a 429, a rejected credential (401 or 403), a 404, and even a 400 or 422, because providers differ on which optional parameters they accept. Your client sees only a slightly higher time to first token.[4] Everything is strictly before the first token; once a response has started, the docs' guarantee does not extend to switching providers mid-stream.[4]

INFRO's own refusals do not fail over. An invalid body, a bad INFRO key (401), a budget or subscription refusal (402), an allowlist refusal (403) and an unknown model (404) are decided before any provider is called and return immediately.[4] That matters for budgets, covered next: a budget stop is not retried onto the second connection.

> **Warning: Check what the second connection costs you**
> Failing over moves spend to a different account with its own rates, so a failover period can change your bill. INFRO's estimate uses the list rate unless you enter the rates your contracts carry.[1] Enter your negotiated rates per provider so the estimate for each connection reflects what you are actually billed, then compare after an incident against both providers' invoices. Our other piece on [failover and the bill](https://infro.io/blog/what-does-failover-do-to-your-bill-price-gaps-and-cold-caches) covers price gaps and cold caches.

If the whole model is down on every connection, INFRO also supports ordered cross-model fallbacks: a `fallbacks` array of up to five catalog model ids, tried once every connection for the primary has failed. They apply only when `model` names a model, not a route.[4] Cross-model fallbacks change the answer's source, so test them before relying on them; see [is your fallback model good enough](https://infro.io/blog/is-your-fallback-model-good-enough-test-fallback-equivalence).

## Budgets and per-key limits on that traffic

INFRO budgets control estimated spend on your own provider accounts. They are not a balance you load, and your providers still bill you directly.[6] The scopes:

- **Organization:** a monthly target that only alerts, and a hard cap that alerts or blocks. Only the owner sets the hard cap.
- **Project:** a separate budget for an application or environment.
- **Member:** a budget tied to a member's activity.
- **Key:** a limit that resets daily, weekly or monthly, or a lifetime ceiling. Key limits always block.[6]

Every applicable blocking limit must allow the request.[6] For LaoZhang traffic, a practical layout:

1. Give each application or environment its own gateway key, so a runaway job cannot spend another service's headroom.
2. Put a daily limit on each key, sized to a bad day rather than a normal one.
3. Set a project budget in alert mode first, with thresholds at fractions you choose, and switch it to block once you trust the numbers.
4. Leave the organization hard cap to the owner as the backstop.

Two mechanics are worth knowing. First, a blocking budget admits a request only if its worst-case estimated cost fits the room left, counting recorded spend and reservations for requests in flight. Close to a limit, a request can be refused briefly for room that is reserved but not yet spent.[6] Second, the worst case assumes the most expensive model and provider the request could fall back to.[6] So adding a second connection or a `fallbacks` list can raise the reservation a request needs, even if it never fails over. That is a reason to size limits with headroom.

A refused request returns 402 before the provider sees it.[7] Handle that code in your application as a budget stop, not a transient error. For more on layering these controls, see [LLM spend controls](https://infro.io/blog/llm-spend-controls-budgets).

## Where each request's provider, cost and attempts show

The request log records the model, the selected provider connection, the outcome, timings, usage and estimated provider cost.[2] The response itself also names the model, provider and connection that served the request, plus the estimated cost.[4] When you call a route, the trace additionally names the route and the connection that served it.[5] The request traces documentation describes the log as covering fallback attempts too.[2]

To read them from code:

```bash
curl "https://api.infro.io/v1/requests?limit=25&status=error" \
  -H "Authorization: Bearer $INFRO_API_KEY"
```

`limit` runs from 1 to 100, and `sort` can be `newest`, `slowest` or `costliest`. Unpriced requests come last under `costliest`, never shown as $0.[2] Use `GET /v1/requests/{id}` for one request's detail.

Access is per key. A gateway key that can call models cannot automatically read every application's history. Its history access is `scoped` by default (its own project), `organization` (granted only by an owner or admin) or `none`. Prompt and response bodies need separate payload access, and content is never returned after its retention deadline.[2]

A short checklist to confirm the setup works before real load:

- [ ] A request through INFRO appears in the log naming your LaoZhang connection.
- [ ] Turning that connection off (or testing with a bad key on a copy) sends the same request to the second connection, and the log shows both attempts.
- [ ] A key with a deliberately tiny limit is refused with 402, and no provider call appears for the refused request.
- [ ] The estimated cost on a known request matches your own arithmetic from the rates you entered.
- [ ] The history key your dashboards use has the narrowest access that works.

## What INFRO does not change

INFRO is an independent service and says that using it does not change your agreement with LaoZhang API.[1] It does not sell inference or hold the provider account for you; the account, the contract and the invoice stay with you and LaoZhang. If LaoZhang itself has an outage or changes terms, INFRO's role is to route around it using the second connection you configured. Whether that is enough depends on how closely the two providers serve the same model, which you should test rather than assume.

## Questions

### Can I use Claude Code with a LaoZhang API key?

INFRO accepts Claude Code's Anthropic Messages requests at POST /v1/messages and OpenAI Responses requests at POST /v1/responses; you change the base URL and use an INFRO gateway key.[7] Whether your LaoZhang connection can serve the model Claude Code asks for depends on the models listed on INFRO's LaoZhang page, so check that list first.[1] On a model INFRO must translate to Chat Completions, a request that needs Claude Code's tool search is refused with 400 unsupported_on_targets before any provider call.[7]

### What is LaoZhang API, as far as INFRO is concerned?

On INFRO it is a provider kind you connect with your own LaoZhang API key. INFRO's page says 46 models in its catalog are served by LaoZhang API, across text, image, video and audio, each with a model id, the vendor's list rate and the other providers that serve it.[1] This guide says nothing further about LaoZhang itself.

### Does connecting change my agreement with LaoZhang?

INFRO states that it is an independent service and that using it does not change your agreement with LaoZhang API.[1] You keep paying LaoZhang directly under your own agreement; INFRO's subscription is separate and carries 0% markup on model spend.[1]

## Sources

1. Use your LaoZhang API account through INFRO — INFRO. https://infro.io/connect/laozhang (accessed 2026-11-26)
2. Request traces — INFRO Docs. https://infro.io/docs/observability/traces (accessed 2026-11-26)
3. Connect a provider — INFRO Docs. https://infro.io/docs/providers (accessed 2026-11-26)
4. Failover & fallbacks — INFRO Docs. https://infro.io/docs/features/fallbacks (accessed 2026-11-26)
5. Routes — INFRO Docs. https://infro.io/docs/routes (accessed 2026-11-26)
6. Spend controls — INFRO Docs. https://infro.io/docs/org/spend-controls (accessed 2026-11-26)
7. Claude Code & Codex — INFRO Docs. https://infro.io/docs/coding-agents (accessed 2026-11-26)
