go changedcli-sdks-libraries/sdks/go
Nearest release: v2.1.300, published 2 hours after 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+7added
Lines−7removed
From line
242
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits11to this page, all time
The whole hunk
from line 242, old and new numbered
/
from line 242
242242
243243## Request fields
244244
245The 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.
245The 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.
246246
247247Required primitive fields (such as `int64` or `string`) feature the tag `` `json:"...,required"` ``. These fields are always serialized, even their zero values.
248248
249249Optional 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)`.
250250
251Any `param.Opt[T]`, map, slice, struct or string enum uses the tag `` `json:"...,omitzero"` ``. Its zero value is considered omitted.
251Any `param.Opt[T]`, map, slice, struct, or string enum uses the tag `` `json:"...,omitzero"` ``. Its zero value is considered omitted.
252252
253253The `param.IsOmitted(any)` function can confirm the presence of any `omitzero` field.
254254
from line 298
298298
299299### Request unions
300300
301Unions 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.
301Unions 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.
302302
303303Subproperties of the union can be accessed through methods on the union struct. These methods return a mutable pointer to the underlying data, if present.
304304
from line 407
407407res.JSON.Age.Raw() == respjson.Omitted // true
408408```
409409
410These `.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.
410These `.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.
411411
412412```go
413413body := res.JSON.ExtraFields["my_unexpected_field"].Raw()
from line 555
555555
556556## File uploads
557557
558Request 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.
558Request 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.
559559
560560```go
561561// A file from the file system
from line 570
570570}
571571```
572572
573The 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.
573The 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.
574574
575575## Pagination
576576
from line 741
7417411. Changes to library internals that are technically public but not intended or documented for external use.
7427422. Changes that aren't expected to impact the vast majority of users in practice.
743743
744Backward-compatibility is taken seriously to ensure you can rely on a smooth upgrade experience.
744Backward compatibility is taken seriously to ensure you can rely on a smooth upgrade experience.
745745
746746Your feedback is welcome; open an [issue](https://github.com/anthropics/anthropic-sdk-go/issues) with questions, bugs, or suggestions.
747747
No line in this hunk matches that.