← Back to Blog

How to Cut AI API Costs by 80%+: A Practical Guide

Zivv17 min read
costbest-practicescase-study

Once a company adopts AI seriously, the bill is usually scarier than expected: a small team easily spends ¥10k+/month on official Claude alone, and ¥20k+ when several models are mixed. The uncomfortable truth is that most of that spend is removable without giving anything up. This guide works through a five-layer methodology — platform, model, prompt, workflow, and team management — and ends with a worked example that takes a real-shaped bill from ¥20,000 to the ¥3,000 range.

Where the Money Actually Goes

A typical breakdown for a small engineering team:

  • Official Claude: ¥10k+/month for daily coding plus application calls
  • GPT-5.5: ¥5k+/month across dev, test, and production inference
  • Multi-model mix: ¥20k+/month total, with bills scattered across platforms and nobody accountable for any of them

Each layer below attacks a different slice of that. The layers compound: applying all five is how teams reach 90%+ total savings.

Layer 1: Pick the Right Platform (~80% savings)

This is the single biggest cut and the smallest code change. For the same model, official pricing and gateway pricing can differ by an order of magnitude or more:

OptionUnit price (Sonnet-class)Monthly at 10M tokensNotes
Claude official$3~15/M¥657USD billing plus currency conversion loss
Zivv gateway¥1.2/M¥12Direct CNY top-up at ¥1 = $1
Other relays¥3~5/M¥30~50Inconsistent pricing and stability

Because Zivv is OpenAI-compatible, switching is a one-line change — point your existing SDK at the gateway:

from openai import OpenAI

client = OpenAI(
    base_url="https://zivv.pro/v1",
    api_key="sk-your-zivv-key",
)

resp = client.chat.completions.create(
    model="claude-sonnet-5",
    messages=[{"role": "user", "content": "Summarize this diff"}],
)

Anthropic-protocol tools like Claude Code switch with ANTHROPIC_BASE_URL=https://zivv.pro, and Gemini tools use https://zivv.pro/v1beta. One key covers 100+ models, so consolidating also collapses several bills into one.

Layer 2: Pick the Right Model (60~80% savings)

Not every task deserves the top model. Running classification or formatting on a flagship reasoning model is pure waste. A practical tiering:

ModelRoleUse it for
gemini-3.5-flashFast and cheapClassification, extraction, formatting, simple Q&A, high-frequency loops
claude-sonnet-5General workhorseDaily coding, content generation, most business logic
claude-opus-4-8Top-tier reasoningArchitecture design, hard debugging, deep multi-step reasoning
gpt-5.5OpenAI workhorseOpenAI-ecosystem workflows and its specific strengths

Because every tier sits behind the same endpoint and key, routing is a dictionary, not an integration project:

MODEL_BY_TASK = {
    "classify":    "gemini-3.5-flash",
    "extract":     "gemini-3.5-flash",
    "code":        "claude-sonnet-5",
    "architecture": "claude-opus-4-8",
}

def pick_model(task_type: str) -> str:
    return MODEL_BY_TASK.get(task_type, "claude-sonnet-5")

The principle: default to the workhorse, downgrade simple work to the cheap tier, and escalate to claude-opus-4-8 only when the task genuinely needs it. Teams that route by scenario typically cut another 60~80% off the post-Layer-1 number. Compare current per-model pricing in Model Hub.

Layer 3: Optimize Prompts (30~50% savings)

Tokens are money on both sides of the request. The usual offenders: dumping entire files when a function would do, repeating background in every message, and letting the model pad answers with restatements.

  • Cut redundant instructions and repeated context; send only what the task needs
  • Use structured input (JSON, tables) instead of verbose prose descriptions
  • Request concise output explicitly — cap length, or require a fixed format
  • Replace long rule blocks with two or three few-shot examples; they are usually shorter and more accurate

Layer 4: Engineer the Workflow (20~40% savings)

Once prompts are lean, engineering mechanisms take over:

  • Prompt caching: route repeated system prompts and long shared context through cache; cache hits are billed far below normal input
  • Batching: submit non-real-time jobs in batches at lower effective cost
  • Streaming with early termination: stop generation once you have what you need instead of paying for the rest
  • Retry with downgrade: on failure, retry on a cheaper tier where acceptable rather than re-running the full flagship call

Layer 5: Team Budget Management

The first four layers control the cost of each call; the fifth controls runaway spend — and it is the layer most companies skip entirely. Zivv Teams provides:

  • Per-member keys and quotas: each member and project gets an independent key with a budget cap that blocks overruns automatically
  • Usage analytics: consumption broken down by member, key, and model, so the question "who is burning budget" has an instant answer
  • Shared balance: one team account and one top-up flow instead of a personal credit card per engineer
  • Multi-dimensional budgets: admins decide which models and quotas each key can reach, so not everyone can call the most expensive tier

Most AI budgets blow up not because unit prices are high, but because nobody can see who is spending what until the invoice lands.

Worked Example: ¥20,000 to ¥3,000

Starting point: a 100-person startup running Claude's flagship model as its default, 10M tokens/month, ¥20,000/month on the official API.

StepActionMonthly costvs previous
StartOfficial flagship only¥20,000
Step 1Switch to Zivv¥240down 98%
Step 2Route by task tier¥150down 38%
Step 3Prompt optimization¥120down 20%
Step 4Batch + cache¥30down 75%
Team budgets to prevent reboundkeeps it there
Note: the absolute numbers from Step 2 onward grow with usage; the table shows the optimization path at constant volume. Real teams, after natural usage growth, tend to settle around ¥3,000/month — still roughly 15% of the starting bill.

FAQ

Q: Does going through a gateway change model quality? A: No. The gateway forwards requests to the same underlying models; responses, context windows, and capabilities are unchanged. Only the price and the endpoint differ.

Q: How disruptive is the migration? A: For OpenAI-compatible code, it is one base_url change. For Claude Code and Codex it is two environment variables. Most teams migrate one project in an afternoon and expand from there.

Q: Which layer should I start with? A: Layer 1 — it is the largest cut and requires no workflow changes. Then pull your usage data and see whether model choice (Layer 2) or context bloat (Layer 3) dominates. The token cost guide shows how to read those numbers.

Q: How do I stop costs from creeping back up? A: Put every key behind a budget cap and review usage weekly. Rebound almost always comes from an unmonitored key or a script quietly defaulting to the most expensive model.

Action Plan

  1. Today: create a Zivv account, switch one project, and observe the Layer 1 drop on real traffic
  2. This week: analyze token consumption and list every task currently running on a flagship model
  3. Next week: implement tiered routing and rewrite your five costliest prompts
  4. In two weeks: adopt batching and prompt caching, then enable team budgets with per-member keys so the savings hold