← Back to Blog

How Teams Should Manage API Keys and AI Budgets

Zivv13 min read
teamsAPI keysbudget

AI API spend rarely gets out of control because a model is expensive. It gets out of control because nobody can answer three questions: who is using it, what are they using it for, and when did usage start growing? A single shared key makes all three unanswerable. Once a team passes three people, key structure and budget layers stop being bureaucracy and become the only way to keep the bill explainable. This is a practical playbook you can implement in an afternoon.

Why One Shared Key Fails

The shared key is always how it starts — someone creates an account, pastes the key in Slack, and everyone gets moving. Then four problems arrive on schedule:

  • No attribution. The bill doubles and you cannot tell whether it was a new feature, a new hire, or a bug.
  • Blast radius. The key leaks once — a public repo, a laptop, a screenshot — and every user and every service is compromised at once.
  • Mixed workloads. Human experimentation and CI automation land in the same bucket, so neither can be budgeted sanely.
  • One-size budgets. You cannot give the intern a small cap and the batch pipeline a large one when they share credentials.

When spend grows, you see only the total, never the cause.

The Key Structure That Works

Issue keys along two axes — who and what:

Key typePurposeBudget posture
Member keyDaily developer usageModerate monthly cap
Project keyEach production serviceSized to the service, monitored
Automation keyCI, scripts, batch jobsStrict daily cap
Temporary keyContractors, trials, spikesSmall cap, short-lived

The automation row is the one teams skip and regret. A human types at human speed; a broken retry loop spends at machine speed. Automation keys need the tightest caps precisely because their failure mode is the fastest.

Step-by-Step Setup

Step 1: Create the team and invite members

With Zivv Teams, the owner funds one shared balance (top-up at 1 CNY = 1 USD) and invites members. Nobody else needs a payment method, and the owner stops collecting money from individuals.

Step 2: Issue one key per member and per workload

Keep environments cleanly separated so a key's usage always means one thing:

# .env.local — a member's personal key
OPENAI_BASE_URL=https://zivv.pro/v1
OPENAI_API_KEY=sk-member-alice

# .env.ci — automation key, strict daily cap
OPENAI_BASE_URL=https://zivv.pro/v1
OPENAI_API_KEY=sk-ci-pipeline

# .env.production — project key for the app itself
OPENAI_BASE_URL=https://zivv.pro/v1
OPENAI_API_KEY=sk-project-webapp

In code, resolve the key by workload rather than hard-coding one client for everything:

import os
from openai import OpenAI

def client_for(workload: str) -> OpenAI:
    key = os.environ["ZIVV_KEY_" + workload.upper()]
    return OpenAI(base_url="https://zivv.pro/v1", api_key=key)

ci_client = client_for("ci")
app_client = client_for("webapp")

Step 3: Add budget layers

Three layers, from the outside in:

  1. Team monthly budget — the number finance signed off on
  2. Member-level budgets — generous for heavy users, present for everyone
  3. Project and automation budgets — sized per workload, strictest on automation

If you can only start with one layer, cap the automation keys first.

Step 4: Review weekly, not constantly

Nobody needs to watch a dashboard all day. A fifteen-minute weekly review of the usage analytics covers it:

  • Member usage ranking — who moved up, and is that expected?
  • Model usage ranking — is expensive-model share creeping upward?
  • Failed requests and retries — retries are silent spend
  • Average cost per task — the efficiency number that matters more than totals
  • Stale keys still active — contractors gone, keys not

These reviews catch the slow, quiet growth that never triggers an alarm. For deciding which models each workload should default to, pair this with the multi-model routing guide.

The Abnormal Spend Runbook

When spend spikes, the instinct is to kill the main key. Resist it — that turns one incident into a team-wide outage. Instead:

  1. Open the usage breakdown and identify the abnormal key
  2. Disable only that key
  3. Trace it to the member, project, or script behind it
  4. Fix the actual cause — usually a retry loop, an unbounded batch, or a model misconfiguration
  5. Re-enable with a reset, tighter budget

Because keys are independent, the incident stays local: one pipeline pauses, everyone else keeps shipping.

What Zivv Teams Provides

The workflow above needs platform support: shared balance funded by the owner, independent keys per member, multi-dimensional budgets, and usage analytics split by member, key, and model. That is exactly the Teams feature set — the playbook maps onto it without glue scripts or spreadsheet reconciliation, and every model behind the Model Hub bills into the same structure.

FAQ

How many keys is too many? Fewer than you fear. One per member plus one per distinct workload is typically 10–20 keys for a small team — trivial to manage, and each one makes the bill more explainable.

Should budgets hard-stop or just alert? Hard-stop automation and temporary keys; a stopped script is an inconvenience. For member keys, generous caps with review work better than caps that block an engineer mid-task.

What do we do with a departing member's key? Disable it the same day, and let the weekly stale-key check catch anything missed. This is the entire reason member keys exist.

Can members see each other's usage? The owner sees the full breakdown by member, key, and model; members simply work against the shared balance without handling billing at all.

Wrap-Up

Team AI budgeting is not about spending less — it is about always knowing who spends what, so the bill is a decision instead of a surprise. Split keys by member, project, and automation, add budget layers, review weekly, and keep an incident runbook. Set up a team and the whole structure is in place before the next billing cycle starts.