Repository Public
1---2title: Go SDK3url: https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/go4description: Install and configure the Anthropic Go SDK with context-based cancellation and functional options5---67The Anthropic Go library provides convenient access to the Claude API from applications written in Go.89<Info>10 For API feature documentation with code examples, see the [API reference](https://platform.claude.com/docs/en/api/overview). This page covers Go-specific SDK features and configuration.11</Info>1213## Installation1415```go16import (17 "github.com/anthropics/anthropic-sdk-go" // imported as anthropic18)19```2021Install with `go get`:2223```bash24go get github.com/anthropics/anthropic-sdk-go25```2627## Requirements2829This library requires Go 1.24+.3031## Usage3233```go34package main3536import (37 "context"38 "fmt"3940 "github.com/anthropics/anthropic-sdk-go"41 "github.com/anthropics/anthropic-sdk-go/option"42)4344func main() {45 client := anthropic.NewClient(46 option.WithAPIKey("my-anthropic-api-key"), // defaults to os.LookupEnv("ANTHROPIC_API_KEY")47 )48 message, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{49 MaxTokens: 1024,50 Messages: []anthropic.MessageParam{51 anthropic.NewUserMessage(anthropic.NewTextBlock("What is a quaternion?")),52 },53 Model: anthropic.ModelClaudeOpus5,54 })55 if err != nil {56 panic(err.Error())57 }58 for _, block := range message.Content {59 if textBlock, ok := block.AsAny().(anthropic.TextBlock); ok {60 fmt.Println(textBlock.Text)61 }62 }63}64```6566For authentication options including Workload Identity Federation, see [Authentication](https://platform.claude.com/docs/en/manage-claude/authentication). If your API key is a [personal or service account key](https://platform.claude.com/docs/en/manage-claude/authentication#key-types) with access to multiple workspaces, set the workspace ID in the `anthropic-workspace-id` request header; [Select a workspace](https://platform.claude.com/docs/en/manage-claude/authentication#select-a-workspace) shows the per-request option for this SDK.6768<AccordionGroup>69 <Accordion title="Conversations">70 ```go71 messages := []anthropic.MessageParam{72 anthropic.NewUserMessage(anthropic.NewTextBlock("What is my first name?")),73 }7475 message, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{76 Model: anthropic.ModelClaudeOpus5,77 Messages: messages,78 MaxTokens: 1024,79 })80 if err != nil {81 panic(err)82 }8384 fmt.Printf("%+v\n", message.Content)8586 messages = append(messages, message.ToParam())87 messages = append(messages, anthropic.NewUserMessage(88 anthropic.NewTextBlock("My full name is John Doe"),89 ))9091 message, err = client.Messages.New(context.TODO(), anthropic.MessageNewParams{92 Model: anthropic.ModelClaudeOpus5,93 Messages: messages,94 MaxTokens: 1024,95 })96 if err != nil {97 panic(err)98 }99100 fmt.Printf("%+v\n", message.Content)101 ```102 </Accordion>103104 <Accordion title="System prompts">105 ```go106 message, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{107 Model: anthropic.ModelClaudeOpus5,108 MaxTokens: 1024,109 System: []anthropic.TextBlockParam{110 {Text: "Be very serious at all times."},111 },112 Messages: messages,113 })114 if err != nil {115 panic(err)116 }117 fmt.Printf("%+v\n", message.Content)118 ```119 </Accordion>120121 <Accordion title="Streaming">122 ```go123 content := "What is a quaternion?"124125 stream := client.Messages.NewStreaming(context.TODO(), anthropic.MessageNewParams{126 Model: anthropic.ModelClaudeOpus5,127 MaxTokens: 1024,128 Messages: []anthropic.MessageParam{129 anthropic.NewUserMessage(anthropic.NewTextBlock(content)),130 },131 })132133 message := anthropic.Message{}134 for stream.Next() {135 event := stream.Current()136 err := message.Accumulate(event)137 if err != nil {138 panic(err)139 }140141 switch eventVariant := event.AsAny().(type) {142 case anthropic.ContentBlockDeltaEvent:143 switch deltaVariant := eventVariant.Delta.AsAny().(type) {144 case anthropic.TextDelta:145 print(deltaVariant.Text)146 }147148 }149 }150151 if stream.Err() != nil {152 panic(stream.Err())153 }154 ```155 </Accordion>156157 <Accordion title="Tool calling">158 ```go159 messages := []anthropic.MessageParam{160 anthropic.NewUserMessage(anthropic.NewTextBlock(content)),161 }162163 toolParams := []anthropic.ToolParam{164 {165 Name: "get_coordinates",166 Description: anthropic.String("Accepts a place as an address, then returns the latitude and longitude coordinates."),167 InputSchema: GetCoordinatesInputSchema,168 },169 }170 tools := make([]anthropic.ToolUnionParam, len(toolParams))171 for i, toolParam := range toolParams {172 tools[i] = anthropic.ToolUnionParam{OfTool: &toolParam}173 }174175 for {176 message, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{177 Model: anthropic.ModelClaudeOpus5,178 MaxTokens: 1024,179 Messages: messages,180 Tools: tools,181 })182183 if err != nil {184 panic(err)185 }186187 print(color("[assistant]: "))188 for _, block := range message.Content {189 switch block := block.AsAny().(type) {190 case anthropic.TextBlock:191 println(block.Text)192 println()193 case anthropic.ToolUseBlock:194 inputJSON, _ := json.Marshal(block.Input)195 println(block.Name + ": " + string(inputJSON))196 println()197 }198 }199200 messages = append(messages, message.ToParam())201 toolResults := []anthropic.ContentBlockParamUnion{}202203 for _, block := range message.Content {204 switch variant := block.AsAny().(type) {205 case anthropic.ToolUseBlock:206 print(color("[user (" + block.Name + ")]: "))207208 var response interface{}209 switch block.Name {210 case "get_coordinates":211 var input struct {212 Location string `json:"location"`213 }214215 err := json.Unmarshal([]byte(variant.JSON.Input.Raw()), &input)216 if err != nil {217 panic(err)218 }219220 response = GetCoordinates(input.Location)221 }222223 b, err := json.Marshal(response)224 if err != nil {225 panic(err)226 }227228 println(string(b))229230 toolResults = append(toolResults, anthropic.NewToolResultBlock(block.ID, string(b), false))231 }232233 }234 if len(toolResults) == 0 {235 break236 }237 messages = append(messages, anthropic.NewUserMessage(toolResults...))238 }239 ```240 </Accordion>241</AccordionGroup>242243## Request fields244245The anthropic library uses the [`omitzero`](https://tip.golang.org/doc/go1.24#encodingjsonpkgencodingjson) semantics from the Go 1.24+ `encoding/json` release for request fields.246247Required primitive fields (such as `int64` or `string`) feature the tag `` `json:"...,required"` ``. These fields are always serialized, even their zero values.248249Optional primitive types are wrapped in a `param.Opt[T]`. These fields can be set with the provided constructors, such as `anthropic.String(string)` or `anthropic.Int(int64)`.250251Any `param.Opt[T]`, map, slice, struct or string enum uses the tag `` `json:"...,omitzero"` ``. Its zero value is considered omitted.252253The `param.IsOmitted(any)` function can confirm the presence of any `omitzero` field.254255```go256p := anthropic.ExampleParams{257 ID: "id_xxx", // required property258 Name: anthropic.String("..."), // optional property259260 Point: anthropic.Point{261 X: 0, // required field will serialize as 0262 Y: anthropic.Int(1), // optional field will serialize as 1263 // ... omitted non-required fields will not be serialized264 },265266 Origin: anthropic.Origin{}, // the zero value of [Origin] is considered omitted267}268```269270To send `null` instead of a `param.Opt[T]`, use `param.Null[T]()`. To send `null` instead of a struct `T`, use `param.NullStruct[T]()`.271272```go273p.Name = param.Null[string]() // 'null' instead of string274p.Point = param.NullStruct[Point]() // 'null' instead of struct275276param.IsNull(p.Name) // true277param.IsNull(p.Point) // true278```279280Request structs contain a `.SetExtraFields(map[string]any)` method which can send non-conforming fields in the request body. Extra fields overwrite any struct fields with a matching key.281282<Warning>283 For security reasons, only use `SetExtraFields` with trusted data.284</Warning>285286To send a custom value instead of a struct, use the generic function `param.Override` (for example, `param.Override[anthropic.FooParams](12)`).287288```go289// In cases where the API specifies a given type,290// but you want to send something else, use [SetExtraFields]:291p.SetExtraFields(map[string]any{292 "x": 0.01, // send "x" as a float instead of int293})294295// Send a number instead of an object296custom := param.Override[anthropic.FooParams](12)297```298299### Request unions300301Unions are represented as a struct with fields prefixed by "Of" for each of its variants, only one field can be non-zero. The non-zero field will be serialized.302303Subproperties of the union can be accessed through methods on the union struct. These methods return a mutable pointer to the underlying data, if present.304305```go306// Only one field can be non-zero, use param.IsOmitted() to check if a field is set307type AnimalUnionParam struct {308 OfCat *Cat `json:",omitzero,inline"`309 OfDog *Dog `json:",omitzero,inline"`310}311312animal := AnimalUnionParam{313 OfCat: &Cat{314 Name: "Whiskers",315 Owner: PersonParam{316 Address: AddressParam{Street: "3333 Coyote Hill Rd", ZipCode: 0},317 },318 },319}320321// Mutating a field322if address := animal.GetOwner().GetAddress(); address != nil {323 address.ZipCode = 94304324}325```326327### Deserializing params328329<Note>330 `param.SetJSON` requires SDK v1.20.0 or later.331</Note>332333Param types (types ending in `Param`, such as `MessageNewParams` or `ToolUnionParam`) are designed for outgoing requests only. They marshal correctly to JSON but do not fully support round-trip deserialization. If you unmarshal raw JSON into a param struct, typed union fields like `OfBashTool20250124` will be nil even when the underlying JSON is valid.334335If you need to reconstruct params from raw JSON (for example, from a database, middleware, or a previous request), call `UnmarshalJSON` to populate non-union fields, then use `param.SetJSON` to attach the raw bytes for correct re-serialization:336337```go338// Serialize params (for example, for storage or forwarding)339b, err := json.Marshal(original)340if err != nil {341 panic(err)342}343344// Later, reconstruct params from the stored JSON345var params anthropic.MessageNewParams346if err := params.UnmarshalJSON(b); err != nil {347 panic(err)348}349param.SetJSON(b, ¶ms)350351// params.Model and other scalar fields are populated by UnmarshalJSON.352// params.Tools[0].OfBashTool20250124 is nil (the union limitation),353// but the raw JSON is preserved. When params is marshaled again354// for the API call, the tools serialize correctly.355b2, _ := json.Marshal(params)356fmt.Println(string(b) == string(b2)) // true357```358359For this use case, `param.SetJSON` (available since v1.20.0) is preferred over the more general `param.Override[T](any)` because it doesn't require spelling out the type parameter and makes the round-trip intent explicit.360361## Response objects362363All fields in response structs are ordinary value types (not pointers or wrappers). Response structs also include a special `JSON` field containing metadata about each property.364365```go366type Animal struct {367 Name string `json:"name,nullable"`368 Owners int `json:"owners"`369 Age int `json:"age"`370 JSON struct {371 Name respjson.Field372 Owners respjson.Field373 Age respjson.Field374 ExtraFields map[string]respjson.Field375 } `json:"-"`376}377```378379To handle optional data, use the `.Valid()` method on the JSON field. `.Valid()` returns true when the field is present, non-`null`, and was unmarshaled successfully.380381If `.Valid()` is false, the corresponding field will be its zero value.382383```go384raw := `{"owners": 1, "name": null}`385386var res Animal387json.Unmarshal([]byte(raw), &res)388389// Accessing regular fields390391res.Owners // 1392res.Name // ""393res.Age // 0394395// Optional field checks396397res.JSON.Owners.Valid() // true398res.JSON.Name.Valid() // false399res.JSON.Age.Valid() // false400401// Raw JSON values402403res.JSON.Owners.Raw() // "1"404res.JSON.Name.Raw() == "null" // true405res.JSON.Name.Raw() == respjson.Null // true406res.JSON.Age.Raw() == "" // true407res.JSON.Age.Raw() == respjson.Omitted // true408```409410These `.JSON` structs also include an `ExtraFields` map containing any properties in the json response that were not specified in the struct. This can be useful for API features not yet present in the SDK.411412```go413body := res.JSON.ExtraFields["my_unexpected_field"].Raw()414```415416### Response unions417418In responses, unions are represented by a flattened struct containing all possible fields from each of the object variants. To convert it to a variant use the `.AsFooVariant()` method or the `.AsAny()` method if present.419420If a response value union contains primitive values, primitive fields will be alongside the properties but prefixed with `Of` and feature the tag `json:"...,inline"`.421422```go423type AnimalUnion struct {424 // From variants [Dog], [Cat]425 Owner Person `json:"owner"`426 // From variant [Dog]427 DogBreed string `json:"dog_breed"`428 // From variant [Cat]429 CatBreed string `json:"cat_breed"`430 // ...431432 JSON struct {433 Owner respjson.Field434 // ...435 } `json:"-"`436}437438// If animal variant439if animal.Owner.Address.ZipCode == "" {440 panic("missing zip code")441}442443// Switch on the variant444switch variant := animal.AsAny().(type) {445case Dog:446case Cat:447default:448 panic("unexpected type")449}450```451452## Error handling453454When the API returns a non-success status code, the SDK returns an error with type `*anthropic.Error`. This contains the `StatusCode`, `*http.Request`, and `*http.Response` values of the request, along with the JSON of the error body (much like other response objects in the SDK). The error also includes the `RequestID` from the response headers, which is useful for troubleshooting with Anthropic support.455456To handle errors, use the `errors.As` pattern:457458```go459_, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{460 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 }},469 Model: anthropic.ModelClaudeOpus5,470})471if err != nil {472 var apierr *anthropic.Error473 if errors.As(err, &apierr) {474 println("Request ID:", apierr.RequestID)475 println(string(apierr.DumpRequest(true))) // Prints the serialized HTTP request476 println(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response477 }478 panic(err.Error()) // POST "/v1/messages": 400 Bad Request (Request-ID: req_xxx) { ... }479}480```481482When other errors occur, they are returned unwrapped; for example, if HTTP transport fails, you might receive `*url.Error` wrapping `*net.OpError`.483484## Retries485486Certain errors will be 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.487488You can use the `WithMaxRetries` option to configure or disable this:489490```go491// Configure the default for all requests:492client := anthropic.NewClient(493 option.WithMaxRetries(0), // default is 2494)495496// Override per-request:497// ...498 client.Messages.New(499 context.TODO(),500 anthropic.MessageNewParams{501 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 }},510 Model: anthropic.ModelClaudeOpus5,511 },512 option.WithMaxRetries(5),513 )514```515516## Timeouts517518Non-streaming Messages requests time out after 10 minutes by default; other requests have no default timeout. Use context to configure a timeout for a request lifecycle.519520Note that if a request is [retried](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/go#retries), the context timeout does not start over. To set a per-retry timeout, use `option.WithRequestTimeout()`.521522```go523// This sets the timeout for the request, including all the retries.524ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)525defer cancel()526// ...527 client.Messages.New(528 ctx,529 anthropic.MessageNewParams{530 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 }},539 Model: anthropic.ModelClaudeOpus5,540 },541 // This sets the per-retry timeout542 option.WithRequestTimeout(20*time.Second),543 )544```545546## Long requests547548<Warning>549 Consider using the streaming Messages API for longer running requests.550</Warning>551552Avoid setting a large `MaxTokens` value without using streaming as some networks may drop idle connections after a certain period of time, which can cause the request to fail or [timeout](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/go#timeouts) without receiving a response from Anthropic.553554This SDK will also return an error if a non-streaming request is expected to be above roughly 10 minutes long. Calling `.Messages.NewStreaming()` or [setting a custom timeout](https://platform.claude.com/docs/en/cli-sdks-libraries/sdks/go#timeouts) disables this error.555556## File uploads557558Request parameters that correspond to file uploads in multipart requests are typed as `io.Reader`. The contents of the `io.Reader` will by default be sent as a multipart form part with the file name of "anonymous\_file" and content-type of "application/octet-stream", so the recommended approach is to specify a custom content-type with the `anthropic.File(reader io.Reader, filename string, contentType string)` helper, which wraps any `io.Reader` with the appropriate file name and content type.559560```go561// A file from the file system562file, err := os.Open("/path/to/file.json")563anthropic.FileUploadParams{564 File: anthropic.File(file, "custom-name.json", "application/json"),565}566567// A file from a string568anthropic.FileUploadParams{569 File: anthropic.File(strings.NewReader("my file contents"), "custom-name.json", "application/json"),570}571```572573The file name and content-type can also be customized by implementing `Name() string` or `ContentType() string` on the run-time type of `io.Reader`. Note that `os.File` implements `Name() string`, so a file returned by `os.Open` will be sent with the file name on disk.574575## Pagination576577This library provides some conveniences for working with paginated list endpoints.578579You can use `.ListAutoPaging()` methods to iterate through items across all pages:580581```go582iter := client.Messages.Batches.ListAutoPaging(context.TODO(), anthropic.MessageBatchListParams{583 Limit: anthropic.Int(20),584})585// Automatically fetches more pages as needed.586for iter.Next() {587 messageBatch := iter.Current()588 fmt.Println(messageBatch.ID)589}590if err := iter.Err(); err != nil {591 panic(err.Error())592}593```594595Or you can use simple `.List()` methods to fetch a single page and receive a standard response object with additional helper methods like `.GetNextPage()`:596597```go598page, err := client.Messages.Batches.List(context.TODO(), anthropic.MessageBatchListParams{599 Limit: anthropic.Int(20),600})601for page != nil {602 for _, batch := range page.Data {603 fmt.Println(batch.ID)604 }605 page, err = page.GetNextPage()606}607if err != nil {608 panic(err.Error())609}610```611612## RequestOptions613614This library uses the functional options pattern. Functions defined in the `option` package return a `RequestOption`, which is a closure that mutates a `RequestConfig`. These options can be supplied to the client or at individual requests. For example:615616```go617client := anthropic.NewClient(618 // Adds a header to every request made by the client619 option.WithHeader("X-Some-Header", "custom_header_info"),620)621622client.Messages.New(context.TODO(), // ...,623 // Override the header624 option.WithHeader("X-Some-Header", "some_other_custom_header_info"),625 // Add an undocumented field to the request body, using sjson syntax626 option.WithJSONSet("some.json.path", map[string]string{"my": "object"}),627)628```629630The request option `option.WithDebugLog(nil)` may be helpful while debugging.631632See the [full list of request options](https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go/option).633634## HTTP client customization635636For request middleware (`option.WithMiddleware`) and replacing the default `http.Client` (`option.WithHTTPClient`), see [SDK middleware](https://platform.claude.com/docs/en/cli-sdks-libraries/middleware).637638## Platform integrations639640<Note>641 For detailed platform setup guides with code examples, see:642643 * [Amazon Bedrock](https://platform.claude.com/docs/en/build-with-claude/claude-in-amazon-bedrock)644 * [Amazon Bedrock (Opus 4.6 and earlier)](https://platform.claude.com/docs/en/build-with-claude/claude-on-amazon-bedrock-legacy)645 * [Claude Platform on AWS](https://platform.claude.com/docs/en/build-with-claude/claude-platform-on-aws)646 * [Google Cloud](https://platform.claude.com/docs/en/build-with-claude/claude-on-vertex-ai)647</Note>648649The Go SDK supports the following platforms:650651* **Agent Platform:** `import "github.com/anthropics/anthropic-sdk-go/vertex"`. Use `vertex.WithGoogleAuth(ctx, region, projectID)` or `vertex.WithCredentials(ctx, region, projectID, creds)`.652* **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`.653* **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.654* **Foundry:** Not currently supported in the Go SDK. See [Claude in Microsoft Foundry](https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry) for supported SDKs.655656Use `bedrock.NewMantleClient` for new projects; `bedrock.WithLoadDefaultConfig`/`WithConfig` remain for existing applications using the Bedrock `InvokeModel` API.657658## Advanced usage659660### Accessing raw response data (for example, response headers)661662You can access the raw HTTP response data by using the `option.WithResponseInto()` request option. This is useful when you need to examine response headers, status codes, or other details.663664```go665// Create a variable to store the HTTP response666var response *http.Response667message, err := client.Messages.New(668 context.TODO(),669 anthropic.MessageNewParams{670 MaxTokens: 1024,671 Messages: []anthropic.MessageParam{{672 Content: []anthropic.ContentBlockParamUnion{{673 OfText: &anthropic.TextBlockParam{674 Text: "What is a quaternion?",675 },676 }},677 Role: anthropic.MessageParamRoleUser,678 }},679 Model: anthropic.ModelClaudeOpus5,680 },681 option.WithResponseInto(&response),682)683if err != nil {684 // handle error685}686fmt.Printf("%+v\n", message.Content)687688fmt.Printf("Status Code: %d\n", response.StatusCode)689fmt.Printf("Headers: %+#v\n", response.Header)690```691692### Making custom/undocumented requests693694This library is typed for convenient access to the documented API. If you need to access undocumented endpoints, params, or response properties, the library can still be used.695696#### Undocumented endpoints697698To make requests to undocumented endpoints, you can use `client.Get`, `client.Post`, and other HTTP verbs. `RequestOptions` on the client, such as retries, will be respected when making these requests.699700```go701var (702 // params can be an io.Reader, a []byte, an encoding/json serializable object,703 // or a "...Params" struct defined in this library.704 params map[string]any705706 // result can be an []byte, *http.Response, a encoding/json deserializable object,707 // or a model defined in this library.708 result *http.Response709)710err := client.Post(context.Background(), "/unspecified", params, &result)711if err != nil {712 // ...713}714```715716#### Undocumented request params717718To make requests using undocumented parameters, you may use either the `option.WithQuerySet()` or the `option.WithJSONSet()` methods.719720```go721params := FooNewParams{722 ID: "id_xxxx",723 Data: FooNewParamsData{724 FirstName: anthropic.String("John"),725 },726}727client.Foo.New(context.Background(), params, option.WithJSONSet("data.last_name", "Doe"))728```729730#### Undocumented response properties731732To access undocumented response properties, you may either access the raw JSON of the response as a string with `result.JSON.RawJSON()`, or get the raw JSON of a particular field on the result with `result.JSON.Foo.Raw()`.733734Any fields that are not present on the response struct are saved and can be accessed through `result.JSON.ExtraFields`, which is a `map[string]respjson.Field`.735736## Semantic versioning737738This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backward-incompatible changes may be released as minor versions:7397401. Changes to library internals that are technically public but not intended or documented for external use.7412. Changes that aren't expected to impact the vast majority of users in practice.742743Backward-compatibility is taken seriously to ensure you can rely on a smooth upgrade experience.744745Your feedback is welcome; open an [issue](https://github.com/anthropics/anthropic-sdk-go/issues) with questions, bugs, or suggestions.746747## Additional resources748749* [GitHub repository](https://github.com/anthropics/anthropic-sdk-go)750* [Go package documentation](https://pkg.go.dev/github.com/anthropics/anthropic-sdk-go)751* [API reference](https://platform.claude.com/docs/en/api/overview)752* [Streaming Messages](https://platform.claude.com/docs/en/build-with-claude/streaming)753