🧭 How toAIIntermediate✨ AI-assisted

How to Add a Fallback to Claude Opus 5.5 Fast Mode

WittyTech Daily··5 min read
#claude#fast-mode#rate-limits#microsoft-foundry

Fast mode gets you up to 2.5x higher output tokens per second from Claude Opus 5.5, right up until its own rate limit says no. When that limit or fast capacity runs out, you get a 429 or 529 instead of an answer. By the end you'll have a Claude fast mode fallback in Python: one fast attempt, a retry at standard speed on a capacity error, and a log of which speed served each request.

Step 1: Send a fast mode request with curl

On Opus 5.5, fast mode needs no beta header and no access request. Add one top-level field, speed, set to "fast".

curl -sS https://api.anthropic.com/v1/messages \
  -D headers.txt \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-opus-5-5",
    "max_tokens": 1024,
    "speed": "fast",
    "messages": [{"role": "user", "content": "Explain what a circuit breaker does in two sentences."}]
  }'

-D headers.txt saves the response headers for step 3. Drop speed and the same request runs at standard speed.

Step 2: Call fast mode from Python and check usage.speed

import anthropic

client = anthropic.Anthropic()  # reads ANTHROPIC_API_KEY

response = client.messages.create(
    model="claude-opus-5-5",
    max_tokens=1024,
    speed="fast",
    messages=[{"role": "user", "content": "Explain what a circuit breaker does in two sentences."}],
)

print(response.usage.speed)  # "fast" or "standard"

Log usage.speed on every call. On Opus 5.5 a fast request that can't run fast returns an error instead of quietly running slow, so a "standard" reading means your own fallback fired.

Step 3: Read the anthropic-fast rate limit headers

Fast mode has a dedicated rate limit, separate from your standard Opus limits. Six response headers track it: anthropic-fast-input-tokens-limit, -remaining and -reset, plus the same three for output tokens, all per minute.

grep -i '^anthropic-fast' headers.txt
raw = client.messages.with_raw_response.create(
    model="claude-opus-5-5",
    max_tokens=1024,
    speed="fast",
    messages=[{"role": "user", "content": "Explain what a circuit breaker does in two sentences."}],
)

for kind in ("input", "output"):
    limit = raw.headers.get(f"anthropic-fast-{kind}-tokens-limit")
    remaining = raw.headers.get(f"anthropic-fast-{kind}-tokens-remaining")
    print(f"fast {kind} tokens: {remaining}/{limit}")

message = raw.parse()  # the same Message object create() would return

Send remaining to your metrics, so a falling output balance warns you before the first 429. Your actual limits are on the Rate limits page in the Claude Console.

Step 4: Build the Claude fast mode fallback

The SDK retries a fast mode 429 twice by default, waiting out retry-after. Fast mode replenishes tokens continuously, so that wait is usually short, and if waiting is fine you can stop here.

If a user is staring at a spinner, answer now at standard speed instead. Anthropic's fast mode docs describe the pattern: max_retries=0 on the first attempt, catch the rate limit error, retry without speed.

import time

import anthropic

client = anthropic.Anthropic()

FAST_COOLDOWN_SECONDS = 30  # tune to your traffic
fast_paused_until = 0.0


def without_speed(params):
    return {k: v for k, v in params.items() if k != "speed"}


def create_message(**params):
    global fast_paused_until

    if params.get("speed") != "fast":
        return client.messages.create(**params)
    if time.monotonic() < fast_paused_until:
        return client.messages.create(**without_speed(params))

    try:
        # max_retries=0: fail immediately instead of waiting for fast capacity
        return client.with_options(max_retries=0).messages.create(**params)
    except anthropic.APIStatusError as e:
        if e.status_code in (429, 529):
            fast_paused_until = time.monotonic() + FAST_COOLDOWN_SECONDS
            return client.messages.create(**without_speed(params))
        if e.status_code < 500:
            raise  # a 400 is a bug in the request, not a capacity signal
    except anthropic.APIConnectionError:
        pass

    # Other transient failure: reissue the fast request with default retries
    return client.messages.create(**params)


message = create_message(
    model="claude-opus-5-5",
    max_tokens=1024,
    speed="fast",
    messages=[{"role": "user", "content": "Explain what a circuit breaker does in two sentences."}],
)
print(message.usage.speed)

Three choices to know. max_retries=0 also disables retries for 5xx and connection errors on the fast attempt, so the last line reissues the request with default retries, as the docs do. I treat 529 like 429 because the docs say exceeding fast mode's limits or capacity returns either one; their sample only catches the 429. The cooldown stops a burst of rejections from bouncing requests between speeds, which matters because of the cache rule below.

Step 5: Use the same pattern on Claude in Microsoft Foundry

Opus 5.5 fast mode on Claude in Microsoft Foundry works only for deployments hosted on Azure, not deployments hosted on Anthropic. You choose the hosting option when you create the deployment, so if yours is hosted on Anthropic, create an Azure-hosted one and update model.

curl https://<your-resource>.services.ai.azure.com/anthropic/v1/messages \
  -H "content-type: application/json" \
  -H "api-key: $AZURE_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "<your-deployment-name>",
    "max_tokens": 1024,
    "speed": "fast",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

model takes your deployment name, which defaults to the model ID. The Foundry docs say Foundry omits Anthropic's standard anthropic-ratelimit-* headers and point you to Azure's monitoring tools, so check what your deployment returns before alerting on the step 3 headers. The fallback itself only needs the status code.

Gotchas

  • Switching speed is a prompt cache miss. Requests at different speeds do not share cached prefixes, so the first standard-speed call after a fallback processes your whole prefix uncached. Flip-flopping pays that again, so after a fallback keep the conversation on standard for a while.
  • Fast costs double. Opus 5.5 fast mode is $8 input and $40 output per MTok, against $4 and $20 at standard speed, across the full context window. Caching and data residency multipliers stack on top. Alert on the share of responses with usage.speed of "standard", since a fallback looks like a cost drop.
  • Not everywhere. Fast mode doesn't work with the Batch API or a Priority Tier commitment. Evaluation tier organizations must move to Start, Build or Scale first.
  • Output speed, not time to first token. Stream the response to see the gain; a long prompt with a short answer won't feel much faster.
  • Older models need a header. Fast mode on Claude Opus 5 and Opus 4.8 is a research preview that needs fast-mode-2026-02-01, and returns a 400 without it.

Fast mode is a latency feature with its own failure mode, so the fallback is what keeps a busy afternoon from turning into error pages for your users.

← More in AI