Last verified: August 15, 2026
Short path: AI API pricing · GPT-5.4 mini · Multi-model API · LLM API gateway
LumeAPI is an independent third-party gateway — not OpenAI, Anthropic, or Google. This page owns agent-loop spend: hops, tool-output replay, and retries. It does not own Flash vs Pro (Gemini cost guide), Sonnet vs Opus (Claude cost guide), or the three-provider rate matrix (2026 pricing comparison).
If the invoice jumped after you added tools, the first leak is usually the same 8,000-token tool dump being sent back on every later hop — not the headline $/1M on the flagship model.
Quick Answer
| Symptom | What to measure | First fix on this page |
|---|---|---|
| Bill grows with “just one more tool” | Input tokens on hops after the tool returns | Compact the tool result once; stop replaying the raw dump |
| Same ticket billed 3–8 times | Calls per accepted task, retry reason | Cap hops; retry 429/5xx only, not schema failures |
| Every hop uses Terra / Sonnet / Opus | Spend by step_id × catalog id | mini/Flash for classify and compress; escalate one hop |
| Gateway swap did nothing | Tokens per attempt before vs after | Rate cuts do not fix an unbounded loop |
- Log
task_id,step_id, model id, input/output tokens, retry count. - Find the two steps with the most input tokens — that is usually replayed history.
- Cap hops and compact tool output before changing providers.
In short
An agent bill is the sum of every hop, including failed ones. Lower catalog rates help only after the loop stops replaying raw tool payloads. LumeAPI meters each hop at the catalog id you send; it does not cap your agent for you.
What most guides get wrong
They publish a cheaper $/1M and leave the loop unbounded. A 50% cheaper hop that runs twice because the tool dump was replayed still costs more than one compact hop on a mid-tier model.
This page therefore does not copy the commercial ten-hop marketing table. The unique evidence here is replay arithmetic on one tool payload.
The leak: tool output replayed on every later hop
Suppose hop 3 calls a ticketing API and the tool returns 8,000 input-side tokens. Hops 4–10 each prepend that dump to the prompt (seven later hops). At LumeAPI gpt-5.6-terra input $0.75 / 1M (catalog sync 2026-07-22):
replay_cost = 7 × 8,000 / 1,000,000 × $0.75 = $0.042Compress the tool result once to 400 tokens and reuse the summary:
compact_cost = 7 × 400 / 1,000,000 × $0.75 = $0.0021The difference is $0.040 per attempt from one tool, before output tokens, retries, or a second tool. That is larger than many teams' entire “chat” message cost.
Store the raw payload outside the model context. Pass a verified excerpt or schema-valid summary. Keep a pointer so the final hop can fetch evidence if the eval requires it.
Hard stop: maximum hops per task
MAX_HOPS = 8
MAX_RETRIES_TRANSIENT = 2 # 429 / 5xx / timeout only
def allow_hop(hop_index: int, http_status: int | None, schema_ok: bool) -> bool:
if hop_index >= MAX_HOPS:
return False
if schema_ok is False:
return False # repair prompt or escalate model — do not blind-retry
if http_status in {429, 500, 502, 503} and hop_index < MAX_RETRIES_TRANSIENT:
return True
return TrueLumeAPI returns standard HTTP errors; it does not auto-failover to another provider. Retries belong in this function. Gateway boundaries: /llm-api-gateway.
Prove one hop before you wire the graph
curl https://api.lumeapi.site/v1/chat/completions \
-H "Authorization: Bearer $LUMEAPI_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-5.4-mini","messages":[{"role":"user","content":"Classify intent: duplicate invoice"}],"max_tokens":32}'If this 401/402/404s, the agent graph will fail the same way. Catalog id gpt-5.4-mini is $0.225 / $1.35 per 1M in/out on LumeAPI. Use it for classify and tool-pick; do not default the whole graph to gpt-5.6-terra ($0.75 / $4.50) or claude-sonnet-4-6 ($1.50 / $7.50). Live two-column table: /ai-api-pricing.
A realistic production scenario
Illustrative support agent: 18,000 input + 2,000 output tokens across the whole loop, no tools billed separately.
All hops on LumeAPI gpt-5.6-terra:
18,000 / 1e6 × $0.75 + 2,000 / 1e6 × $4.50 = $0.0135 + $0.0090 = $0.0225 / attemptSame tokens, but 12,000 of the input is replayed tool text you could have compacted away (save ~$0.009 on Terra input). The remaining 6,000 in / 2,000 out on Terra is $0.0135. That is the order of operations: compact first, then pick catalog ids. It is arithmetic on catalog rates, not a customer saving.
If you still need a stronger synthesis hop, change one model field to claude-sonnet-4-6 after the compact step — do not upgrade hops 1–3.
When not to use a gateway for the agent
Stay on the official provider when the loop depends on Anthropic prompt cache, Google Grounding, or OpenAI Batch. Those products are not the same as Chat Completions at catalog rates. Compare them on their own invoices; do not apply LumeAPI's 50%/70% text-rate badges to them.
Expert take
Instrument step_id before you argue about models. The two most expensive steps are usually “replayed tool dump” and “blind retry.” Cap those, then route classify/compress to mini or Flash. A cheaper gateway on an unbounded graph only makes the waste cheaper per hop.
FAQ
Why are multi-agent workflow API costs so high?
Each agent can replay context and retry on its own. Measure spend per accepted workflow outcome. Cap hops per agent, share a compact state object, and keep Opus/Sol off routine sub-agents.
Is chatbot API cost the same as agent API cost?
A chatbot without tools is usually one or two hops. An agent adds plan, tools, repair, and synthesis. Same LumeAPI key; the bill difference is loop shape. SDK swap: /openai-compatible-api.
How do I route GPT, Claude, and Gemini in one agent loop?
One client, base_url=https://api.lumeapi.site/v1, different model per hop: gpt-5.4-mini classify, gemini-3.5-flash compress, claude-sonnet-4-6 synthesis. LumeAPI does not pick the id. Operations hub: /multi-model-api.
Should every agent step use the cheapest model?
No. Cheap hops that fail schema checks create extra paid hops. Use the lowest catalog id that passes that step's eval.
How many retries should an agent allow?
Cap transient HTTP retries (429/5xx) separately from schema failures. Schema failures need a different prompt or model, not the same JSON again.
Sources and methodology
- OpenAI API pricing — Terra live short-context $2 / $12 per 1M as of this verification; LumeAPI catalog
official_priceforgpt-5.6-terrais still$2.50 / $15.00. - Anthropic platform pricing
- Google Gemini API pricing
- LumeAPI pricing catalog — gateway rates; catalog last synced 2026-07-22.
Examples are token arithmetic on published rates. No production customer saving is claimed.