Skip to content

Connect Claude Code to Meter

Ten minutes: a team, a provider key, a Meter key per developer and two environment variables. Nothing to install, nothing in your repositories to change.

What you need

  • An Anthropic or Ollama cloud API key. Meter doesn’t support Claude Pro and Max subscriptions: they can’t be routed through a proxy.
  • Claude Code on your developers’ machines.

The team owner

  1. Create an account

    With email and password (the address must be confirmed) or with Google or GitHub.

  2. Create a team

    It needs only a name. You are its owner.

  3. Turn on a provider

    On the Providers page, turn on Anthropic or Ollama cloud and paste the key. It is encrypted in the database and never shown in the browser again.

  4. Invite your developers

    On the Team page, by email. Roles are owner, admin and member; only owners and admins change provider keys and policies.

Each developer

  1. Issue your Meter key

    On the Connect page in the dashboard. The key is shown once. It is not the team’s key: it can be revoked without touching anyone else.

  2. Point Claude Code at Meter

    Paste this into your shell and add the lines to your shell profile. Claude Code asks you to approve the key once.

    Anthropic

    export ANTHROPIC_BASE_URL=https://gw.metergateway.com/anthropic
    export ANTHROPIC_API_KEY=mtr_your_key_here
     

    Ollama cloud

    export ANTHROPIC_BASE_URL=https://gw.metergateway.com/ollama
    export ANTHROPIC_API_KEY=mtr_your_key_here
    export ANTHROPIC_MODEL=glm-5.3-flash:cloud
    export ANTHROPIC_DEFAULT_HAIKU_MODEL=glm-5.3-flash:cloud
     

    Ollama serves its own models, so Claude Code has to be told which to ask for. Any Ollama cloud model works.

  3. Check it works

    A call through Meter answers exactly as Anthropic would. Within seconds it shows up in the dashboard.

    curl -s https://gw.metergateway.com/anthropic/v1/messages \
      -H "x-api-key: $ANTHROPIC_API_KEY" \
      -H "anthropic-version: 2023-06-01" \
      -H "content-type: application/json" \
      -d '{"model":"claude-sonnet-4-5","max_tokens":16,"messages":[{"role":"user","content":"say hello"}]}'
     

Naming the repository

Meter takes the repository from the working directory Claude Code states in every request. To name it explicitly, send an X-Meter-Repo header (Claude Code v2.1.227 or later):

export ANTHROPIC_CUSTOM_HEADERS="X-Meter-Repo: payments-api"
 

So nobody goes around Meter

A developer can unset the variable and call Anthropic directly. To prevent that, distribute Claude Code managed settings with Meter’s address in the env block and allowedProviders: ["customEndpoint"] — Claude Code then refuses any other address. Requires Claude Code v2.1.285 or later.

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://gw.metergateway.com/anthropic"
  },
  "allowedProviders": [
    "customEndpoint"
  ]
}
 
Managed settings in the Claude Code docs

What to expect

Nothing gets slower.
Responses stream through untouched. Usage is recorded after your bytes have gone out, never before.
Your key is not your team’s key.
Meter swaps in the team credential on the way upstream, so yours can be revoked on its own without touching anyone else.
A refusal says why.
If your team’s policy stops a call you get a 403 naming the rule — a denied repository, a budget, a path that needs an approval. It is not a Meter outage.
A 429 means slow down.
Meter limits requests per key and per team to stop one runaway loop drowning everyone else. The response carries Retry-After.

What Meter flags

Security flags are raised on every call, on every plan. A flag only marks the event; blocking an action or requiring approval is done with policies on the Control plan.

secret-file-access
The agent read or wrote a file that usually holds secrets: .env, keys, .pem, credentials, tfstate.
protected-branch-push
The agent pushed to a protected branch: main, master, release/*, production.
sensitive-path-access
The agent touched infrastructure or deployment: secrets/, infra/, terraform/, CI workflows, charts, k8s.
credential-exfiltration-shape
A shell command sent local files or environment variables to the network.
destructive-git
The agent rewrote history or discarded work: push --force, reset --hard, clean -fd, branch -D.

Next

  • Budgets that warn — the Policies page, on every plan. Blocking on a budget, repository and path rules, approval of risky actions — the same page, on the Control plan.
  • A weekly report and alerts in Slack or by email — the Reports page, on the Control plan.
  • What Meter keeps and how it protects keys — the security page.
Start free