Follow Discord
Sweep 03 Dec 2026 · 19:13Z Build v2.1.336 553 read Stable v2.1.332 Latest v2.1.336 Next v2.1.336 Feeds RSS JSON llms.txt llms-full.txt Unofficial
One change · api

go changedcli-sdks-libraries/sdks/go

Nearest release: v2.1.332, published 6 hours before this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.

Recorded here
Lines+20added
Lines−3removed
From line 474 where the diff opens
First seen 14 Aug 2026 this site's first read of the page
Recorded edits22to this page, all time

### Retries for create methods

The whole hunk

from line 474, old and new numbered
/
lines
from line 474
474474}
475475```
476476 
477To branch on the error code and the HTTP status, see [Handle errors](https://platform.claude.com/docs/en/api/handle-errors).
478 
477479When other errors occur, they are returned unwrapped; for example, if HTTP transport fails, you might receive `*url.Error` wrapping `*net.OpError`.
478480 
479481## Retries
480482 
481Certain errors are automatically retried 2 times by default, with a short exponential backoff. The SDK retries by default all connection errors, 408 Request Timeout, 409 Conflict, 429 Rate Limit, and >=500 Internal errors.
483By default, the SDK retries certain errors up to two times (three attempts in all). It retries [some create methods](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/go#retries-for-create-methods) in fewer cases.
482484 
483You can use the `WithMaxRetries` option to configure or disable this:
485For most methods, such as `client.Messages.New()`, the SDK retries connection errors, timeouts, 408 Request Timeout, 409 Conflict, 429 Too Many Requests, and 5xx server errors.
484486 
487For these methods, if a response has an `x-should-retry` header (`true` or `false`), the SDK follows it instead of the status. Between attempts, the SDK waits as long as the `retry-after` header says, or it uses a short exponential backoff.
488 
489Use `option.WithMaxRetries()` to configure or disable retries:
490 
485491```go
486492// Configure the default for all requests:
487493client := anthropic.NewClient(
from line 508
502508 option.WithMaxRetries(5),
503509 )
504510```
511 
512### Retries for create methods
513 
514To avoid duplicate resources, the SDK retries some create methods, such as `client.Beta.Agents.New()`, in only two cases:
515 
516* The API returns a 429 Too Many Requests response.
517* The SDK can’t connect to the API, so it never sends the request.
518 
519In both cases, the API hasn’t processed the request, so a retry can’t create a second resource.
520 
521These methods return any other error without a retry even if the response has `x-should-retry: true`. The API might have created the resource if a server error occurred or if the connection dropped or timed out after the SDK sent the request. Check whether the resource exists before you call the method again.
505522 
506523## Timeouts
507524 
Feedback