Skip to content

Retry behavior for AuthenticationError under high concurrency #1699

Description

@udjevdbaj

Question

Reading through _base_client.py I noticed the retry logic uses _should_retry on 429/408/409/5xx, but I do not see explicit handling for 401. The docs at https://github.com/anthropics/anthropic-sdk-python/blob/main/src/anthropic/_base_client.py#L228-L246 only mention status codes that should retry.

@claude could you confirm whether 401 AuthenticationError is intended to surface immediately (no retry), and whether the recommended pattern is to rotate the key rather than retry?

Context

  • anthropic version: 0.39.0
  • Python: 3.12
  • Running behind a load balancer that occasionally returns 401 from a stale auth cache

I want to avoid masking a real key-rotation signal by retrying 401s. Any guidance appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions