Follow Discord
Sweep 22 Oct 2026 · 21:04Z Build v2.1.309 528 read Stable v2.1.308 Latest v2.1.309 Next v2.1.309 Feeds RSS JSON llms.txt llms-full.txt Unofficial
One change · api

go changedcli-sdks-libraries/sdks/go

Nearest release: v2.1.309, published under an hour 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+22added
Lines−42removed
From line 14 where the diff opens
First seen 14 Aug 2026 this site's first read of the page
Recorded edits15to this page, all time

The whole hunk

from line 14, old and new numbered
/
lines
from line 14
1414 
1515```go
1616import (
17 "github.com/anthropics/anthropic-sdk-go" // imported as anthropic
17 "github.com/anthropics/anthropic-sdk-go/v2" // imported as anthropic
1818)
1919```
2020 
from line 21
2121Install with `go get`:
2222 
2323```bash
24go get github.com/anthropics/anthropic-sdk-go
24go get github.com/anthropics/anthropic-sdk-go/v2
2525```
2626 
2727## Requirements
from line 37
3737 "context"
3838 "fmt"
3939 
40 "github.com/anthropics/anthropic-sdk-go"
41 "github.com/anthropics/anthropic-sdk-go/option"
40 "github.com/anthropics/anthropic-sdk-go/v2"
41 "github.com/anthropics/anthropic-sdk-go/v2/option"
4242)
4343 
4444func main() {
from line 458
458458```go
459459_, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
460460 MaxTokens: 1024,
461 Messages: []anthropic.MessageParam{{
462 Content: []anthropic.ContentBlockParamUnion{{
463 OfText: &anthropic.TextBlockParam{
464 Text: "What is a quaternion?",
465 },
466 }},
467 Role: anthropic.MessageParamRoleUser,
468 }},
461 Messages: []anthropic.MessageParam{
462 anthropic.NewUserMessage(anthropic.NewTextBlock("What is a quaternion?")),
463 },
469464 Model: anthropic.ModelClaudeOpus5_5,
470465})
471466if err != nil {
from line 494
499494 context.TODO(),
500495 anthropic.MessageNewParams{
501496 MaxTokens: 1024,
502 Messages: []anthropic.MessageParam{{
503 Content: []anthropic.ContentBlockParamUnion{{
504 OfText: &anthropic.TextBlockParam{
505 Text: "What is a quaternion?",
506 },
507 }},
508 Role: anthropic.MessageParamRoleUser,
509 }},
497 Messages: []anthropic.MessageParam{
498 anthropic.NewUserMessage(anthropic.NewTextBlock("What is a quaternion?")),
499 },
510500 Model: anthropic.ModelClaudeOpus5_5,
511501 },
512502 option.WithMaxRetries(5),
from line 518
528518 ctx,
529519 anthropic.MessageNewParams{
530520 MaxTokens: 1024,
531 Messages: []anthropic.MessageParam{{
532 Content: []anthropic.ContentBlockParamUnion{{
533 OfText: &anthropic.TextBlockParam{
534 Text: "What is a quaternion?",
535 },
536 }},
537 Role: anthropic.MessageParamRoleUser,
538 }},
521 Messages: []anthropic.MessageParam{
522 anthropic.NewUserMessage(anthropic.NewTextBlock("What is a quaternion?")),
523 },
539524 Model: anthropic.ModelClaudeOpus5_5,
540525 },
541526 // This sets the per-retry timeout
from line 614
629614 
630615The request option `option.WithDebugLog(nil)` might be helpful while debugging.
631616 
632See the [full list of request options](https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/option).
617See the [full list of request options](https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/v2/option).
633618 
634619## HTTP client customization
635620 
from line 634
649634 
650635The Go SDK supports the following platforms:
651636 
652* **Agent Platform:** `import "github.com/anthropics/anthropic-sdk-go/vertex"`. Use `vertex.WithGoogleAuth(ctx, region, projectID)` or `vertex.WithCredentials(ctx, region, projectID, creds)`.
653* **Bedrock:** `import "github.com/anthropics/anthropic-sdk-go/bedrock"`. Use `bedrock.NewMantleClient` for the Messages-API Bedrock endpoint (streams over SSE), or `bedrock.WithLoadDefaultConfig(ctx)` / `bedrock.WithConfig(cfg)` (`bedrock-runtime` path). Importing the `bedrock` package globally registers a decoder for `application/vnd.amazon.eventstream` with the SDK's streaming layer (through package `init()`). This applies whether you use the `bedrock-runtime` `WithConfig`/`WithLoadDefaultConfig` path or `NewMantleClient`.
654* **Claude Platform on AWS:** `import anthropicaws "github.com/anthropics/anthropic-sdk-go/aws"`. Use `anthropicaws.NewClient(ctx, cfg)` with an `anthropicaws.ClientConfig` value to construct a client; set `WorkspaceID` on the config or the `ANTHROPIC_AWS_WORKSPACE_ID` environment variable. The `anthropicaws` import alias avoids a name collision with `github.com/aws/aws-sdk-go-v2/aws` when both are imported. Available in beta.
655* **Foundry:** `import "github.com/anthropics/anthropic-sdk-go/foundry"`. Use `foundry.NewClient(cfg)` with a `foundry.ClientConfig` value to construct a client; set `APIKey` (or `AzureADTokenProvider` for Microsoft Entra ID) and `Resource` on the config, or the `ANTHROPIC_FOUNDRY_API_KEY` and `ANTHROPIC_FOUNDRY_RESOURCE` environment variables.
637* **Agent Platform:** `import "github.com/anthropics/anthropic-sdk-go/v2/vertex"`. Use `vertex.WithGoogleAuth(ctx, region, projectID)` or `vertex.WithCredentials(ctx, region, projectID, creds)`.
638* **Bedrock:** `import "github.com/anthropics/anthropic-sdk-go/v2/bedrock"`. Use `bedrock.NewMantleClient` for the Messages-API Bedrock endpoint (streams over SSE), or `bedrock.WithLoadDefaultConfig(ctx)` / `bedrock.WithConfig(cfg)` (`bedrock-runtime` path). Importing the `bedrock` package globally registers a decoder for `application/vnd.amazon.eventstream` with the SDK's streaming layer (through package `init()`). This applies whether you use the `bedrock-runtime` `WithConfig`/`WithLoadDefaultConfig` path or `NewMantleClient`.
639* **Claude Platform on AWS:** `import anthropicaws "github.com/anthropics/anthropic-sdk-go/v2/aws"`. Use `anthropicaws.NewClient(ctx, cfg)` with an `anthropicaws.ClientConfig` value to construct a client; set `WorkspaceID` on the config or the `ANTHROPIC_AWS_WORKSPACE_ID` environment variable. The `anthropicaws` import alias avoids a name collision with `github.com/aws/aws-sdk-go-v2/aws` when both are imported. Available in beta.
640* **Foundry:** `import "github.com/anthropics/anthropic-sdk-go/v2/foundry"`. Use `foundry.NewClient(cfg)` with a `foundry.ClientConfig` value to construct a client; set `APIKey` (or `AzureADTokenProvider` for Microsoft Entra ID) and `Resource` on the config, or the `ANTHROPIC_FOUNDRY_API_KEY` and `ANTHROPIC_FOUNDRY_RESOURCE` environment variables.
656641 
657642Use `bedrock.NewMantleClient` for new projects; `bedrock.WithLoadDefaultConfig`/`WithConfig` remain for existing applications using the Bedrock `InvokeModel` API.
658643 
from line 654
669654 context.TODO(),
670655 anthropic.MessageNewParams{
671656 MaxTokens: 1024,
672 Messages: []anthropic.MessageParam{{
673 Content: []anthropic.ContentBlockParamUnion{{
674 OfText: &anthropic.TextBlockParam{
675 Text: "What is a quaternion?",
676 },
677 }},
678 Role: anthropic.MessageParamRoleUser,
679 }},
657 Messages: []anthropic.MessageParam{
658 anthropic.NewUserMessage(anthropic.NewTextBlock("What is a quaternion?")),
659 },
680660 Model: anthropic.ModelClaudeOpus5_5,
681661 },
682662 option.WithResponseInto(&response),
from line 730
750730## Additional resources
751731 
752732* [GitHub repository](https://github.com/anthropics/anthropic-sdk-go)
753* [Go package documentation](https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go)
733* [Go package documentation](https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/v2)
754734* [API reference](https://platform.claude.com/docs/en/api/overview)
755735* [Streaming Messages](https://platform.claude.com/docs/en/build-with-claude/streaming)
756736 
Feedback