Claude Code

Gateways and protocols

Passion8 endpoints, authentication, forwarding, model discovery, caching, tool search and common 400/401 failures.

ANTHROPIC_BASE_URL connects Code to an LLM gateway. The CLI sends Anthropic Messages while Passion8 handles forwarding, authentication, routing, billing and observability.

Code uses https://passion8.cc without /v1. Codex and OpenAI-compatible clients use https://passion8.cc/v1.

For client configuration, start here and with provider authentication guidance. Implementers should use the protocol checklist.

#Minimal setup

export ANTHROPIC_BASE_URL="https://passion8.cc"
export ANTHROPIC_AUTH_TOKEN="sk-YOUR_PASSION8_API_KEY"
claude -p "Reply only ok"

Windows PowerShell:

$env:ANTHROPIC_BASE_URL = "https://passion8.cc"
$env:ANTHROPIC_AUTH_TOKEN = "sk-YOUR_PASSION8_API_KEY"
claude -p "Reply only ok"

Store keys in user settings or local environment, never project Git history:

~/.claude/settings.json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://passion8.cc",
    "ANTHROPIC_AUTH_TOKEN": "sk-YOUR_PASSION8_API_KEY"
  }
}

#Request format

Code uses Anthropic Messages for ANTHROPIC_BASE_URL:

ItemDetails
Main endpoint/v1/messages
Optional endpoint/v1/messages/count_tokens
AuthenticationBearer authorization or x-api-key
StreamingSSE forwarding required
ModelsOptional /v1/models?limit=1000

Provider dialect conversion belongs to the gateway. Do not use the OpenAI /v1 root for Code.

#Required forwarding

Avoid fixed allowlists that strip new fields. Client capabilities and beta headers evolve.

ContentImportance
anthropic-versionUpstream version
anthropic-betaSearch, context and beta tool capabilities
system array orderingAttribution, prompt and cache key
tools/schemasMCP, built-ins and deferred loading
thinkingadaptive reasoning
output_configeffort、structured output、task budget
context_managementAutomatic context controls
Error bodyRetry and capability fallback decisions

Auditing should inspect without rewriting bodies. Header stripping or flattening system arrays changes capabilities and caching.

#Attribution blocks and caching

Code prepends attribution; the official endpoint strips it when correctly positioned to protect first-party caching.

Custom gateway considerations:

BehaviorResult
Preserve arrays and first attribution blockMost reliable
Prepend custom system blockAttribution may enter prompt/cache key
Flatten arrayCan break stripping/caching
Required system rewritingConsider CLAUDE_CODE_ATTRIBUTION_HEADER=0

From v2.1.181, attribution is more stable within conversations on custom base URLs, helping full-body caches. Older deployments may need the attribution override.

#Prompt caching through Passion8

Check three layers:

LayerCheck
ClientFrequent model/effort/fast/compact changes or upgrades
GatewayCache controls, headers, tools and usage preserved
ModelCaching, search, one-hour TTL and context support

Usage fields:

FieldMeaning
cache_creation_input_tokensTokens written this turn
cache_read_input_tokensTokens read this turn

A higher read/write ratio suggests better reuse. Repeated high writes warrant checking model, effort, fast mode, MCP schemas, plugins, tool denies and compaction.

#Model discovery

Implementing /v1/models lets gateway models appear in the picker.

Enable:

export CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1

Notes:

ConditionExplanation
ANTHROPIC_BASE_URL onlyHigher-priority cloud-provider variables bypass this discovery
Short timeoutSlow or redirected discovery silently fails
Cached results~/.claude/cache/gateway-models.json
Custom capabilitiesPicker presence does not prove effort, search or 1M context

#Common errors

SymptomPossible causeFix
401Wrong key/header or stale loginVerify token; log out if needed
ConnectionRefusedEndpoint, VPN or firewallTest gateway with curl
200 but malformedHTML login/proxy responseFix routing to return API JSON/SSE
400 context_managementUnsupported upstreamRoute to support or temporarily disable experimental betas
400 thinking/adaptiveUnsupported reasoningUpgrade upstream or use documented capability controls
No model listMissing endpoint or disabled discoveryEnable discovery or set an actual model ID
Remote Control unavailableCustom credential/base URLSee remote access
Official account features missingDifferent provider/account pathSee availability
Inaccurate context estimatesMissing count_tokensImplement counting or accept estimates

#Enterprise configuration

Teams can use:

CapabilityPurpose
Managed settingsEndpoint, models, permissions and hooks
Server-managedOrganizational policy for eligible cloud/web sessions
apiKeyHelperDynamic gateway tokens
Custom headersTenant, routing and audit metadata
OpenTelemetryUsage, tools, hooks and costs
Gateway limitsPer-user daily/weekly/monthly caps

Helper output is cached. CLAUDE_CODE_API_KEY_HELPER_TTL_MS controls the documented helper cache duration.

See operations and apps-gateway deployment for OIDC, Postgres, budgets, discovery, forwarding and TTL boundaries.

#Passion8 checklist

  1. Use the root URL without /v1.
  2. Use ANTHROPIC_AUTH_TOKEN and avoid conflicting credentials.
  3. Choose model, effort and fast mode before long tasks.
  4. Verify search/deferred tools for large MCP inventories.
  5. Diagnose zero reads with stable model/effort and no MCP.
  6. Verify the actual model ID before enabling discovery.
  7. For unavailable Remote Control or dictation, test the documented official-account boundary separately.

#Official references

Support

Need help?

For setup, billing, or model issues, email us. Check the status page for uptime.

WeChat / QQ support is available at the bottom right.