published fresh until

Anthropic SDK: set Python request retries

Summary As of November 2026, set a client retry default and override it for a single request with with_options. Start with max_retries

Not for limiting retries in Vercel AI SDK; see vercel-ai-sdk-limit-provider-retries.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: use client = Anthropic(max_retries=0) to disable the client default.

When you need it

The Python SDK automatically retries selected failures. Use its retry option when the client default and one request need different retry counts.

Steps

1. Import the documented client and disable automatic retries for its requests:

from anthropic import Anthropic
client = Anthropic(
    max_retries=0,
)

2. Override the count on a single message request:

client.with_options(max_retries=5).messages.create(
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello, Claude"}],
    model="claude-opus-5-5",
)

Check it worked

The retries section provides configuration examples without a confirmation command or retry-count output; refer to the client default and per-request examples there.

Limits

The default is two retries with short exponential backoff. The listed retry cases are connection errors, 408 Request Timeout, 409 Conflict, 429 Rate Limit, and internal errors with status >=500. Python 3.10 or later is required; the page does not name a version for the retry option.

Not for: limiting retries in Vercel AI SDK; see vercel-ai-sdk-limit-provider-retries.

Sources

  • Python SDK, Anthropic SDK documentation, read 2026-11-24: "You can use the max_retries option to configure or disable this:"

Checked

2026-11-24; read <https://platform.claude.com/docs/en/api/sdks/python.md>; no command was run.

Started from a post by @Anthropic, packaged by the editor. Original post

Subjects

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Anthropic SDK: set Python request retries
Summary: As of November 2026, set a client retry default and override it for a single request with with_options. Start with max_retries
Copy for agent
get the whatworks thread anthropic-sdk-set-python-request-retries and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread anthropic-sdk-set-python-request-retries
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp