How to Evaluate a Claude Code Relay or API Gateway: Protocol, Real Cost, and Data Boundaries
Before pointing Claude Code at a third-party relay or LLM gateway, check whether you even need one, then verify native /v1/messages support, prompt-cache and tool streaming, all four token pricing buckets, data-retention boundaries, and isolated subshell rollback.
UniRoute ·
Before pointing Claude Code at a third-party relay or LLM gateway, the most helpful first step is not comparing headline discount claims or editing your global configuration file—it is answering four practical questions in order:
- Do you actually need a third-party gateway? If you already have an official
claude.aisubscription (Pro, Max, Team, or Enterprise) that covers your interactive coding volume, simply run/login. If you only need single-vendor pay-as-you-go billing or CI automation, use the official Anthropic Claude Console API directly without adding an extra hop. - Does the gateway support the full Claude Code workflow? A basic chat wrapper only needs to exchange short text completions. Claude Code relies on the native Anthropic Messages endpoint, prompt caching, multi-step tool execution, and long-thinking SSE keep-alives—and the terminal CLI, VS Code extension, and Claude Desktop app each read different configuration surfaces.
- What will a multi-turn coding session actually cost? Real coding bills are determined by all four token buckets (uncached input, output, cache write, and cache read), plus top-up processing fees, credit expiry or refund rules, and how the provider defines its channel routing tiers.
- Where do your prompts and code snippets travel? Routing requests through a non-Anthropic
ANTHROPIC_BASE_URLsends your prompts, file context, and tool results through that gateway and its upstream provider. Because projects differ in sensitivity, check the gateway's and upstream provider's data-handling and retention terms against what your specific repository requires before sending private code.
Conflict-of-Interest Disclosure & Verification Scope (Checked 2026-10-23)
Published by UniRoute. UniRoute operates an independent third-party API gateway and is not affiliated with, endorsed by, or sponsored by Anthropic. If your existing official Claude subscription or direct Anthropic Console API setup already fits your workflow, you do not need UniRoute. All Anthropic protocol, authentication-precedence, and data-handling references below were verified against official documentation on 2026-10-23. This guide does not rank "best relays," make fixed discount or uptime guarantees, or rely on any new paid model calls during authoring.
6 Quick Checks Before Switching Claude Code to a Gateway
Runs locally in your browser with zero network requests. Mark each item as you verify it.
Confirm you need a gateway and pair Base URL with its credential
PendingHave you confirmed an official subscription or direct API is not enough, and paired ANTHROPIC_BASE_URL with the exact credential header your gateway reads?
Next action: Check /status first; set ANTHROPIC_AUTH_TOKEN (Authorization: Bearer) or ANTHROPIC_API_KEY (x-api-key) per gateway docs instead of setting ANTHROPIC_BASE_URL alone.
Check native /v1/messages, prompt caching, and tool streaming
PendingDoes the gateway support native POST /v1/messages, pass anthropic-beta and cache_control blocks, and stream tool calls without premature disconnects?
Next action: Verify native Anthropic Messages API support in the provider docs rather than relying on an OpenAI /v1/chat/completions translation endpoint.
Match config method to your client surface (CLI vs VS Code vs Desktop)
PendingAre you configuring the exact client surface you use, and do you rely on official-only features like Remote Control or Voice Dictation?
Next action: Configure CLI via shell or ~/.claude/settings.json, VS Code via claudeCode.environmentVariables in VS Code settings, and Desktop via Developer Mode → Configure Third-Party Inference.
Compare all 4 token buckets, channel rules, and refund terms
PendingHave you checked uncached input, output, 5m/1h cache write, and cache read rates, plus deposit fees, channel routing rules, and refund/expiry terms?
Next action: Review the full pricing table and terms of service, and check how the gateway defines channel tiers and whether keys can be restricted to specific channels.
Check request data handling and local/background traffic settings
PendingDoes the gateway and upstream data-retention policy fit your codebase requirements, and have you configured non-essential background traffic if needed?
Next action: Test only with non-sensitive sample files until you review the gateway and upstream retention terms for your project.
Test in an isolated child subshell and keep a non-overwriting backup
PendingAre you running your first test in a temporary child subshell so your parent shell and ~/.claude/settings.json remain untouched until you decide to persist changes?
Next action: Use the Section 6 bash -c subshell launcher (and a timestamped backup if you later edit ~/.claude/settings.json) so exiting the session restores your prior environment.
1. Separate the Connection Paths First: Official Subscription, Direct Console API, and Gateways
Before setting any environment variables, verify which account authenticates and settles your requests. Per Anthropic's official Authentication documentation, LLM gateway overview, and gateway connection guide (all checked 2026-10-23), these paths use distinct credentials and billing models:
| Connection Path | Primary Credential | Billing Account & Settlement | Best Fit | Common Pitfall |
|---|---|---|---|---|
| 1. Official Claude Subscription | /login (claude.ai OAuth) or CLAUDE_CODE_OAUTH_TOKEN from claude setup-token | Claude Pro / Max / Team / Enterprise subscription usage limits | Daily interactive coding in terminal, Desktop, IDE, and web | Leftover higher-precedence API env vars in your shell override subscription login and switch you to metered billing |
| 2. Official Claude Console API | ANTHROPIC_API_KEY (x-api-key header) or Console OAuth login | Claude Console organization prepaid balance or eligible linked monthly API credits | First-party pay-as-you-go, headless scripts (claude -p), CI/CD pipelines | Official sk-ant-... keys are strictly for api.anthropic.com; never send them to a third-party ANTHROPIC_BASE_URL |
| 3. Commercial Hosted Gateways / Relays (e.g., OpenRouter, UniRoute) & Self-Hosted Enterprise Proxies (e.g., LiteLLM) | ANTHROPIC_BASE_URL + gateway credential (ANTHROPIC_AUTH_TOKEN, ANTHROPIC_API_KEY, or apiKeyHelper) | Commercial hosted gateways meter and bill against their own prepaid wallet ledger; self-hosted enterprise gateways can authenticate upstream using your organization's own Anthropic Console, Bedrock, Vertex, or Foundry credentials and bill those upstream accounts directly (or forward a user's claude.ai subscription login) | Multi-vendor routing, unified cross-model budgets, per-key spend caps, or centralized enterprise proxy governance | Setting ANTHROPIC_BASE_URL without a gateway credential does not replace a saved claude.ai login |
Why You Should Never Set ANTHROPIC_BASE_URL Without a Gateway Credential
Per Anthropic's official LLM gateway overview and Connect Claude Code to an LLM gateway (checked 2026-10-23):
- Setting
ANTHROPIC_BASE_URLalone does not change how Claude Code authenticates: WithoutANTHROPIC_AUTH_TOKEN,ANTHROPIC_API_KEY, orapiKeyHelper, Claude Code does not replace a savedclaude.aisubscription login—it sends requests toANTHROPIC_BASE_URLusing that saved login (and enterprise gateways that forward subscription traffic to Anthropic must forward the OAuth flag in theanthropic-betaheader). - Gateways that issue their own keys require the matching credential variable: Commercial pay-as-you-go gateways or proxies configured with per-user gateway keys require the client to pass that gateway credential. In Claude Code,
ANTHROPIC_AUTH_TOKENsendsAuthorization: Bearer <token>, whereasANTHROPIC_API_KEYsendsx-api-key: <key>. Omitting the credential variable or choosing the wrong one sends your key in a header the gateway does not read (or sends no gateway key at all), causing authentication failures.
Check Authentication Precedence and Managed Policy Locks
Per Anthropic's official Authentication precedence and Settings documentation (checked 2026-10-23), local environment variables do not always win:
- Enterprise
Claude apps gatewayand managed settings take top priority: If you are signed into an enterpriseClaude apps gatewaysession, it overrides cloud provider flags (CLAUDE_CODE_USE_BEDROCK,CLAUDE_CODE_USE_VERTEX,CLAUDE_CODE_USE_FOUNDRY),ANTHROPIC_AUTH_TOKEN,ANTHROPIC_API_KEY,apiKeyHelper, and standard/login. In addition, administrators can configureforceLoginMethod(such as restricting logins toclaudeaiorconsole),forceLoginOrgUUID, orallowedProviders(such as restricting tofirstParty) inmanaged-settings.jsonto block third-party gateways. - Standard CLI precedence and headless
-pbehavior: In a standard shell without organization locks, cloud provider flags take precedence overANTHROPIC_AUTH_TOKEN, which in turn takes precedence overANTHROPIC_API_KEY. WhenANTHROPIC_API_KEYis selected, interactive sessions show a one-time approval prompt and remember your choice (if previously declined, re-enable Use custom API key in/config). Non-interactive mode (claude -p) skips that approval prompt and usesANTHROPIC_API_KEYdirectly, but-pdoes not alter precedence order—ifANTHROPIC_AUTH_TOKENor a cloud provider flag is also set, the higher-precedence credential still wins.
For official API key creation steps, Max/Team monthly API credit eligibility, and a redaction-safe SET/UNSET shell audit snippet, see our Claude Code API Key & Authentication Precedence Guide.
2. Why "Works in a Basic Chat App" Does Not Mean "Works in Claude Code"
Many providers advertise support for Claude models, yet fail or silently lose prompt caching during multi-file edits, tool calls, or long-context refactoring in Claude Code. That happens because Claude Code relies on specific protocol and streaming behaviors from the underlying gateway.
Six Protocol Requirements for a Claude Code Gateway
Checked against Anthropic's official LLM gateway protocol requirements (2026-10-23), evaluate any candidate gateway across these six areas:
| Protocol Dimension | What Claude Code Sends / Expects | What Happens When a Gateway Breaks It |
|---|---|---|
| 1. Native Endpoint Paths | Sends POST /v1/messages and optional POST /v1/messages/count_tokens (falling back to estimation if unavailable) to ANTHROPIC_BASE_URL. | Gateways that only expose OpenAI-style /v1/chat/completions or apply lossy schema translation often break message blocks, thinking blocks, or tool loops. |
| 2. Header Passthrough | Sends anthropic-version: 2023-06-01 and multiple anthropic-beta feature flags (such as extended thinking, 1M context, interleaved thinking, or effort control). | If a gateway strips unknown anthropic-beta values or drops multi-value headers, features gated on those beta flags (such as extended thinking or 1M context) will not activate. |
3. Prompt Caching & system[0] Attribution Order | Attaches cache_control ({"type": "ephemeral"} with optional "ttl": "1h") on system, tools, and messages blocks, keeping the attribution block fixed at system[0]. | Stripping cache_control disables prompt caching so every turn is billed at full input token rates; prepending a custom system block before system[0] shifts the attribution block out of system[0], preventing upstream from stripping it before inference so the attribution header enters the model prompt and cache key. |
| 4. Tool Schemas & Streaming Deltas | Passes strict, defer_loading, and input_examples inside tools, and streams tool arguments via SSE content_block_delta (input_json_delta). | Filtering out tool schema fields, rewriting tool_use.id, or truncating input_json_delta breaks local file edits, Bash execution, and MCP tool calls. |
| 5. SSE Event Order & Keep-Alives | Expects message_start → content block events → message_delta → message_stop, plus periodic SSE ping events during long thinking pauses. | Response buffering, dropped ping events, or closing the connection during thinking pauses causes mid-turn stream disconnects (see our Claude Stream Idle Timeout Guide). |
| 6. Raw Error Bodies & Model Discovery | Reads upstream HTTP status codes and JSON error bodies so it can strip unsupported parameters and retry; requests GET /v1/models?limit=1000 when CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1 is set. | Rewriting upstream 400 responses into generic HTML error pages or 500 errors prevents automatic parameter fallback (see our Claude Code API Error 500 Guide); /v1/models responses slower than 3 seconds or returning 3xx redirects fail model discovery. |
Client Surface Differences: Why Terminal Settings Don't Apply Everywhere
Always match your configuration method to the client surface you actually use. Per Connect Claude Code to an LLM gateway and Settings (checked 2026-10-23):
- Terminal CLI: Reads shell environment variables and managed policy files, plus user settings (
~/.claude/settings.json), local project settings (.claude/settings.local.json), and shared project settings (.claude/settings.json). - VS Code Extension: Requires setting
claudeCode.environmentVariablesin VS Code settings; placing variables only in~/.claude/settings.jsoncovers the spawned process but does not cover the extension's own login check. - Claude Desktop App: Does not read terminal shell variables or CLI
~/.claude/settings.json. You must configure a gateway separately via Help → Troubleshooting → Enable Developer Mode → Configure Third-Party Inference, and Desktop sessions remain separate from CLI sessions (see our Claude Code Terminal vs. Desktop Guide). - Web Cloud Sessions (Claude Code on the Web) & Slack: Always ignore local gateway environment variables and cannot be routed to a third-party
ANTHROPIC_BASE_URL. - First-Party-Only Feature Limits: Remote Control and Voice Dictation are unavailable whenever you use gateway credentials or a custom
ANTHROPIC_BASE_URL.
3. Pricing and Account Terms: Why Headline Discounts Don't Tell the Whole Story
Comparing gateways by a single "dollars per million input tokens" number or a promotional discount multiplier rarely reflects real Claude Code spend. In multi-turn coding sessions, file reads, tool outputs, and growing conversation history generate heavy prompt-cache activity alongside background helper-model calls.
Five Cost and Account Checks Before Topping Up
- All Four Token Billing Buckets Disclosed Up Front:
- Uncached Input
- Output (including extended thinking tokens)
- Cache Write (distinguishing 5-minute default TTL from 1-hour extended TTL multipliers)
- Cache Read / Hit
If a provider only lists input/output rates while hiding cache-write pricing—or breaks
cache_controlso cache hits fall back to uncached input—your multi-turn session cost can easily exceed standard pay-as-you-go rates. See our Claude Code API Pricing & Token Budget Guide for full bucket formulas.
- Primary and Helper Role Model Mapping:
Claude Code invokes helper models for background summaries, session titles, and subagents. Verify that your gateway catalog includes the target model IDs and map them explicitly via
ANTHROPIC_DEFAULT_HAIKU_MODEL,ANTHROPIC_DEFAULT_SONNET_MODEL,ANTHROPIC_DEFAULT_OPUS_MODEL, andCLAUDE_CODE_SUBAGENT_MODELso subagents never request a default model ID the gateway does not serve. - Currency Unit, Top-Up Fees, and Exchange Math: Check whether balances are denominated in USD or custom point credits, whether checkout adds a payment processing fee, and compare total cost across identical workloads in the same currency.
- Channel Tier Definitions and Per-Key Channel Restrictions: Some gateways divide routes into multiple channel tiers (such as standard vs. promotional/discounted channels). Because each provider defines its own upstream pools, rate-limit behavior, and fallback rules differently, inspect how the provider documents its channel tiers and whether you can restrict an API key to specific channels.
- Principal Expiry, Bonus Credit TTL, and Refund Policy: Before depositing funds, check the Terms of Service for refund windows (whether unused principal is refundable or non-refundable except as required by law), whether purchased principal ever expires, and the exact expiration window for promotional bonus credits.
4. Data Flow, Local Cache, and Privacy Boundaries: Match the Policy to Your Project
Evaluating how a gateway handles your code does not require one-size-fits-all slogans, but it does require knowing which nodes touch your request payload and matching the provider's policies to your project's sensitivity.
The Three Data Nodes on a Gateway Request Path
When you point ANTHROPIC_BASE_URL at a third-party gateway, a coding request flows through the following three nodes:
[1. Local Workspace & Terminal Process]
├── Reads repo files, Git status, CLAUDE.md, env vars, and local tool outputs
├── Writes local plaintext session transcripts: ~/.claude/projects/ (30-day default retention via cleanupPeriodDays)
└── Direct non-inference traffic to api.anthropic.com (auto-update, telemetry, /fast checks, WebFetch domain preflight)
│
▼ (Sends /v1/messages JSON payload over HTTPS/TLS)
[2. Third-Party Gateway / Relay (ANTHROPIC_BASE_URL)]
├── Receives system prompts, conversation history, code snippets, tool schemas, and gateway credentials
└── Governed by the gateway's own Terms of Service, logging policy, and security controls
│
▼ (Forwarded by the gateway to its selected upstream channel)
[3. Upstream Model Provider / Channel Behind the Gateway]
└── Governed by the upstream provider's training, abuse-monitoring, and data-retention rules
Three Privacy Concepts Not to Confuse
Per Anthropic's official Data usage, Security, and LLM gateway overview documentation (checked 2026-10-23):
- Transport Encryption (HTTPS / TLS) ≠ Zero Server-Side Retention:
HTTPS protects payloads in transit across the public network, but once the request reaches
ANTHROPIC_BASE_URL, the gateway process terminates TLS and reads the JSON payload to route and bill the call. - "No Model Training" ≠ "No Request Retention": Under Anthropic's official data usage policy, commercial plans (Team, Enterprise, and Claude API) do not use prompts or code to train generative models by default, but standard commercial retention is 30 days unless a qualified Claude for Enterprise organization has Zero Data Retention (ZDR) enabled by its account team. More importantly, Anthropic's commercial terms apply only to Anthropic's own services and never automatically extend to a third-party gateway or its upstream channels.
- Gateway Terms vs. Upstream Channel Policies: Different codebases have different requirements. For open-source repos or non-sensitive sandbox scripts, standard metered routing is often fine; if your repository contains customer data, proprietary algorithms, or regulated workloads, review the data-handling and retention policies of both the gateway and the upstream channel it routes to before connecting.
Local Plaintext Transcripts and Background Traffic to api.anthropic.com
Even when ANTHROPIC_BASE_URL points to a custom gateway, the following local and background behaviors remain active by default (verified against official docs on 2026-10-23):
- Local session transcripts: Claude Code stores plaintext session logs under
~/.claude/projects/to support session resumption, retaining them for 30 days by default (configurable viacleanupPeriodDaysin settings). - Non-inference background traffic: By default, Claude Code still contacts
api.anthropic.comdirectly for auto-update checks, telemetry events, session quality surveys,/fastmode checks, and target-domain safety preflight checks when theWebFetchtool runs. Use the environment variable below to disable auto-updates,/bugreporting, error reporting, telemetry, surveys, and/fastchecks;WebFetchdomain preflight is not affected by that variable and must be disabled separately viaskipWebFetchPreflightin settings:
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
# settings.json: "skipWebFetchPreflight": true
5. Worked Example Using UniRoute's Public Docs: Verified Facts vs. Unverified Boundaries
To show how the 6-point checklist works in practice, the table below applies the exact same rules to UniRoute's public documentation, pricing page, and legal terms (checked 2026-10-23). Facts explicitly stated in public docs are cited directly; anything not disclosed or dependent on your specific workload is marked as unverified / check for your workload.
| Verification Dimension | Facts Stated in UniRoute Public Docs (as of 2026-10-23) | Limitations, Undisclosed Details & What You Should Verify |
|---|---|---|
| 1. Base URL & Credential Pairing | Base URL is https://api.uniroute.app (Claude Code appends /v1/messages automatically; do not append /v1 or /v1/messages). Pass the UniRoute API key via ANTHROPIC_AUTH_TOKEN and set ANTHROPIC_API_KEY="" to avoid header conflicts (Claude Code CLI Guide). | A UniRoute key is not interchangeable with an official Anthropic key or an OpenRouter key. If your machine is locked by an enterprise Claude apps gateway or managed policy, local env vars will not override organization policy. |
| 2. Native Protocol & Endpoint Scope | The public Route Selection Guide documents native /v1/messages (Anthropic), /v1/responses (OpenAI Responses), /v1/chat/completions (OpenAI Chat), /v1beta (Gemini), and /v1/models without cross-protocol translation. | Listing native endpoints in documentation does not mean every Claude model ID, long-context tier, or new beta flag has been validated end-to-end against your specific repository. |
| 3. Scope of Historical Canary Record | The Claude Code CLI Guide records a dated canary run (2026-10-08, client 2.1.293 (Claude Code), model claude-haiku-4-5-20251001, billed at $0.00579548 USD). | That record only proves that single short Haiku request and ledger charge succeeded on 2026-10-08. No new paid model calls were executed while writing this guide, and a single Haiku smoke test does not prove Sonnet/Opus long-task or high-concurrency stability. |
| 4. Key Controls, Spend Caps & Quotas | The Create API Key Guide documents per-key Spend Limits, Channel Restrictions, and Model Restrictions, with a default quota of up to 5 active keys per account (support can adjust if needed). | Public pages do not document enterprise SSO/SCIM, multi-member team workspaces, or compliance audit-log exports; teams needing those governance controls should verify fit first. |
| 5. Channel Tiers & Provider Documentation | UniRoute's own Channel Management Guide states that it aggregates "official subscriptions, AWS, discounted channels, etc." using "price-first with automatic fallback" routing, and states that its discounted channels split large resource pools into smaller quotas and may be less stable when high usage triggers upstream risk controls. Users can disable discounted channels per provider in the console or restrict an API key to non-discounted channels (described in docs as official or AWS channels). | These routing and discounted-channel explanations are statements from UniRoute's own documentation rather than third-party audits or contractual guarantees. If evaluating UniRoute for stability-sensitive coding sessions, you can exclude discounted channels in your key or channel settings and verify with your own workload. |
| 6. Billing, Refunds, Uptime Target & Privacy Terms | The Billing & Top-Up Guide states that accounts use prepaid USD pay-as-you-go balances. The Terms of Service (updated 2026-10-10, Section 3) state that newly purchased USD principal never expires and is non-refundable except as required by law, promotional bonus credits expire after 30 days, and requests that fail before generating output are not billed; Section 6 states a 99.9% monthly availability target (provided "as is"). | The 99.9% figure is an availability target statement, not a historical uptime measurement or credit-backed SLA. Terms of Service Section 5 states that Zero Data Retention (ZDR) applies to forwarded requests, whereas the Privacy Policy (updated 2026-05-21) primarily covers account, usage, device, cookie, and payment data without detailing forwarded prompt payload handling or upstream provider retention—evaluate whether this matches your project's confidentiality requirements. |
If you are comparing multiple gateway options side by side (such as keeping OpenRouter and tuning provider.order / zdr, connecting directly to a single model vendor, self-hosting LiteLLM, or using UniRoute), see our Claude Code with OpenRouter Setup & Cost Guide and OpenRouter Alternatives Comparison.
6. Voluntary Small-Scale Acceptance Test and Child-Subshell Rollback
Once you have reviewed the documentation and terms—and voluntarily choose to run a small live acceptance test against a gateway—the safest approach is to run the test inside a temporary child subshell (bash -c). Because the gateway variables only exist inside that child process, exiting the session leaves your parent shell's existing environment variables and ~/.claude/settings.json untouched.
Billing & Execution Notice: Sending a test request to
/v1/messagesor runningclaude -p/ interactive prompts executes a real model call that consumes balance or quota on the active account. The commands below are provided strictly for your voluntary local testing; no new paid model calls were executed while authoring this guide.
Step 1: Check Your CLI Version and Make a Non-Overwriting Backup (If You Plan to Edit Settings Later)
Never place secret keys inside a project-committed .claude/settings.json. If you ever plan to edit ~/.claude/settings.json, create a timestamped backup with cp -n so you never overwrite an earlier backup:
claude --version
if [ -f "$HOME/.claude/settings.json" ]; then
backup_path="$HOME/.claude/settings.json.bak.$(date +%Y%m%d-%H%M%S)"
cp -n "$HOME/.claude/settings.json" "$backup_path"
echo "Created non-overwriting backup: $backup_path"
else
echo "No ~/.claude/settings.json found; no backup needed"
fi
Step 2: Launch Inside an Isolated Child Subshell (Without Touching Parent Shell or Global Files)
For your first acceptance test, do not edit ~/.claude/settings.json and do not export gateway variables in your parent shell. Instead, read the key silently inside a temporary bash -c child subshell, align primary and helper role model variables, and run claude auth status --text inside that same child process before launching claude (shown below with https://api.uniroute.app as an example; substitute your chosen gateway's root URL and exact model ID if testing another provider):
bash -c '
set +x
read -r -s -p "Gateway API key: " ANTHROPIC_AUTH_TOKEN
printf "\n"
[ -n "$ANTHROPIC_AUTH_TOKEN" ] || exit 1
read -r -p "Target Claude model ID: " route_model
[ -n "$route_model" ] || exit 1
export ANTHROPIC_BASE_URL="https://api.uniroute.app"
export ANTHROPIC_AUTH_TOKEN
export ANTHROPIC_API_KEY=""
export ANTHROPIC_DEFAULT_HAIKU_MODEL="$route_model"
export ANTHROPIC_DEFAULT_SONNET_MODEL="$route_model"
export ANTHROPIC_DEFAULT_OPUS_MODEL="$route_model"
export CLAUDE_CODE_SUBAGENT_MODEL="$route_model"
claude auth status --text
claude --model "$route_model"
'
Step 3: Record the Four Minimum Acceptance Checks in Order
Inside that child subshell's Claude Code session, complete Check 1 before sending any prompt, then run Checks 2–4 only if the active auth source matches and your test budget allows:
| Acceptance Step | Local Action | Pass Criteria | How to Treat Unobserved Items |
|---|---|---|---|
1. Verify /status Inside the Same Test Subshell | Inspect the claude auth status --text output printed inside the child subshell and run /status inside the active session (do not run claude auth status in a separate terminal window, which does not inherit the child subshell's temporary ANTHROPIC_BASE_URL or credentials) | Confirm the session's Anthropic base URL matches the target gateway root URL, auth method shows the expected Auth token or API key, primary model ID matches, and no managed policy or leftover subscription login is overriding it. | If the URL or auth method does not match, type /exit immediately to leave the subshell and resolve the conflict before sending any prompt. |
| 2. Non-Sensitive Smoke Prompt | Send a short prompt containing zero proprietary code (or a minimal 1-token check) | Streaming response starts and finishes cleanly with message_stop (no mid-stream disconnect, 401/403/500, or schema error). | A single smoke test only confirms basic reachability at that moment; tool loops and long context remain unverified. |
| 3. Local Tool Round-Trip Check | In a clean scratch directory, ask Claude Code to read and make a tiny edit to a sample text file | Client receives streamed tool_use arguments, executes the local file read/edit, and returns tool_result to complete the turn. | Confirms basic tool round-trip for this test only; Extended Thinking and large multi-file refactors remain unverified until tested. |
| 4. Console Ledger & Cache Bucket Check | Open your gateway's usage log (such as the UniRoute Console) | Verify timestamp, exact model ID, routed channel, uncached input tokens, cache write/read tokens, output tokens, and total USD charge against the public rate card. | Any field not shown in the gateway ledger (such as upstream retention state or long-term uptime) stays marked as unverified. |
Step 4: Exit the Child Subshell to Return to Your Prior Setup (and Targeted Restore If You Edited Files)
- If you launched via the Step 2
bash -cchild subshell: Simply type/exitto close Claude Code. When the child subshell exits, its temporaryANTHROPIC_BASE_URL,ANTHROPIC_AUTH_TOKEN, and role-model exports disappear automatically while leaving any pre-existing variables in your parent shell (such as an officialANTHROPIC_API_KEYor custom model defaults you already used) and~/.claude/settings.jsonunchanged. Do not run bulkunsetcommands in your parent shell, which would delete variables your existing environment relied on. - If you manually edited
~/.claude/settings.jsonor exported gateway variables directly in your current shell: Restore your~/.claude/settings.jsonfrom the timestamped backup created in Step 1, revert only the specific shell variables you modified back to their prior values (or open a fresh terminal session), and run/statusinsideclaude(or/loginif returning to an official subscription) to verify your original auth source is active.
7. Frequently Asked Questions (FAQ)
If I already have a Claude Pro or Max subscription, do I need a Claude Code relay?
Usually no. As long as your interactive coding fits within your subscription usage limits and you can sign into claude.ai, running /login in Claude Code is the simplest path. You only need to evaluate the official Console API or a third-party gateway if you want separate metered budgets, multi-provider model routing under one wallet, or isolated per-key spend caps for scripts and teams.
Why does a relay work in a basic chat client but fail inside Claude Code?
Basic chat clients usually send simple /v1/chat/completions requests. Claude Code sends native /v1/messages requests with anthropic-beta capability flags, cache_control blocks, strict tool schemas, and multi-turn tool_result blocks. If a relay performs lossy format conversion, strips anthropic-beta feature headers or cache_control blocks, alters the system array order, or drops SSE ping events during long thinking pauses, beta features, prompt caching, tool execution, or streaming can break inside Claude Code.
How can I tell whether a gateway's advertised low price will actually save money?
Look beyond headline discount multipliers or single input-token rates. Run a representative multi-turn file read/edit task in a scratch folder, then inspect all four token buckets (uncached input, 5m/1h cache write, cache read, and output) and the actual total charge in the gateway's usage ledger, factor in any top-up fees or non-refundable principal/bonus expiry rules, and check how the provider documents the routing and rate-limit rules for that channel tier.
Does Claude Code still contact Anthropic's servers when ANTHROPIC_BASE_URL points to a third-party gateway?
Yes. Per Anthropic's official gateway and data-usage documentation, even when inference traffic goes to ANTHROPIC_BASE_URL, Claude Code still contacts api.anthropic.com by default for auto-update checks, telemetry, session quality surveys, /fast availability checks, and WebFetch domain safety preflight requests. Set the environment variable below to disable auto-updates, error reporting, telemetry, surveys, and /fast checks, and configure skipWebFetchPreflight in settings to disable WebFetch domain preflight checks:
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
# settings.json: "skipWebFetchPreflight": true
Next Steps: Verify Pricing, Docs, and Optional Setup in Order
If you have completed the checklist above and want to inspect UniRoute's exact pricing or configuration details before deciding whether to test, follow these steps in order:
- Check live pricing and token bucket rules first: Review the UniRoute Live Model Pricing Table alongside our Claude Code API Pricing & Cache Bucket Guide to compare
standardanddiscountedchannel rates and context tiers. - Read the setup, native endpoint, and billing documentation: Inspect the Claude Code CLI Setup & Rollback Guide, Native Route Selection Guide, and Wallet Top-Up & Billing Rules.
- Create a restricted API key and reconcile usage only when ready: If you choose to run a small test, follow the Create API Key Guide to set a Spend Limit, Channel Restriction, and Model Restriction, then verify your per-request token buckets and charges in the UniRoute Console.

