claude-code-multi-backend-switching · EN · 2026-10-19

Switching Claude Code Between Backends on One Aggregator Key: What Changes in the Session

Switching Claude Code between backends on a single aggregator key changes model routing and response behavior but not your client-side session state. This guide explains what stays the same, what changes, and how to manage the transition without losing work.

What stays the same when you switch backends

Your Claude Code session is primarily a client-side construct. The conversation history, tool definitions, and local file context live in your environment, not on the backend. When you point Claude Code at a different model through the same aggregator key, the following remain unchanged:

  • Your API key and endpoint – The aggregator key authenticates all requests; you only change the model identifier.
  • Conversation history – Messages already exchanged are still part of the context sent with each new request.
  • Local tooling – File system access, shell commands, and other tools run in your environment and are unaffected by the backend swap.
  • Billing relationship – You continue to pay the aggregator’s uniform multiplier (official price × 1.3) regardless of which model you call.

What changes in the session

Switching backends alters the model that generates responses. This has several practical effects:

  • Model-specific behavior – Different models have different strengths, token limits, and response styles. Code generation, reasoning depth, and instruction following can vary.
  • Context window size – Each model has its own maximum context length. A model with a smaller window may truncate earlier messages or require you to start a fresh session.
  • Tokenization and cost – Token counts differ between models, so the same conversation may consume a different number of tokens. Your cost is still calculated as official price × 1.3, but the underlying token count affects the final amount.
  • Latency and throughput – Response times and rate limits depend on the model and the aggregator’s routing.

How to switch backends

In Claude Code, the backend is typically selected via a configuration setting or environment variable that specifies the model name. With an aggregator key, you use the aggregator’s model identifier (for example, claude-3-5-sonnet or gpt-4o) in the same way you would use a provider-specific name.

  1. Locate your Claude Code configuration (often a .claude/config.json file or environment variables like ANTHROPIC_MODEL).
  2. Replace the model identifier with the desired model from the aggregator’s supported list.
  3. Restart the Claude Code session or reload the configuration.

The aggregator key remains the same; only the model string changes.

Managing context and continuity

When switching to a model with a smaller context window, you may need to trim the conversation history. Claude Code does not automatically summarize or forget messages; it sends the full history up to the model’s limit. To avoid errors:

  • Start a new session if the history exceeds the new model’s window.
  • Use Claude Code’s built-in commands to clear or compact history if available.
  • Keep critical context in local files or notes that you can re-inject.

Billing and contributor credits

All calls through the aggregator are billed at official price × 1.3, regardless of the backend. If you are a key contributor (for example, you provided the API key or refer users), you receive credits at official price × 1.1 (or × 1.2 for premium models) in USDC. Switching backends does not change your contributor rate.

Practical tips

  • Test a new backend with a small, non-critical task before committing to a long session.
  • Monitor token usage when switching, as different models may tokenize the same text differently.
  • Keep your aggregator key secure; it works across all supported models.
  • Refer to the aggregator’s documentation for the exact model identifiers and any model-specific parameters.