Skip to content

Architecture and migrationGuide

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

If your application already calls LaoZhang API, the missing pieces are usually a spend ceiling, a second path when the first one fails, and a record of what each request did. This guide connects your LaoZhang key to INFRO and adds all three without changing who bills you.

By INFRO Editorial

Published

8 min read

One application request entering a central AI gateway and branching to many model routes

In short

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.1

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:

app.py
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:

StrategyBehaviourUse it for
priorityWalks enabled targets in order, uses the first that answersA primary with a fallback
weightedPicks the first target at random in proportion to weight, then falls through the restA canary or a gradual migration
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:

Shell
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.

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.

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.

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:

Shell
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 readers ask

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

From the team that builds it

Where this shows up in INFRO

INFRO is a control plane in front of the provider accounts you already hold. The capabilities below are the parts of it this article touches, each with the documentation that defines its behaviour.

  • Provider connections

    Available with a plan

    Connect provider accounts you already hold. Each credential is encrypted when saved, scoped to your organization and never shown again; applications use INFRO gateway keys instead.

    Read the documentation for Provider connections
  • Automatic failover

    Available with a plan

    A route that times out or 5xxs before the response starts is retried elsewhere without your client seeing it.

    Read the documentation for Automatic failover
  • Budgets and spend ceilings

    Available with a plan

    A hard cap per organization, project, member, and key, with alerts at your own thresholds.

    Read the documentation for Budgets and spend ceilings
  • Request traces and payload logs

    Available with a plan

    Per-request timing detail, with prompt and completion logging off by default and a retention window you choose.

    Read the documentation for Request traces and payload logs
  • Health-aware routing

    Available with a plan

    Named routes use priority or weighted targets over your own connections, with health checks, retries and failover.

    Read the documentation for Health-aware routing
  • Usage and cost per request

    Available with a plan

    Every request records its model, latency, token or unit counts, and estimated provider cost, queryable by project and key.

    Read the documentation for Usage and cost per request
  • Claude Code and Codex through INFRO

    Available with a plan

    Point Claude Code, the Claude Agent SDK, Codex or the OpenAI Agents SDK at INFRO by changing the base URL and the key. Anthropic's Messages API and OpenAI's Responses API, with routing, budgets refused before the call, guardrails and the request log applied as on every other request.

INFRO accounts are self-serve. Provider usage is billed to you by your providers; INFRO charges a software subscription and takes 0% of model spend. See plans.

Sources

Numbered in order of first citation. Each was opened and checked against the claim on the date shown.

  1. 1.Use your LaoZhang API account through INFRO (opens in a new tab) — INFRO. Accessed Nov 26, 2026.
  2. 2.Request traces (opens in a new tab) — INFRO Docs. Accessed Nov 26, 2026.
  3. 3.Connect a provider (opens in a new tab) — INFRO Docs. Accessed Nov 26, 2026.
  4. 4.Failover & fallbacks (opens in a new tab) — INFRO Docs. Accessed Nov 26, 2026.
  5. 5.Routes (opens in a new tab) — INFRO Docs. Accessed Nov 26, 2026.
  6. 6.Spend controls (opens in a new tab) — INFRO Docs. Accessed Nov 26, 2026.
  7. 7.Claude Code & Codex (opens in a new tab) — INFRO Docs. Accessed Nov 26, 2026.

About this article

Read INFRO's LaoZhang connect page and its docs pages on connecting providers, failover, routes, spend controls, request traces and coding agents on 2026-11-26. Nothing about LaoZhang API's own pricing, uptime or terms is stated, because INFRO's pages do not confirm it; some docs pages were returned truncated, so only the parts read are cited.

Last checked against its sources on . The next review is due by . No separate named reviewer is recorded for this article.

How articles are written, sourced and corrected is set out in the editorial standards.