anthropic

package module
v0.2.0-beta.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2025 License: MIT Imports: 23 Imported by: 52

README

Anthropic Go API Library

Go Reference

The Anthropic Go library provides convenient access to the Anthropic REST API from applications written in Go. The full API of this library can be found in api.md.

[!WARNING] The latest version of this package uses a new design with significant breaking changes. Please refer to the migration guide for more information on how to update your code.

Installation

import (
	"github.com/anthropics/anthropic-sdk-go" // imported as anthropic
)

Or to pin the version:

go get -u 'github.com/anthropics/anthropic-sdk-go@v0.2.0-beta.3'

Requirements

This library requires Go 1.18+.

Usage

The full API of this library can be found in api.md.

package main

import (
	"context"
	"fmt"

	"github.com/anthropics/anthropic-sdk-go"
	"github.com/anthropics/anthropic-sdk-go/option"
)

func main() {
	client := anthropic.NewClient(
		option.WithAPIKey("my-anthropic-api-key"), // defaults to os.LookupEnv("ANTHROPIC_API_KEY")
	)
	message, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
		MaxTokens: 1024,
		Messages: []anthropic.MessageParam{{
			Role: anthropic.MessageParamRoleUser,
			Content: []anthropic.ContentBlockParamUnion{{
				OfRequestTextBlock: &anthropic.TextBlockParam{Text: "What is a quaternion?"},
			}},
		}},
		Model: anthropic.ModelClaude3_7SonnetLatest,
	})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", message.Content)
}

Conversations
messages := []anthropic.MessageParam{
    anthropic.NewUserMessage(anthropic.NewTextBlock("What is my first name?")),
}

message, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
    Model:     anthropic.ModelClaude3_7SonnetLatest,
    Messages:  messages,
    MaxTokens: 1024,
})
if err != nil {
    panic(err)
}

fmt.Printf("%+v\n", message.Content)

messages = append(messages, message.ToParam())
messages = append(messages, anthropic.NewUserMessage(
    anthropic.NewTextBlock("My full name is John Doe"),
))

message, err = client.Messages.New(context.TODO(), anthropic.MessageNewParams{
    Model:     anthropic.ModelClaude3_7SonnetLatest,
    Messages:  messages,
    MaxTokens: 1024,
})

fmt.Printf("%+v\n", message.Content)
System prompts
message, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
    Model:     anthropic.ModelClaude3_7SonnetLatest,
    MaxTokens: 1024,
    System: []anthropic.TextBlockParam{
        {Text: "Be very serious at all times."},
    },
    Messages: messages,
})
Streaming
content := "What is a quaternion?"

stream := client.Messages.NewStreaming(context.TODO(), anthropic.MessageNewParams{
    Model:     anthropic.ModelClaude3_7SonnetLatest,
    MaxTokens: 1024,
    Messages: []anthropic.MessageParam{
        anthropic.NewUserMessage(anthropic.NewTextBlock(content)),
    },
})

message := anthropic.Message{}
for stream.Next() {
    event := stream.Current()
    err := message.Accumulate(event)
    if err != nil {
        panic(err)
    }

    switch eventVariant := event.AsAny().(type) {
        case anthropic.ContentBlockDeltaEvent:
        switch deltaVariant := eventVariant.Delta.AsAny().(type) {
        case anthropic.TextDelta:
            print(deltaVariant.Text)
        }

    }

    if stream.Err() != nil {
        panic(stream.Err())
    }
}
Tool calling
package main

import (
	"context"
	"encoding/json"
	"fmt"

	"github.com/anthropics/anthropic-sdk-go"
	"github.com/invopop/jsonschema"
)

func main() {
	client := anthropic.NewClient()

	content := "Where is San Francisco?"

	println("[user]: " + content)

	messages := []anthropic.MessageParam{
		anthropic.NewUserMessage(anthropic.NewTextBlock(content)),
	}

	toolParams := []anthropic.ToolParam{
		{
			Name:        "get_coordinates",
			Description: anthropic.String("Accepts a place as an address, then returns the latitude and longitude coordinates."),
			InputSchema: GetCoordinatesInputSchema,
		},
	}
	tools := make([]anthropic.ToolUnionParam, len(toolParams))
	for i, toolParam := range toolParams {
		tools[i] = anthropic.ToolUnionParam{OfTool: &toolParam}
	}

	for {
		message, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
			Model:     anthropic.ModelClaude3_7SonnetLatest,
			MaxTokens: 1024,
			Messages:  messages,
			Tools:     tools,
		})

		if err != nil {
			panic(err)
		}

		print(color("[assistant]: "))
		for _, block := range message.Content {
			switch block := block.AsAny().(type) {
			case anthropic.TextBlock:
				println(block.Text)
				println()
			case anthropic.ToolUseBlock:
				inputJSON, _ := json.Marshal(block.Input)
				println(block.Name + ": " + string(inputJSON))
				println()
			}
		}

		messages = append(messages, message.ToParam())
		toolResults := []anthropic.ContentBlockParamUnion{}

		for _, block := range message.Content {
			switch variant := block.AsAny().(type) {
			case anthropic.ToolUseBlock:
				print(color("[user (" + block.Name + ")]: "))

				var response interface{}
				switch block.Name {
				case "get_coordinates":
					var input struct {
						Location string `json:"location"`
					}

					err := json.Unmarshal([]byte(variant.JSON.Input.Raw()), &input)
					if err != nil {
						panic(err)
					}

					response = GetCoordinates(input.Location)
				}

				b, err := json.Marshal(response)
				if err != nil {
					panic(err)
				}

				println(string(b))

				toolResults = append(toolResults, anthropic.NewToolResultBlock(block.ID, string(b), false))
			}

		}
		if len(toolResults) == 0 {
			break
		}
		messages = append(messages, anthropic.NewUserMessage(toolResults...))
	}
}

type GetCoordinatesInput struct {
	Location string `json:"location" jsonschema_description:"The location to look up."`
}

var GetCoordinatesInputSchema = GenerateSchema[GetCoordinatesInput]()

type GetCoordinateResponse struct {
	Long float64 `json:"long"`
	Lat  float64 `json:"lat"`
}

func GetCoordinates(location string) GetCoordinateResponse {
	return GetCoordinateResponse{
		Long: -122.4194,
		Lat:  37.7749,
	}
}

func GenerateSchema[T any]() anthropic.ToolInputSchemaParam {
	reflector := jsonschema.Reflector{
		AllowAdditionalProperties: false,
		DoNotReference:            true,
	}
	var v T

	schema := reflector.Reflect(v)

	return anthropic.ToolInputSchemaParam{
		Properties: schema.Properties,
	}
}

func color(s string) string {
	return fmt.Sprintf("\033[1;%sm%s\033[0m", "33", s)
}
Request fields

The anthropic library uses the omitzero semantics from the Go 1.24+ encoding/json release for request fields.

Required primitive fields (int64, string, etc.) feature the tag `json:...,required`. These fields are always serialized, even their zero values.

Optional primitive types are wrapped in a param.Opt[T]. Use the provided constructors set param.Opt[T] fields such as anthropic.String(string), anthropic.Int(int64), etc.

Optional primitives, maps, slices and structs and string enums (represented as string) always feature the tag `json:"...,omitzero"`. Their zero values are considered omitted.

Any non-nil slice of length zero will serialize as an empty JSON array, "[]". Similarly, any non-nil map with length zero with serialize as an empty JSON object, "{}".

To send null instead of an param.Opt[T], use param.NullOpt[T](). To send null instead of a struct, use param.NullObj[T](), where T is a struct. To send a custom value instead of a struct, use param.OverrideObj[T](value).

To override request structs contain a .WithExtraFields(map[string]any) method which can be used to send non-conforming fields in the request body. Extra fields overwrite any struct fields with a matching key, so only use with trusted data.

params := FooParams{
	ID: "id_xxx",                          // required property
	Name: anthropic.String("hello"), // optional property
	Description: param.NullOpt[string](),  // explicit null property

	Point: anthropic.Point{
		X: 0, // required field will serialize as 0
		Y: anthropic.Int(1), // optional field will serialize as 1
	  // ... omitted non-required fields will not be serialized
	}),

	Origin: anthropic.Origin{}, // the zero value of [Origin] is considered omitted
}

// In cases where the API specifies a given type,
// but you want to send something else, use [WithExtraFields]:
params.WithExtraFields(map[string]any{
	"x": 0.01, // send "x" as a float instead of int
})

// Send a number instead of an object
custom := param.OverrideObj[anthropic.FooParams](12)

When available, use the .IsPresent() method to check if an optional parameter is not omitted or null. Otherwise, the param.IsOmitted(any) function can confirm the presence of any omitzero field.

Request unions

Unions are represented as a struct with fields prefixed by "Of" for each of it's variants, only one field can be non-zero. The non-zero field will be serialized.

Sub-properties of the union can be accessed via methods on the union struct. These methods return a mutable pointer to the underlying data, if present.

// Only one field can be non-zero, use param.IsOmitted() to check if a field is set
type AnimalUnionParam struct {
	OfCat 	 *Cat              `json:",omitzero,inline`
	OfDog    *Dog              `json:",omitzero,inline`
}

animal := AnimalUnionParam{
	OfCat: &Cat{
		Name: "Whiskers",
		Owner: PersonParam{
			Address: AddressParam{Street: "3333 Coyote Hill Rd", Zip: 0},
		},
	},
}

// Mutating a field
if address := animal.GetOwner().GetAddress(); address != nil {
	address.ZipCode = 94304
}
Response objects

All fields in response structs are value types (not pointers or wrappers).

If a given field is null, not present, or invalid, the corresponding field will simply be its zero value.

All response structs also include a special JSON field, containing more detailed information about each property, which you can use like so:

if res.Name == "" {
	// true if `"name"` was unmarshalled successfully
	res.JSON.Name.IsPresent()

	res.JSON.Name.IsExplicitNull() // true if `"name"` is explicitly null
	res.JSON.Name.Raw() == ""          // true if `"name"` field does not exist

	// When the API returns data that cannot be coerced to the expected type:
	if !res.JSON.Name.IsPresent() && res.JSON.Name.Raw() != "" {
		raw := res.JSON.Name.Raw()

		legacyName := struct{
			First string `json:"first"`
			Last  string `json:"last"`
		}{}
		json.Unmarshal([]byte(raw), &legacyName)
		name = legacyName.First + " " + legacyName.Last
	}
}

These .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.

body := res.JSON.ExtraFields["my_unexpected_field"].Raw()
Response Unions

In 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.

If a response value union contains primitive values, primitive fields will be alongside the properties but prefixed with Of and feature the tag json:"...,inline".

type AnimalUnion struct {
	OfString string `json:",inline"`
	Name     string `json:"name"`
	Owner    Person `json:"owner"`
	// ...
	JSON struct {
		OfString resp.Field
		Name     resp.Field
		Owner    resp.Field
		// ...
	}
}

// If animal variant
if animal.Owner.Address.JSON.ZipCode == "" {
	panic("missing zip code")
}

// If string variant
if !animal.OfString == "" {
	panic("expected a name")
}

// Switch on the variant
switch variant := animalOrName.AsAny().(type) {
case string:
case Dog:
case Cat:
default:
	panic("unexpected type")
}
RequestOptions

This 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:

client := anthropic.NewClient(
	// Adds a header to every request made by the client
	option.WithHeader("X-Some-Header", "custom_header_info"),
)

client.Messages.New(context.TODO(), ...,
	// Override the header
	option.WithHeader("X-Some-Header", "some_other_custom_header_info"),
	// Add an undocumented field to the request body, using sjson syntax
	option.WithJSONSet("some.json.path", map[string]string{"my": "object"}),
)

See the full list of request options.

Pagination

This library provides some conveniences for working with paginated list endpoints.

You can use .ListAutoPaging() methods to iterate through items across all pages:

iter := client.Beta.Messages.Batches.ListAutoPaging(context.TODO(), anthropic.BetaMessageBatchListParams{
	Limit: anthropic.Int(20),
})
// Automatically fetches more pages as needed.
for iter.Next() {
	betaMessageBatch := iter.Current()
	fmt.Printf("%+v\n", betaMessageBatch)
}
if err := iter.Err(); err != nil {
	panic(err.Error())
}

Or you can use simple .List() methods to fetch a single page and receive a standard response object with additional helper methods like .GetNextPage(), e.g.:

page, err := client.Beta.Messages.Batches.List(context.TODO(), anthropic.BetaMessageBatchListParams{
	Limit: anthropic.Int(20),
})
for page != nil {
	for _, batch := range page.Data {
		fmt.Printf("%+v\n", batch)
	}
	page, err = page.GetNextPage()
}
if err != nil {
	panic(err.Error())
}
Errors

When the API returns a non-success status code, we return an error with type *anthropic.Error. This contains the StatusCode, *http.Request, and *http.Response values of the request, as well as the JSON of the error body (much like other response objects in the SDK).

To handle errors, we recommend that you use the errors.As pattern:

_, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
	MaxTokens: 1024,
	Messages: []anthropic.MessageParam{{
		Role: anthropic.MessageParamRoleUser,
		Content: []anthropic.ContentBlockParamUnion{{
			OfRequestTextBlock: &anthropic.TextBlockParam{Text: "What is a quaternion?", CacheControl: anthropic.CacheControlEphemeralParam{}, Citations: []anthropic.TextCitationParamUnion{{
				OfRequestCharLocationCitation: &anthropic.CitationCharLocationParam{CitedText: "cited_text", DocumentIndex: 0, DocumentTitle: anthropic.String("x"), EndCharIndex: 0, StartCharIndex: 0},
			}}},
		}},
	}},
	Model: anthropic.ModelClaude3_7SonnetLatest,
})
if err != nil {
	var apierr *anthropic.Error
	if errors.As(err, &apierr) {
		println(string(apierr.DumpRequest(true)))  // Prints the serialized HTTP request
		println(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response
	}
	panic(err.Error()) // GET "/v1/messages": 400 Bad Request { ... }
}

When other errors occur, they are returned unwrapped; for example, if HTTP transport fails, you might receive *url.Error wrapping *net.OpError.

Timeouts

Requests do not time out by default; use context to configure a timeout for a request lifecycle.

Note that if a request is retried, the context timeout does not start over. To set a per-retry timeout, use option.WithRequestTimeout().

// This sets the timeout for the request, including all the retries.
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
client.Messages.New(
	ctx,
	anthropic.MessageNewParams{
		MaxTokens: 1024,
		Messages: []anthropic.MessageParam{{
			Role: anthropic.MessageParamRoleUser,
			Content: []anthropic.ContentBlockParamUnion{{
				OfRequestTextBlock: &anthropic.TextBlockParam{Text: "What is a quaternion?"},
			}},
		}},
		Model: anthropic.ModelClaude3_7SonnetLatest,
	},
	// This sets the per-retry timeout
	option.WithRequestTimeout(20*time.Second),
)
Long Requests

[!IMPORTANT] We highly encourage you use the streaming Messages API for longer running requests.

We do not recommend 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 without receiving a response from Anthropic.

This 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 disables this error.

File uploads

Request 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".

The file name and content-type can 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.

We also provide a helper anthropic.FileParam(reader io.Reader, filename string, contentType string) which can be used to wrap any io.Reader with the appropriate file name and content type.

Retries

Certain errors will be automatically retried 2 times by default, with a short exponential backoff. We retry by default all connection errors, 408 Request Timeout, 409 Conflict, 429 Rate Limit, and >=500 Internal errors.

You can use the WithMaxRetries option to configure or disable this:

// Configure the default for all requests:
client := anthropic.NewClient(
	option.WithMaxRetries(0), // default is 2
)

// Override per-request:
client.Messages.New(
	context.TODO(),
	anthropic.MessageNewParams{
		MaxTokens: 1024,
		Messages: []anthropic.MessageParam{{
			Role: anthropic.MessageParamRoleUser,
			Content: []anthropic.ContentBlockParamUnion{{
				OfRequestTextBlock: &anthropic.TextBlockParam{Text: "What is a quaternion?"},
			}},
		}},
		Model: anthropic.ModelClaude3_7SonnetLatest,
	},
	option.WithMaxRetries(5),
)
Accessing raw response data (e.g. response headers)

You 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.

// Create a variable to store the HTTP response
var response *http.Response
message, err := client.Messages.New(
	context.TODO(),
	anthropic.MessageNewParams{
		MaxTokens: 1024,
		Messages: []anthropic.MessageParam{{
			Role: anthropic.MessageParamRoleUser,
			Content: []anthropic.ContentBlockParamUnion{{
				OfRequestTextBlock: &anthropic.TextBlockParam{Text: "What is a quaternion?", CacheControl: anthropic.CacheControlEphemeralParam{}, Citations: []anthropic.TextCitationParamUnion{{
					OfRequestCharLocationCitation: &anthropic.CitationCharLocationParam{CitedText: "cited_text", DocumentIndex: 0, DocumentTitle: anthropic.String("x"), EndCharIndex: 0, StartCharIndex: 0},
				}}},
			}},
		}},
		Model: anthropic.ModelClaude3_7SonnetLatest,
	},
	option.WithResponseInto(&response),
)
if err != nil {
	// handle error
}
fmt.Printf("%+v\n", message)

fmt.Printf("Status Code: %d\n", response.StatusCode)
fmt.Printf("Headers: %+#v\n", response.Header)
Making custom/undocumented requests

This 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.

Undocumented endpoints

To 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.

var (
    // params can be an io.Reader, a []byte, an encoding/json serializable object,
    // or a "…Params" struct defined in this library.
    params map[string]interface{}

    // result can be an []byte, *http.Response, a encoding/json deserializable object,
    // or a model defined in this library.
    result *http.Response
)
err := client.Post(context.Background(), "/unspecified", params, &result)
if err != nil {
    …
}
Undocumented request params

To make requests using undocumented parameters, you may use either the option.WithQuerySet() or the option.WithJSONSet() methods.

params := FooNewParams{
    ID:   "id_xxxx",
    Data: FooNewParamsData{
        FirstName: anthropic.String("John"),
    },
}
client.Foo.New(context.Background(), params, option.WithJSONSet("data.last_name", "Doe"))
Undocumented response properties

To 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().

Any fields that are not present on the response struct will be saved and can be accessed by result.JSON.ExtraFields() which returns the extra fields as a map[string]Field.

Middleware

We provide option.WithMiddleware which applies the given middleware to requests.

func Logger(req *http.Request, next option.MiddlewareNext) (res *http.Response, err error) {
	// Before the request
	start := time.Now()
	LogReq(req)

	// Forward the request to the next handler
	res, err = next(req)

	// Handle stuff after the request
	end := time.Now()
	LogRes(res, err, start - end)

    return res, err
}

client := anthropic.NewClient(
	option.WithMiddleware(Logger),
)

When multiple middlewares are provided as variadic arguments, the middlewares are applied left to right. If option.WithMiddleware is given multiple times, for example first in the client then the method, the middleware in the client will run first and the middleware given in the method will run next.

You may also replace the default http.Client with option.WithHTTPClient(client). Only one http client is accepted (this overwrites any previous client) and receives requests after any middleware has been applied.

Amazon Bedrock

To use this library with Amazon Bedrock, use the bedrock request option bedrock.WithLoadDefaultConfig(…) which reads the default config.

Importing the bedrock library also globally registers a decoder for application/vnd.amazon.eventstream for streaming.

package main

import (
	"github.com/anthropics/anthropic-sdk-go"
	"github.com/anthropics/anthropic-sdk-go/bedrock"
)

func main() {
	client := anthropic.NewClient(
		bedrock.WithLoadDefaultConfig(context.Background()),
	)
}

If you already have an aws.Config, you can also use it directly with bedrock.WithConfig(cfg).

Read more about Anthropic and Amazon Bedrock here.

Google Vertex AI

To use this library with Google Vertex AI, use the request option vertex.WithGoogleAuth(…) which reads the Application Default Credentials.

package main

import (
	"context"

	"github.com/anthropics/anthropic-sdk-go"
	"github.com/anthropics/anthropic-sdk-go/vertex"
)

func main() {
	client := anthropic.NewClient(
		vertex.WithGoogleAuth(context.Background(), "us-central1", "id-xxx"),
	)
}

If you already have *google.Credentials, you can also use it directly with vertex.WithCredentials(ctx, region, projectId, creds).

Read more about Anthropic and Google Vertex here.

Semantic versioning

This package generally follows SemVer conventions, though certain backwards-incompatible changes may be released as minor versions:

  1. Changes to library internals which are technically public but not intended or documented for external use. (Please open a GitHub issue to let us know if you are relying on such internals.)
  2. Changes that we do not expect to impact the vast majority of users in practice.

We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.

We are keen for your feedback; please open an issue with questions, bugs, or suggestions.

Contributing

See the contributing documentation.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(b bool) param.Opt[bool]

func BoolPtr

func BoolPtr(v bool) *bool

func DefaultClientOptions

func DefaultClientOptions() []option.RequestOption

DefaultClientOptions read from the environment (ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN). This should be used to initialize new clients.

func File

func File(rdr io.Reader, filename string, contentType string) file

func Float

func Float(f float64) param.Opt[float64]

func FloatPtr

func FloatPtr(v float64) *float64

func Int

func Int(i int64) param.Opt[int64]

func IntPtr

func IntPtr(v int64) *int64

func Opt

func Opt[T comparable](v T) param.Opt[T]

func Ptr

func Ptr[T any](v T) *T

func String

func String(s string) param.Opt[string]

func StringPtr

func StringPtr(v string) *string

func Time

func Time(t time.Time) param.Opt[time.Time]

func TimePtr

func TimePtr(v time.Time) *time.Time

Types

type APIErrorObject

type APIErrorObject = shared.APIErrorObject

This is an alias to an internal type.

type AnthropicBeta

type AnthropicBeta = string
const (
	AnthropicBetaMessageBatches2024_09_24      AnthropicBeta = "message-batches-2024-09-24"
	AnthropicBetaPromptCaching2024_07_31       AnthropicBeta = "prompt-caching-2024-07-31"
	AnthropicBetaComputerUse2024_10_22         AnthropicBeta = "computer-use-2024-10-22"
	AnthropicBetaComputerUse2025_01_24         AnthropicBeta = "computer-use-2025-01-24"
	AnthropicBetaPDFs2024_09_25                AnthropicBeta = "pdfs-2024-09-25"
	AnthropicBetaTokenCounting2024_11_01       AnthropicBeta = "token-counting-2024-11-01"
	AnthropicBetaTokenEfficientTools2025_02_19 AnthropicBeta = "token-efficient-tools-2025-02-19"
	AnthropicBetaOutput128k2025_02_19          AnthropicBeta = "output-128k-2025-02-19"
)

type Base64ImageSourceMediaType

type Base64ImageSourceMediaType string
const (
	Base64ImageSourceMediaTypeImageJPEG Base64ImageSourceMediaType = "image/jpeg"
	Base64ImageSourceMediaTypeImagePNG  Base64ImageSourceMediaType = "image/png"
	Base64ImageSourceMediaTypeImageGIF  Base64ImageSourceMediaType = "image/gif"
	Base64ImageSourceMediaTypeImageWebP Base64ImageSourceMediaType = "image/webp"
)

type Base64ImageSourceParam

type Base64ImageSourceParam struct {
	Data string `json:"data,required" format:"byte"`
	// Any of "image/jpeg", "image/png", "image/gif", "image/webp".
	MediaType Base64ImageSourceMediaType `json:"media_type,omitzero,required"`
	// This field can be elided, and will marshal its zero value as "base64".
	Type constant.Base64 `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Data, MediaType, Type are required.

func (Base64ImageSourceParam) IsPresent

func (f Base64ImageSourceParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (Base64ImageSourceParam) MarshalJSON

func (r Base64ImageSourceParam) MarshalJSON() (data []byte, err error)

type Base64PDFSourceParam

type Base64PDFSourceParam struct {
	Data string `json:"data,required" format:"byte"`
	// This field can be elided, and will marshal its zero value as "application/pdf".
	MediaType constant.ApplicationPDF `json:"media_type,required"`
	// This field can be elided, and will marshal its zero value as "base64".
	Type constant.Base64 `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Data, MediaType, Type are required.

func (Base64PDFSourceParam) IsPresent

func (f Base64PDFSourceParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (Base64PDFSourceParam) MarshalJSON

func (r Base64PDFSourceParam) MarshalJSON() (data []byte, err error)

type BetaAPIError

type BetaAPIError struct {
	Message string            `json:"message,required"`
	Type    constant.APIError `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Message     resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaAPIError) RawJSON

func (r BetaAPIError) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaAPIError) UnmarshalJSON

func (r *BetaAPIError) UnmarshalJSON(data []byte) error

type BetaAuthenticationError

type BetaAuthenticationError struct {
	Message string                       `json:"message,required"`
	Type    constant.AuthenticationError `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Message     resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaAuthenticationError) RawJSON

func (r BetaAuthenticationError) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaAuthenticationError) UnmarshalJSON

func (r *BetaAuthenticationError) UnmarshalJSON(data []byte) error

type BetaBase64ImageSourceMediaType

type BetaBase64ImageSourceMediaType string
const (
	BetaBase64ImageSourceMediaTypeImageJPEG BetaBase64ImageSourceMediaType = "image/jpeg"
	BetaBase64ImageSourceMediaTypeImagePNG  BetaBase64ImageSourceMediaType = "image/png"
	BetaBase64ImageSourceMediaTypeImageGIF  BetaBase64ImageSourceMediaType = "image/gif"
	BetaBase64ImageSourceMediaTypeImageWebP BetaBase64ImageSourceMediaType = "image/webp"
)

type BetaBase64ImageSourceParam

type BetaBase64ImageSourceParam struct {
	Data string `json:"data,required" format:"byte"`
	// Any of "image/jpeg", "image/png", "image/gif", "image/webp".
	MediaType BetaBase64ImageSourceMediaType `json:"media_type,omitzero,required"`
	// This field can be elided, and will marshal its zero value as "base64".
	Type constant.Base64 `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Data, MediaType, Type are required.

func (BetaBase64ImageSourceParam) IsPresent

func (f BetaBase64ImageSourceParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaBase64ImageSourceParam) MarshalJSON

func (r BetaBase64ImageSourceParam) MarshalJSON() (data []byte, err error)

type BetaBase64PDFBlockParam

type BetaBase64PDFBlockParam struct {
	Source       BetaBase64PDFBlockSourceUnionParam `json:"source,omitzero,required"`
	Context      param.Opt[string]                  `json:"context,omitzero"`
	Title        param.Opt[string]                  `json:"title,omitzero"`
	CacheControl BetaCacheControlEphemeralParam     `json:"cache_control,omitzero"`
	Citations    BetaCitationsConfigParam           `json:"citations,omitzero"`
	// This field can be elided, and will marshal its zero value as "document".
	Type constant.Document `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Source, Type are required.

func (BetaBase64PDFBlockParam) IsPresent

func (f BetaBase64PDFBlockParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaBase64PDFBlockParam) MarshalJSON

func (r BetaBase64PDFBlockParam) MarshalJSON() (data []byte, err error)

type BetaBase64PDFBlockSourceUnionParam

type BetaBase64PDFBlockSourceUnionParam struct {
	OfBase64PDFSource    *BetaBase64PDFSourceParam    `json:",omitzero,inline"`
	OfPlainTextSource    *BetaPlainTextSourceParam    `json:",omitzero,inline"`
	OfContentBlockSource *BetaContentBlockSourceParam `json:",omitzero,inline"`
	OfUrlpdfSource       *BetaURLPDFSourceParam       `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (BetaBase64PDFBlockSourceUnionParam) GetContent

Returns a pointer to the underlying variant's property, if present.

func (BetaBase64PDFBlockSourceUnionParam) GetData

Returns a pointer to the underlying variant's property, if present.

func (BetaBase64PDFBlockSourceUnionParam) GetMediaType

func (u BetaBase64PDFBlockSourceUnionParam) GetMediaType() *string

Returns a pointer to the underlying variant's property, if present.

func (BetaBase64PDFBlockSourceUnionParam) GetType

Returns a pointer to the underlying variant's property, if present.

func (BetaBase64PDFBlockSourceUnionParam) GetURL

Returns a pointer to the underlying variant's property, if present.

func (BetaBase64PDFBlockSourceUnionParam) IsPresent

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaBase64PDFBlockSourceUnionParam) MarshalJSON

func (u BetaBase64PDFBlockSourceUnionParam) MarshalJSON() ([]byte, error)

type BetaBase64PDFSourceParam

type BetaBase64PDFSourceParam struct {
	Data string `json:"data,required" format:"byte"`
	// This field can be elided, and will marshal its zero value as "application/pdf".
	MediaType constant.ApplicationPDF `json:"media_type,required"`
	// This field can be elided, and will marshal its zero value as "base64".
	Type constant.Base64 `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Data, MediaType, Type are required.

func (BetaBase64PDFSourceParam) IsPresent

func (f BetaBase64PDFSourceParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaBase64PDFSourceParam) MarshalJSON

func (r BetaBase64PDFSourceParam) MarshalJSON() (data []byte, err error)

type BetaBillingError

type BetaBillingError struct {
	Message string                `json:"message,required"`
	Type    constant.BillingError `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Message     resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaBillingError) RawJSON

func (r BetaBillingError) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaBillingError) UnmarshalJSON

func (r *BetaBillingError) UnmarshalJSON(data []byte) error

type BetaCacheControlEphemeralParam

type BetaCacheControlEphemeralParam struct {
	// This field can be elided, and will marshal its zero value as "ephemeral".
	Type constant.Ephemeral `json:"type,required"`
	// contains filtered or unexported fields
}

The property Type is required.

func (BetaCacheControlEphemeralParam) IsPresent

func (f BetaCacheControlEphemeralParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaCacheControlEphemeralParam) MarshalJSON

func (r BetaCacheControlEphemeralParam) MarshalJSON() (data []byte, err error)

type BetaCitationCharLocation

type BetaCitationCharLocation struct {
	CitedText      string                `json:"cited_text,required"`
	DocumentIndex  int64                 `json:"document_index,required"`
	DocumentTitle  string                `json:"document_title,required"`
	EndCharIndex   int64                 `json:"end_char_index,required"`
	StartCharIndex int64                 `json:"start_char_index,required"`
	Type           constant.CharLocation `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		CitedText      resp.Field
		DocumentIndex  resp.Field
		DocumentTitle  resp.Field
		EndCharIndex   resp.Field
		StartCharIndex resp.Field
		Type           resp.Field
		ExtraFields    map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaCitationCharLocation) RawJSON

func (r BetaCitationCharLocation) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaCitationCharLocation) UnmarshalJSON

func (r *BetaCitationCharLocation) UnmarshalJSON(data []byte) error

type BetaCitationCharLocationParam

type BetaCitationCharLocationParam struct {
	DocumentTitle  param.Opt[string] `json:"document_title,omitzero,required"`
	CitedText      string            `json:"cited_text,required"`
	DocumentIndex  int64             `json:"document_index,required"`
	EndCharIndex   int64             `json:"end_char_index,required"`
	StartCharIndex int64             `json:"start_char_index,required"`
	// This field can be elided, and will marshal its zero value as "char_location".
	Type constant.CharLocation `json:"type,required"`
	// contains filtered or unexported fields
}

The properties CitedText, DocumentIndex, DocumentTitle, EndCharIndex, StartCharIndex, Type are required.

func (BetaCitationCharLocationParam) IsPresent

func (f BetaCitationCharLocationParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaCitationCharLocationParam) MarshalJSON

func (r BetaCitationCharLocationParam) MarshalJSON() (data []byte, err error)

type BetaCitationContentBlockLocation

type BetaCitationContentBlockLocation struct {
	CitedText       string                        `json:"cited_text,required"`
	DocumentIndex   int64                         `json:"document_index,required"`
	DocumentTitle   string                        `json:"document_title,required"`
	EndBlockIndex   int64                         `json:"end_block_index,required"`
	StartBlockIndex int64                         `json:"start_block_index,required"`
	Type            constant.ContentBlockLocation `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		CitedText       resp.Field
		DocumentIndex   resp.Field
		DocumentTitle   resp.Field
		EndBlockIndex   resp.Field
		StartBlockIndex resp.Field
		Type            resp.Field
		ExtraFields     map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaCitationContentBlockLocation) RawJSON

Returns the unmodified JSON received from the API

func (*BetaCitationContentBlockLocation) UnmarshalJSON

func (r *BetaCitationContentBlockLocation) UnmarshalJSON(data []byte) error

type BetaCitationContentBlockLocationParam

type BetaCitationContentBlockLocationParam struct {
	DocumentTitle   param.Opt[string] `json:"document_title,omitzero,required"`
	CitedText       string            `json:"cited_text,required"`
	DocumentIndex   int64             `json:"document_index,required"`
	EndBlockIndex   int64             `json:"end_block_index,required"`
	StartBlockIndex int64             `json:"start_block_index,required"`
	// This field can be elided, and will marshal its zero value as
	// "content_block_location".
	Type constant.ContentBlockLocation `json:"type,required"`
	// contains filtered or unexported fields
}

The properties CitedText, DocumentIndex, DocumentTitle, EndBlockIndex, StartBlockIndex, Type are required.

func (BetaCitationContentBlockLocationParam) IsPresent

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaCitationContentBlockLocationParam) MarshalJSON

func (r BetaCitationContentBlockLocationParam) MarshalJSON() (data []byte, err error)

type BetaCitationPageLocation

type BetaCitationPageLocation struct {
	CitedText       string                `json:"cited_text,required"`
	DocumentIndex   int64                 `json:"document_index,required"`
	DocumentTitle   string                `json:"document_title,required"`
	EndPageNumber   int64                 `json:"end_page_number,required"`
	StartPageNumber int64                 `json:"start_page_number,required"`
	Type            constant.PageLocation `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		CitedText       resp.Field
		DocumentIndex   resp.Field
		DocumentTitle   resp.Field
		EndPageNumber   resp.Field
		StartPageNumber resp.Field
		Type            resp.Field
		ExtraFields     map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaCitationPageLocation) RawJSON

func (r BetaCitationPageLocation) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaCitationPageLocation) UnmarshalJSON

func (r *BetaCitationPageLocation) UnmarshalJSON(data []byte) error

type BetaCitationPageLocationParam

type BetaCitationPageLocationParam struct {
	DocumentTitle   param.Opt[string] `json:"document_title,omitzero,required"`
	CitedText       string            `json:"cited_text,required"`
	DocumentIndex   int64             `json:"document_index,required"`
	EndPageNumber   int64             `json:"end_page_number,required"`
	StartPageNumber int64             `json:"start_page_number,required"`
	// This field can be elided, and will marshal its zero value as "page_location".
	Type constant.PageLocation `json:"type,required"`
	// contains filtered or unexported fields
}

The properties CitedText, DocumentIndex, DocumentTitle, EndPageNumber, StartPageNumber, Type are required.

func (BetaCitationPageLocationParam) IsPresent

func (f BetaCitationPageLocationParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaCitationPageLocationParam) MarshalJSON

func (r BetaCitationPageLocationParam) MarshalJSON() (data []byte, err error)

type BetaCitationsConfigParam

type BetaCitationsConfigParam struct {
	Enabled param.Opt[bool] `json:"enabled,omitzero"`
	// contains filtered or unexported fields
}

func (BetaCitationsConfigParam) IsPresent

func (f BetaCitationsConfigParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaCitationsConfigParam) MarshalJSON

func (r BetaCitationsConfigParam) MarshalJSON() (data []byte, err error)

type BetaCitationsDelta

type BetaCitationsDelta struct {
	Citation BetaCitationsDeltaCitationUnion `json:"citation,required"`
	Type     constant.CitationsDelta         `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Citation    resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaCitationsDelta) RawJSON

func (r BetaCitationsDelta) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaCitationsDelta) UnmarshalJSON

func (r *BetaCitationsDelta) UnmarshalJSON(data []byte) error

type BetaCitationsDeltaCitationUnion

type BetaCitationsDeltaCitationUnion struct {
	CitedText     string `json:"cited_text"`
	DocumentIndex int64  `json:"document_index"`
	DocumentTitle string `json:"document_title"`
	// This field is from variant [BetaCitationCharLocation].
	EndCharIndex int64 `json:"end_char_index"`
	// This field is from variant [BetaCitationCharLocation].
	StartCharIndex int64 `json:"start_char_index"`
	// Any of "char_location", "page_location", "content_block_location".
	Type string `json:"type"`
	// This field is from variant [BetaCitationPageLocation].
	EndPageNumber int64 `json:"end_page_number"`
	// This field is from variant [BetaCitationPageLocation].
	StartPageNumber int64 `json:"start_page_number"`
	// This field is from variant [BetaCitationContentBlockLocation].
	EndBlockIndex int64 `json:"end_block_index"`
	// This field is from variant [BetaCitationContentBlockLocation].
	StartBlockIndex int64 `json:"start_block_index"`
	JSON            struct {
		CitedText       resp.Field
		DocumentIndex   resp.Field
		DocumentTitle   resp.Field
		EndCharIndex    resp.Field
		StartCharIndex  resp.Field
		Type            resp.Field
		EndPageNumber   resp.Field
		StartPageNumber resp.Field
		EndBlockIndex   resp.Field
		StartBlockIndex resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

BetaCitationsDeltaCitationUnion contains all possible properties and values from BetaCitationCharLocation, BetaCitationPageLocation, BetaCitationContentBlockLocation.

Use the BetaCitationsDeltaCitationUnion.AsAny method to switch on the variant.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (BetaCitationsDeltaCitationUnion) AsAny

Use the following switch statement to find the correct variant

switch variant := BetaCitationsDeltaCitationUnion.AsAny().(type) {
case BetaCitationCharLocation:
case BetaCitationPageLocation:
case BetaCitationContentBlockLocation:
default:
  fmt.Errorf("no variant present")
}

func (BetaCitationsDeltaCitationUnion) AsResponseCharLocationCitation

func (u BetaCitationsDeltaCitationUnion) AsResponseCharLocationCitation() (v BetaCitationCharLocation)

func (BetaCitationsDeltaCitationUnion) AsResponseContentBlockLocationCitation

func (u BetaCitationsDeltaCitationUnion) AsResponseContentBlockLocationCitation() (v BetaCitationContentBlockLocation)

func (BetaCitationsDeltaCitationUnion) AsResponsePageLocationCitation

func (u BetaCitationsDeltaCitationUnion) AsResponsePageLocationCitation() (v BetaCitationPageLocation)

func (BetaCitationsDeltaCitationUnion) RawJSON

Returns the unmodified JSON received from the API

func (*BetaCitationsDeltaCitationUnion) UnmarshalJSON

func (r *BetaCitationsDeltaCitationUnion) UnmarshalJSON(data []byte) error

type BetaContentBlockParamUnion

type BetaContentBlockParamUnion struct {
	OfRequestTextBlock             *BetaTextBlockParam             `json:",omitzero,inline"`
	OfRequestImageBlock            *BetaImageBlockParam            `json:",omitzero,inline"`
	OfRequestToolUseBlock          *BetaToolUseBlockParam          `json:",omitzero,inline"`
	OfRequestToolResultBlock       *BetaToolResultBlockParam       `json:",omitzero,inline"`
	OfRequestDocumentBlock         *BetaBase64PDFBlockParam        `json:",omitzero,inline"`
	OfRequestThinkingBlock         *BetaThinkingBlockParam         `json:",omitzero,inline"`
	OfRequestRedactedThinkingBlock *BetaRedactedThinkingBlockParam `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func BetaContentBlockParamOfRequestRedactedThinkingBlock

func BetaContentBlockParamOfRequestRedactedThinkingBlock(data string) BetaContentBlockParamUnion

func BetaContentBlockParamOfRequestTextBlock

func BetaContentBlockParamOfRequestTextBlock(text string) BetaContentBlockParamUnion

func BetaContentBlockParamOfRequestThinkingBlock

func BetaContentBlockParamOfRequestThinkingBlock(signature string, thinking string) BetaContentBlockParamUnion

func BetaContentBlockParamOfRequestToolResultBlock

func BetaContentBlockParamOfRequestToolResultBlock(toolUseID string) BetaContentBlockParamUnion

func BetaContentBlockParamOfRequestToolUseBlock

func BetaContentBlockParamOfRequestToolUseBlock(id string, input interface{}, name string) BetaContentBlockParamUnion

func (BetaContentBlockParamUnion) GetCacheControl

Returns a pointer to the underlying variant's CacheControl property, if present.

func (BetaContentBlockParamUnion) GetCitations

func (u BetaContentBlockParamUnion) GetCitations() (res betaContentBlockParamUnionCitations)

Returns a subunion which exports methods to access subproperties

Or use AsAny() to get the underlying value

func (BetaContentBlockParamUnion) GetContent

Returns a pointer to the underlying variant's property, if present.

func (BetaContentBlockParamUnion) GetContext

func (u BetaContentBlockParamUnion) GetContext() *string

Returns a pointer to the underlying variant's property, if present.

func (BetaContentBlockParamUnion) GetData

func (u BetaContentBlockParamUnion) GetData() *string

Returns a pointer to the underlying variant's property, if present.

func (BetaContentBlockParamUnion) GetID

Returns a pointer to the underlying variant's property, if present.

func (BetaContentBlockParamUnion) GetInput

func (u BetaContentBlockParamUnion) GetInput() *interface{}

Returns a pointer to the underlying variant's property, if present.

func (BetaContentBlockParamUnion) GetIsError

func (u BetaContentBlockParamUnion) GetIsError() *bool

Returns a pointer to the underlying variant's property, if present.

func (BetaContentBlockParamUnion) GetName

func (u BetaContentBlockParamUnion) GetName() *string

Returns a pointer to the underlying variant's property, if present.

func (BetaContentBlockParamUnion) GetSignature

func (u BetaContentBlockParamUnion) GetSignature() *string

Returns a pointer to the underlying variant's property, if present.

func (BetaContentBlockParamUnion) GetSource

func (u BetaContentBlockParamUnion) GetSource() (res betaContentBlockParamUnionSource)

Returns a subunion which exports methods to access subproperties

Or use AsAny() to get the underlying value

func (BetaContentBlockParamUnion) GetText

func (u BetaContentBlockParamUnion) GetText() *string

Returns a pointer to the underlying variant's property, if present.

func (BetaContentBlockParamUnion) GetThinking

func (u BetaContentBlockParamUnion) GetThinking() *string

Returns a pointer to the underlying variant's property, if present.

func (BetaContentBlockParamUnion) GetTitle

func (u BetaContentBlockParamUnion) GetTitle() *string

Returns a pointer to the underlying variant's property, if present.

func (BetaContentBlockParamUnion) GetToolUseID

func (u BetaContentBlockParamUnion) GetToolUseID() *string

Returns a pointer to the underlying variant's property, if present.

func (BetaContentBlockParamUnion) GetType

func (u BetaContentBlockParamUnion) GetType() *string

Returns a pointer to the underlying variant's property, if present.

func (BetaContentBlockParamUnion) IsPresent

func (u BetaContentBlockParamUnion) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaContentBlockParamUnion) MarshalJSON

func (u BetaContentBlockParamUnion) MarshalJSON() ([]byte, error)

type BetaContentBlockSourceContentUnionParam

type BetaContentBlockSourceContentUnionParam struct {
	OfString                        param.Opt[string]                         `json:",omitzero,inline"`
	OfBetaContentBlockSourceContent []BetaContentBlockSourceContentUnionParam `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (BetaContentBlockSourceContentUnionParam) IsPresent

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaContentBlockSourceContentUnionParam) MarshalJSON

func (u BetaContentBlockSourceContentUnionParam) MarshalJSON() ([]byte, error)

type BetaContentBlockSourceParam

type BetaContentBlockSourceParam struct {
	Content BetaContentBlockSourceContentUnionParam `json:"content,omitzero,required"`
	// This field can be elided, and will marshal its zero value as "content".
	Type constant.Content `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Content, Type are required.

func (BetaContentBlockSourceParam) IsPresent

func (f BetaContentBlockSourceParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaContentBlockSourceParam) MarshalJSON

func (r BetaContentBlockSourceParam) MarshalJSON() (data []byte, err error)

type BetaContentBlockUnion

type BetaContentBlockUnion struct {
	// This field is from variant [BetaTextBlock].
	Citations []BetaTextCitationUnion `json:"citations"`
	// This field is from variant [BetaTextBlock].
	Text string `json:"text"`
	// Any of "text", "tool_use", "thinking", "redacted_thinking".
	Type string `json:"type"`
	// This field is from variant [BetaToolUseBlock].
	ID string `json:"id"`
	// This field is from variant [BetaToolUseBlock].
	Input interface{} `json:"input"`
	// This field is from variant [BetaToolUseBlock].
	Name string `json:"name"`
	// This field is from variant [BetaThinkingBlock].
	Signature string `json:"signature"`
	// This field is from variant [BetaThinkingBlock].
	Thinking string `json:"thinking"`
	// This field is from variant [BetaRedactedThinkingBlock].
	Data string `json:"data"`
	JSON struct {
		Citations resp.Field
		Text      resp.Field
		Type      resp.Field
		ID        resp.Field
		Input     resp.Field
		Name      resp.Field
		Signature resp.Field
		Thinking  resp.Field
		Data      resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

BetaContentBlockUnion contains all possible properties and values from BetaTextBlock, BetaToolUseBlock, BetaThinkingBlock, BetaRedactedThinkingBlock.

Use the BetaContentBlockUnion.AsAny method to switch on the variant.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (BetaContentBlockUnion) AsAny

func (u BetaContentBlockUnion) AsAny() any

Use the following switch statement to find the correct variant

switch variant := BetaContentBlockUnion.AsAny().(type) {
case BetaTextBlock:
case BetaToolUseBlock:
case BetaThinkingBlock:
case BetaRedactedThinkingBlock:
default:
  fmt.Errorf("no variant present")
}

func (BetaContentBlockUnion) AsResponseRedactedThinkingBlock

func (u BetaContentBlockUnion) AsResponseRedactedThinkingBlock() (v BetaRedactedThinkingBlock)

func (BetaContentBlockUnion) AsResponseTextBlock

func (u BetaContentBlockUnion) AsResponseTextBlock() (v BetaTextBlock)

func (BetaContentBlockUnion) AsResponseThinkingBlock

func (u BetaContentBlockUnion) AsResponseThinkingBlock() (v BetaThinkingBlock)

func (BetaContentBlockUnion) AsResponseToolUseBlock

func (u BetaContentBlockUnion) AsResponseToolUseBlock() (v BetaToolUseBlock)

func (BetaContentBlockUnion) RawJSON

func (u BetaContentBlockUnion) RawJSON() string

Returns the unmodified JSON received from the API

func (BetaContentBlockUnion) ToParam

func (*BetaContentBlockUnion) UnmarshalJSON

func (r *BetaContentBlockUnion) UnmarshalJSON(data []byte) error

type BetaDeletedMessageBatch

type BetaDeletedMessageBatch struct {
	// ID of the Message Batch.
	ID string `json:"id,required"`
	// Deleted object type.
	//
	// For Message Batches, this is always `"message_batch_deleted"`.
	Type constant.MessageBatchDeleted `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		ID          resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaDeletedMessageBatch) RawJSON

func (r BetaDeletedMessageBatch) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaDeletedMessageBatch) UnmarshalJSON

func (r *BetaDeletedMessageBatch) UnmarshalJSON(data []byte) error

type BetaErrorResponse

type BetaErrorResponse struct {
	Error BetaErrorUnion `json:"error,required"`
	Type  constant.Error `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Error       resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaErrorResponse) RawJSON

func (r BetaErrorResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaErrorResponse) UnmarshalJSON

func (r *BetaErrorResponse) UnmarshalJSON(data []byte) error

type BetaErrorUnion

type BetaErrorUnion struct {
	Message string `json:"message"`
	// Any of "invalid_request_error", "authentication_error", "billing_error",
	// "permission_error", "not_found_error", "rate_limit_error", "timeout_error",
	// "api_error", "overloaded_error".
	Type string `json:"type"`
	JSON struct {
		Message resp.Field
		Type    resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

BetaErrorUnion contains all possible properties and values from BetaInvalidRequestError, BetaAuthenticationError, BetaBillingError, BetaPermissionError, BetaNotFoundError, BetaRateLimitError, BetaGatewayTimeoutError, BetaAPIError, BetaOverloadedError.

Use the BetaErrorUnion.AsAny method to switch on the variant.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (BetaErrorUnion) AsAPIError

func (u BetaErrorUnion) AsAPIError() (v BetaAPIError)

func (BetaErrorUnion) AsAny

func (u BetaErrorUnion) AsAny() any

Use the following switch statement to find the correct variant

switch variant := BetaErrorUnion.AsAny().(type) {
case BetaInvalidRequestError:
case BetaAuthenticationError:
case BetaBillingError:
case BetaPermissionError:
case BetaNotFoundError:
case BetaRateLimitError:
case BetaGatewayTimeoutError:
case BetaAPIError:
case BetaOverloadedError:
default:
  fmt.Errorf("no variant present")
}

func (BetaErrorUnion) AsAuthenticationError

func (u BetaErrorUnion) AsAuthenticationError() (v BetaAuthenticationError)

func (BetaErrorUnion) AsBillingError

func (u BetaErrorUnion) AsBillingError() (v BetaBillingError)

func (BetaErrorUnion) AsGatewayTimeoutError

func (u BetaErrorUnion) AsGatewayTimeoutError() (v BetaGatewayTimeoutError)

func (BetaErrorUnion) AsInvalidRequestError

func (u BetaErrorUnion) AsInvalidRequestError() (v BetaInvalidRequestError)

func (BetaErrorUnion) AsNotFoundError

func (u BetaErrorUnion) AsNotFoundError() (v BetaNotFoundError)

func (BetaErrorUnion) AsOverloadedError

func (u BetaErrorUnion) AsOverloadedError() (v BetaOverloadedError)

func (BetaErrorUnion) AsPermissionError

func (u BetaErrorUnion) AsPermissionError() (v BetaPermissionError)

func (BetaErrorUnion) AsRateLimitError

func (u BetaErrorUnion) AsRateLimitError() (v BetaRateLimitError)

func (BetaErrorUnion) RawJSON

func (u BetaErrorUnion) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaErrorUnion) UnmarshalJSON

func (r *BetaErrorUnion) UnmarshalJSON(data []byte) error

type BetaGatewayTimeoutError

type BetaGatewayTimeoutError struct {
	Message string                `json:"message,required"`
	Type    constant.TimeoutError `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Message     resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaGatewayTimeoutError) RawJSON

func (r BetaGatewayTimeoutError) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaGatewayTimeoutError) UnmarshalJSON

func (r *BetaGatewayTimeoutError) UnmarshalJSON(data []byte) error

type BetaImageBlockParam

type BetaImageBlockParam struct {
	Source       BetaImageBlockParamSourceUnion `json:"source,omitzero,required"`
	CacheControl BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	// This field can be elided, and will marshal its zero value as "image".
	Type constant.Image `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Source, Type are required.

func (BetaImageBlockParam) IsPresent

func (f BetaImageBlockParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaImageBlockParam) MarshalJSON

func (r BetaImageBlockParam) MarshalJSON() (data []byte, err error)

type BetaImageBlockParamSourceUnion

type BetaImageBlockParamSourceUnion struct {
	OfBase64ImageSource *BetaBase64ImageSourceParam `json:",omitzero,inline"`
	OfURLImageSource    *BetaURLImageSourceParam    `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (BetaImageBlockParamSourceUnion) GetData

Returns a pointer to the underlying variant's property, if present.

func (BetaImageBlockParamSourceUnion) GetMediaType

func (u BetaImageBlockParamSourceUnion) GetMediaType() *string

Returns a pointer to the underlying variant's property, if present.

func (BetaImageBlockParamSourceUnion) GetType

Returns a pointer to the underlying variant's property, if present.

func (BetaImageBlockParamSourceUnion) GetURL

Returns a pointer to the underlying variant's property, if present.

func (BetaImageBlockParamSourceUnion) IsPresent

func (u BetaImageBlockParamSourceUnion) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaImageBlockParamSourceUnion) MarshalJSON

func (u BetaImageBlockParamSourceUnion) MarshalJSON() ([]byte, error)

type BetaInputJSONDelta

type BetaInputJSONDelta struct {
	PartialJSON string                  `json:"partial_json,required"`
	Type        constant.InputJSONDelta `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		PartialJSON resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaInputJSONDelta) RawJSON

func (r BetaInputJSONDelta) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaInputJSONDelta) UnmarshalJSON

func (r *BetaInputJSONDelta) UnmarshalJSON(data []byte) error

type BetaInvalidRequestError

type BetaInvalidRequestError struct {
	Message string                       `json:"message,required"`
	Type    constant.InvalidRequestError `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Message     resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaInvalidRequestError) RawJSON

func (r BetaInvalidRequestError) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaInvalidRequestError) UnmarshalJSON

func (r *BetaInvalidRequestError) UnmarshalJSON(data []byte) error

type BetaMessage

type BetaMessage struct {
	// Unique object identifier.
	//
	// The format and length of IDs may change over time.
	ID string `json:"id,required"`
	// Content generated by the model.
	//
	// This is an array of content blocks, each of which has a `type` that determines
	// its shape.
	//
	// Example:
	//
	// “`json
	// [{ "type": "text", "text": "Hi, I'm Claude." }]
	// “`
	//
	// If the request input `messages` ended with an `assistant` turn, then the
	// response `content` will continue directly from that last turn. You can use this
	// to constrain the model's output.
	//
	// For example, if the input `messages` were:
	//
	// “`json
	// [
	//
	//	{
	//	  "role": "user",
	//	  "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"
	//	},
	//	{ "role": "assistant", "content": "The best answer is (" }
	//
	// ]
	// “`
	//
	// Then the response `content` might be:
	//
	// “`json
	// [{ "type": "text", "text": "B)" }]
	// “`
	Content []BetaContentBlockUnion `json:"content,required"`
	// The model that will complete your prompt.\n\nSee
	// [models](https://docs.anthropic.com/en/docs/models-overview) for additional
	// details and options.
	Model Model `json:"model,required"`
	// Conversational role of the generated message.
	//
	// This will always be `"assistant"`.
	Role constant.Assistant `json:"role,required"`
	// The reason that we stopped.
	//
	// This may be one the following values:
	//
	// - `"end_turn"`: the model reached a natural stopping point
	// - `"max_tokens"`: we exceeded the requested `max_tokens` or the model's maximum
	// - `"stop_sequence"`: one of your provided custom `stop_sequences` was generated
	// - `"tool_use"`: the model invoked one or more tools
	//
	// In non-streaming mode this value is always non-null. In streaming mode, it is
	// null in the `message_start` event and non-null otherwise.
	//
	// Any of "end_turn", "max_tokens", "stop_sequence", "tool_use".
	StopReason BetaMessageStopReason `json:"stop_reason,required"`
	// Which custom stop sequence was generated, if any.
	//
	// This value will be a non-null string if one of your custom stop sequences was
	// generated.
	StopSequence string `json:"stop_sequence,required"`
	// Object type.
	//
	// For Messages, this is always `"message"`.
	Type constant.Message `json:"type,required"`
	// Billing and rate-limit usage.
	//
	// Anthropic's API bills and rate-limits by token counts, as tokens represent the
	// underlying cost to our systems.
	//
	// Under the hood, the API transforms requests into a format suitable for the
	// model. The model's output then goes through a parsing stage before becoming an
	// API response. As a result, the token counts in `usage` will not match one-to-one
	// with the exact visible content of an API request or response.
	//
	// For example, `output_tokens` will be non-zero, even for an empty string response
	// from Claude.
	//
	// Total input tokens in a request is the summation of `input_tokens`,
	// `cache_creation_input_tokens`, and `cache_read_input_tokens`.
	Usage BetaUsage `json:"usage,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		ID           resp.Field
		Content      resp.Field
		Model        resp.Field
		Role         resp.Field
		StopReason   resp.Field
		StopSequence resp.Field
		Type         resp.Field
		Usage        resp.Field
		ExtraFields  map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaMessage) RawJSON

func (r BetaMessage) RawJSON() string

Returns the unmodified JSON received from the API

func (BetaMessage) ToParam

func (r BetaMessage) ToParam() BetaMessageParam

func (*BetaMessage) UnmarshalJSON

func (r *BetaMessage) UnmarshalJSON(data []byte) error

type BetaMessageBatch

type BetaMessageBatch struct {
	// Unique object identifier.
	//
	// The format and length of IDs may change over time.
	ID string `json:"id,required"`
	// RFC 3339 datetime string representing the time at which the Message Batch was
	// archived and its results became unavailable.
	ArchivedAt time.Time `json:"archived_at,required" format:"date-time"`
	// RFC 3339 datetime string representing the time at which cancellation was
	// initiated for the Message Batch. Specified only if cancellation was initiated.
	CancelInitiatedAt time.Time `json:"cancel_initiated_at,required" format:"date-time"`
	// RFC 3339 datetime string representing the time at which the Message Batch was
	// created.
	CreatedAt time.Time `json:"created_at,required" format:"date-time"`
	// RFC 3339 datetime string representing the time at which processing for the
	// Message Batch ended. Specified only once processing ends.
	//
	// Processing ends when every request in a Message Batch has either succeeded,
	// errored, canceled, or expired.
	EndedAt time.Time `json:"ended_at,required" format:"date-time"`
	// RFC 3339 datetime string representing the time at which the Message Batch will
	// expire and end processing, which is 24 hours after creation.
	ExpiresAt time.Time `json:"expires_at,required" format:"date-time"`
	// Processing status of the Message Batch.
	//
	// Any of "in_progress", "canceling", "ended".
	ProcessingStatus BetaMessageBatchProcessingStatus `json:"processing_status,required"`
	// Tallies requests within the Message Batch, categorized by their status.
	//
	// Requests start as `processing` and move to one of the other statuses only once
	// processing of the entire batch ends. The sum of all values always matches the
	// total number of requests in the batch.
	RequestCounts BetaMessageBatchRequestCounts `json:"request_counts,required"`
	// URL to a `.jsonl` file containing the results of the Message Batch requests.
	// Specified only once processing ends.
	//
	// Results in the file are not guaranteed to be in the same order as requests. Use
	// the `custom_id` field to match results to requests.
	ResultsURL string `json:"results_url,required"`
	// Object type.
	//
	// For Message Batches, this is always `"message_batch"`.
	Type constant.MessageBatch `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		ID                resp.Field
		ArchivedAt        resp.Field
		CancelInitiatedAt resp.Field
		CreatedAt         resp.Field
		EndedAt           resp.Field
		ExpiresAt         resp.Field
		ProcessingStatus  resp.Field
		RequestCounts     resp.Field
		ResultsURL        resp.Field
		Type              resp.Field
		ExtraFields       map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaMessageBatch) RawJSON

func (r BetaMessageBatch) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaMessageBatch) UnmarshalJSON

func (r *BetaMessageBatch) UnmarshalJSON(data []byte) error

type BetaMessageBatchCancelParams

type BetaMessageBatchCancelParams struct {
	// Optional header to specify the beta version(s) you want to use.
	Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (BetaMessageBatchCancelParams) IsPresent

func (f BetaMessageBatchCancelParams) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

type BetaMessageBatchCanceledResult

type BetaMessageBatchCanceledResult struct {
	Type constant.Canceled `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaMessageBatchCanceledResult) RawJSON

Returns the unmodified JSON received from the API

func (*BetaMessageBatchCanceledResult) UnmarshalJSON

func (r *BetaMessageBatchCanceledResult) UnmarshalJSON(data []byte) error

type BetaMessageBatchDeleteParams

type BetaMessageBatchDeleteParams struct {
	// Optional header to specify the beta version(s) you want to use.
	Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (BetaMessageBatchDeleteParams) IsPresent

func (f BetaMessageBatchDeleteParams) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

type BetaMessageBatchErroredResult

type BetaMessageBatchErroredResult struct {
	Error BetaErrorResponse `json:"error,required"`
	Type  constant.Errored  `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Error       resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaMessageBatchErroredResult) RawJSON

Returns the unmodified JSON received from the API

func (*BetaMessageBatchErroredResult) UnmarshalJSON

func (r *BetaMessageBatchErroredResult) UnmarshalJSON(data []byte) error

type BetaMessageBatchExpiredResult

type BetaMessageBatchExpiredResult struct {
	Type constant.Expired `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaMessageBatchExpiredResult) RawJSON

Returns the unmodified JSON received from the API

func (*BetaMessageBatchExpiredResult) UnmarshalJSON

func (r *BetaMessageBatchExpiredResult) UnmarshalJSON(data []byte) error

type BetaMessageBatchGetParams

type BetaMessageBatchGetParams struct {
	// Optional header to specify the beta version(s) you want to use.
	Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (BetaMessageBatchGetParams) IsPresent

func (f BetaMessageBatchGetParams) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

type BetaMessageBatchIndividualResponse

type BetaMessageBatchIndividualResponse struct {
	// Developer-provided ID created for each request in a Message Batch. Useful for
	// matching results to requests, as results may be given out of request order.
	//
	// Must be unique for each request within the Message Batch.
	CustomID string `json:"custom_id,required"`
	// Processing result for this request.
	//
	// Contains a Message output if processing was successful, an error response if
	// processing failed, or the reason why processing was not attempted, such as
	// cancellation or expiration.
	Result BetaMessageBatchResultUnion `json:"result,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		CustomID    resp.Field
		Result      resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

This is a single line in the response `.jsonl` file and does not represent the response as a whole.

func (BetaMessageBatchIndividualResponse) RawJSON

Returns the unmodified JSON received from the API

func (*BetaMessageBatchIndividualResponse) UnmarshalJSON

func (r *BetaMessageBatchIndividualResponse) UnmarshalJSON(data []byte) error

type BetaMessageBatchListParams

type BetaMessageBatchListParams struct {
	// ID of the object to use as a cursor for pagination. When provided, returns the
	// page of results immediately after this object.
	AfterID param.Opt[string] `query:"after_id,omitzero" json:"-"`
	// ID of the object to use as a cursor for pagination. When provided, returns the
	// page of results immediately before this object.
	BeforeID param.Opt[string] `query:"before_id,omitzero" json:"-"`
	// Number of items to return per page.
	//
	// Defaults to `20`. Ranges from `1` to `1000`.
	Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
	// Optional header to specify the beta version(s) you want to use.
	Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (BetaMessageBatchListParams) IsPresent

func (f BetaMessageBatchListParams) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaMessageBatchListParams) URLQuery

func (r BetaMessageBatchListParams) URLQuery() (v url.Values)

URLQuery serializes BetaMessageBatchListParams's query parameters as `url.Values`.

type BetaMessageBatchNewParams

type BetaMessageBatchNewParams struct {
	// List of requests for prompt completion. Each is an individual request to create
	// a Message.
	Requests []BetaMessageBatchNewParamsRequest `json:"requests,omitzero,required"`
	// Optional header to specify the beta version(s) you want to use.
	Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (BetaMessageBatchNewParams) IsPresent

func (f BetaMessageBatchNewParams) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaMessageBatchNewParams) MarshalJSON

func (r BetaMessageBatchNewParams) MarshalJSON() (data []byte, err error)

type BetaMessageBatchNewParamsRequest

type BetaMessageBatchNewParamsRequest struct {
	// Developer-provided ID created for each request in a Message Batch. Useful for
	// matching results to requests, as results may be given out of request order.
	//
	// Must be unique for each request within the Message Batch.
	CustomID string `json:"custom_id,required"`
	// Messages API creation parameters for the individual request.
	//
	// See the [Messages API reference](/en/api/messages) for full documentation on
	// available parameters.
	Params BetaMessageBatchNewParamsRequestParams `json:"params,omitzero,required"`
	// contains filtered or unexported fields
}

The properties CustomID, Params are required.

func (BetaMessageBatchNewParamsRequest) IsPresent

func (f BetaMessageBatchNewParamsRequest) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaMessageBatchNewParamsRequest) MarshalJSON

func (r BetaMessageBatchNewParamsRequest) MarshalJSON() (data []byte, err error)

type BetaMessageBatchNewParamsRequestParams

type BetaMessageBatchNewParamsRequestParams struct {
	// The maximum number of tokens to generate before stopping.
	//
	// Note that our models may stop _before_ reaching this maximum. This parameter
	// only specifies the absolute maximum number of tokens to generate.
	//
	// Different models have different maximum values for this parameter. See
	// [models](https://docs.anthropic.com/en/docs/models-overview) for details.
	MaxTokens int64 `json:"max_tokens,required"`
	// Input messages.
	//
	// Our models are trained to operate on alternating `user` and `assistant`
	// conversational turns. When creating a new `Message`, you specify the prior
	// conversational turns with the `messages` parameter, and the model then generates
	// the next `Message` in the conversation. Consecutive `user` or `assistant` turns
	// in your request will be combined into a single turn.
	//
	// Each input message must be an object with a `role` and `content`. You can
	// specify a single `user`-role message, or you can include multiple `user` and
	// `assistant` messages.
	//
	// If the final message uses the `assistant` role, the response content will
	// continue immediately from the content in that message. This can be used to
	// constrain part of the model's response.
	//
	// Example with a single `user` message:
	//
	// “`json
	// [{ "role": "user", "content": "Hello, Claude" }]
	// “`
	//
	// Example with multiple conversational turns:
	//
	// “`json
	// [
	//
	//	{ "role": "user", "content": "Hello there." },
	//	{ "role": "assistant", "content": "Hi, I'm Claude. How can I help you?" },
	//	{ "role": "user", "content": "Can you explain LLMs in plain English?" }
	//
	// ]
	// “`
	//
	// Example with a partially-filled response from Claude:
	//
	// “`json
	// [
	//
	//	{
	//	  "role": "user",
	//	  "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"
	//	},
	//	{ "role": "assistant", "content": "The best answer is (" }
	//
	// ]
	// “`
	//
	// Each input message `content` may be either a single `string` or an array of
	// content blocks, where each block has a specific `type`. Using a `string` for
	// `content` is shorthand for an array of one content block of type `"text"`. The
	// following input messages are equivalent:
	//
	// “`json
	// { "role": "user", "content": "Hello, Claude" }
	// “`
	//
	// “`json
	// { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
	// “`
	//
	// Starting with Claude 3 models, you can also send image content blocks:
	//
	// “`json
	//
	//	{
	//	  "role": "user",
	//	  "content": [
	//	    {
	//	      "type": "image",
	//	      "source": {
	//	        "type": "base64",
	//	        "media_type": "image/jpeg",
	//	        "data": "/9j/4AAQSkZJRg..."
	//	      }
	//	    },
	//	    { "type": "text", "text": "What is in this image?" }
	//	  ]
	//	}
	//
	// “`
	//
	// We currently support the `base64` source type for images, and the `image/jpeg`,
	// `image/png`, `image/gif`, and `image/webp` media types.
	//
	// See [examples](https://docs.anthropic.com/en/api/messages-examples#vision) for
	// more input examples.
	//
	// Note that if you want to include a
	// [system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
	// the top-level `system` parameter — there is no `"system"` role for input
	// messages in the Messages API.
	Messages []BetaMessageParam `json:"messages,omitzero,required"`
	// The model that will complete your prompt.\n\nSee
	// [models](https://docs.anthropic.com/en/docs/models-overview) for additional
	// details and options.
	Model Model `json:"model,omitzero,required"`
	// Whether to incrementally stream the response using server-sent events.
	//
	// See [streaming](https://docs.anthropic.com/en/api/messages-streaming) for
	// details.
	Stream param.Opt[bool] `json:"stream,omitzero"`
	// Amount of randomness injected into the response.
	//
	// Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0`
	// for analytical / multiple choice, and closer to `1.0` for creative and
	// generative tasks.
	//
	// Note that even with `temperature` of `0.0`, the results will not be fully
	// deterministic.
	Temperature param.Opt[float64] `json:"temperature,omitzero"`
	// Only sample from the top K options for each subsequent token.
	//
	// Used to remove "long tail" low probability responses.
	// [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).
	//
	// Recommended for advanced use cases only. You usually only need to use
	// `temperature`.
	TopK param.Opt[int64] `json:"top_k,omitzero"`
	// Use nucleus sampling.
	//
	// In nucleus sampling, we compute the cumulative distribution over all the options
	// for each subsequent token in decreasing probability order and cut it off once it
	// reaches a particular probability specified by `top_p`. You should either alter
	// `temperature` or `top_p`, but not both.
	//
	// Recommended for advanced use cases only. You usually only need to use
	// `temperature`.
	TopP param.Opt[float64] `json:"top_p,omitzero"`
	// An object describing metadata about the request.
	Metadata BetaMetadataParam `json:"metadata,omitzero"`
	// Custom text sequences that will cause the model to stop generating.
	//
	// Our models will normally stop when they have naturally completed their turn,
	// which will result in a response `stop_reason` of `"end_turn"`.
	//
	// If you want the model to stop generating when it encounters custom strings of
	// text, you can use the `stop_sequences` parameter. If the model encounters one of
	// the custom sequences, the response `stop_reason` value will be `"stop_sequence"`
	// and the response `stop_sequence` value will contain the matched stop sequence.
	StopSequences []string `json:"stop_sequences,omitzero"`
	// System prompt.
	//
	// A system prompt is a way of providing context and instructions to Claude, such
	// as specifying a particular goal or role. See our
	// [guide to system prompts](https://docs.anthropic.com/en/docs/system-prompts).
	System []BetaTextBlockParam `json:"system,omitzero"`
	// Configuration for enabling Claude's extended thinking.
	//
	// When enabled, responses include `thinking` content blocks showing Claude's
	// thinking process before the final answer. Requires a minimum budget of 1,024
	// tokens and counts towards your `max_tokens` limit.
	//
	// See
	// [extended thinking](https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking)
	// for details.
	Thinking BetaThinkingConfigParamUnion `json:"thinking,omitzero"`
	// How the model should use the provided tools. The model can use a specific tool,
	// any available tool, decide by itself, or not use tools at all.
	ToolChoice BetaToolChoiceUnionParam `json:"tool_choice,omitzero"`
	// Definitions of tools that the model may use.
	//
	// If you include `tools` in your API request, the model may return `tool_use`
	// content blocks that represent the model's use of those tools. You can then run
	// those tools using the tool input generated by the model and then optionally
	// return results back to the model using `tool_result` content blocks.
	//
	// Each tool definition includes:
	//
	//   - `name`: Name of the tool.
	//   - `description`: Optional, but strongly-recommended description of the tool.
	//   - `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the
	//     tool `input` shape that the model will produce in `tool_use` output content
	//     blocks.
	//
	// For example, if you defined `tools` as:
	//
	// “`json
	// [
	//
	//	{
	//	  "name": "get_stock_price",
	//	  "description": "Get the current stock price for a given ticker symbol.",
	//	  "input_schema": {
	//	    "type": "object",
	//	    "properties": {
	//	      "ticker": {
	//	        "type": "string",
	//	        "description": "The stock ticker symbol, e.g. AAPL for Apple Inc."
	//	      }
	//	    },
	//	    "required": ["ticker"]
	//	  }
	//	}
	//
	// ]
	// “`
	//
	// And then asked the model "What's the S&P 500 at today?", the model might produce
	// `tool_use` content blocks in the response like this:
	//
	// “`json
	// [
	//
	//	{
	//	  "type": "tool_use",
	//	  "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
	//	  "name": "get_stock_price",
	//	  "input": { "ticker": "^GSPC" }
	//	}
	//
	// ]
	// “`
	//
	// You might then run your `get_stock_price` tool with `{"ticker": "^GSPC"}` as an
	// input, and return the following back to the model in a subsequent `user`
	// message:
	//
	// “`json
	// [
	//
	//	{
	//	  "type": "tool_result",
	//	  "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
	//	  "content": "259.75 USD"
	//	}
	//
	// ]
	// “`
	//
	// Tools can be used for workflows that include running client-side tools and
	// functions, or more generally whenever you want the model to produce a particular
	// JSON structure of output.
	//
	// See our [guide](https://docs.anthropic.com/en/docs/tool-use) for more details.
	Tools []BetaToolUnionParam `json:"tools,omitzero"`
	// contains filtered or unexported fields
}

Messages API creation parameters for the individual request.

See the [Messages API reference](/en/api/messages) for full documentation on available parameters.

The properties MaxTokens, Messages, Model are required.

func (BetaMessageBatchNewParamsRequestParams) IsPresent

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaMessageBatchNewParamsRequestParams) MarshalJSON

func (r BetaMessageBatchNewParamsRequestParams) MarshalJSON() (data []byte, err error)

type BetaMessageBatchProcessingStatus

type BetaMessageBatchProcessingStatus string

Processing status of the Message Batch.

const (
	BetaMessageBatchProcessingStatusInProgress BetaMessageBatchProcessingStatus = "in_progress"
	BetaMessageBatchProcessingStatusCanceling  BetaMessageBatchProcessingStatus = "canceling"
	BetaMessageBatchProcessingStatusEnded      BetaMessageBatchProcessingStatus = "ended"
)

type BetaMessageBatchRequestCounts

type BetaMessageBatchRequestCounts struct {
	// Number of requests in the Message Batch that have been canceled.
	//
	// This is zero until processing of the entire Message Batch has ended.
	Canceled int64 `json:"canceled,required"`
	// Number of requests in the Message Batch that encountered an error.
	//
	// This is zero until processing of the entire Message Batch has ended.
	Errored int64 `json:"errored,required"`
	// Number of requests in the Message Batch that have expired.
	//
	// This is zero until processing of the entire Message Batch has ended.
	Expired int64 `json:"expired,required"`
	// Number of requests in the Message Batch that are processing.
	Processing int64 `json:"processing,required"`
	// Number of requests in the Message Batch that have completed successfully.
	//
	// This is zero until processing of the entire Message Batch has ended.
	Succeeded int64 `json:"succeeded,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Canceled    resp.Field
		Errored     resp.Field
		Expired     resp.Field
		Processing  resp.Field
		Succeeded   resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaMessageBatchRequestCounts) RawJSON

Returns the unmodified JSON received from the API

func (*BetaMessageBatchRequestCounts) UnmarshalJSON

func (r *BetaMessageBatchRequestCounts) UnmarshalJSON(data []byte) error

type BetaMessageBatchResultUnion

type BetaMessageBatchResultUnion struct {
	// This field is from variant [BetaMessageBatchSucceededResult].
	Message BetaMessage `json:"message"`
	// Any of "succeeded", "errored", "canceled", "expired".
	Type string `json:"type"`
	// This field is from variant [BetaMessageBatchErroredResult].
	Error BetaErrorResponse `json:"error"`
	JSON  struct {
		Message resp.Field
		Type    resp.Field
		Error   resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

BetaMessageBatchResultUnion contains all possible properties and values from BetaMessageBatchSucceededResult, BetaMessageBatchErroredResult, BetaMessageBatchCanceledResult, BetaMessageBatchExpiredResult.

Use the BetaMessageBatchResultUnion.AsAny method to switch on the variant.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (BetaMessageBatchResultUnion) AsAny

func (u BetaMessageBatchResultUnion) AsAny() any

Use the following switch statement to find the correct variant

switch variant := BetaMessageBatchResultUnion.AsAny().(type) {
case BetaMessageBatchSucceededResult:
case BetaMessageBatchErroredResult:
case BetaMessageBatchCanceledResult:
case BetaMessageBatchExpiredResult:
default:
  fmt.Errorf("no variant present")
}

func (BetaMessageBatchResultUnion) AsCanceledResult

func (BetaMessageBatchResultUnion) AsErroredResult

func (BetaMessageBatchResultUnion) AsExpiredResult

func (BetaMessageBatchResultUnion) AsSucceededResult

func (BetaMessageBatchResultUnion) RawJSON

func (u BetaMessageBatchResultUnion) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaMessageBatchResultUnion) UnmarshalJSON

func (r *BetaMessageBatchResultUnion) UnmarshalJSON(data []byte) error

type BetaMessageBatchResultsParams

type BetaMessageBatchResultsParams struct {
	// Optional header to specify the beta version(s) you want to use.
	Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (BetaMessageBatchResultsParams) IsPresent

func (f BetaMessageBatchResultsParams) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

type BetaMessageBatchService

type BetaMessageBatchService struct {
	Options []option.RequestOption
}

BetaMessageBatchService contains methods and other services that help with interacting with the anthropic API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewBetaMessageBatchService method instead.

func NewBetaMessageBatchService

func NewBetaMessageBatchService(opts ...option.RequestOption) (r BetaMessageBatchService)

NewBetaMessageBatchService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*BetaMessageBatchService) Cancel

func (r *BetaMessageBatchService) Cancel(ctx context.Context, messageBatchID string, body BetaMessageBatchCancelParams, opts ...option.RequestOption) (res *BetaMessageBatch, err error)

Batches may be canceled any time before processing ends. Once cancellation is initiated, the batch enters a `canceling` state, at which time the system may complete any in-progress, non-interruptible requests before finalizing cancellation.

The number of canceled requests is specified in `request_counts`. To determine which requests were canceled, check the individual results within the batch. Note that cancellation may not result in any canceled requests if they were non-interruptible.

Learn more about the Message Batches API in our [user guide](/en/docs/build-with-claude/batch-processing)

func (*BetaMessageBatchService) Delete

Delete a Message Batch.

Message Batches can only be deleted once they've finished processing. If you'd like to delete an in-progress batch, you must first cancel it.

Learn more about the Message Batches API in our [user guide](/en/docs/build-with-claude/batch-processing)

func (*BetaMessageBatchService) Get

func (r *BetaMessageBatchService) Get(ctx context.Context, messageBatchID string, query BetaMessageBatchGetParams, opts ...option.RequestOption) (res *BetaMessageBatch, err error)

This endpoint is idempotent and can be used to poll for Message Batch completion. To access the results of a Message Batch, make a request to the `results_url` field in the response.

Learn more about the Message Batches API in our [user guide](/en/docs/build-with-claude/batch-processing)

func (*BetaMessageBatchService) List

List all Message Batches within a Workspace. Most recently created batches are returned first.

Learn more about the Message Batches API in our [user guide](/en/docs/build-with-claude/batch-processing)

func (*BetaMessageBatchService) ListAutoPaging

List all Message Batches within a Workspace. Most recently created batches are returned first.

Learn more about the Message Batches API in our [user guide](/en/docs/build-with-claude/batch-processing)

func (*BetaMessageBatchService) New

Send a batch of Message creation requests.

The Message Batches API can be used to process multiple Messages API requests at once. Once a Message Batch is created, it begins processing immediately. Batches can take up to 24 hours to complete.

Learn more about the Message Batches API in our [user guide](/en/docs/build-with-claude/batch-processing)

func (*BetaMessageBatchService) ResultsStreaming

Streams the results of a Message Batch as a `.jsonl` file.

Each line in the file is a JSON object containing the result of a single request in the Message Batch. Results are not guaranteed to be in the same order as requests. Use the `custom_id` field to match results to requests.

Learn more about the Message Batches API in our [user guide](/en/docs/build-with-claude/batch-processing)

type BetaMessageBatchSucceededResult

type BetaMessageBatchSucceededResult struct {
	Message BetaMessage        `json:"message,required"`
	Type    constant.Succeeded `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Message     resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaMessageBatchSucceededResult) RawJSON

Returns the unmodified JSON received from the API

func (*BetaMessageBatchSucceededResult) UnmarshalJSON

func (r *BetaMessageBatchSucceededResult) UnmarshalJSON(data []byte) error

type BetaMessageCountTokensParams

type BetaMessageCountTokensParams struct {
	// Input messages.
	//
	// Our models are trained to operate on alternating `user` and `assistant`
	// conversational turns. When creating a new `Message`, you specify the prior
	// conversational turns with the `messages` parameter, and the model then generates
	// the next `Message` in the conversation. Consecutive `user` or `assistant` turns
	// in your request will be combined into a single turn.
	//
	// Each input message must be an object with a `role` and `content`. You can
	// specify a single `user`-role message, or you can include multiple `user` and
	// `assistant` messages.
	//
	// If the final message uses the `assistant` role, the response content will
	// continue immediately from the content in that message. This can be used to
	// constrain part of the model's response.
	//
	// Example with a single `user` message:
	//
	// “`json
	// [{ "role": "user", "content": "Hello, Claude" }]
	// “`
	//
	// Example with multiple conversational turns:
	//
	// “`json
	// [
	//
	//	{ "role": "user", "content": "Hello there." },
	//	{ "role": "assistant", "content": "Hi, I'm Claude. How can I help you?" },
	//	{ "role": "user", "content": "Can you explain LLMs in plain English?" }
	//
	// ]
	// “`
	//
	// Example with a partially-filled response from Claude:
	//
	// “`json
	// [
	//
	//	{
	//	  "role": "user",
	//	  "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"
	//	},
	//	{ "role": "assistant", "content": "The best answer is (" }
	//
	// ]
	// “`
	//
	// Each input message `content` may be either a single `string` or an array of
	// content blocks, where each block has a specific `type`. Using a `string` for
	// `content` is shorthand for an array of one content block of type `"text"`. The
	// following input messages are equivalent:
	//
	// “`json
	// { "role": "user", "content": "Hello, Claude" }
	// “`
	//
	// “`json
	// { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
	// “`
	//
	// Starting with Claude 3 models, you can also send image content blocks:
	//
	// “`json
	//
	//	{
	//	  "role": "user",
	//	  "content": [
	//	    {
	//	      "type": "image",
	//	      "source": {
	//	        "type": "base64",
	//	        "media_type": "image/jpeg",
	//	        "data": "/9j/4AAQSkZJRg..."
	//	      }
	//	    },
	//	    { "type": "text", "text": "What is in this image?" }
	//	  ]
	//	}
	//
	// “`
	//
	// We currently support the `base64` source type for images, and the `image/jpeg`,
	// `image/png`, `image/gif`, and `image/webp` media types.
	//
	// See [examples](https://docs.anthropic.com/en/api/messages-examples#vision) for
	// more input examples.
	//
	// Note that if you want to include a
	// [system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
	// the top-level `system` parameter — there is no `"system"` role for input
	// messages in the Messages API.
	Messages []BetaMessageParam `json:"messages,omitzero,required"`
	// The model that will complete your prompt.\n\nSee
	// [models](https://docs.anthropic.com/en/docs/models-overview) for additional
	// details and options.
	Model Model `json:"model,omitzero,required"`
	// System prompt.
	//
	// A system prompt is a way of providing context and instructions to Claude, such
	// as specifying a particular goal or role. See our
	// [guide to system prompts](https://docs.anthropic.com/en/docs/system-prompts).
	System BetaMessageCountTokensParamsSystemUnion `json:"system,omitzero"`
	// Configuration for enabling Claude's extended thinking.
	//
	// When enabled, responses include `thinking` content blocks showing Claude's
	// thinking process before the final answer. Requires a minimum budget of 1,024
	// tokens and counts towards your `max_tokens` limit.
	//
	// See
	// [extended thinking](https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking)
	// for details.
	Thinking BetaThinkingConfigParamUnion `json:"thinking,omitzero"`
	// How the model should use the provided tools. The model can use a specific tool,
	// any available tool, decide by itself, or not use tools at all.
	ToolChoice BetaToolChoiceUnionParam `json:"tool_choice,omitzero"`
	// Definitions of tools that the model may use.
	//
	// If you include `tools` in your API request, the model may return `tool_use`
	// content blocks that represent the model's use of those tools. You can then run
	// those tools using the tool input generated by the model and then optionally
	// return results back to the model using `tool_result` content blocks.
	//
	// Each tool definition includes:
	//
	//   - `name`: Name of the tool.
	//   - `description`: Optional, but strongly-recommended description of the tool.
	//   - `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the
	//     tool `input` shape that the model will produce in `tool_use` output content
	//     blocks.
	//
	// For example, if you defined `tools` as:
	//
	// “`json
	// [
	//
	//	{
	//	  "name": "get_stock_price",
	//	  "description": "Get the current stock price for a given ticker symbol.",
	//	  "input_schema": {
	//	    "type": "object",
	//	    "properties": {
	//	      "ticker": {
	//	        "type": "string",
	//	        "description": "The stock ticker symbol, e.g. AAPL for Apple Inc."
	//	      }
	//	    },
	//	    "required": ["ticker"]
	//	  }
	//	}
	//
	// ]
	// “`
	//
	// And then asked the model "What's the S&P 500 at today?", the model might produce
	// `tool_use` content blocks in the response like this:
	//
	// “`json
	// [
	//
	//	{
	//	  "type": "tool_use",
	//	  "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
	//	  "name": "get_stock_price",
	//	  "input": { "ticker": "^GSPC" }
	//	}
	//
	// ]
	// “`
	//
	// You might then run your `get_stock_price` tool with `{"ticker": "^GSPC"}` as an
	// input, and return the following back to the model in a subsequent `user`
	// message:
	//
	// “`json
	// [
	//
	//	{
	//	  "type": "tool_result",
	//	  "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
	//	  "content": "259.75 USD"
	//	}
	//
	// ]
	// “`
	//
	// Tools can be used for workflows that include running client-side tools and
	// functions, or more generally whenever you want the model to produce a particular
	// JSON structure of output.
	//
	// See our [guide](https://docs.anthropic.com/en/docs/tool-use) for more details.
	Tools []BetaMessageCountTokensParamsToolUnion `json:"tools,omitzero"`
	// Optional header to specify the beta version(s) you want to use.
	Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (BetaMessageCountTokensParams) IsPresent

func (f BetaMessageCountTokensParams) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaMessageCountTokensParams) MarshalJSON

func (r BetaMessageCountTokensParams) MarshalJSON() (data []byte, err error)

type BetaMessageCountTokensParamsSystemUnion

type BetaMessageCountTokensParamsSystemUnion struct {
	OfString                             param.Opt[string]    `json:",omitzero,inline"`
	OfBetaMessageCountTokenssSystemArray []BetaTextBlockParam `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (BetaMessageCountTokensParamsSystemUnion) IsPresent

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaMessageCountTokensParamsSystemUnion) MarshalJSON

func (u BetaMessageCountTokensParamsSystemUnion) MarshalJSON() ([]byte, error)

type BetaMessageCountTokensParamsToolUnion

type BetaMessageCountTokensParamsToolUnion struct {
	OfTool                    *BetaToolParam                    `json:",omitzero,inline"`
	OfComputerUseTool20241022 *BetaToolComputerUse20241022Param `json:",omitzero,inline"`
	OfBashTool20241022        *BetaToolBash20241022Param        `json:",omitzero,inline"`
	OfTextEditor20241022      *BetaToolTextEditor20241022Param  `json:",omitzero,inline"`
	OfComputerUseTool20250124 *BetaToolComputerUse20250124Param `json:",omitzero,inline"`
	OfBashTool20250124        *BetaToolBash20250124Param        `json:",omitzero,inline"`
	OfTextEditor20250124      *BetaToolTextEditor20250124Param  `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (BetaMessageCountTokensParamsToolUnion) GetCacheControl

Returns a pointer to the underlying variant's CacheControl property, if present.

func (BetaMessageCountTokensParamsToolUnion) GetDescription

func (u BetaMessageCountTokensParamsToolUnion) GetDescription() *string

Returns a pointer to the underlying variant's property, if present.

func (BetaMessageCountTokensParamsToolUnion) GetDisplayHeightPx

func (u BetaMessageCountTokensParamsToolUnion) GetDisplayHeightPx() *int64

Returns a pointer to the underlying variant's property, if present.

func (BetaMessageCountTokensParamsToolUnion) GetDisplayNumber

func (u BetaMessageCountTokensParamsToolUnion) GetDisplayNumber() *int64

Returns a pointer to the underlying variant's property, if present.

func (BetaMessageCountTokensParamsToolUnion) GetDisplayWidthPx

func (u BetaMessageCountTokensParamsToolUnion) GetDisplayWidthPx() *int64

Returns a pointer to the underlying variant's property, if present.

func (BetaMessageCountTokensParamsToolUnion) GetInputSchema

Returns a pointer to the underlying variant's property, if present.

func (BetaMessageCountTokensParamsToolUnion) GetName

Returns a pointer to the underlying variant's property, if present.

func (BetaMessageCountTokensParamsToolUnion) GetType

Returns a pointer to the underlying variant's property, if present.

func (BetaMessageCountTokensParamsToolUnion) IsPresent

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaMessageCountTokensParamsToolUnion) MarshalJSON

func (u BetaMessageCountTokensParamsToolUnion) MarshalJSON() ([]byte, error)

type BetaMessageDeltaUsage

type BetaMessageDeltaUsage struct {
	// The cumulative number of output tokens which were used.
	OutputTokens int64 `json:"output_tokens,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		OutputTokens resp.Field
		ExtraFields  map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaMessageDeltaUsage) RawJSON

func (r BetaMessageDeltaUsage) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaMessageDeltaUsage) UnmarshalJSON

func (r *BetaMessageDeltaUsage) UnmarshalJSON(data []byte) error

type BetaMessageNewParams

type BetaMessageNewParams struct {
	// The maximum number of tokens to generate before stopping.
	//
	// Note that our models may stop _before_ reaching this maximum. This parameter
	// only specifies the absolute maximum number of tokens to generate.
	//
	// Different models have different maximum values for this parameter. See
	// [models](https://docs.anthropic.com/en/docs/models-overview) for details.
	MaxTokens int64 `json:"max_tokens,required"`
	// Input messages.
	//
	// Our models are trained to operate on alternating `user` and `assistant`
	// conversational turns. When creating a new `Message`, you specify the prior
	// conversational turns with the `messages` parameter, and the model then generates
	// the next `Message` in the conversation. Consecutive `user` or `assistant` turns
	// in your request will be combined into a single turn.
	//
	// Each input message must be an object with a `role` and `content`. You can
	// specify a single `user`-role message, or you can include multiple `user` and
	// `assistant` messages.
	//
	// If the final message uses the `assistant` role, the response content will
	// continue immediately from the content in that message. This can be used to
	// constrain part of the model's response.
	//
	// Example with a single `user` message:
	//
	// “`json
	// [{ "role": "user", "content": "Hello, Claude" }]
	// “`
	//
	// Example with multiple conversational turns:
	//
	// “`json
	// [
	//
	//	{ "role": "user", "content": "Hello there." },
	//	{ "role": "assistant", "content": "Hi, I'm Claude. How can I help you?" },
	//	{ "role": "user", "content": "Can you explain LLMs in plain English?" }
	//
	// ]
	// “`
	//
	// Example with a partially-filled response from Claude:
	//
	// “`json
	// [
	//
	//	{
	//	  "role": "user",
	//	  "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"
	//	},
	//	{ "role": "assistant", "content": "The best answer is (" }
	//
	// ]
	// “`
	//
	// Each input message `content` may be either a single `string` or an array of
	// content blocks, where each block has a specific `type`. Using a `string` for
	// `content` is shorthand for an array of one content block of type `"text"`. The
	// following input messages are equivalent:
	//
	// “`json
	// { "role": "user", "content": "Hello, Claude" }
	// “`
	//
	// “`json
	// { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
	// “`
	//
	// Starting with Claude 3 models, you can also send image content blocks:
	//
	// “`json
	//
	//	{
	//	  "role": "user",
	//	  "content": [
	//	    {
	//	      "type": "image",
	//	      "source": {
	//	        "type": "base64",
	//	        "media_type": "image/jpeg",
	//	        "data": "/9j/4AAQSkZJRg..."
	//	      }
	//	    },
	//	    { "type": "text", "text": "What is in this image?" }
	//	  ]
	//	}
	//
	// “`
	//
	// We currently support the `base64` source type for images, and the `image/jpeg`,
	// `image/png`, `image/gif`, and `image/webp` media types.
	//
	// See [examples](https://docs.anthropic.com/en/api/messages-examples#vision) for
	// more input examples.
	//
	// Note that if you want to include a
	// [system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
	// the top-level `system` parameter — there is no `"system"` role for input
	// messages in the Messages API.
	Messages []BetaMessageParam `json:"messages,omitzero,required"`
	// The model that will complete your prompt.\n\nSee
	// [models](https://docs.anthropic.com/en/docs/models-overview) for additional
	// details and options.
	Model Model `json:"model,omitzero,required"`
	// Amount of randomness injected into the response.
	//
	// Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0`
	// for analytical / multiple choice, and closer to `1.0` for creative and
	// generative tasks.
	//
	// Note that even with `temperature` of `0.0`, the results will not be fully
	// deterministic.
	Temperature param.Opt[float64] `json:"temperature,omitzero"`
	// Only sample from the top K options for each subsequent token.
	//
	// Used to remove "long tail" low probability responses.
	// [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).
	//
	// Recommended for advanced use cases only. You usually only need to use
	// `temperature`.
	TopK param.Opt[int64] `json:"top_k,omitzero"`
	// Use nucleus sampling.
	//
	// In nucleus sampling, we compute the cumulative distribution over all the options
	// for each subsequent token in decreasing probability order and cut it off once it
	// reaches a particular probability specified by `top_p`. You should either alter
	// `temperature` or `top_p`, but not both.
	//
	// Recommended for advanced use cases only. You usually only need to use
	// `temperature`.
	TopP param.Opt[float64] `json:"top_p,omitzero"`
	// An object describing metadata about the request.
	Metadata BetaMetadataParam `json:"metadata,omitzero"`
	// Custom text sequences that will cause the model to stop generating.
	//
	// Our models will normally stop when they have naturally completed their turn,
	// which will result in a response `stop_reason` of `"end_turn"`.
	//
	// If you want the model to stop generating when it encounters custom strings of
	// text, you can use the `stop_sequences` parameter. If the model encounters one of
	// the custom sequences, the response `stop_reason` value will be `"stop_sequence"`
	// and the response `stop_sequence` value will contain the matched stop sequence.
	StopSequences []string `json:"stop_sequences,omitzero"`
	// System prompt.
	//
	// A system prompt is a way of providing context and instructions to Claude, such
	// as specifying a particular goal or role. See our
	// [guide to system prompts](https://docs.anthropic.com/en/docs/system-prompts).
	System []BetaTextBlockParam `json:"system,omitzero"`
	// Configuration for enabling Claude's extended thinking.
	//
	// When enabled, responses include `thinking` content blocks showing Claude's
	// thinking process before the final answer. Requires a minimum budget of 1,024
	// tokens and counts towards your `max_tokens` limit.
	//
	// See
	// [extended thinking](https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking)
	// for details.
	Thinking BetaThinkingConfigParamUnion `json:"thinking,omitzero"`
	// How the model should use the provided tools. The model can use a specific tool,
	// any available tool, decide by itself, or not use tools at all.
	ToolChoice BetaToolChoiceUnionParam `json:"tool_choice,omitzero"`
	// Definitions of tools that the model may use.
	//
	// If you include `tools` in your API request, the model may return `tool_use`
	// content blocks that represent the model's use of those tools. You can then run
	// those tools using the tool input generated by the model and then optionally
	// return results back to the model using `tool_result` content blocks.
	//
	// Each tool definition includes:
	//
	//   - `name`: Name of the tool.
	//   - `description`: Optional, but strongly-recommended description of the tool.
	//   - `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the
	//     tool `input` shape that the model will produce in `tool_use` output content
	//     blocks.
	//
	// For example, if you defined `tools` as:
	//
	// “`json
	// [
	//
	//	{
	//	  "name": "get_stock_price",
	//	  "description": "Get the current stock price for a given ticker symbol.",
	//	  "input_schema": {
	//	    "type": "object",
	//	    "properties": {
	//	      "ticker": {
	//	        "type": "string",
	//	        "description": "The stock ticker symbol, e.g. AAPL for Apple Inc."
	//	      }
	//	    },
	//	    "required": ["ticker"]
	//	  }
	//	}
	//
	// ]
	// “`
	//
	// And then asked the model "What's the S&P 500 at today?", the model might produce
	// `tool_use` content blocks in the response like this:
	//
	// “`json
	// [
	//
	//	{
	//	  "type": "tool_use",
	//	  "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
	//	  "name": "get_stock_price",
	//	  "input": { "ticker": "^GSPC" }
	//	}
	//
	// ]
	// “`
	//
	// You might then run your `get_stock_price` tool with `{"ticker": "^GSPC"}` as an
	// input, and return the following back to the model in a subsequent `user`
	// message:
	//
	// “`json
	// [
	//
	//	{
	//	  "type": "tool_result",
	//	  "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
	//	  "content": "259.75 USD"
	//	}
	//
	// ]
	// “`
	//
	// Tools can be used for workflows that include running client-side tools and
	// functions, or more generally whenever you want the model to produce a particular
	// JSON structure of output.
	//
	// See our [guide](https://docs.anthropic.com/en/docs/tool-use) for more details.
	Tools []BetaToolUnionParam `json:"tools,omitzero"`
	// Optional header to specify the beta version(s) you want to use.
	Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (BetaMessageNewParams) IsPresent

func (f BetaMessageNewParams) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaMessageNewParams) MarshalJSON

func (r BetaMessageNewParams) MarshalJSON() (data []byte, err error)

type BetaMessageParam

type BetaMessageParam struct {
	Content []BetaContentBlockParamUnion `json:"content,omitzero,required"`
	// Any of "user", "assistant".
	Role BetaMessageParamRole `json:"role,omitzero,required"`
	// contains filtered or unexported fields
}

The properties Content, Role are required.

func (BetaMessageParam) IsPresent

func (f BetaMessageParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaMessageParam) MarshalJSON

func (r BetaMessageParam) MarshalJSON() (data []byte, err error)

type BetaMessageParamRole

type BetaMessageParamRole string
const (
	BetaMessageParamRoleUser      BetaMessageParamRole = "user"
	BetaMessageParamRoleAssistant BetaMessageParamRole = "assistant"
)

type BetaMessageService

type BetaMessageService struct {
	Options []option.RequestOption
	Batches BetaMessageBatchService
}

BetaMessageService contains methods and other services that help with interacting with the anthropic API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewBetaMessageService method instead.

func NewBetaMessageService

func NewBetaMessageService(opts ...option.RequestOption) (r BetaMessageService)

NewBetaMessageService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*BetaMessageService) CountTokens

Count the number of tokens in a Message.

The Token Count API can be used to count the number of tokens in a Message, including tools, images, and documents, without creating it.

Learn more about token counting in our [user guide](/en/docs/build-with-claude/token-counting)

func (*BetaMessageService) New

Send a structured list of input messages with text and/or image content, and the model will generate the next message in the conversation.

The Messages API can be used for either single queries or stateless multi-turn conversations.

Learn more about the Messages API in our [user guide](/en/docs/initial-setup)

Note: If you choose to set a timeout for this request, we recommend 10 minutes.

func (*BetaMessageService) NewStreaming

Send a structured list of input messages with text and/or image content, and the model will generate the next message in the conversation.

The Messages API can be used for either single queries or stateless multi-turn conversations.

Learn more about the Messages API in our [user guide](/en/docs/initial-setup)

Note: If you choose to set a timeout for this request, we recommend 10 minutes.

type BetaMessageStopReason

type BetaMessageStopReason string

The reason that we stopped.

This may be one the following values:

- `"end_turn"`: the model reached a natural stopping point - `"max_tokens"`: we exceeded the requested `max_tokens` or the model's maximum - `"stop_sequence"`: one of your provided custom `stop_sequences` was generated - `"tool_use"`: the model invoked one or more tools

In non-streaming mode this value is always non-null. In streaming mode, it is null in the `message_start` event and non-null otherwise.

const (
	BetaMessageStopReasonEndTurn      BetaMessageStopReason = "end_turn"
	BetaMessageStopReasonMaxTokens    BetaMessageStopReason = "max_tokens"
	BetaMessageStopReasonStopSequence BetaMessageStopReason = "stop_sequence"
	BetaMessageStopReasonToolUse      BetaMessageStopReason = "tool_use"
)

type BetaMessageTokensCount

type BetaMessageTokensCount struct {
	// The total number of tokens across the provided list of messages, system prompt,
	// and tools.
	InputTokens int64 `json:"input_tokens,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		InputTokens resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaMessageTokensCount) RawJSON

func (r BetaMessageTokensCount) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaMessageTokensCount) UnmarshalJSON

func (r *BetaMessageTokensCount) UnmarshalJSON(data []byte) error

type BetaMetadataParam

type BetaMetadataParam struct {
	// An external identifier for the user who is associated with the request.
	//
	// This should be a uuid, hash value, or other opaque identifier. Anthropic may use
	// this id to help detect abuse. Do not include any identifying information such as
	// name, email address, or phone number.
	UserID param.Opt[string] `json:"user_id,omitzero"`
	// contains filtered or unexported fields
}

func (BetaMetadataParam) IsPresent

func (f BetaMetadataParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaMetadataParam) MarshalJSON

func (r BetaMetadataParam) MarshalJSON() (data []byte, err error)

type BetaModelInfo

type BetaModelInfo struct {
	// Unique model identifier.
	ID string `json:"id,required"`
	// RFC 3339 datetime string representing the time at which the model was released.
	// May be set to an epoch value if the release date is unknown.
	CreatedAt time.Time `json:"created_at,required" format:"date-time"`
	// A human-readable name for the model.
	DisplayName string `json:"display_name,required"`
	// Object type.
	//
	// For Models, this is always `"model"`.
	Type constant.Model `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		ID          resp.Field
		CreatedAt   resp.Field
		DisplayName resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaModelInfo) RawJSON

func (r BetaModelInfo) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaModelInfo) UnmarshalJSON

func (r *BetaModelInfo) UnmarshalJSON(data []byte) error

type BetaModelListParams

type BetaModelListParams struct {
	// ID of the object to use as a cursor for pagination. When provided, returns the
	// page of results immediately after this object.
	AfterID param.Opt[string] `query:"after_id,omitzero" json:"-"`
	// ID of the object to use as a cursor for pagination. When provided, returns the
	// page of results immediately before this object.
	BeforeID param.Opt[string] `query:"before_id,omitzero" json:"-"`
	// Number of items to return per page.
	//
	// Defaults to `20`. Ranges from `1` to `1000`.
	Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (BetaModelListParams) IsPresent

func (f BetaModelListParams) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaModelListParams) URLQuery

func (r BetaModelListParams) URLQuery() (v url.Values)

URLQuery serializes BetaModelListParams's query parameters as `url.Values`.

type BetaModelService

type BetaModelService struct {
	Options []option.RequestOption
}

BetaModelService contains methods and other services that help with interacting with the anthropic API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewBetaModelService method instead.

func NewBetaModelService

func NewBetaModelService(opts ...option.RequestOption) (r BetaModelService)

NewBetaModelService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*BetaModelService) Get

func (r *BetaModelService) Get(ctx context.Context, modelID string, opts ...option.RequestOption) (res *BetaModelInfo, err error)

Get a specific model.

The Models API response can be used to determine information about a specific model or resolve a model alias to a model ID.

func (*BetaModelService) List

List available models.

The Models API response can be used to determine which models are available for use in the API. More recently released models are listed first.

func (*BetaModelService) ListAutoPaging

List available models.

The Models API response can be used to determine which models are available for use in the API. More recently released models are listed first.

type BetaNotFoundError

type BetaNotFoundError struct {
	Message string                 `json:"message,required"`
	Type    constant.NotFoundError `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Message     resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaNotFoundError) RawJSON

func (r BetaNotFoundError) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaNotFoundError) UnmarshalJSON

func (r *BetaNotFoundError) UnmarshalJSON(data []byte) error

type BetaOverloadedError

type BetaOverloadedError struct {
	Message string                   `json:"message,required"`
	Type    constant.OverloadedError `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Message     resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaOverloadedError) RawJSON

func (r BetaOverloadedError) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaOverloadedError) UnmarshalJSON

func (r *BetaOverloadedError) UnmarshalJSON(data []byte) error

type BetaPermissionError

type BetaPermissionError struct {
	Message string                   `json:"message,required"`
	Type    constant.PermissionError `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Message     resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaPermissionError) RawJSON

func (r BetaPermissionError) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaPermissionError) UnmarshalJSON

func (r *BetaPermissionError) UnmarshalJSON(data []byte) error

type BetaPlainTextSourceParam

type BetaPlainTextSourceParam struct {
	Data string `json:"data,required"`
	// This field can be elided, and will marshal its zero value as "text/plain".
	MediaType constant.TextPlain `json:"media_type,required"`
	// This field can be elided, and will marshal its zero value as "text".
	Type constant.Text `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Data, MediaType, Type are required.

func (BetaPlainTextSourceParam) IsPresent

func (f BetaPlainTextSourceParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaPlainTextSourceParam) MarshalJSON

func (r BetaPlainTextSourceParam) MarshalJSON() (data []byte, err error)

type BetaRateLimitError

type BetaRateLimitError struct {
	Message string                  `json:"message,required"`
	Type    constant.RateLimitError `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Message     resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaRateLimitError) RawJSON

func (r BetaRateLimitError) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaRateLimitError) UnmarshalJSON

func (r *BetaRateLimitError) UnmarshalJSON(data []byte) error

type BetaRawContentBlockDeltaEvent

type BetaRawContentBlockDeltaEvent struct {
	Delta BetaRawContentBlockDeltaEventDeltaUnion `json:"delta,required"`
	Index int64                                   `json:"index,required"`
	Type  constant.ContentBlockDelta              `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Delta       resp.Field
		Index       resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaRawContentBlockDeltaEvent) RawJSON

Returns the unmodified JSON received from the API

func (*BetaRawContentBlockDeltaEvent) UnmarshalJSON

func (r *BetaRawContentBlockDeltaEvent) UnmarshalJSON(data []byte) error

type BetaRawContentBlockDeltaEventDeltaUnion

type BetaRawContentBlockDeltaEventDeltaUnion struct {
	// This field is from variant [BetaTextDelta].
	Text string `json:"text"`
	// Any of "text_delta", "input_json_delta", "citations_delta", "thinking_delta",
	// "signature_delta".
	Type string `json:"type"`
	// This field is from variant [BetaInputJSONDelta].
	PartialJSON string `json:"partial_json"`
	// This field is from variant [BetaCitationsDelta].
	Citation BetaCitationsDeltaCitationUnion `json:"citation"`
	// This field is from variant [BetaThinkingDelta].
	Thinking string `json:"thinking"`
	// This field is from variant [BetaSignatureDelta].
	Signature string `json:"signature"`
	JSON      struct {
		Text        resp.Field
		Type        resp.Field
		PartialJSON resp.Field
		Citation    resp.Field
		Thinking    resp.Field
		Signature   resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

BetaRawContentBlockDeltaEventDeltaUnion contains all possible properties and values from BetaTextDelta, BetaInputJSONDelta, BetaCitationsDelta, BetaThinkingDelta, BetaSignatureDelta.

Use the BetaRawContentBlockDeltaEventDeltaUnion.AsAny method to switch on the variant.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (BetaRawContentBlockDeltaEventDeltaUnion) AsAny

Use the following switch statement to find the correct variant

switch variant := BetaRawContentBlockDeltaEventDeltaUnion.AsAny().(type) {
case BetaTextDelta:
case BetaInputJSONDelta:
case BetaCitationsDelta:
case BetaThinkingDelta:
case BetaSignatureDelta:
default:
  fmt.Errorf("no variant present")
}

func (BetaRawContentBlockDeltaEventDeltaUnion) AsCitationsDelta

func (BetaRawContentBlockDeltaEventDeltaUnion) AsInputJSONContentBlockDelta

func (u BetaRawContentBlockDeltaEventDeltaUnion) AsInputJSONContentBlockDelta() (v BetaInputJSONDelta)

func (BetaRawContentBlockDeltaEventDeltaUnion) AsSignatureContentBlockDelta

func (u BetaRawContentBlockDeltaEventDeltaUnion) AsSignatureContentBlockDelta() (v BetaSignatureDelta)

func (BetaRawContentBlockDeltaEventDeltaUnion) AsTextContentBlockDelta

func (u BetaRawContentBlockDeltaEventDeltaUnion) AsTextContentBlockDelta() (v BetaTextDelta)

func (BetaRawContentBlockDeltaEventDeltaUnion) AsThinkingContentBlockDelta

func (u BetaRawContentBlockDeltaEventDeltaUnion) AsThinkingContentBlockDelta() (v BetaThinkingDelta)

func (BetaRawContentBlockDeltaEventDeltaUnion) RawJSON

Returns the unmodified JSON received from the API

func (*BetaRawContentBlockDeltaEventDeltaUnion) UnmarshalJSON

func (r *BetaRawContentBlockDeltaEventDeltaUnion) UnmarshalJSON(data []byte) error

type BetaRawContentBlockStartEvent

type BetaRawContentBlockStartEvent struct {
	ContentBlock BetaRawContentBlockStartEventContentBlockUnion `json:"content_block,required"`
	Index        int64                                          `json:"index,required"`
	Type         constant.ContentBlockStart                     `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		ContentBlock resp.Field
		Index        resp.Field
		Type         resp.Field
		ExtraFields  map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaRawContentBlockStartEvent) RawJSON

Returns the unmodified JSON received from the API

func (*BetaRawContentBlockStartEvent) UnmarshalJSON

func (r *BetaRawContentBlockStartEvent) UnmarshalJSON(data []byte) error

type BetaRawContentBlockStartEventContentBlockUnion

type BetaRawContentBlockStartEventContentBlockUnion struct {
	// This field is from variant [BetaTextBlock].
	Citations []BetaTextCitationUnion `json:"citations"`
	// This field is from variant [BetaTextBlock].
	Text string `json:"text"`
	// Any of "text", "tool_use", "thinking", "redacted_thinking".
	Type string `json:"type"`
	// This field is from variant [BetaToolUseBlock].
	ID string `json:"id"`
	// This field is from variant [BetaToolUseBlock].
	Input interface{} `json:"input"`
	// This field is from variant [BetaToolUseBlock].
	Name string `json:"name"`
	// This field is from variant [BetaThinkingBlock].
	Signature string `json:"signature"`
	// This field is from variant [BetaThinkingBlock].
	Thinking string `json:"thinking"`
	// This field is from variant [BetaRedactedThinkingBlock].
	Data string `json:"data"`
	JSON struct {
		Citations resp.Field
		Text      resp.Field
		Type      resp.Field
		ID        resp.Field
		Input     resp.Field
		Name      resp.Field
		Signature resp.Field
		Thinking  resp.Field
		Data      resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

BetaRawContentBlockStartEventContentBlockUnion contains all possible properties and values from BetaTextBlock, BetaToolUseBlock, BetaThinkingBlock, BetaRedactedThinkingBlock.

Use the BetaRawContentBlockStartEventContentBlockUnion.AsAny method to switch on the variant.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (BetaRawContentBlockStartEventContentBlockUnion) AsAny

Use the following switch statement to find the correct variant

switch variant := BetaRawContentBlockStartEventContentBlockUnion.AsAny().(type) {
case BetaTextBlock:
case BetaToolUseBlock:
case BetaThinkingBlock:
case BetaRedactedThinkingBlock:
default:
  fmt.Errorf("no variant present")
}

func (BetaRawContentBlockStartEventContentBlockUnion) AsResponseRedactedThinkingBlock

func (u BetaRawContentBlockStartEventContentBlockUnion) AsResponseRedactedThinkingBlock() (v BetaRedactedThinkingBlock)

func (BetaRawContentBlockStartEventContentBlockUnion) AsResponseTextBlock

func (BetaRawContentBlockStartEventContentBlockUnion) AsResponseThinkingBlock

func (u BetaRawContentBlockStartEventContentBlockUnion) AsResponseThinkingBlock() (v BetaThinkingBlock)

func (BetaRawContentBlockStartEventContentBlockUnion) AsResponseToolUseBlock

func (BetaRawContentBlockStartEventContentBlockUnion) RawJSON

Returns the unmodified JSON received from the API

func (*BetaRawContentBlockStartEventContentBlockUnion) UnmarshalJSON

type BetaRawContentBlockStopEvent

type BetaRawContentBlockStopEvent struct {
	Index int64                     `json:"index,required"`
	Type  constant.ContentBlockStop `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Index       resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaRawContentBlockStopEvent) RawJSON

Returns the unmodified JSON received from the API

func (*BetaRawContentBlockStopEvent) UnmarshalJSON

func (r *BetaRawContentBlockStopEvent) UnmarshalJSON(data []byte) error

type BetaRawMessageDeltaEvent

type BetaRawMessageDeltaEvent struct {
	Delta BetaRawMessageDeltaEventDelta `json:"delta,required"`
	Type  constant.MessageDelta         `json:"type,required"`
	// Billing and rate-limit usage.
	//
	// Anthropic's API bills and rate-limits by token counts, as tokens represent the
	// underlying cost to our systems.
	//
	// Under the hood, the API transforms requests into a format suitable for the
	// model. The model's output then goes through a parsing stage before becoming an
	// API response. As a result, the token counts in `usage` will not match one-to-one
	// with the exact visible content of an API request or response.
	//
	// For example, `output_tokens` will be non-zero, even for an empty string response
	// from Claude.
	//
	// Total input tokens in a request is the summation of `input_tokens`,
	// `cache_creation_input_tokens`, and `cache_read_input_tokens`.
	Usage BetaMessageDeltaUsage `json:"usage,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Delta       resp.Field
		Type        resp.Field
		Usage       resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaRawMessageDeltaEvent) RawJSON

func (r BetaRawMessageDeltaEvent) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaRawMessageDeltaEvent) UnmarshalJSON

func (r *BetaRawMessageDeltaEvent) UnmarshalJSON(data []byte) error

type BetaRawMessageDeltaEventDelta

type BetaRawMessageDeltaEventDelta struct {
	// Any of "end_turn", "max_tokens", "stop_sequence", "tool_use".
	StopReason   string `json:"stop_reason,required"`
	StopSequence string `json:"stop_sequence,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		StopReason   resp.Field
		StopSequence resp.Field
		ExtraFields  map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaRawMessageDeltaEventDelta) RawJSON

Returns the unmodified JSON received from the API

func (*BetaRawMessageDeltaEventDelta) UnmarshalJSON

func (r *BetaRawMessageDeltaEventDelta) UnmarshalJSON(data []byte) error

type BetaRawMessageStartEvent

type BetaRawMessageStartEvent struct {
	Message BetaMessage           `json:"message,required"`
	Type    constant.MessageStart `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Message     resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaRawMessageStartEvent) RawJSON

func (r BetaRawMessageStartEvent) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaRawMessageStartEvent) UnmarshalJSON

func (r *BetaRawMessageStartEvent) UnmarshalJSON(data []byte) error

type BetaRawMessageStopEvent

type BetaRawMessageStopEvent struct {
	Type constant.MessageStop `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaRawMessageStopEvent) RawJSON

func (r BetaRawMessageStopEvent) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaRawMessageStopEvent) UnmarshalJSON

func (r *BetaRawMessageStopEvent) UnmarshalJSON(data []byte) error

type BetaRawMessageStreamEventUnion

type BetaRawMessageStreamEventUnion struct {
	// This field is from variant [BetaRawMessageStartEvent].
	Message BetaMessage `json:"message"`
	// Any of "message_start", "message_delta", "message_stop", "content_block_start",
	// "content_block_delta", "content_block_stop".
	Type string `json:"type"`
	// This field is a union of [BetaRawMessageDeltaEventDelta],
	// [BetaRawContentBlockDeltaEventDeltaUnion]
	Delta BetaRawMessageStreamEventUnionDelta `json:"delta"`
	// This field is from variant [BetaRawMessageDeltaEvent].
	Usage BetaMessageDeltaUsage `json:"usage"`
	// This field is from variant [BetaRawContentBlockStartEvent].
	ContentBlock BetaRawContentBlockStartEventContentBlockUnion `json:"content_block"`
	Index        int64                                          `json:"index"`
	JSON         struct {
		Message      resp.Field
		Type         resp.Field
		Delta        resp.Field
		Usage        resp.Field
		ContentBlock resp.Field
		Index        resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

BetaRawMessageStreamEventUnion contains all possible properties and values from BetaRawMessageStartEvent, BetaRawMessageDeltaEvent, BetaRawMessageStopEvent, BetaRawContentBlockStartEvent, BetaRawContentBlockDeltaEvent, BetaRawContentBlockStopEvent.

Use the BetaRawMessageStreamEventUnion.AsAny method to switch on the variant.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (BetaRawMessageStreamEventUnion) AsAny

Use the following switch statement to find the correct variant

switch variant := BetaRawMessageStreamEventUnion.AsAny().(type) {
case BetaRawMessageStartEvent:
case BetaRawMessageDeltaEvent:
case BetaRawMessageStopEvent:
case BetaRawContentBlockStartEvent:
case BetaRawContentBlockDeltaEvent:
case BetaRawContentBlockStopEvent:
default:
  fmt.Errorf("no variant present")
}

func (BetaRawMessageStreamEventUnion) AsContentBlockDeltaEvent

func (u BetaRawMessageStreamEventUnion) AsContentBlockDeltaEvent() (v BetaRawContentBlockDeltaEvent)

func (BetaRawMessageStreamEventUnion) AsContentBlockStartEvent

func (u BetaRawMessageStreamEventUnion) AsContentBlockStartEvent() (v BetaRawContentBlockStartEvent)

func (BetaRawMessageStreamEventUnion) AsContentBlockStopEvent

func (u BetaRawMessageStreamEventUnion) AsContentBlockStopEvent() (v BetaRawContentBlockStopEvent)

func (BetaRawMessageStreamEventUnion) AsMessageDeltaEvent

func (u BetaRawMessageStreamEventUnion) AsMessageDeltaEvent() (v BetaRawMessageDeltaEvent)

func (BetaRawMessageStreamEventUnion) AsMessageStartEvent

func (u BetaRawMessageStreamEventUnion) AsMessageStartEvent() (v BetaRawMessageStartEvent)

func (BetaRawMessageStreamEventUnion) AsMessageStopEvent

func (u BetaRawMessageStreamEventUnion) AsMessageStopEvent() (v BetaRawMessageStopEvent)

func (BetaRawMessageStreamEventUnion) RawJSON

Returns the unmodified JSON received from the API

func (*BetaRawMessageStreamEventUnion) UnmarshalJSON

func (r *BetaRawMessageStreamEventUnion) UnmarshalJSON(data []byte) error

type BetaRawMessageStreamEventUnionDelta

type BetaRawMessageStreamEventUnionDelta struct {
	// This field is from variant [BetaRawMessageDeltaEventDelta].
	StopReason string `json:"stop_reason"`
	// This field is from variant [BetaRawMessageDeltaEventDelta].
	StopSequence string `json:"stop_sequence"`
	// This field is from variant [BetaRawContentBlockDeltaEventDeltaUnion].
	Text string `json:"text"`
	Type string `json:"type"`
	// This field is from variant [BetaRawContentBlockDeltaEventDeltaUnion].
	PartialJSON string `json:"partial_json"`
	// This field is from variant [BetaRawContentBlockDeltaEventDeltaUnion].
	Citation BetaCitationsDeltaCitationUnion `json:"citation"`
	// This field is from variant [BetaRawContentBlockDeltaEventDeltaUnion].
	Thinking string `json:"thinking"`
	// This field is from variant [BetaRawContentBlockDeltaEventDeltaUnion].
	Signature string `json:"signature"`
	JSON      struct {
		StopReason   resp.Field
		StopSequence resp.Field
		Text         resp.Field
		Type         resp.Field
		PartialJSON  resp.Field
		Citation     resp.Field
		Thinking     resp.Field
		Signature    resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

BetaRawMessageStreamEventUnionDelta is an implicit subunion of BetaRawMessageStreamEventUnion. BetaRawMessageStreamEventUnionDelta provides convenient access to the sub-properties of the union.

For type safety it is recommended to directly use a variant of the BetaRawMessageStreamEventUnion.

func (*BetaRawMessageStreamEventUnionDelta) UnmarshalJSON

func (r *BetaRawMessageStreamEventUnionDelta) UnmarshalJSON(data []byte) error

type BetaRedactedThinkingBlock

type BetaRedactedThinkingBlock struct {
	Data string                    `json:"data,required"`
	Type constant.RedactedThinking `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Data        resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaRedactedThinkingBlock) RawJSON

func (r BetaRedactedThinkingBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (BetaRedactedThinkingBlock) ToParam

func (*BetaRedactedThinkingBlock) UnmarshalJSON

func (r *BetaRedactedThinkingBlock) UnmarshalJSON(data []byte) error

type BetaRedactedThinkingBlockParam

type BetaRedactedThinkingBlockParam struct {
	Data string `json:"data,required"`
	// This field can be elided, and will marshal its zero value as
	// "redacted_thinking".
	Type constant.RedactedThinking `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Data, Type are required.

func (BetaRedactedThinkingBlockParam) IsPresent

func (f BetaRedactedThinkingBlockParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaRedactedThinkingBlockParam) MarshalJSON

func (r BetaRedactedThinkingBlockParam) MarshalJSON() (data []byte, err error)

type BetaService

type BetaService struct {
	Options  []option.RequestOption
	Models   BetaModelService
	Messages BetaMessageService
}

BetaService contains methods and other services that help with interacting with the anthropic API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewBetaService method instead.

func NewBetaService

func NewBetaService(opts ...option.RequestOption) (r BetaService)

NewBetaService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

type BetaSignatureDelta

type BetaSignatureDelta struct {
	Signature string                  `json:"signature,required"`
	Type      constant.SignatureDelta `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Signature   resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaSignatureDelta) RawJSON

func (r BetaSignatureDelta) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaSignatureDelta) UnmarshalJSON

func (r *BetaSignatureDelta) UnmarshalJSON(data []byte) error

type BetaTextBlock

type BetaTextBlock struct {
	// Citations supporting the text block.
	//
	// The type of citation returned will depend on the type of document being cited.
	// Citing a PDF results in `page_location`, plain text results in `char_location`,
	// and content document results in `content_block_location`.
	Citations []BetaTextCitationUnion `json:"citations,required"`
	Text      string                  `json:"text,required"`
	Type      constant.Text           `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Citations   resp.Field
		Text        resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaTextBlock) RawJSON

func (r BetaTextBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (BetaTextBlock) ToParam

func (r BetaTextBlock) ToParam() BetaTextBlockParam

func (*BetaTextBlock) UnmarshalJSON

func (r *BetaTextBlock) UnmarshalJSON(data []byte) error

type BetaTextBlockParam

type BetaTextBlockParam struct {
	Text         string                         `json:"text,required"`
	Citations    []BetaTextCitationParamUnion   `json:"citations,omitzero"`
	CacheControl BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	// This field can be elided, and will marshal its zero value as "text".
	Type constant.Text `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Text, Type are required.

func (BetaTextBlockParam) IsPresent

func (f BetaTextBlockParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaTextBlockParam) MarshalJSON

func (r BetaTextBlockParam) MarshalJSON() (data []byte, err error)

type BetaTextCitationParamUnion

type BetaTextCitationParamUnion struct {
	OfRequestCharLocationCitation         *BetaCitationCharLocationParam         `json:",omitzero,inline"`
	OfRequestPageLocationCitation         *BetaCitationPageLocationParam         `json:",omitzero,inline"`
	OfRequestContentBlockLocationCitation *BetaCitationContentBlockLocationParam `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (BetaTextCitationParamUnion) GetCitedText

func (u BetaTextCitationParamUnion) GetCitedText() *string

Returns a pointer to the underlying variant's property, if present.

func (BetaTextCitationParamUnion) GetDocumentIndex

func (u BetaTextCitationParamUnion) GetDocumentIndex() *int64

Returns a pointer to the underlying variant's property, if present.

func (BetaTextCitationParamUnion) GetDocumentTitle

func (u BetaTextCitationParamUnion) GetDocumentTitle() *string

Returns a pointer to the underlying variant's property, if present.

func (BetaTextCitationParamUnion) GetEndBlockIndex

func (u BetaTextCitationParamUnion) GetEndBlockIndex() *int64

Returns a pointer to the underlying variant's property, if present.

func (BetaTextCitationParamUnion) GetEndCharIndex

func (u BetaTextCitationParamUnion) GetEndCharIndex() *int64

Returns a pointer to the underlying variant's property, if present.

func (BetaTextCitationParamUnion) GetEndPageNumber

func (u BetaTextCitationParamUnion) GetEndPageNumber() *int64

Returns a pointer to the underlying variant's property, if present.

func (BetaTextCitationParamUnion) GetStartBlockIndex

func (u BetaTextCitationParamUnion) GetStartBlockIndex() *int64

Returns a pointer to the underlying variant's property, if present.

func (BetaTextCitationParamUnion) GetStartCharIndex

func (u BetaTextCitationParamUnion) GetStartCharIndex() *int64

Returns a pointer to the underlying variant's property, if present.

func (BetaTextCitationParamUnion) GetStartPageNumber

func (u BetaTextCitationParamUnion) GetStartPageNumber() *int64

Returns a pointer to the underlying variant's property, if present.

func (BetaTextCitationParamUnion) GetType

func (u BetaTextCitationParamUnion) GetType() *string

Returns a pointer to the underlying variant's property, if present.

func (BetaTextCitationParamUnion) IsPresent

func (u BetaTextCitationParamUnion) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaTextCitationParamUnion) MarshalJSON

func (u BetaTextCitationParamUnion) MarshalJSON() ([]byte, error)

type BetaTextCitationUnion

type BetaTextCitationUnion struct {
	CitedText     string `json:"cited_text"`
	DocumentIndex int64  `json:"document_index"`
	DocumentTitle string `json:"document_title"`
	// This field is from variant [BetaCitationCharLocation].
	EndCharIndex int64 `json:"end_char_index"`
	// This field is from variant [BetaCitationCharLocation].
	StartCharIndex int64 `json:"start_char_index"`
	// Any of "char_location", "page_location", "content_block_location".
	Type string `json:"type"`
	// This field is from variant [BetaCitationPageLocation].
	EndPageNumber int64 `json:"end_page_number"`
	// This field is from variant [BetaCitationPageLocation].
	StartPageNumber int64 `json:"start_page_number"`
	// This field is from variant [BetaCitationContentBlockLocation].
	EndBlockIndex int64 `json:"end_block_index"`
	// This field is from variant [BetaCitationContentBlockLocation].
	StartBlockIndex int64 `json:"start_block_index"`
	JSON            struct {
		CitedText       resp.Field
		DocumentIndex   resp.Field
		DocumentTitle   resp.Field
		EndCharIndex    resp.Field
		StartCharIndex  resp.Field
		Type            resp.Field
		EndPageNumber   resp.Field
		StartPageNumber resp.Field
		EndBlockIndex   resp.Field
		StartBlockIndex resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

BetaTextCitationUnion contains all possible properties and values from BetaCitationCharLocation, BetaCitationPageLocation, BetaCitationContentBlockLocation.

Use the BetaTextCitationUnion.AsAny method to switch on the variant.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (BetaTextCitationUnion) AsAny

func (u BetaTextCitationUnion) AsAny() any

Use the following switch statement to find the correct variant

switch variant := BetaTextCitationUnion.AsAny().(type) {
case BetaCitationCharLocation:
case BetaCitationPageLocation:
case BetaCitationContentBlockLocation:
default:
  fmt.Errorf("no variant present")
}

func (BetaTextCitationUnion) AsResponseCharLocationCitation

func (u BetaTextCitationUnion) AsResponseCharLocationCitation() (v BetaCitationCharLocation)

func (BetaTextCitationUnion) AsResponseContentBlockLocationCitation

func (u BetaTextCitationUnion) AsResponseContentBlockLocationCitation() (v BetaCitationContentBlockLocation)

func (BetaTextCitationUnion) AsResponsePageLocationCitation

func (u BetaTextCitationUnion) AsResponsePageLocationCitation() (v BetaCitationPageLocation)

func (BetaTextCitationUnion) RawJSON

func (u BetaTextCitationUnion) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaTextCitationUnion) UnmarshalJSON

func (r *BetaTextCitationUnion) UnmarshalJSON(data []byte) error

type BetaTextDelta

type BetaTextDelta struct {
	Text string             `json:"text,required"`
	Type constant.TextDelta `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Text        resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaTextDelta) RawJSON

func (r BetaTextDelta) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaTextDelta) UnmarshalJSON

func (r *BetaTextDelta) UnmarshalJSON(data []byte) error

type BetaThinkingBlock

type BetaThinkingBlock struct {
	Signature string            `json:"signature,required"`
	Thinking  string            `json:"thinking,required"`
	Type      constant.Thinking `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Signature   resp.Field
		Thinking    resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaThinkingBlock) RawJSON

func (r BetaThinkingBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (BetaThinkingBlock) ToParam

func (*BetaThinkingBlock) UnmarshalJSON

func (r *BetaThinkingBlock) UnmarshalJSON(data []byte) error

type BetaThinkingBlockParam

type BetaThinkingBlockParam struct {
	Signature string `json:"signature,required"`
	Thinking  string `json:"thinking,required"`
	// This field can be elided, and will marshal its zero value as "thinking".
	Type constant.Thinking `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Signature, Thinking, Type are required.

func (BetaThinkingBlockParam) IsPresent

func (f BetaThinkingBlockParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaThinkingBlockParam) MarshalJSON

func (r BetaThinkingBlockParam) MarshalJSON() (data []byte, err error)

type BetaThinkingConfigDisabledParam

type BetaThinkingConfigDisabledParam struct {
	// This field can be elided, and will marshal its zero value as "disabled".
	Type constant.Disabled `json:"type,required"`
	// contains filtered or unexported fields
}

The property Type is required.

func (BetaThinkingConfigDisabledParam) IsPresent

func (f BetaThinkingConfigDisabledParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaThinkingConfigDisabledParam) MarshalJSON

func (r BetaThinkingConfigDisabledParam) MarshalJSON() (data []byte, err error)

type BetaThinkingConfigEnabledParam

type BetaThinkingConfigEnabledParam struct {
	// Determines how many tokens Claude can use for its internal reasoning process.
	// Larger budgets can enable more thorough analysis for complex problems, improving
	// response quality.
	//
	// Must be ≥1024 and less than `max_tokens`.
	//
	// See
	// [extended thinking](https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking)
	// for details.
	BudgetTokens int64 `json:"budget_tokens,required"`
	// This field can be elided, and will marshal its zero value as "enabled".
	Type constant.Enabled `json:"type,required"`
	// contains filtered or unexported fields
}

The properties BudgetTokens, Type are required.

func (BetaThinkingConfigEnabledParam) IsPresent

func (f BetaThinkingConfigEnabledParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaThinkingConfigEnabledParam) MarshalJSON

func (r BetaThinkingConfigEnabledParam) MarshalJSON() (data []byte, err error)

type BetaThinkingConfigParamUnion

type BetaThinkingConfigParamUnion struct {
	OfThinkingConfigEnabled  *BetaThinkingConfigEnabledParam  `json:",omitzero,inline"`
	OfThinkingConfigDisabled *BetaThinkingConfigDisabledParam `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func BetaThinkingConfigParamOfThinkingConfigEnabled

func BetaThinkingConfigParamOfThinkingConfigEnabled(budgetTokens int64) BetaThinkingConfigParamUnion

func (BetaThinkingConfigParamUnion) GetBudgetTokens

func (u BetaThinkingConfigParamUnion) GetBudgetTokens() *int64

Returns a pointer to the underlying variant's property, if present.

func (BetaThinkingConfigParamUnion) GetType

func (u BetaThinkingConfigParamUnion) GetType() *string

Returns a pointer to the underlying variant's property, if present.

func (BetaThinkingConfigParamUnion) IsPresent

func (u BetaThinkingConfigParamUnion) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaThinkingConfigParamUnion) MarshalJSON

func (u BetaThinkingConfigParamUnion) MarshalJSON() ([]byte, error)

type BetaThinkingDelta

type BetaThinkingDelta struct {
	Thinking string                 `json:"thinking,required"`
	Type     constant.ThinkingDelta `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Thinking    resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaThinkingDelta) RawJSON

func (r BetaThinkingDelta) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaThinkingDelta) UnmarshalJSON

func (r *BetaThinkingDelta) UnmarshalJSON(data []byte) error

type BetaToolBash20241022Param

type BetaToolBash20241022Param struct {
	CacheControl BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	// Name of the tool.
	//
	// This is how the tool will be called by the model and in tool_use blocks.
	//
	// This field can be elided, and will marshal its zero value as "bash".
	Name constant.Bash `json:"name,required"`
	// This field can be elided, and will marshal its zero value as "bash_20241022".
	Type constant.Bash20241022 `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Name, Type are required.

func (BetaToolBash20241022Param) IsPresent

func (f BetaToolBash20241022Param) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaToolBash20241022Param) MarshalJSON

func (r BetaToolBash20241022Param) MarshalJSON() (data []byte, err error)

type BetaToolBash20250124Param

type BetaToolBash20250124Param struct {
	CacheControl BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	// Name of the tool.
	//
	// This is how the tool will be called by the model and in tool_use blocks.
	//
	// This field can be elided, and will marshal its zero value as "bash".
	Name constant.Bash `json:"name,required"`
	// This field can be elided, and will marshal its zero value as "bash_20250124".
	Type constant.Bash20250124 `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Name, Type are required.

func (BetaToolBash20250124Param) IsPresent

func (f BetaToolBash20250124Param) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaToolBash20250124Param) MarshalJSON

func (r BetaToolBash20250124Param) MarshalJSON() (data []byte, err error)

type BetaToolChoiceAnyParam

type BetaToolChoiceAnyParam struct {
	// Whether to disable parallel tool use.
	//
	// Defaults to `false`. If set to `true`, the model will output exactly one tool
	// use.
	DisableParallelToolUse param.Opt[bool] `json:"disable_parallel_tool_use,omitzero"`
	// This field can be elided, and will marshal its zero value as "any".
	Type constant.Any `json:"type,required"`
	// contains filtered or unexported fields
}

The model will use any available tools.

The property Type is required.

func (BetaToolChoiceAnyParam) IsPresent

func (f BetaToolChoiceAnyParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaToolChoiceAnyParam) MarshalJSON

func (r BetaToolChoiceAnyParam) MarshalJSON() (data []byte, err error)

type BetaToolChoiceAutoParam

type BetaToolChoiceAutoParam struct {
	// Whether to disable parallel tool use.
	//
	// Defaults to `false`. If set to `true`, the model will output at most one tool
	// use.
	DisableParallelToolUse param.Opt[bool] `json:"disable_parallel_tool_use,omitzero"`
	// This field can be elided, and will marshal its zero value as "auto".
	Type constant.Auto `json:"type,required"`
	// contains filtered or unexported fields
}

The model will automatically decide whether to use tools.

The property Type is required.

func (BetaToolChoiceAutoParam) IsPresent

func (f BetaToolChoiceAutoParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaToolChoiceAutoParam) MarshalJSON

func (r BetaToolChoiceAutoParam) MarshalJSON() (data []byte, err error)

type BetaToolChoiceNoneParam

type BetaToolChoiceNoneParam struct {
	// This field can be elided, and will marshal its zero value as "none".
	Type constant.None `json:"type,required"`
	// contains filtered or unexported fields
}

The model will not be allowed to use tools.

The property Type is required.

func (BetaToolChoiceNoneParam) IsPresent

func (f BetaToolChoiceNoneParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaToolChoiceNoneParam) MarshalJSON

func (r BetaToolChoiceNoneParam) MarshalJSON() (data []byte, err error)

type BetaToolChoiceToolParam

type BetaToolChoiceToolParam struct {
	// The name of the tool to use.
	Name string `json:"name,required"`
	// Whether to disable parallel tool use.
	//
	// Defaults to `false`. If set to `true`, the model will output exactly one tool
	// use.
	DisableParallelToolUse param.Opt[bool] `json:"disable_parallel_tool_use,omitzero"`
	// This field can be elided, and will marshal its zero value as "tool".
	Type constant.Tool `json:"type,required"`
	// contains filtered or unexported fields
}

The model will use the specified tool with `tool_choice.name`.

The properties Name, Type are required.

func (BetaToolChoiceToolParam) IsPresent

func (f BetaToolChoiceToolParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaToolChoiceToolParam) MarshalJSON

func (r BetaToolChoiceToolParam) MarshalJSON() (data []byte, err error)

type BetaToolChoiceUnionParam

type BetaToolChoiceUnionParam struct {
	OfToolChoiceAuto *BetaToolChoiceAutoParam `json:",omitzero,inline"`
	OfToolChoiceAny  *BetaToolChoiceAnyParam  `json:",omitzero,inline"`
	OfToolChoiceTool *BetaToolChoiceToolParam `json:",omitzero,inline"`
	OfToolChoiceNone *BetaToolChoiceNoneParam `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func BetaToolChoiceParamOfToolChoiceTool

func BetaToolChoiceParamOfToolChoiceTool(name string) BetaToolChoiceUnionParam

func (BetaToolChoiceUnionParam) GetDisableParallelToolUse

func (u BetaToolChoiceUnionParam) GetDisableParallelToolUse() *bool

Returns a pointer to the underlying variant's property, if present.

func (BetaToolChoiceUnionParam) GetName

func (u BetaToolChoiceUnionParam) GetName() *string

Returns a pointer to the underlying variant's property, if present.

func (BetaToolChoiceUnionParam) GetType

func (u BetaToolChoiceUnionParam) GetType() *string

Returns a pointer to the underlying variant's property, if present.

func (BetaToolChoiceUnionParam) IsPresent

func (u BetaToolChoiceUnionParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaToolChoiceUnionParam) MarshalJSON

func (u BetaToolChoiceUnionParam) MarshalJSON() ([]byte, error)

type BetaToolComputerUse20241022Param

type BetaToolComputerUse20241022Param struct {
	// The height of the display in pixels.
	DisplayHeightPx int64 `json:"display_height_px,required"`
	// The width of the display in pixels.
	DisplayWidthPx int64 `json:"display_width_px,required"`
	// The X11 display number (e.g. 0, 1) for the display.
	DisplayNumber param.Opt[int64]               `json:"display_number,omitzero"`
	CacheControl  BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	// Name of the tool.
	//
	// This is how the tool will be called by the model and in tool_use blocks.
	//
	// This field can be elided, and will marshal its zero value as "computer".
	Name constant.Computer `json:"name,required"`
	// This field can be elided, and will marshal its zero value as
	// "computer_20241022".
	Type constant.Computer20241022 `json:"type,required"`
	// contains filtered or unexported fields
}

The properties DisplayHeightPx, DisplayWidthPx, Name, Type are required.

func (BetaToolComputerUse20241022Param) IsPresent

func (f BetaToolComputerUse20241022Param) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaToolComputerUse20241022Param) MarshalJSON

func (r BetaToolComputerUse20241022Param) MarshalJSON() (data []byte, err error)

type BetaToolComputerUse20250124Param

type BetaToolComputerUse20250124Param struct {
	// The height of the display in pixels.
	DisplayHeightPx int64 `json:"display_height_px,required"`
	// The width of the display in pixels.
	DisplayWidthPx int64 `json:"display_width_px,required"`
	// The X11 display number (e.g. 0, 1) for the display.
	DisplayNumber param.Opt[int64]               `json:"display_number,omitzero"`
	CacheControl  BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	// Name of the tool.
	//
	// This is how the tool will be called by the model and in tool_use blocks.
	//
	// This field can be elided, and will marshal its zero value as "computer".
	Name constant.Computer `json:"name,required"`
	// This field can be elided, and will marshal its zero value as
	// "computer_20250124".
	Type constant.Computer20250124 `json:"type,required"`
	// contains filtered or unexported fields
}

The properties DisplayHeightPx, DisplayWidthPx, Name, Type are required.

func (BetaToolComputerUse20250124Param) IsPresent

func (f BetaToolComputerUse20250124Param) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaToolComputerUse20250124Param) MarshalJSON

func (r BetaToolComputerUse20250124Param) MarshalJSON() (data []byte, err error)

type BetaToolInputSchemaParam

type BetaToolInputSchemaParam struct {
	Properties interface{} `json:"properties,omitzero"`
	// This field can be elided, and will marshal its zero value as "object".
	Type        constant.Object        `json:"type,required"`
	ExtraFields map[string]interface{} `json:"-,extras"`
	// contains filtered or unexported fields
}

[JSON schema](https://json-schema.org/draft/2020-12) for this tool's input.

This defines the shape of the `input` that your tool accepts and that the model will produce.

The property Type is required.

func (BetaToolInputSchemaParam) IsPresent

func (f BetaToolInputSchemaParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaToolInputSchemaParam) MarshalJSON

func (r BetaToolInputSchemaParam) MarshalJSON() (data []byte, err error)

type BetaToolParam

type BetaToolParam struct {
	// [JSON schema](https://json-schema.org/draft/2020-12) for this tool's input.
	//
	// This defines the shape of the `input` that your tool accepts and that the model
	// will produce.
	InputSchema BetaToolInputSchemaParam `json:"input_schema,omitzero,required"`
	// Name of the tool.
	//
	// This is how the tool will be called by the model and in tool_use blocks.
	Name string `json:"name,required"`
	// Description of what this tool does.
	//
	// Tool descriptions should be as detailed as possible. The more information that
	// the model has about what the tool is and how to use it, the better it will
	// perform. You can use natural language descriptions to reinforce important
	// aspects of the tool input JSON schema.
	Description param.Opt[string] `json:"description,omitzero"`
	// Any of "custom".
	Type         BetaToolType                   `json:"type,omitzero"`
	CacheControl BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	// contains filtered or unexported fields
}

The properties InputSchema, Name are required.

func (BetaToolParam) IsPresent

func (f BetaToolParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaToolParam) MarshalJSON

func (r BetaToolParam) MarshalJSON() (data []byte, err error)

type BetaToolResultBlockParam

type BetaToolResultBlockParam struct {
	ToolUseID    string                                 `json:"tool_use_id,required"`
	IsError      param.Opt[bool]                        `json:"is_error,omitzero"`
	CacheControl BetaCacheControlEphemeralParam         `json:"cache_control,omitzero"`
	Content      []BetaToolResultBlockParamContentUnion `json:"content,omitzero"`
	// This field can be elided, and will marshal its zero value as "tool_result".
	Type constant.ToolResult `json:"type,required"`
	// contains filtered or unexported fields
}

The properties ToolUseID, Type are required.

func (BetaToolResultBlockParam) IsPresent

func (f BetaToolResultBlockParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaToolResultBlockParam) MarshalJSON

func (r BetaToolResultBlockParam) MarshalJSON() (data []byte, err error)

type BetaToolResultBlockParamContentUnion

type BetaToolResultBlockParamContentUnion struct {
	OfRequestTextBlock  *BetaTextBlockParam  `json:",omitzero,inline"`
	OfRequestImageBlock *BetaImageBlockParam `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (BetaToolResultBlockParamContentUnion) GetCacheControl

Returns a pointer to the underlying variant's CacheControl property, if present.

func (BetaToolResultBlockParamContentUnion) GetCitations

Returns a pointer to the underlying variant's property, if present.

func (BetaToolResultBlockParamContentUnion) GetSource

Returns a pointer to the underlying variant's property, if present.

func (BetaToolResultBlockParamContentUnion) GetText

Returns a pointer to the underlying variant's property, if present.

func (BetaToolResultBlockParamContentUnion) GetType

Returns a pointer to the underlying variant's property, if present.

func (BetaToolResultBlockParamContentUnion) IsPresent

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaToolResultBlockParamContentUnion) MarshalJSON

func (u BetaToolResultBlockParamContentUnion) MarshalJSON() ([]byte, error)

type BetaToolTextEditor20241022Param

type BetaToolTextEditor20241022Param struct {
	CacheControl BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	// Name of the tool.
	//
	// This is how the tool will be called by the model and in tool_use blocks.
	//
	// This field can be elided, and will marshal its zero value as
	// "str_replace_editor".
	Name constant.StrReplaceEditor `json:"name,required"`
	// This field can be elided, and will marshal its zero value as
	// "text_editor_20241022".
	Type constant.TextEditor20241022 `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Name, Type are required.

func (BetaToolTextEditor20241022Param) IsPresent

func (f BetaToolTextEditor20241022Param) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaToolTextEditor20241022Param) MarshalJSON

func (r BetaToolTextEditor20241022Param) MarshalJSON() (data []byte, err error)

type BetaToolTextEditor20250124Param

type BetaToolTextEditor20250124Param struct {
	CacheControl BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	// Name of the tool.
	//
	// This is how the tool will be called by the model and in tool_use blocks.
	//
	// This field can be elided, and will marshal its zero value as
	// "str_replace_editor".
	Name constant.StrReplaceEditor `json:"name,required"`
	// This field can be elided, and will marshal its zero value as
	// "text_editor_20250124".
	Type constant.TextEditor20250124 `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Name, Type are required.

func (BetaToolTextEditor20250124Param) IsPresent

func (f BetaToolTextEditor20250124Param) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaToolTextEditor20250124Param) MarshalJSON

func (r BetaToolTextEditor20250124Param) MarshalJSON() (data []byte, err error)

type BetaToolType

type BetaToolType string
const (
	BetaToolTypeCustom BetaToolType = "custom"
)

type BetaToolUnionParam

type BetaToolUnionParam struct {
	OfTool                    *BetaToolParam                    `json:",omitzero,inline"`
	OfComputerUseTool20241022 *BetaToolComputerUse20241022Param `json:",omitzero,inline"`
	OfBashTool20241022        *BetaToolBash20241022Param        `json:",omitzero,inline"`
	OfTextEditor20241022      *BetaToolTextEditor20241022Param  `json:",omitzero,inline"`
	OfComputerUseTool20250124 *BetaToolComputerUse20250124Param `json:",omitzero,inline"`
	OfBashTool20250124        *BetaToolBash20250124Param        `json:",omitzero,inline"`
	OfTextEditor20250124      *BetaToolTextEditor20250124Param  `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func BetaToolUnionParamOfComputerUseTool20241022

func BetaToolUnionParamOfComputerUseTool20241022(displayHeightPx int64, displayWidthPx int64) BetaToolUnionParam

func BetaToolUnionParamOfComputerUseTool20250124

func BetaToolUnionParamOfComputerUseTool20250124(displayHeightPx int64, displayWidthPx int64) BetaToolUnionParam

func BetaToolUnionParamOfTool

func BetaToolUnionParamOfTool(inputSchema BetaToolInputSchemaParam, name string) BetaToolUnionParam

func (BetaToolUnionParam) GetCacheControl

Returns a pointer to the underlying variant's CacheControl property, if present.

func (BetaToolUnionParam) GetDescription

func (u BetaToolUnionParam) GetDescription() *string

Returns a pointer to the underlying variant's property, if present.

func (BetaToolUnionParam) GetDisplayHeightPx

func (u BetaToolUnionParam) GetDisplayHeightPx() *int64

Returns a pointer to the underlying variant's property, if present.

func (BetaToolUnionParam) GetDisplayNumber

func (u BetaToolUnionParam) GetDisplayNumber() *int64

Returns a pointer to the underlying variant's property, if present.

func (BetaToolUnionParam) GetDisplayWidthPx

func (u BetaToolUnionParam) GetDisplayWidthPx() *int64

Returns a pointer to the underlying variant's property, if present.

func (BetaToolUnionParam) GetInputSchema

func (u BetaToolUnionParam) GetInputSchema() *BetaToolInputSchemaParam

Returns a pointer to the underlying variant's property, if present.

func (BetaToolUnionParam) GetName

func (u BetaToolUnionParam) GetName() *string

Returns a pointer to the underlying variant's property, if present.

func (BetaToolUnionParam) GetType

func (u BetaToolUnionParam) GetType() *string

Returns a pointer to the underlying variant's property, if present.

func (BetaToolUnionParam) IsPresent

func (u BetaToolUnionParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaToolUnionParam) MarshalJSON

func (u BetaToolUnionParam) MarshalJSON() ([]byte, error)

type BetaToolUseBlock

type BetaToolUseBlock struct {
	ID    string           `json:"id,required"`
	Input interface{}      `json:"input,required"`
	Name  string           `json:"name,required"`
	Type  constant.ToolUse `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		ID          resp.Field
		Input       resp.Field
		Name        resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaToolUseBlock) RawJSON

func (r BetaToolUseBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (BetaToolUseBlock) ToParam

func (*BetaToolUseBlock) UnmarshalJSON

func (r *BetaToolUseBlock) UnmarshalJSON(data []byte) error

type BetaToolUseBlockParam

type BetaToolUseBlockParam struct {
	ID           string                         `json:"id,required"`
	Input        interface{}                    `json:"input,omitzero,required"`
	Name         string                         `json:"name,required"`
	CacheControl BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	// This field can be elided, and will marshal its zero value as "tool_use".
	Type constant.ToolUse `json:"type,required"`
	// contains filtered or unexported fields
}

The properties ID, Input, Name, Type are required.

func (BetaToolUseBlockParam) IsPresent

func (f BetaToolUseBlockParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaToolUseBlockParam) MarshalJSON

func (r BetaToolUseBlockParam) MarshalJSON() (data []byte, err error)

type BetaURLImageSourceParam

type BetaURLImageSourceParam struct {
	URL string `json:"url,required"`
	// This field can be elided, and will marshal its zero value as "url".
	Type constant.URL `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Type, URL are required.

func (BetaURLImageSourceParam) IsPresent

func (f BetaURLImageSourceParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaURLImageSourceParam) MarshalJSON

func (r BetaURLImageSourceParam) MarshalJSON() (data []byte, err error)

type BetaURLPDFSourceParam

type BetaURLPDFSourceParam struct {
	URL string `json:"url,required"`
	// This field can be elided, and will marshal its zero value as "url".
	Type constant.URL `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Type, URL are required.

func (BetaURLPDFSourceParam) IsPresent

func (f BetaURLPDFSourceParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (BetaURLPDFSourceParam) MarshalJSON

func (r BetaURLPDFSourceParam) MarshalJSON() (data []byte, err error)

type BetaUsage

type BetaUsage struct {
	// The number of input tokens used to create the cache entry.
	CacheCreationInputTokens int64 `json:"cache_creation_input_tokens,required"`
	// The number of input tokens read from the cache.
	CacheReadInputTokens int64 `json:"cache_read_input_tokens,required"`
	// The number of input tokens which were used.
	InputTokens int64 `json:"input_tokens,required"`
	// The number of output tokens which were used.
	OutputTokens int64 `json:"output_tokens,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		CacheCreationInputTokens resp.Field
		CacheReadInputTokens     resp.Field
		InputTokens              resp.Field
		OutputTokens             resp.Field
		ExtraFields              map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaUsage) RawJSON

func (r BetaUsage) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaUsage) UnmarshalJSON

func (r *BetaUsage) UnmarshalJSON(data []byte) error

type CacheControlEphemeralParam

type CacheControlEphemeralParam struct {
	// This field can be elided, and will marshal its zero value as "ephemeral".
	Type constant.Ephemeral `json:"type,required"`
	// contains filtered or unexported fields
}

The property Type is required.

func (CacheControlEphemeralParam) IsPresent

func (f CacheControlEphemeralParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (CacheControlEphemeralParam) MarshalJSON

func (r CacheControlEphemeralParam) MarshalJSON() (data []byte, err error)

type CitationCharLocation

type CitationCharLocation struct {
	CitedText      string                `json:"cited_text,required"`
	DocumentIndex  int64                 `json:"document_index,required"`
	DocumentTitle  string                `json:"document_title,required"`
	EndCharIndex   int64                 `json:"end_char_index,required"`
	StartCharIndex int64                 `json:"start_char_index,required"`
	Type           constant.CharLocation `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		CitedText      resp.Field
		DocumentIndex  resp.Field
		DocumentTitle  resp.Field
		EndCharIndex   resp.Field
		StartCharIndex resp.Field
		Type           resp.Field
		ExtraFields    map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (CitationCharLocation) RawJSON

func (r CitationCharLocation) RawJSON() string

Returns the unmodified JSON received from the API

func (*CitationCharLocation) UnmarshalJSON

func (r *CitationCharLocation) UnmarshalJSON(data []byte) error

type CitationCharLocationParam

type CitationCharLocationParam struct {
	DocumentTitle  param.Opt[string] `json:"document_title,omitzero,required"`
	CitedText      string            `json:"cited_text,required"`
	DocumentIndex  int64             `json:"document_index,required"`
	EndCharIndex   int64             `json:"end_char_index,required"`
	StartCharIndex int64             `json:"start_char_index,required"`
	// This field can be elided, and will marshal its zero value as "char_location".
	Type constant.CharLocation `json:"type,required"`
	// contains filtered or unexported fields
}

The properties CitedText, DocumentIndex, DocumentTitle, EndCharIndex, StartCharIndex, Type are required.

func (CitationCharLocationParam) IsPresent

func (f CitationCharLocationParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (CitationCharLocationParam) MarshalJSON

func (r CitationCharLocationParam) MarshalJSON() (data []byte, err error)

type CitationContentBlockLocation

type CitationContentBlockLocation struct {
	CitedText       string                        `json:"cited_text,required"`
	DocumentIndex   int64                         `json:"document_index,required"`
	DocumentTitle   string                        `json:"document_title,required"`
	EndBlockIndex   int64                         `json:"end_block_index,required"`
	StartBlockIndex int64                         `json:"start_block_index,required"`
	Type            constant.ContentBlockLocation `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		CitedText       resp.Field
		DocumentIndex   resp.Field
		DocumentTitle   resp.Field
		EndBlockIndex   resp.Field
		StartBlockIndex resp.Field
		Type            resp.Field
		ExtraFields     map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (CitationContentBlockLocation) RawJSON

Returns the unmodified JSON received from the API

func (*CitationContentBlockLocation) UnmarshalJSON

func (r *CitationContentBlockLocation) UnmarshalJSON(data []byte) error

type CitationContentBlockLocationParam

type CitationContentBlockLocationParam struct {
	DocumentTitle   param.Opt[string] `json:"document_title,omitzero,required"`
	CitedText       string            `json:"cited_text,required"`
	DocumentIndex   int64             `json:"document_index,required"`
	EndBlockIndex   int64             `json:"end_block_index,required"`
	StartBlockIndex int64             `json:"start_block_index,required"`
	// This field can be elided, and will marshal its zero value as
	// "content_block_location".
	Type constant.ContentBlockLocation `json:"type,required"`
	// contains filtered or unexported fields
}

The properties CitedText, DocumentIndex, DocumentTitle, EndBlockIndex, StartBlockIndex, Type are required.

func (CitationContentBlockLocationParam) IsPresent

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (CitationContentBlockLocationParam) MarshalJSON

func (r CitationContentBlockLocationParam) MarshalJSON() (data []byte, err error)

type CitationPageLocation

type CitationPageLocation struct {
	CitedText       string                `json:"cited_text,required"`
	DocumentIndex   int64                 `json:"document_index,required"`
	DocumentTitle   string                `json:"document_title,required"`
	EndPageNumber   int64                 `json:"end_page_number,required"`
	StartPageNumber int64                 `json:"start_page_number,required"`
	Type            constant.PageLocation `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		CitedText       resp.Field
		DocumentIndex   resp.Field
		DocumentTitle   resp.Field
		EndPageNumber   resp.Field
		StartPageNumber resp.Field
		Type            resp.Field
		ExtraFields     map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (CitationPageLocation) RawJSON

func (r CitationPageLocation) RawJSON() string

Returns the unmodified JSON received from the API

func (*CitationPageLocation) UnmarshalJSON

func (r *CitationPageLocation) UnmarshalJSON(data []byte) error

type CitationPageLocationParam

type CitationPageLocationParam struct {
	DocumentTitle   param.Opt[string] `json:"document_title,omitzero,required"`
	CitedText       string            `json:"cited_text,required"`
	DocumentIndex   int64             `json:"document_index,required"`
	EndPageNumber   int64             `json:"end_page_number,required"`
	StartPageNumber int64             `json:"start_page_number,required"`
	// This field can be elided, and will marshal its zero value as "page_location".
	Type constant.PageLocation `json:"type,required"`
	// contains filtered or unexported fields
}

The properties CitedText, DocumentIndex, DocumentTitle, EndPageNumber, StartPageNumber, Type are required.

func (CitationPageLocationParam) IsPresent

func (f CitationPageLocationParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (CitationPageLocationParam) MarshalJSON

func (r CitationPageLocationParam) MarshalJSON() (data []byte, err error)

type CitationsConfigParam

type CitationsConfigParam struct {
	Enabled param.Opt[bool] `json:"enabled,omitzero"`
	// contains filtered or unexported fields
}

func (CitationsConfigParam) IsPresent

func (f CitationsConfigParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (CitationsConfigParam) MarshalJSON

func (r CitationsConfigParam) MarshalJSON() (data []byte, err error)

type CitationsDelta

type CitationsDelta struct {
	Citation CitationsDeltaCitationUnion `json:"citation,required"`
	Type     constant.CitationsDelta     `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Citation    resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (CitationsDelta) RawJSON

func (r CitationsDelta) RawJSON() string

Returns the unmodified JSON received from the API

func (*CitationsDelta) UnmarshalJSON

func (r *CitationsDelta) UnmarshalJSON(data []byte) error

type CitationsDeltaCitationUnion

type CitationsDeltaCitationUnion struct {
	CitedText     string `json:"cited_text"`
	DocumentIndex int64  `json:"document_index"`
	DocumentTitle string `json:"document_title"`
	// This field is from variant [CitationCharLocation].
	EndCharIndex int64 `json:"end_char_index"`
	// This field is from variant [CitationCharLocation].
	StartCharIndex int64 `json:"start_char_index"`
	// Any of "char_location", "page_location", "content_block_location".
	Type string `json:"type"`
	// This field is from variant [CitationPageLocation].
	EndPageNumber int64 `json:"end_page_number"`
	// This field is from variant [CitationPageLocation].
	StartPageNumber int64 `json:"start_page_number"`
	// This field is from variant [CitationContentBlockLocation].
	EndBlockIndex int64 `json:"end_block_index"`
	// This field is from variant [CitationContentBlockLocation].
	StartBlockIndex int64 `json:"start_block_index"`
	JSON            struct {
		CitedText       resp.Field
		DocumentIndex   resp.Field
		DocumentTitle   resp.Field
		EndCharIndex    resp.Field
		StartCharIndex  resp.Field
		Type            resp.Field
		EndPageNumber   resp.Field
		StartPageNumber resp.Field
		EndBlockIndex   resp.Field
		StartBlockIndex resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

CitationsDeltaCitationUnion contains all possible properties and values from CitationCharLocation, CitationPageLocation, CitationContentBlockLocation.

Use the CitationsDeltaCitationUnion.AsAny method to switch on the variant.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (CitationsDeltaCitationUnion) AsAny

func (u CitationsDeltaCitationUnion) AsAny() any

Use the following switch statement to find the correct variant

switch variant := CitationsDeltaCitationUnion.AsAny().(type) {
case CitationCharLocation:
case CitationPageLocation:
case CitationContentBlockLocation:
default:
  fmt.Errorf("no variant present")
}

func (CitationsDeltaCitationUnion) AsResponseCharLocationCitation

func (u CitationsDeltaCitationUnion) AsResponseCharLocationCitation() (v CitationCharLocation)

func (CitationsDeltaCitationUnion) AsResponseContentBlockLocationCitation

func (u CitationsDeltaCitationUnion) AsResponseContentBlockLocationCitation() (v CitationContentBlockLocation)

func (CitationsDeltaCitationUnion) AsResponsePageLocationCitation

func (u CitationsDeltaCitationUnion) AsResponsePageLocationCitation() (v CitationPageLocation)

func (CitationsDeltaCitationUnion) RawJSON

func (u CitationsDeltaCitationUnion) RawJSON() string

Returns the unmodified JSON received from the API

func (*CitationsDeltaCitationUnion) UnmarshalJSON

func (r *CitationsDeltaCitationUnion) UnmarshalJSON(data []byte) error

type Client

type Client struct {
	Options     []option.RequestOption
	Completions CompletionService
	Messages    MessageService
	Models      ModelService
	Beta        BetaService
}

Client creates a struct with services and top level methods that help with interacting with the anthropic API. You should not instantiate this client directly, and instead use the NewClient method instead.

func NewClient

func NewClient(opts ...option.RequestOption) (r Client)

NewClient generates a new client with the default option read from the environment (ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN). The option passed in as arguments are applied after these default arguments, and all option will be passed down to the services and requests that this client makes.

func (*Client) Delete

func (r *Client) Delete(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error

Delete makes a DELETE request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Execute

func (r *Client) Execute(ctx context.Context, method string, path string, params interface{}, res interface{}, opts ...option.RequestOption) error

Execute makes a request with the given context, method, URL, request params, response, and request options. This is useful for hitting undocumented endpoints while retaining the base URL, auth, retries, and other options from the client.

If a byte slice or an io.Reader is supplied to params, it will be used as-is for the request body.

The params is by default serialized into the body using encoding/json. If your type implements a MarshalJSON function, it will be used instead to serialize the request. If a URLQuery method is implemented, the returned url.Values will be used as query strings to the url.

If your params struct uses param.Field, you must provide either [MarshalJSON], [URLQuery], and/or [MarshalForm] functions. It is undefined behavior to use a struct uses param.Field without specifying how it is serialized.

Any "…Params" object defined in this library can be used as the request argument. Note that 'path' arguments will not be forwarded into the url.

The response body will be deserialized into the res variable, depending on its type:

  • A pointer to a *http.Response is populated by the raw response.
  • A pointer to a byte array will be populated with the contents of the request body.
  • A pointer to any other type uses this library's default JSON decoding, which respects UnmarshalJSON if it is defined on the type.
  • A nil value will not read the response body.

For even greater flexibility, see option.WithResponseInto and option.WithResponseBodyInto.

func (*Client) Get

func (r *Client) Get(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error

Get makes a GET request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Patch

func (r *Client) Patch(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error

Patch makes a PATCH request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Post

func (r *Client) Post(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error

Post makes a POST request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Put

func (r *Client) Put(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error

Put makes a PUT request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

type Completion

type Completion struct {
	// Unique object identifier.
	//
	// The format and length of IDs may change over time.
	ID string `json:"id,required"`
	// The resulting completion up to and excluding the stop sequences.
	Completion string `json:"completion,required"`
	// The model that will complete your prompt.\n\nSee
	// [models](https://docs.anthropic.com/en/docs/models-overview) for additional
	// details and options.
	Model Model `json:"model,required"`
	// The reason that we stopped.
	//
	// This may be one the following values:
	//
	//   - `"stop_sequence"`: we reached a stop sequence — either provided by you via the
	//     `stop_sequences` parameter, or a stop sequence built into the model
	//   - `"max_tokens"`: we exceeded `max_tokens_to_sample` or the model's maximum
	StopReason string `json:"stop_reason,required"`
	// Object type.
	//
	// For Text Completions, this is always `"completion"`.
	Type constant.Completion `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		ID          resp.Field
		Completion  resp.Field
		Model       resp.Field
		StopReason  resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (Completion) RawJSON

func (r Completion) RawJSON() string

Returns the unmodified JSON received from the API

func (*Completion) UnmarshalJSON

func (r *Completion) UnmarshalJSON(data []byte) error

type CompletionNewParams

type CompletionNewParams struct {
	// The maximum number of tokens to generate before stopping.
	//
	// Note that our models may stop _before_ reaching this maximum. This parameter
	// only specifies the absolute maximum number of tokens to generate.
	MaxTokensToSample int64 `json:"max_tokens_to_sample,required"`
	// The model that will complete your prompt.\n\nSee
	// [models](https://docs.anthropic.com/en/docs/models-overview) for additional
	// details and options.
	Model Model `json:"model,omitzero,required"`
	// The prompt that you want Claude to complete.
	//
	// For proper response generation you will need to format your prompt using
	// alternating `\n\nHuman:` and `\n\nAssistant:` conversational turns. For example:
	//
	// “`
	// "\n\nHuman: {userQuestion}\n\nAssistant:"
	// “`
	//
	// See [prompt validation](https://docs.anthropic.com/en/api/prompt-validation) and
	// our guide to
	// [prompt design](https://docs.anthropic.com/en/docs/intro-to-prompting) for more
	// details.
	Prompt string `json:"prompt,required"`
	// Amount of randomness injected into the response.
	//
	// Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0`
	// for analytical / multiple choice, and closer to `1.0` for creative and
	// generative tasks.
	//
	// Note that even with `temperature` of `0.0`, the results will not be fully
	// deterministic.
	Temperature param.Opt[float64] `json:"temperature,omitzero"`
	// Only sample from the top K options for each subsequent token.
	//
	// Used to remove "long tail" low probability responses.
	// [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).
	//
	// Recommended for advanced use cases only. You usually only need to use
	// `temperature`.
	TopK param.Opt[int64] `json:"top_k,omitzero"`
	// Use nucleus sampling.
	//
	// In nucleus sampling, we compute the cumulative distribution over all the options
	// for each subsequent token in decreasing probability order and cut it off once it
	// reaches a particular probability specified by `top_p`. You should either alter
	// `temperature` or `top_p`, but not both.
	//
	// Recommended for advanced use cases only. You usually only need to use
	// `temperature`.
	TopP param.Opt[float64] `json:"top_p,omitzero"`
	// An object describing metadata about the request.
	Metadata MetadataParam `json:"metadata,omitzero"`
	// Sequences that will cause the model to stop generating.
	//
	// Our models stop on `"\n\nHuman:"`, and may include additional built-in stop
	// sequences in the future. By providing the stop_sequences parameter, you may
	// include additional strings that will cause the model to stop generating.
	StopSequences []string `json:"stop_sequences,omitzero"`
	// contains filtered or unexported fields
}

func (CompletionNewParams) IsPresent

func (f CompletionNewParams) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (CompletionNewParams) MarshalJSON

func (r CompletionNewParams) MarshalJSON() (data []byte, err error)

type CompletionService

type CompletionService struct {
	Options []option.RequestOption
}

CompletionService contains methods and other services that help with interacting with the anthropic API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewCompletionService method instead.

func NewCompletionService

func NewCompletionService(opts ...option.RequestOption) (r CompletionService)

NewCompletionService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*CompletionService) New

[Legacy] Create a Text Completion.

The Text Completions API is a legacy API. We recommend using the [Messages API](https://docs.anthropic.com/en/api/messages) going forward.

Future models and features will not be compatible with Text Completions. See our [migration guide](https://docs.anthropic.com/en/api/migrating-from-text-completions-to-messages) for guidance in migrating from Text Completions to Messages.

Note: If you choose to set a timeout for this request, we recommend 10 minutes.

func (*CompletionService) NewStreaming

func (r *CompletionService) NewStreaming(ctx context.Context, body CompletionNewParams, opts ...option.RequestOption) (stream *ssestream.Stream[Completion])

[Legacy] Create a Text Completion.

The Text Completions API is a legacy API. We recommend using the [Messages API](https://docs.anthropic.com/en/api/messages) going forward.

Future models and features will not be compatible with Text Completions. See our [migration guide](https://docs.anthropic.com/en/api/migrating-from-text-completions-to-messages) for guidance in migrating from Text Completions to Messages.

Note: If you choose to set a timeout for this request, we recommend 10 minutes.

type ContentBlockDeltaEvent

type ContentBlockDeltaEvent struct {
	Delta ContentBlockDeltaEventDeltaUnion `json:"delta,required"`
	Index int64                            `json:"index,required"`
	Type  constant.ContentBlockDelta       `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Delta       resp.Field
		Index       resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ContentBlockDeltaEvent) RawJSON

func (r ContentBlockDeltaEvent) RawJSON() string

Returns the unmodified JSON received from the API

func (*ContentBlockDeltaEvent) UnmarshalJSON

func (r *ContentBlockDeltaEvent) UnmarshalJSON(data []byte) error

type ContentBlockDeltaEventDeltaUnion

type ContentBlockDeltaEventDeltaUnion struct {
	// This field is from variant [TextDelta].
	Text string `json:"text"`
	// Any of "text_delta", "input_json_delta", "citations_delta", "thinking_delta",
	// "signature_delta".
	Type string `json:"type"`
	// This field is from variant [InputJSONDelta].
	PartialJSON string `json:"partial_json"`
	// This field is from variant [CitationsDelta].
	Citation CitationsDeltaCitationUnion `json:"citation"`
	// This field is from variant [ThinkingDelta].
	Thinking string `json:"thinking"`
	// This field is from variant [SignatureDelta].
	Signature string `json:"signature"`
	JSON      struct {
		Text        resp.Field
		Type        resp.Field
		PartialJSON resp.Field
		Citation    resp.Field
		Thinking    resp.Field
		Signature   resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

ContentBlockDeltaEventDeltaUnion contains all possible properties and values from TextDelta, InputJSONDelta, CitationsDelta, ThinkingDelta, SignatureDelta.

Use the ContentBlockDeltaEventDeltaUnion.AsAny method to switch on the variant.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (ContentBlockDeltaEventDeltaUnion) AsAny

Use the following switch statement to find the correct variant

switch variant := ContentBlockDeltaEventDeltaUnion.AsAny().(type) {
case TextDelta:
case InputJSONDelta:
case CitationsDelta:
case ThinkingDelta:
case SignatureDelta:
default:
  fmt.Errorf("no variant present")
}

func (ContentBlockDeltaEventDeltaUnion) AsCitationsDelta

func (u ContentBlockDeltaEventDeltaUnion) AsCitationsDelta() (v CitationsDelta)

func (ContentBlockDeltaEventDeltaUnion) AsInputJSONContentBlockDelta

func (u ContentBlockDeltaEventDeltaUnion) AsInputJSONContentBlockDelta() (v InputJSONDelta)

func (ContentBlockDeltaEventDeltaUnion) AsSignatureContentBlockDelta

func (u ContentBlockDeltaEventDeltaUnion) AsSignatureContentBlockDelta() (v SignatureDelta)

func (ContentBlockDeltaEventDeltaUnion) AsTextContentBlockDelta

func (u ContentBlockDeltaEventDeltaUnion) AsTextContentBlockDelta() (v TextDelta)

func (ContentBlockDeltaEventDeltaUnion) AsThinkingContentBlockDelta

func (u ContentBlockDeltaEventDeltaUnion) AsThinkingContentBlockDelta() (v ThinkingDelta)

func (ContentBlockDeltaEventDeltaUnion) RawJSON

Returns the unmodified JSON received from the API

func (*ContentBlockDeltaEventDeltaUnion) UnmarshalJSON

func (r *ContentBlockDeltaEventDeltaUnion) UnmarshalJSON(data []byte) error

type ContentBlockParamUnion

type ContentBlockParamUnion struct {
	OfRequestTextBlock             *TextBlockParam             `json:",omitzero,inline"`
	OfRequestImageBlock            *ImageBlockParam            `json:",omitzero,inline"`
	OfRequestToolUseBlock          *ToolUseBlockParam          `json:",omitzero,inline"`
	OfRequestToolResultBlock       *ToolResultBlockParam       `json:",omitzero,inline"`
	OfRequestDocumentBlock         *DocumentBlockParam         `json:",omitzero,inline"`
	OfRequestThinkingBlock         *ThinkingBlockParam         `json:",omitzero,inline"`
	OfRequestRedactedThinkingBlock *RedactedThinkingBlockParam `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func ContentBlockParamOfRequestImageBlock

func ContentBlockParamOfRequestImageBlock[T Base64ImageSourceParam | URLImageSourceParam](source T) ContentBlockParamUnion

func ContentBlockParamOfRequestRedactedThinkingBlock

func ContentBlockParamOfRequestRedactedThinkingBlock(data string) ContentBlockParamUnion

func ContentBlockParamOfRequestTextBlock

func ContentBlockParamOfRequestTextBlock(text string) ContentBlockParamUnion

func ContentBlockParamOfRequestThinkingBlock

func ContentBlockParamOfRequestThinkingBlock(signature string, thinking string) ContentBlockParamUnion

func ContentBlockParamOfRequestToolResultBlock

func ContentBlockParamOfRequestToolResultBlock(toolUseID string) ContentBlockParamUnion

func ContentBlockParamOfRequestToolUseBlock

func ContentBlockParamOfRequestToolUseBlock(id string, input interface{}, name string) ContentBlockParamUnion

func NewImageBlockBase64

func NewImageBlockBase64(mediaType string, encodedData string) ContentBlockParamUnion

func NewTextBlock

func NewTextBlock(text string) ContentBlockParamUnion

func NewToolResultBlock

func NewToolResultBlock(toolUseID string, content string, isError bool) ContentBlockParamUnion

func (ContentBlockParamUnion) GetCacheControl

Returns a pointer to the underlying variant's CacheControl property, if present.

func (ContentBlockParamUnion) GetCitations

func (u ContentBlockParamUnion) GetCitations() (res contentBlockParamUnionCitations)

Returns a subunion which exports methods to access subproperties

Or use AsAny() to get the underlying value

func (ContentBlockParamUnion) GetContent

Returns a pointer to the underlying variant's property, if present.

func (ContentBlockParamUnion) GetContext

func (u ContentBlockParamUnion) GetContext() *string

Returns a pointer to the underlying variant's property, if present.

func (ContentBlockParamUnion) GetData

func (u ContentBlockParamUnion) GetData() *string

Returns a pointer to the underlying variant's property, if present.

func (ContentBlockParamUnion) GetID

func (u ContentBlockParamUnion) GetID() *string

Returns a pointer to the underlying variant's property, if present.

func (ContentBlockParamUnion) GetInput

func (u ContentBlockParamUnion) GetInput() *interface{}

Returns a pointer to the underlying variant's property, if present.

func (ContentBlockParamUnion) GetIsError

func (u ContentBlockParamUnion) GetIsError() *bool

Returns a pointer to the underlying variant's property, if present.

func (ContentBlockParamUnion) GetName

func (u ContentBlockParamUnion) GetName() *string

Returns a pointer to the underlying variant's property, if present.

func (ContentBlockParamUnion) GetSignature

func (u ContentBlockParamUnion) GetSignature() *string

Returns a pointer to the underlying variant's property, if present.

func (ContentBlockParamUnion) GetSource

func (u ContentBlockParamUnion) GetSource() (res contentBlockParamUnionSource)

Returns a subunion which exports methods to access subproperties

Or use AsAny() to get the underlying value

func (ContentBlockParamUnion) GetText

func (u ContentBlockParamUnion) GetText() *string

Returns a pointer to the underlying variant's property, if present.

func (ContentBlockParamUnion) GetThinking

func (u ContentBlockParamUnion) GetThinking() *string

Returns a pointer to the underlying variant's property, if present.

func (ContentBlockParamUnion) GetTitle

func (u ContentBlockParamUnion) GetTitle() *string

Returns a pointer to the underlying variant's property, if present.

func (ContentBlockParamUnion) GetToolUseID

func (u ContentBlockParamUnion) GetToolUseID() *string

Returns a pointer to the underlying variant's property, if present.

func (ContentBlockParamUnion) GetType

func (u ContentBlockParamUnion) GetType() *string

Returns a pointer to the underlying variant's property, if present.

func (ContentBlockParamUnion) IsPresent

func (u ContentBlockParamUnion) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (ContentBlockParamUnion) MarshalJSON

func (u ContentBlockParamUnion) MarshalJSON() ([]byte, error)

type ContentBlockSourceContentUnionParam

type ContentBlockSourceContentUnionParam struct {
	OfString                    param.Opt[string]                     `json:",omitzero,inline"`
	OfContentBlockSourceContent []ContentBlockSourceContentUnionParam `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (ContentBlockSourceContentUnionParam) IsPresent

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (ContentBlockSourceContentUnionParam) MarshalJSON

func (u ContentBlockSourceContentUnionParam) MarshalJSON() ([]byte, error)

type ContentBlockSourceParam

type ContentBlockSourceParam struct {
	Content ContentBlockSourceContentUnionParam `json:"content,omitzero,required"`
	// This field can be elided, and will marshal its zero value as "content".
	Type constant.Content `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Content, Type are required.

func (ContentBlockSourceParam) IsPresent

func (f ContentBlockSourceParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (ContentBlockSourceParam) MarshalJSON

func (r ContentBlockSourceParam) MarshalJSON() (data []byte, err error)

type ContentBlockStartEvent

type ContentBlockStartEvent struct {
	ContentBlock ContentBlockStartEventContentBlockUnion `json:"content_block,required"`
	Index        int64                                   `json:"index,required"`
	Type         constant.ContentBlockStart              `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		ContentBlock resp.Field
		Index        resp.Field
		Type         resp.Field
		ExtraFields  map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ContentBlockStartEvent) RawJSON

func (r ContentBlockStartEvent) RawJSON() string

Returns the unmodified JSON received from the API

func (*ContentBlockStartEvent) UnmarshalJSON

func (r *ContentBlockStartEvent) UnmarshalJSON(data []byte) error

type ContentBlockStartEventContentBlockUnion

type ContentBlockStartEventContentBlockUnion struct {
	// This field is from variant [TextBlock].
	Citations []TextCitationUnion `json:"citations"`
	// This field is from variant [TextBlock].
	Text string `json:"text"`
	// Any of "text", "tool_use", "thinking", "redacted_thinking".
	Type string `json:"type"`
	// This field is from variant [ToolUseBlock].
	ID string `json:"id"`
	// This field is from variant [ToolUseBlock].
	Input interface{} `json:"input"`
	// This field is from variant [ToolUseBlock].
	Name string `json:"name"`
	// This field is from variant [ThinkingBlock].
	Signature string `json:"signature"`
	// This field is from variant [ThinkingBlock].
	Thinking string `json:"thinking"`
	// This field is from variant [RedactedThinkingBlock].
	Data string `json:"data"`
	JSON struct {
		Citations resp.Field
		Text      resp.Field
		Type      resp.Field
		ID        resp.Field
		Input     resp.Field
		Name      resp.Field
		Signature resp.Field
		Thinking  resp.Field
		Data      resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

ContentBlockStartEventContentBlockUnion contains all possible properties and values from TextBlock, ToolUseBlock, ThinkingBlock, RedactedThinkingBlock.

Use the ContentBlockStartEventContentBlockUnion.AsAny method to switch on the variant.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (ContentBlockStartEventContentBlockUnion) AsAny

Use the following switch statement to find the correct variant

switch variant := ContentBlockStartEventContentBlockUnion.AsAny().(type) {
case TextBlock:
case ToolUseBlock:
case ThinkingBlock:
case RedactedThinkingBlock:
default:
  fmt.Errorf("no variant present")
}

func (ContentBlockStartEventContentBlockUnion) AsResponseRedactedThinkingBlock

func (u ContentBlockStartEventContentBlockUnion) AsResponseRedactedThinkingBlock() (v RedactedThinkingBlock)

func (ContentBlockStartEventContentBlockUnion) AsResponseTextBlock

func (u ContentBlockStartEventContentBlockUnion) AsResponseTextBlock() (v TextBlock)

func (ContentBlockStartEventContentBlockUnion) AsResponseThinkingBlock

func (u ContentBlockStartEventContentBlockUnion) AsResponseThinkingBlock() (v ThinkingBlock)

func (ContentBlockStartEventContentBlockUnion) AsResponseToolUseBlock

func (u ContentBlockStartEventContentBlockUnion) AsResponseToolUseBlock() (v ToolUseBlock)

func (ContentBlockStartEventContentBlockUnion) RawJSON

Returns the unmodified JSON received from the API

func (*ContentBlockStartEventContentBlockUnion) UnmarshalJSON

func (r *ContentBlockStartEventContentBlockUnion) UnmarshalJSON(data []byte) error

type ContentBlockStopEvent

type ContentBlockStopEvent struct {
	Index int64                     `json:"index,required"`
	Type  constant.ContentBlockStop `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Index       resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ContentBlockStopEvent) RawJSON

func (r ContentBlockStopEvent) RawJSON() string

Returns the unmodified JSON received from the API

func (*ContentBlockStopEvent) UnmarshalJSON

func (r *ContentBlockStopEvent) UnmarshalJSON(data []byte) error

type ContentBlockUnion

type ContentBlockUnion struct {
	// This field is from variant [TextBlock].
	Citations []TextCitationUnion `json:"citations"`
	// This field is from variant [TextBlock].
	Text string `json:"text"`
	// Any of "text", "tool_use", "thinking", "redacted_thinking".
	Type string `json:"type"`
	// This field is from variant [ToolUseBlock].
	ID string `json:"id"`
	// This field is from variant [ToolUseBlock].
	Input json.RawMessage `json:"input"`
	// This field is from variant [ToolUseBlock].
	Name string `json:"name"`
	// This field is from variant [ThinkingBlock].
	Signature string `json:"signature"`
	// This field is from variant [ThinkingBlock].
	Thinking string `json:"thinking"`
	// This field is from variant [RedactedThinkingBlock].
	Data string `json:"data"`
	JSON struct {
		Citations resp.Field
		Text      resp.Field
		Type      resp.Field
		ID        resp.Field
		Input     resp.Field
		Name      resp.Field
		Signature resp.Field
		Thinking  resp.Field
		Data      resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

ContentBlockUnion contains all possible properties and values from TextBlock, ToolUseBlock, ThinkingBlock, RedactedThinkingBlock.

Use the ContentBlockUnion.AsAny method to switch on the variant.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (ContentBlockUnion) AsAny

func (u ContentBlockUnion) AsAny() any

Use the following switch statement to find the correct variant

switch variant := ContentBlockUnion.AsAny().(type) {
case TextBlock:
case ToolUseBlock:
case ThinkingBlock:
case RedactedThinkingBlock:
default:
  fmt.Errorf("no variant present")
}

func (ContentBlockUnion) AsResponseRedactedThinkingBlock

func (u ContentBlockUnion) AsResponseRedactedThinkingBlock() (v RedactedThinkingBlock)

func (ContentBlockUnion) AsResponseTextBlock

func (u ContentBlockUnion) AsResponseTextBlock() (v TextBlock)

func (ContentBlockUnion) AsResponseThinkingBlock

func (u ContentBlockUnion) AsResponseThinkingBlock() (v ThinkingBlock)

func (ContentBlockUnion) AsResponseToolUseBlock

func (u ContentBlockUnion) AsResponseToolUseBlock() (v ToolUseBlock)

func (ContentBlockUnion) RawJSON

func (u ContentBlockUnion) RawJSON() string

Returns the unmodified JSON received from the API

func (ContentBlockUnion) ToParam

func (*ContentBlockUnion) UnmarshalJSON

func (r *ContentBlockUnion) UnmarshalJSON(data []byte) error

type DeletedMessageBatch

type DeletedMessageBatch struct {
	// ID of the Message Batch.
	ID string `json:"id,required"`
	// Deleted object type.
	//
	// For Message Batches, this is always `"message_batch_deleted"`.
	Type constant.MessageBatchDeleted `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		ID          resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (DeletedMessageBatch) RawJSON

func (r DeletedMessageBatch) RawJSON() string

Returns the unmodified JSON received from the API

func (*DeletedMessageBatch) UnmarshalJSON

func (r *DeletedMessageBatch) UnmarshalJSON(data []byte) error

type DocumentBlockParam

type DocumentBlockParam struct {
	Source       DocumentBlockParamSourceUnion `json:"source,omitzero,required"`
	Context      param.Opt[string]             `json:"context,omitzero"`
	Title        param.Opt[string]             `json:"title,omitzero"`
	CacheControl CacheControlEphemeralParam    `json:"cache_control,omitzero"`
	Citations    CitationsConfigParam          `json:"citations,omitzero"`
	// This field can be elided, and will marshal its zero value as "document".
	Type constant.Document `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Source, Type are required.

func (DocumentBlockParam) IsPresent

func (f DocumentBlockParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (DocumentBlockParam) MarshalJSON

func (r DocumentBlockParam) MarshalJSON() (data []byte, err error)

type DocumentBlockParamSourceUnion

type DocumentBlockParamSourceUnion struct {
	OfBase64PDFSource    *Base64PDFSourceParam    `json:",omitzero,inline"`
	OfPlainTextSource    *PlainTextSourceParam    `json:",omitzero,inline"`
	OfContentBlockSource *ContentBlockSourceParam `json:",omitzero,inline"`
	OfUrlpdfSource       *URLPDFSourceParam       `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (DocumentBlockParamSourceUnion) GetContent

Returns a pointer to the underlying variant's property, if present.

func (DocumentBlockParamSourceUnion) GetData

Returns a pointer to the underlying variant's property, if present.

func (DocumentBlockParamSourceUnion) GetMediaType

func (u DocumentBlockParamSourceUnion) GetMediaType() *string

Returns a pointer to the underlying variant's property, if present.

func (DocumentBlockParamSourceUnion) GetType

Returns a pointer to the underlying variant's property, if present.

func (DocumentBlockParamSourceUnion) GetURL

Returns a pointer to the underlying variant's property, if present.

func (DocumentBlockParamSourceUnion) IsPresent

func (u DocumentBlockParamSourceUnion) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (DocumentBlockParamSourceUnion) MarshalJSON

func (u DocumentBlockParamSourceUnion) MarshalJSON() ([]byte, error)

type Error

type Error = apierror.Error

type ErrorObjectUnion

type ErrorObjectUnion = shared.ErrorObjectUnion

This is an alias to an internal type.

type ErrorResponse

type ErrorResponse = shared.ErrorResponse

This is an alias to an internal type.

type GatewayTimeoutError

type GatewayTimeoutError = shared.GatewayTimeoutError

This is an alias to an internal type.

type ImageBlockParam

type ImageBlockParam struct {
	Source       ImageBlockParamSourceUnion `json:"source,omitzero,required"`
	CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"`
	// This field can be elided, and will marshal its zero value as "image".
	Type constant.Image `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Source, Type are required.

func (ImageBlockParam) IsPresent

func (f ImageBlockParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (ImageBlockParam) MarshalJSON

func (r ImageBlockParam) MarshalJSON() (data []byte, err error)

type ImageBlockParamSourceUnion

type ImageBlockParamSourceUnion struct {
	OfBase64ImageSource *Base64ImageSourceParam `json:",omitzero,inline"`
	OfURLImageSource    *URLImageSourceParam    `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (ImageBlockParamSourceUnion) GetData

func (u ImageBlockParamSourceUnion) GetData() *string

Returns a pointer to the underlying variant's property, if present.

func (ImageBlockParamSourceUnion) GetMediaType

func (u ImageBlockParamSourceUnion) GetMediaType() *string

Returns a pointer to the underlying variant's property, if present.

func (ImageBlockParamSourceUnion) GetType

func (u ImageBlockParamSourceUnion) GetType() *string

Returns a pointer to the underlying variant's property, if present.

func (ImageBlockParamSourceUnion) GetURL

func (u ImageBlockParamSourceUnion) GetURL() *string

Returns a pointer to the underlying variant's property, if present.

func (ImageBlockParamSourceUnion) IsPresent

func (u ImageBlockParamSourceUnion) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (ImageBlockParamSourceUnion) MarshalJSON

func (u ImageBlockParamSourceUnion) MarshalJSON() ([]byte, error)

type InputJSONDelta

type InputJSONDelta struct {
	PartialJSON string                  `json:"partial_json,required"`
	Type        constant.InputJSONDelta `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		PartialJSON resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (InputJSONDelta) RawJSON

func (r InputJSONDelta) RawJSON() string

Returns the unmodified JSON received from the API

func (*InputJSONDelta) UnmarshalJSON

func (r *InputJSONDelta) UnmarshalJSON(data []byte) error

type Message

type Message struct {
	// Unique object identifier.
	//
	// The format and length of IDs may change over time.
	ID string `json:"id,required"`
	// Content generated by the model.
	//
	// This is an array of content blocks, each of which has a `type` that determines
	// its shape.
	//
	// Example:
	//
	// “`json
	// [{ "type": "text", "text": "Hi, I'm Claude." }]
	// “`
	//
	// If the request input `messages` ended with an `assistant` turn, then the
	// response `content` will continue directly from that last turn. You can use this
	// to constrain the model's output.
	//
	// For example, if the input `messages` were:
	//
	// “`json
	// [
	//
	//	{
	//	  "role": "user",
	//	  "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"
	//	},
	//	{ "role": "assistant", "content": "The best answer is (" }
	//
	// ]
	// “`
	//
	// Then the response `content` might be:
	//
	// “`json
	// [{ "type": "text", "text": "B)" }]
	// “`
	Content []ContentBlockUnion `json:"content,required"`
	// The model that will complete your prompt.\n\nSee
	// [models](https://docs.anthropic.com/en/docs/models-overview) for additional
	// details and options.
	Model Model `json:"model,required"`
	// Conversational role of the generated message.
	//
	// This will always be `"assistant"`.
	Role constant.Assistant `json:"role,required"`
	// The reason that we stopped.
	//
	// This may be one the following values:
	//
	// - `"end_turn"`: the model reached a natural stopping point
	// - `"max_tokens"`: we exceeded the requested `max_tokens` or the model's maximum
	// - `"stop_sequence"`: one of your provided custom `stop_sequences` was generated
	// - `"tool_use"`: the model invoked one or more tools
	//
	// In non-streaming mode this value is always non-null. In streaming mode, it is
	// null in the `message_start` event and non-null otherwise.
	//
	// Any of "end_turn", "max_tokens", "stop_sequence", "tool_use".
	StopReason MessageStopReason `json:"stop_reason,required"`
	// Which custom stop sequence was generated, if any.
	//
	// This value will be a non-null string if one of your custom stop sequences was
	// generated.
	StopSequence string `json:"stop_sequence,required"`
	// Object type.
	//
	// For Messages, this is always `"message"`.
	Type constant.Message `json:"type,required"`
	// Billing and rate-limit usage.
	//
	// Anthropic's API bills and rate-limits by token counts, as tokens represent the
	// underlying cost to our systems.
	//
	// Under the hood, the API transforms requests into a format suitable for the
	// model. The model's output then goes through a parsing stage before becoming an
	// API response. As a result, the token counts in `usage` will not match one-to-one
	// with the exact visible content of an API request or response.
	//
	// For example, `output_tokens` will be non-zero, even for an empty string response
	// from Claude.
	//
	// Total input tokens in a request is the summation of `input_tokens`,
	// `cache_creation_input_tokens`, and `cache_read_input_tokens`.
	Usage Usage `json:"usage,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		ID           resp.Field
		Content      resp.Field
		Model        resp.Field
		Role         resp.Field
		StopReason   resp.Field
		StopSequence resp.Field
		Type         resp.Field
		Usage        resp.Field
		ExtraFields  map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (*Message) Accumulate

func (acc *Message) Accumulate(event MessageStreamEventUnion) error

Accumulate builds up the Message incrementally from a MessageStreamEvent. The Message then can be used as any other Message, except with the caveat that the Message.JSON field which normally can be used to inspect the JSON sent over the network may not be populated fully.

message := anthropic.Message{}
for stream.Next() {
	event := stream.Current()
	message.Accumulate(event)
}

func (Message) RawJSON

func (r Message) RawJSON() string

Returns the unmodified JSON received from the API

func (Message) ToParam

func (r Message) ToParam() MessageParam

func (*Message) UnmarshalJSON

func (r *Message) UnmarshalJSON(data []byte) error

type MessageBatch

type MessageBatch struct {
	// Unique object identifier.
	//
	// The format and length of IDs may change over time.
	ID string `json:"id,required"`
	// RFC 3339 datetime string representing the time at which the Message Batch was
	// archived and its results became unavailable.
	ArchivedAt time.Time `json:"archived_at,required" format:"date-time"`
	// RFC 3339 datetime string representing the time at which cancellation was
	// initiated for the Message Batch. Specified only if cancellation was initiated.
	CancelInitiatedAt time.Time `json:"cancel_initiated_at,required" format:"date-time"`
	// RFC 3339 datetime string representing the time at which the Message Batch was
	// created.
	CreatedAt time.Time `json:"created_at,required" format:"date-time"`
	// RFC 3339 datetime string representing the time at which processing for the
	// Message Batch ended. Specified only once processing ends.
	//
	// Processing ends when every request in a Message Batch has either succeeded,
	// errored, canceled, or expired.
	EndedAt time.Time `json:"ended_at,required" format:"date-time"`
	// RFC 3339 datetime string representing the time at which the Message Batch will
	// expire and end processing, which is 24 hours after creation.
	ExpiresAt time.Time `json:"expires_at,required" format:"date-time"`
	// Processing status of the Message Batch.
	//
	// Any of "in_progress", "canceling", "ended".
	ProcessingStatus MessageBatchProcessingStatus `json:"processing_status,required"`
	// Tallies requests within the Message Batch, categorized by their status.
	//
	// Requests start as `processing` and move to one of the other statuses only once
	// processing of the entire batch ends. The sum of all values always matches the
	// total number of requests in the batch.
	RequestCounts MessageBatchRequestCounts `json:"request_counts,required"`
	// URL to a `.jsonl` file containing the results of the Message Batch requests.
	// Specified only once processing ends.
	//
	// Results in the file are not guaranteed to be in the same order as requests. Use
	// the `custom_id` field to match results to requests.
	ResultsURL string `json:"results_url,required"`
	// Object type.
	//
	// For Message Batches, this is always `"message_batch"`.
	Type constant.MessageBatch `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		ID                resp.Field
		ArchivedAt        resp.Field
		CancelInitiatedAt resp.Field
		CreatedAt         resp.Field
		EndedAt           resp.Field
		ExpiresAt         resp.Field
		ProcessingStatus  resp.Field
		RequestCounts     resp.Field
		ResultsURL        resp.Field
		Type              resp.Field
		ExtraFields       map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (MessageBatch) RawJSON

func (r MessageBatch) RawJSON() string

Returns the unmodified JSON received from the API

func (*MessageBatch) UnmarshalJSON

func (r *MessageBatch) UnmarshalJSON(data []byte) error

type MessageBatchCanceledResult

type MessageBatchCanceledResult struct {
	Type constant.Canceled `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (MessageBatchCanceledResult) RawJSON

func (r MessageBatchCanceledResult) RawJSON() string

Returns the unmodified JSON received from the API

func (*MessageBatchCanceledResult) UnmarshalJSON

func (r *MessageBatchCanceledResult) UnmarshalJSON(data []byte) error

type MessageBatchErroredResult

type MessageBatchErroredResult struct {
	Error shared.ErrorResponse `json:"error,required"`
	Type  constant.Errored     `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Error       resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (MessageBatchErroredResult) RawJSON

func (r MessageBatchErroredResult) RawJSON() string

Returns the unmodified JSON received from the API

func (*MessageBatchErroredResult) UnmarshalJSON

func (r *MessageBatchErroredResult) UnmarshalJSON(data []byte) error

type MessageBatchExpiredResult

type MessageBatchExpiredResult struct {
	Type constant.Expired `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (MessageBatchExpiredResult) RawJSON

func (r MessageBatchExpiredResult) RawJSON() string

Returns the unmodified JSON received from the API

func (*MessageBatchExpiredResult) UnmarshalJSON

func (r *MessageBatchExpiredResult) UnmarshalJSON(data []byte) error

type MessageBatchIndividualResponse

type MessageBatchIndividualResponse struct {
	// Developer-provided ID created for each request in a Message Batch. Useful for
	// matching results to requests, as results may be given out of request order.
	//
	// Must be unique for each request within the Message Batch.
	CustomID string `json:"custom_id,required"`
	// Processing result for this request.
	//
	// Contains a Message output if processing was successful, an error response if
	// processing failed, or the reason why processing was not attempted, such as
	// cancellation or expiration.
	Result MessageBatchResultUnion `json:"result,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		CustomID    resp.Field
		Result      resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

This is a single line in the response `.jsonl` file and does not represent the response as a whole.

func (MessageBatchIndividualResponse) RawJSON

Returns the unmodified JSON received from the API

func (*MessageBatchIndividualResponse) UnmarshalJSON

func (r *MessageBatchIndividualResponse) UnmarshalJSON(data []byte) error

type MessageBatchListParams

type MessageBatchListParams struct {
	// ID of the object to use as a cursor for pagination. When provided, returns the
	// page of results immediately after this object.
	AfterID param.Opt[string] `query:"after_id,omitzero" json:"-"`
	// ID of the object to use as a cursor for pagination. When provided, returns the
	// page of results immediately before this object.
	BeforeID param.Opt[string] `query:"before_id,omitzero" json:"-"`
	// Number of items to return per page.
	//
	// Defaults to `20`. Ranges from `1` to `1000`.
	Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (MessageBatchListParams) IsPresent

func (f MessageBatchListParams) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (MessageBatchListParams) URLQuery

func (r MessageBatchListParams) URLQuery() (v url.Values)

URLQuery serializes MessageBatchListParams's query parameters as `url.Values`.

type MessageBatchNewParams

type MessageBatchNewParams struct {
	// List of requests for prompt completion. Each is an individual request to create
	// a Message.
	Requests []MessageBatchNewParamsRequest `json:"requests,omitzero,required"`
	// contains filtered or unexported fields
}

func (MessageBatchNewParams) IsPresent

func (f MessageBatchNewParams) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (MessageBatchNewParams) MarshalJSON

func (r MessageBatchNewParams) MarshalJSON() (data []byte, err error)

type MessageBatchNewParamsRequest

type MessageBatchNewParamsRequest struct {
	// Developer-provided ID created for each request in a Message Batch. Useful for
	// matching results to requests, as results may be given out of request order.
	//
	// Must be unique for each request within the Message Batch.
	CustomID string `json:"custom_id,required"`
	// Messages API creation parameters for the individual request.
	//
	// See the [Messages API reference](/en/api/messages) for full documentation on
	// available parameters.
	Params MessageBatchNewParamsRequestParams `json:"params,omitzero,required"`
	// contains filtered or unexported fields
}

The properties CustomID, Params are required.

func (MessageBatchNewParamsRequest) IsPresent

func (f MessageBatchNewParamsRequest) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (MessageBatchNewParamsRequest) MarshalJSON

func (r MessageBatchNewParamsRequest) MarshalJSON() (data []byte, err error)

type MessageBatchNewParamsRequestParams

type MessageBatchNewParamsRequestParams struct {
	// The maximum number of tokens to generate before stopping.
	//
	// Note that our models may stop _before_ reaching this maximum. This parameter
	// only specifies the absolute maximum number of tokens to generate.
	//
	// Different models have different maximum values for this parameter. See
	// [models](https://docs.anthropic.com/en/docs/models-overview) for details.
	MaxTokens int64 `json:"max_tokens,required"`
	// Input messages.
	//
	// Our models are trained to operate on alternating `user` and `assistant`
	// conversational turns. When creating a new `Message`, you specify the prior
	// conversational turns with the `messages` parameter, and the model then generates
	// the next `Message` in the conversation. Consecutive `user` or `assistant` turns
	// in your request will be combined into a single turn.
	//
	// Each input message must be an object with a `role` and `content`. You can
	// specify a single `user`-role message, or you can include multiple `user` and
	// `assistant` messages.
	//
	// If the final message uses the `assistant` role, the response content will
	// continue immediately from the content in that message. This can be used to
	// constrain part of the model's response.
	//
	// Example with a single `user` message:
	//
	// “`json
	// [{ "role": "user", "content": "Hello, Claude" }]
	// “`
	//
	// Example with multiple conversational turns:
	//
	// “`json
	// [
	//
	//	{ "role": "user", "content": "Hello there." },
	//	{ "role": "assistant", "content": "Hi, I'm Claude. How can I help you?" },
	//	{ "role": "user", "content": "Can you explain LLMs in plain English?" }
	//
	// ]
	// “`
	//
	// Example with a partially-filled response from Claude:
	//
	// “`json
	// [
	//
	//	{
	//	  "role": "user",
	//	  "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"
	//	},
	//	{ "role": "assistant", "content": "The best answer is (" }
	//
	// ]
	// “`
	//
	// Each input message `content` may be either a single `string` or an array of
	// content blocks, where each block has a specific `type`. Using a `string` for
	// `content` is shorthand for an array of one content block of type `"text"`. The
	// following input messages are equivalent:
	//
	// “`json
	// { "role": "user", "content": "Hello, Claude" }
	// “`
	//
	// “`json
	// { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
	// “`
	//
	// Starting with Claude 3 models, you can also send image content blocks:
	//
	// “`json
	//
	//	{
	//	  "role": "user",
	//	  "content": [
	//	    {
	//	      "type": "image",
	//	      "source": {
	//	        "type": "base64",
	//	        "media_type": "image/jpeg",
	//	        "data": "/9j/4AAQSkZJRg..."
	//	      }
	//	    },
	//	    { "type": "text", "text": "What is in this image?" }
	//	  ]
	//	}
	//
	// “`
	//
	// We currently support the `base64` source type for images, and the `image/jpeg`,
	// `image/png`, `image/gif`, and `image/webp` media types.
	//
	// See [examples](https://docs.anthropic.com/en/api/messages-examples#vision) for
	// more input examples.
	//
	// Note that if you want to include a
	// [system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
	// the top-level `system` parameter — there is no `"system"` role for input
	// messages in the Messages API.
	Messages []MessageParam `json:"messages,omitzero,required"`
	// The model that will complete your prompt.\n\nSee
	// [models](https://docs.anthropic.com/en/docs/models-overview) for additional
	// details and options.
	Model Model `json:"model,omitzero,required"`
	// Whether to incrementally stream the response using server-sent events.
	//
	// See [streaming](https://docs.anthropic.com/en/api/messages-streaming) for
	// details.
	Stream param.Opt[bool] `json:"stream,omitzero"`
	// Amount of randomness injected into the response.
	//
	// Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0`
	// for analytical / multiple choice, and closer to `1.0` for creative and
	// generative tasks.
	//
	// Note that even with `temperature` of `0.0`, the results will not be fully
	// deterministic.
	Temperature param.Opt[float64] `json:"temperature,omitzero"`
	// Only sample from the top K options for each subsequent token.
	//
	// Used to remove "long tail" low probability responses.
	// [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).
	//
	// Recommended for advanced use cases only. You usually only need to use
	// `temperature`.
	TopK param.Opt[int64] `json:"top_k,omitzero"`
	// Use nucleus sampling.
	//
	// In nucleus sampling, we compute the cumulative distribution over all the options
	// for each subsequent token in decreasing probability order and cut it off once it
	// reaches a particular probability specified by `top_p`. You should either alter
	// `temperature` or `top_p`, but not both.
	//
	// Recommended for advanced use cases only. You usually only need to use
	// `temperature`.
	TopP param.Opt[float64] `json:"top_p,omitzero"`
	// An object describing metadata about the request.
	Metadata MetadataParam `json:"metadata,omitzero"`
	// Custom text sequences that will cause the model to stop generating.
	//
	// Our models will normally stop when they have naturally completed their turn,
	// which will result in a response `stop_reason` of `"end_turn"`.
	//
	// If you want the model to stop generating when it encounters custom strings of
	// text, you can use the `stop_sequences` parameter. If the model encounters one of
	// the custom sequences, the response `stop_reason` value will be `"stop_sequence"`
	// and the response `stop_sequence` value will contain the matched stop sequence.
	StopSequences []string `json:"stop_sequences,omitzero"`
	// System prompt.
	//
	// A system prompt is a way of providing context and instructions to Claude, such
	// as specifying a particular goal or role. See our
	// [guide to system prompts](https://docs.anthropic.com/en/docs/system-prompts).
	System []TextBlockParam `json:"system,omitzero"`
	// Configuration for enabling Claude's extended thinking.
	//
	// When enabled, responses include `thinking` content blocks showing Claude's
	// thinking process before the final answer. Requires a minimum budget of 1,024
	// tokens and counts towards your `max_tokens` limit.
	//
	// See
	// [extended thinking](https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking)
	// for details.
	Thinking ThinkingConfigParamUnion `json:"thinking,omitzero"`
	// How the model should use the provided tools. The model can use a specific tool,
	// any available tool, decide by itself, or not use tools at all.
	ToolChoice ToolChoiceUnionParam `json:"tool_choice,omitzero"`
	// Definitions of tools that the model may use.
	//
	// If you include `tools` in your API request, the model may return `tool_use`
	// content blocks that represent the model's use of those tools. You can then run
	// those tools using the tool input generated by the model and then optionally
	// return results back to the model using `tool_result` content blocks.
	//
	// Each tool definition includes:
	//
	//   - `name`: Name of the tool.
	//   - `description`: Optional, but strongly-recommended description of the tool.
	//   - `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the
	//     tool `input` shape that the model will produce in `tool_use` output content
	//     blocks.
	//
	// For example, if you defined `tools` as:
	//
	// “`json
	// [
	//
	//	{
	//	  "name": "get_stock_price",
	//	  "description": "Get the current stock price for a given ticker symbol.",
	//	  "input_schema": {
	//	    "type": "object",
	//	    "properties": {
	//	      "ticker": {
	//	        "type": "string",
	//	        "description": "The stock ticker symbol, e.g. AAPL for Apple Inc."
	//	      }
	//	    },
	//	    "required": ["ticker"]
	//	  }
	//	}
	//
	// ]
	// “`
	//
	// And then asked the model "What's the S&P 500 at today?", the model might produce
	// `tool_use` content blocks in the response like this:
	//
	// “`json
	// [
	//
	//	{
	//	  "type": "tool_use",
	//	  "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
	//	  "name": "get_stock_price",
	//	  "input": { "ticker": "^GSPC" }
	//	}
	//
	// ]
	// “`
	//
	// You might then run your `get_stock_price` tool with `{"ticker": "^GSPC"}` as an
	// input, and return the following back to the model in a subsequent `user`
	// message:
	//
	// “`json
	// [
	//
	//	{
	//	  "type": "tool_result",
	//	  "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
	//	  "content": "259.75 USD"
	//	}
	//
	// ]
	// “`
	//
	// Tools can be used for workflows that include running client-side tools and
	// functions, or more generally whenever you want the model to produce a particular
	// JSON structure of output.
	//
	// See our [guide](https://docs.anthropic.com/en/docs/tool-use) for more details.
	Tools []ToolUnionParam `json:"tools,omitzero"`
	// contains filtered or unexported fields
}

Messages API creation parameters for the individual request.

See the [Messages API reference](/en/api/messages) for full documentation on available parameters.

The properties MaxTokens, Messages, Model are required.

func (MessageBatchNewParamsRequestParams) IsPresent

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (MessageBatchNewParamsRequestParams) MarshalJSON

func (r MessageBatchNewParamsRequestParams) MarshalJSON() (data []byte, err error)

type MessageBatchProcessingStatus

type MessageBatchProcessingStatus string

Processing status of the Message Batch.

const (
	MessageBatchProcessingStatusInProgress MessageBatchProcessingStatus = "in_progress"
	MessageBatchProcessingStatusCanceling  MessageBatchProcessingStatus = "canceling"
	MessageBatchProcessingStatusEnded      MessageBatchProcessingStatus = "ended"
)

type MessageBatchRequestCounts

type MessageBatchRequestCounts struct {
	// Number of requests in the Message Batch that have been canceled.
	//
	// This is zero until processing of the entire Message Batch has ended.
	Canceled int64 `json:"canceled,required"`
	// Number of requests in the Message Batch that encountered an error.
	//
	// This is zero until processing of the entire Message Batch has ended.
	Errored int64 `json:"errored,required"`
	// Number of requests in the Message Batch that have expired.
	//
	// This is zero until processing of the entire Message Batch has ended.
	Expired int64 `json:"expired,required"`
	// Number of requests in the Message Batch that are processing.
	Processing int64 `json:"processing,required"`
	// Number of requests in the Message Batch that have completed successfully.
	//
	// This is zero until processing of the entire Message Batch has ended.
	Succeeded int64 `json:"succeeded,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Canceled    resp.Field
		Errored     resp.Field
		Expired     resp.Field
		Processing  resp.Field
		Succeeded   resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (MessageBatchRequestCounts) RawJSON

func (r MessageBatchRequestCounts) RawJSON() string

Returns the unmodified JSON received from the API

func (*MessageBatchRequestCounts) UnmarshalJSON

func (r *MessageBatchRequestCounts) UnmarshalJSON(data []byte) error

type MessageBatchResultUnion

type MessageBatchResultUnion struct {
	// This field is from variant [MessageBatchSucceededResult].
	Message Message `json:"message"`
	// Any of "succeeded", "errored", "canceled", "expired".
	Type string `json:"type"`
	// This field is from variant [MessageBatchErroredResult].
	Error shared.ErrorResponse `json:"error"`
	JSON  struct {
		Message resp.Field
		Type    resp.Field
		Error   resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

MessageBatchResultUnion contains all possible properties and values from MessageBatchSucceededResult, MessageBatchErroredResult, MessageBatchCanceledResult, MessageBatchExpiredResult.

Use the MessageBatchResultUnion.AsAny method to switch on the variant.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (MessageBatchResultUnion) AsAny

func (u MessageBatchResultUnion) AsAny() any

Use the following switch statement to find the correct variant

switch variant := MessageBatchResultUnion.AsAny().(type) {
case MessageBatchSucceededResult:
case MessageBatchErroredResult:
case MessageBatchCanceledResult:
case MessageBatchExpiredResult:
default:
  fmt.Errorf("no variant present")
}

func (MessageBatchResultUnion) AsCanceledResult

func (u MessageBatchResultUnion) AsCanceledResult() (v MessageBatchCanceledResult)

func (MessageBatchResultUnion) AsErroredResult

func (u MessageBatchResultUnion) AsErroredResult() (v MessageBatchErroredResult)

func (MessageBatchResultUnion) AsExpiredResult

func (u MessageBatchResultUnion) AsExpiredResult() (v MessageBatchExpiredResult)

func (MessageBatchResultUnion) AsSucceededResult

func (u MessageBatchResultUnion) AsSucceededResult() (v MessageBatchSucceededResult)

func (MessageBatchResultUnion) RawJSON

func (u MessageBatchResultUnion) RawJSON() string

Returns the unmodified JSON received from the API

func (*MessageBatchResultUnion) UnmarshalJSON

func (r *MessageBatchResultUnion) UnmarshalJSON(data []byte) error

type MessageBatchService

type MessageBatchService struct {
	Options []option.RequestOption
}

MessageBatchService contains methods and other services that help with interacting with the anthropic API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewMessageBatchService method instead.

func NewMessageBatchService

func NewMessageBatchService(opts ...option.RequestOption) (r MessageBatchService)

NewMessageBatchService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*MessageBatchService) Cancel

func (r *MessageBatchService) Cancel(ctx context.Context, messageBatchID string, opts ...option.RequestOption) (res *MessageBatch, err error)

Batches may be canceled any time before processing ends. Once cancellation is initiated, the batch enters a `canceling` state, at which time the system may complete any in-progress, non-interruptible requests before finalizing cancellation.

The number of canceled requests is specified in `request_counts`. To determine which requests were canceled, check the individual results within the batch. Note that cancellation may not result in any canceled requests if they were non-interruptible.

Learn more about the Message Batches API in our [user guide](/en/docs/build-with-claude/batch-processing)

func (*MessageBatchService) Delete

func (r *MessageBatchService) Delete(ctx context.Context, messageBatchID string, opts ...option.RequestOption) (res *DeletedMessageBatch, err error)

Delete a Message Batch.

Message Batches can only be deleted once they've finished processing. If you'd like to delete an in-progress batch, you must first cancel it.

Learn more about the Message Batches API in our [user guide](/en/docs/build-with-claude/batch-processing)

func (*MessageBatchService) Get

func (r *MessageBatchService) Get(ctx context.Context, messageBatchID string, opts ...option.RequestOption) (res *MessageBatch, err error)

This endpoint is idempotent and can be used to poll for Message Batch completion. To access the results of a Message Batch, make a request to the `results_url` field in the response.

Learn more about the Message Batches API in our [user guide](/en/docs/build-with-claude/batch-processing)

func (*MessageBatchService) List

List all Message Batches within a Workspace. Most recently created batches are returned first.

Learn more about the Message Batches API in our [user guide](/en/docs/build-with-claude/batch-processing)

func (*MessageBatchService) ListAutoPaging

List all Message Batches within a Workspace. Most recently created batches are returned first.

Learn more about the Message Batches API in our [user guide](/en/docs/build-with-claude/batch-processing)

func (*MessageBatchService) New

Send a batch of Message creation requests.

The Message Batches API can be used to process multiple Messages API requests at once. Once a Message Batch is created, it begins processing immediately. Batches can take up to 24 hours to complete.

Learn more about the Message Batches API in our [user guide](/en/docs/build-with-claude/batch-processing)

func (*MessageBatchService) ResultsStreaming

func (r *MessageBatchService) ResultsStreaming(ctx context.Context, messageBatchID string, opts ...option.RequestOption) (stream *jsonl.Stream[MessageBatchIndividualResponse])

Streams the results of a Message Batch as a `.jsonl` file.

Each line in the file is a JSON object containing the result of a single request in the Message Batch. Results are not guaranteed to be in the same order as requests. Use the `custom_id` field to match results to requests.

Learn more about the Message Batches API in our [user guide](/en/docs/build-with-claude/batch-processing)

type MessageBatchSucceededResult

type MessageBatchSucceededResult struct {
	Message Message            `json:"message,required"`
	Type    constant.Succeeded `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Message     resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (MessageBatchSucceededResult) RawJSON

func (r MessageBatchSucceededResult) RawJSON() string

Returns the unmodified JSON received from the API

func (*MessageBatchSucceededResult) UnmarshalJSON

func (r *MessageBatchSucceededResult) UnmarshalJSON(data []byte) error

type MessageCountTokensParams

type MessageCountTokensParams struct {
	// Input messages.
	//
	// Our models are trained to operate on alternating `user` and `assistant`
	// conversational turns. When creating a new `Message`, you specify the prior
	// conversational turns with the `messages` parameter, and the model then generates
	// the next `Message` in the conversation. Consecutive `user` or `assistant` turns
	// in your request will be combined into a single turn.
	//
	// Each input message must be an object with a `role` and `content`. You can
	// specify a single `user`-role message, or you can include multiple `user` and
	// `assistant` messages.
	//
	// If the final message uses the `assistant` role, the response content will
	// continue immediately from the content in that message. This can be used to
	// constrain part of the model's response.
	//
	// Example with a single `user` message:
	//
	// “`json
	// [{ "role": "user", "content": "Hello, Claude" }]
	// “`
	//
	// Example with multiple conversational turns:
	//
	// “`json
	// [
	//
	//	{ "role": "user", "content": "Hello there." },
	//	{ "role": "assistant", "content": "Hi, I'm Claude. How can I help you?" },
	//	{ "role": "user", "content": "Can you explain LLMs in plain English?" }
	//
	// ]
	// “`
	//
	// Example with a partially-filled response from Claude:
	//
	// “`json
	// [
	//
	//	{
	//	  "role": "user",
	//	  "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"
	//	},
	//	{ "role": "assistant", "content": "The best answer is (" }
	//
	// ]
	// “`
	//
	// Each input message `content` may be either a single `string` or an array of
	// content blocks, where each block has a specific `type`. Using a `string` for
	// `content` is shorthand for an array of one content block of type `"text"`. The
	// following input messages are equivalent:
	//
	// “`json
	// { "role": "user", "content": "Hello, Claude" }
	// “`
	//
	// “`json
	// { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
	// “`
	//
	// Starting with Claude 3 models, you can also send image content blocks:
	//
	// “`json
	//
	//	{
	//	  "role": "user",
	//	  "content": [
	//	    {
	//	      "type": "image",
	//	      "source": {
	//	        "type": "base64",
	//	        "media_type": "image/jpeg",
	//	        "data": "/9j/4AAQSkZJRg..."
	//	      }
	//	    },
	//	    { "type": "text", "text": "What is in this image?" }
	//	  ]
	//	}
	//
	// “`
	//
	// We currently support the `base64` source type for images, and the `image/jpeg`,
	// `image/png`, `image/gif`, and `image/webp` media types.
	//
	// See [examples](https://docs.anthropic.com/en/api/messages-examples#vision) for
	// more input examples.
	//
	// Note that if you want to include a
	// [system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
	// the top-level `system` parameter — there is no `"system"` role for input
	// messages in the Messages API.
	Messages []MessageParam `json:"messages,omitzero,required"`
	// The model that will complete your prompt.\n\nSee
	// [models](https://docs.anthropic.com/en/docs/models-overview) for additional
	// details and options.
	Model Model `json:"model,omitzero,required"`
	// System prompt.
	//
	// A system prompt is a way of providing context and instructions to Claude, such
	// as specifying a particular goal or role. See our
	// [guide to system prompts](https://docs.anthropic.com/en/docs/system-prompts).
	System MessageCountTokensParamsSystemUnion `json:"system,omitzero"`
	// Configuration for enabling Claude's extended thinking.
	//
	// When enabled, responses include `thinking` content blocks showing Claude's
	// thinking process before the final answer. Requires a minimum budget of 1,024
	// tokens and counts towards your `max_tokens` limit.
	//
	// See
	// [extended thinking](https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking)
	// for details.
	Thinking ThinkingConfigParamUnion `json:"thinking,omitzero"`
	// How the model should use the provided tools. The model can use a specific tool,
	// any available tool, decide by itself, or not use tools at all.
	ToolChoice ToolChoiceUnionParam `json:"tool_choice,omitzero"`
	// Definitions of tools that the model may use.
	//
	// If you include `tools` in your API request, the model may return `tool_use`
	// content blocks that represent the model's use of those tools. You can then run
	// those tools using the tool input generated by the model and then optionally
	// return results back to the model using `tool_result` content blocks.
	//
	// Each tool definition includes:
	//
	//   - `name`: Name of the tool.
	//   - `description`: Optional, but strongly-recommended description of the tool.
	//   - `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the
	//     tool `input` shape that the model will produce in `tool_use` output content
	//     blocks.
	//
	// For example, if you defined `tools` as:
	//
	// “`json
	// [
	//
	//	{
	//	  "name": "get_stock_price",
	//	  "description": "Get the current stock price for a given ticker symbol.",
	//	  "input_schema": {
	//	    "type": "object",
	//	    "properties": {
	//	      "ticker": {
	//	        "type": "string",
	//	        "description": "The stock ticker symbol, e.g. AAPL for Apple Inc."
	//	      }
	//	    },
	//	    "required": ["ticker"]
	//	  }
	//	}
	//
	// ]
	// “`
	//
	// And then asked the model "What's the S&P 500 at today?", the model might produce
	// `tool_use` content blocks in the response like this:
	//
	// “`json
	// [
	//
	//	{
	//	  "type": "tool_use",
	//	  "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
	//	  "name": "get_stock_price",
	//	  "input": { "ticker": "^GSPC" }
	//	}
	//
	// ]
	// “`
	//
	// You might then run your `get_stock_price` tool with `{"ticker": "^GSPC"}` as an
	// input, and return the following back to the model in a subsequent `user`
	// message:
	//
	// “`json
	// [
	//
	//	{
	//	  "type": "tool_result",
	//	  "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
	//	  "content": "259.75 USD"
	//	}
	//
	// ]
	// “`
	//
	// Tools can be used for workflows that include running client-side tools and
	// functions, or more generally whenever you want the model to produce a particular
	// JSON structure of output.
	//
	// See our [guide](https://docs.anthropic.com/en/docs/tool-use) for more details.
	Tools []MessageCountTokensToolUnionParam `json:"tools,omitzero"`
	// contains filtered or unexported fields
}

func (MessageCountTokensParams) IsPresent

func (f MessageCountTokensParams) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (MessageCountTokensParams) MarshalJSON

func (r MessageCountTokensParams) MarshalJSON() (data []byte, err error)

type MessageCountTokensParamsSystemUnion

type MessageCountTokensParamsSystemUnion struct {
	OfString                         param.Opt[string] `json:",omitzero,inline"`
	OfMessageCountTokenssSystemArray []TextBlockParam  `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (MessageCountTokensParamsSystemUnion) IsPresent

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (MessageCountTokensParamsSystemUnion) MarshalJSON

func (u MessageCountTokensParamsSystemUnion) MarshalJSON() ([]byte, error)

type MessageCountTokensToolUnionParam

type MessageCountTokensToolUnionParam struct {
	OfTool               *ToolParam                   `json:",omitzero,inline"`
	OfBashTool20250124   *ToolBash20250124Param       `json:",omitzero,inline"`
	OfTextEditor20250124 *ToolTextEditor20250124Param `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func MessageCountTokensToolParamOfTool

func MessageCountTokensToolParamOfTool(inputSchema ToolInputSchemaParam, name string) MessageCountTokensToolUnionParam

func (MessageCountTokensToolUnionParam) GetCacheControl

Returns a pointer to the underlying variant's CacheControl property, if present.

func (MessageCountTokensToolUnionParam) GetDescription

func (u MessageCountTokensToolUnionParam) GetDescription() *string

Returns a pointer to the underlying variant's property, if present.

func (MessageCountTokensToolUnionParam) GetInputSchema

Returns a pointer to the underlying variant's property, if present.

func (MessageCountTokensToolUnionParam) GetName

Returns a pointer to the underlying variant's property, if present.

func (MessageCountTokensToolUnionParam) GetType

Returns a pointer to the underlying variant's property, if present.

func (MessageCountTokensToolUnionParam) IsPresent

func (u MessageCountTokensToolUnionParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (MessageCountTokensToolUnionParam) MarshalJSON

func (u MessageCountTokensToolUnionParam) MarshalJSON() ([]byte, error)

type MessageDeltaEvent

type MessageDeltaEvent struct {
	Delta MessageDeltaEventDelta `json:"delta,required"`
	Type  constant.MessageDelta  `json:"type,required"`
	// Billing and rate-limit usage.
	//
	// Anthropic's API bills and rate-limits by token counts, as tokens represent the
	// underlying cost to our systems.
	//
	// Under the hood, the API transforms requests into a format suitable for the
	// model. The model's output then goes through a parsing stage before becoming an
	// API response. As a result, the token counts in `usage` will not match one-to-one
	// with the exact visible content of an API request or response.
	//
	// For example, `output_tokens` will be non-zero, even for an empty string response
	// from Claude.
	//
	// Total input tokens in a request is the summation of `input_tokens`,
	// `cache_creation_input_tokens`, and `cache_read_input_tokens`.
	Usage MessageDeltaUsage `json:"usage,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Delta       resp.Field
		Type        resp.Field
		Usage       resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (MessageDeltaEvent) RawJSON

func (r MessageDeltaEvent) RawJSON() string

Returns the unmodified JSON received from the API

func (*MessageDeltaEvent) UnmarshalJSON

func (r *MessageDeltaEvent) UnmarshalJSON(data []byte) error

type MessageDeltaEventDelta

type MessageDeltaEventDelta struct {
	// Any of "end_turn", "max_tokens", "stop_sequence", "tool_use".
	StopReason   string `json:"stop_reason,required"`
	StopSequence string `json:"stop_sequence,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		StopReason   resp.Field
		StopSequence resp.Field
		ExtraFields  map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (MessageDeltaEventDelta) RawJSON

func (r MessageDeltaEventDelta) RawJSON() string

Returns the unmodified JSON received from the API

func (*MessageDeltaEventDelta) UnmarshalJSON

func (r *MessageDeltaEventDelta) UnmarshalJSON(data []byte) error

type MessageDeltaUsage

type MessageDeltaUsage struct {
	// The cumulative number of output tokens which were used.
	OutputTokens int64 `json:"output_tokens,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		OutputTokens resp.Field
		ExtraFields  map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (MessageDeltaUsage) RawJSON

func (r MessageDeltaUsage) RawJSON() string

Returns the unmodified JSON received from the API

func (*MessageDeltaUsage) UnmarshalJSON

func (r *MessageDeltaUsage) UnmarshalJSON(data []byte) error

type MessageNewParams

type MessageNewParams struct {
	// The maximum number of tokens to generate before stopping.
	//
	// Note that our models may stop _before_ reaching this maximum. This parameter
	// only specifies the absolute maximum number of tokens to generate.
	//
	// Different models have different maximum values for this parameter. See
	// [models](https://docs.anthropic.com/en/docs/models-overview) for details.
	MaxTokens int64 `json:"max_tokens,required"`
	// Input messages.
	//
	// Our models are trained to operate on alternating `user` and `assistant`
	// conversational turns. When creating a new `Message`, you specify the prior
	// conversational turns with the `messages` parameter, and the model then generates
	// the next `Message` in the conversation. Consecutive `user` or `assistant` turns
	// in your request will be combined into a single turn.
	//
	// Each input message must be an object with a `role` and `content`. You can
	// specify a single `user`-role message, or you can include multiple `user` and
	// `assistant` messages.
	//
	// If the final message uses the `assistant` role, the response content will
	// continue immediately from the content in that message. This can be used to
	// constrain part of the model's response.
	//
	// Example with a single `user` message:
	//
	// “`json
	// [{ "role": "user", "content": "Hello, Claude" }]
	// “`
	//
	// Example with multiple conversational turns:
	//
	// “`json
	// [
	//
	//	{ "role": "user", "content": "Hello there." },
	//	{ "role": "assistant", "content": "Hi, I'm Claude. How can I help you?" },
	//	{ "role": "user", "content": "Can you explain LLMs in plain English?" }
	//
	// ]
	// “`
	//
	// Example with a partially-filled response from Claude:
	//
	// “`json
	// [
	//
	//	{
	//	  "role": "user",
	//	  "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"
	//	},
	//	{ "role": "assistant", "content": "The best answer is (" }
	//
	// ]
	// “`
	//
	// Each input message `content` may be either a single `string` or an array of
	// content blocks, where each block has a specific `type`. Using a `string` for
	// `content` is shorthand for an array of one content block of type `"text"`. The
	// following input messages are equivalent:
	//
	// “`json
	// { "role": "user", "content": "Hello, Claude" }
	// “`
	//
	// “`json
	// { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
	// “`
	//
	// Starting with Claude 3 models, you can also send image content blocks:
	//
	// “`json
	//
	//	{
	//	  "role": "user",
	//	  "content": [
	//	    {
	//	      "type": "image",
	//	      "source": {
	//	        "type": "base64",
	//	        "media_type": "image/jpeg",
	//	        "data": "/9j/4AAQSkZJRg..."
	//	      }
	//	    },
	//	    { "type": "text", "text": "What is in this image?" }
	//	  ]
	//	}
	//
	// “`
	//
	// We currently support the `base64` source type for images, and the `image/jpeg`,
	// `image/png`, `image/gif`, and `image/webp` media types.
	//
	// See [examples](https://docs.anthropic.com/en/api/messages-examples#vision) for
	// more input examples.
	//
	// Note that if you want to include a
	// [system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
	// the top-level `system` parameter — there is no `"system"` role for input
	// messages in the Messages API.
	Messages []MessageParam `json:"messages,omitzero,required"`
	// The model that will complete your prompt.\n\nSee
	// [models](https://docs.anthropic.com/en/docs/models-overview) for additional
	// details and options.
	Model Model `json:"model,omitzero,required"`
	// Amount of randomness injected into the response.
	//
	// Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0`
	// for analytical / multiple choice, and closer to `1.0` for creative and
	// generative tasks.
	//
	// Note that even with `temperature` of `0.0`, the results will not be fully
	// deterministic.
	Temperature param.Opt[float64] `json:"temperature,omitzero"`
	// Only sample from the top K options for each subsequent token.
	//
	// Used to remove "long tail" low probability responses.
	// [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).
	//
	// Recommended for advanced use cases only. You usually only need to use
	// `temperature`.
	TopK param.Opt[int64] `json:"top_k,omitzero"`
	// Use nucleus sampling.
	//
	// In nucleus sampling, we compute the cumulative distribution over all the options
	// for each subsequent token in decreasing probability order and cut it off once it
	// reaches a particular probability specified by `top_p`. You should either alter
	// `temperature` or `top_p`, but not both.
	//
	// Recommended for advanced use cases only. You usually only need to use
	// `temperature`.
	TopP param.Opt[float64] `json:"top_p,omitzero"`
	// An object describing metadata about the request.
	Metadata MetadataParam `json:"metadata,omitzero"`
	// Custom text sequences that will cause the model to stop generating.
	//
	// Our models will normally stop when they have naturally completed their turn,
	// which will result in a response `stop_reason` of `"end_turn"`.
	//
	// If you want the model to stop generating when it encounters custom strings of
	// text, you can use the `stop_sequences` parameter. If the model encounters one of
	// the custom sequences, the response `stop_reason` value will be `"stop_sequence"`
	// and the response `stop_sequence` value will contain the matched stop sequence.
	StopSequences []string `json:"stop_sequences,omitzero"`
	// System prompt.
	//
	// A system prompt is a way of providing context and instructions to Claude, such
	// as specifying a particular goal or role. See our
	// [guide to system prompts](https://docs.anthropic.com/en/docs/system-prompts).
	System []TextBlockParam `json:"system,omitzero"`
	// Configuration for enabling Claude's extended thinking.
	//
	// When enabled, responses include `thinking` content blocks showing Claude's
	// thinking process before the final answer. Requires a minimum budget of 1,024
	// tokens and counts towards your `max_tokens` limit.
	//
	// See
	// [extended thinking](https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking)
	// for details.
	Thinking ThinkingConfigParamUnion `json:"thinking,omitzero"`
	// How the model should use the provided tools. The model can use a specific tool,
	// any available tool, decide by itself, or not use tools at all.
	ToolChoice ToolChoiceUnionParam `json:"tool_choice,omitzero"`
	// Definitions of tools that the model may use.
	//
	// If you include `tools` in your API request, the model may return `tool_use`
	// content blocks that represent the model's use of those tools. You can then run
	// those tools using the tool input generated by the model and then optionally
	// return results back to the model using `tool_result` content blocks.
	//
	// Each tool definition includes:
	//
	//   - `name`: Name of the tool.
	//   - `description`: Optional, but strongly-recommended description of the tool.
	//   - `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the
	//     tool `input` shape that the model will produce in `tool_use` output content
	//     blocks.
	//
	// For example, if you defined `tools` as:
	//
	// “`json
	// [
	//
	//	{
	//	  "name": "get_stock_price",
	//	  "description": "Get the current stock price for a given ticker symbol.",
	//	  "input_schema": {
	//	    "type": "object",
	//	    "properties": {
	//	      "ticker": {
	//	        "type": "string",
	//	        "description": "The stock ticker symbol, e.g. AAPL for Apple Inc."
	//	      }
	//	    },
	//	    "required": ["ticker"]
	//	  }
	//	}
	//
	// ]
	// “`
	//
	// And then asked the model "What's the S&P 500 at today?", the model might produce
	// `tool_use` content blocks in the response like this:
	//
	// “`json
	// [
	//
	//	{
	//	  "type": "tool_use",
	//	  "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
	//	  "name": "get_stock_price",
	//	  "input": { "ticker": "^GSPC" }
	//	}
	//
	// ]
	// “`
	//
	// You might then run your `get_stock_price` tool with `{"ticker": "^GSPC"}` as an
	// input, and return the following back to the model in a subsequent `user`
	// message:
	//
	// “`json
	// [
	//
	//	{
	//	  "type": "tool_result",
	//	  "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
	//	  "content": "259.75 USD"
	//	}
	//
	// ]
	// “`
	//
	// Tools can be used for workflows that include running client-side tools and
	// functions, or more generally whenever you want the model to produce a particular
	// JSON structure of output.
	//
	// See our [guide](https://docs.anthropic.com/en/docs/tool-use) for more details.
	Tools []ToolUnionParam `json:"tools,omitzero"`
	// contains filtered or unexported fields
}

func (MessageNewParams) IsPresent

func (f MessageNewParams) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (MessageNewParams) MarshalJSON

func (r MessageNewParams) MarshalJSON() (data []byte, err error)

type MessageParam

type MessageParam struct {
	Content []ContentBlockParamUnion `json:"content,omitzero,required"`
	// Any of "user", "assistant".
	Role MessageParamRole `json:"role,omitzero,required"`
	// contains filtered or unexported fields
}

The properties Content, Role are required.

func NewAssistantMessage

func NewAssistantMessage(blocks ...ContentBlockParamUnion) MessageParam

func NewUserMessage

func NewUserMessage(blocks ...ContentBlockParamUnion) MessageParam

func (MessageParam) IsPresent

func (f MessageParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (MessageParam) MarshalJSON

func (r MessageParam) MarshalJSON() (data []byte, err error)

type MessageParamRole

type MessageParamRole string
const (
	MessageParamRoleUser      MessageParamRole = "user"
	MessageParamRoleAssistant MessageParamRole = "assistant"
)

type MessageService

type MessageService struct {
	Options []option.RequestOption
	Batches MessageBatchService
}

MessageService contains methods and other services that help with interacting with the anthropic API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewMessageService method instead.

func NewMessageService

func NewMessageService(opts ...option.RequestOption) (r MessageService)

NewMessageService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*MessageService) CountTokens

func (r *MessageService) CountTokens(ctx context.Context, body MessageCountTokensParams, opts ...option.RequestOption) (res *MessageTokensCount, err error)

Count the number of tokens in a Message.

The Token Count API can be used to count the number of tokens in a Message, including tools, images, and documents, without creating it.

Learn more about token counting in our [user guide](/en/docs/build-with-claude/token-counting)

func (*MessageService) New

func (r *MessageService) New(ctx context.Context, body MessageNewParams, opts ...option.RequestOption) (res *Message, err error)

Send a structured list of input messages with text and/or image content, and the model will generate the next message in the conversation.

The Messages API can be used for either single queries or stateless multi-turn conversations.

Learn more about the Messages API in our [user guide](/en/docs/initial-setup)

Note: If you choose to set a timeout for this request, we recommend 10 minutes.

func (*MessageService) NewStreaming

Send a structured list of input messages with text and/or image content, and the model will generate the next message in the conversation.

The Messages API can be used for either single queries or stateless multi-turn conversations.

Learn more about the Messages API in our [user guide](/en/docs/initial-setup)

Note: If you choose to set a timeout for this request, we recommend 10 minutes.

type MessageStartEvent

type MessageStartEvent struct {
	Message Message               `json:"message,required"`
	Type    constant.MessageStart `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Message     resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (MessageStartEvent) RawJSON

func (r MessageStartEvent) RawJSON() string

Returns the unmodified JSON received from the API

func (*MessageStartEvent) UnmarshalJSON

func (r *MessageStartEvent) UnmarshalJSON(data []byte) error

type MessageStopEvent

type MessageStopEvent struct {
	Type constant.MessageStop `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (MessageStopEvent) RawJSON

func (r MessageStopEvent) RawJSON() string

Returns the unmodified JSON received from the API

func (*MessageStopEvent) UnmarshalJSON

func (r *MessageStopEvent) UnmarshalJSON(data []byte) error

type MessageStopReason

type MessageStopReason string

The reason that we stopped.

This may be one the following values:

- `"end_turn"`: the model reached a natural stopping point - `"max_tokens"`: we exceeded the requested `max_tokens` or the model's maximum - `"stop_sequence"`: one of your provided custom `stop_sequences` was generated - `"tool_use"`: the model invoked one or more tools

In non-streaming mode this value is always non-null. In streaming mode, it is null in the `message_start` event and non-null otherwise.

const (
	MessageStopReasonEndTurn      MessageStopReason = "end_turn"
	MessageStopReasonMaxTokens    MessageStopReason = "max_tokens"
	MessageStopReasonStopSequence MessageStopReason = "stop_sequence"
	MessageStopReasonToolUse      MessageStopReason = "tool_use"
)

type MessageStreamEventUnion

type MessageStreamEventUnion struct {
	// This field is from variant [MessageStartEvent].
	Message Message `json:"message"`
	// Any of "message_start", "message_delta", "message_stop", "content_block_start",
	// "content_block_delta", "content_block_stop".
	Type string `json:"type"`
	// This field is a union of [MessageDeltaEventDelta],
	// [ContentBlockDeltaEventDeltaUnion]
	Delta MessageStreamEventUnionDelta `json:"delta"`
	// This field is from variant [MessageDeltaEvent].
	Usage MessageDeltaUsage `json:"usage"`
	// This field is from variant [ContentBlockStartEvent].
	ContentBlock ContentBlockStartEventContentBlockUnion `json:"content_block"`
	Index        int64                                   `json:"index"`
	JSON         struct {
		Message      resp.Field
		Type         resp.Field
		Delta        resp.Field
		Usage        resp.Field
		ContentBlock resp.Field
		Index        resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

MessageStreamEventUnion contains all possible properties and values from MessageStartEvent, MessageDeltaEvent, MessageStopEvent, ContentBlockStartEvent, ContentBlockDeltaEvent, ContentBlockStopEvent.

Use the MessageStreamEventUnion.AsAny method to switch on the variant.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (MessageStreamEventUnion) AsAny

func (u MessageStreamEventUnion) AsAny() any

Use the following switch statement to find the correct variant

switch variant := MessageStreamEventUnion.AsAny().(type) {
case MessageStartEvent:
case MessageDeltaEvent:
case MessageStopEvent:
case ContentBlockStartEvent:
case ContentBlockDeltaEvent:
case ContentBlockStopEvent:
default:
  fmt.Errorf("no variant present")
}

func (MessageStreamEventUnion) AsContentBlockDeltaEvent

func (u MessageStreamEventUnion) AsContentBlockDeltaEvent() (v ContentBlockDeltaEvent)

func (MessageStreamEventUnion) AsContentBlockStartEvent

func (u MessageStreamEventUnion) AsContentBlockStartEvent() (v ContentBlockStartEvent)

func (MessageStreamEventUnion) AsContentBlockStopEvent

func (u MessageStreamEventUnion) AsContentBlockStopEvent() (v ContentBlockStopEvent)

func (MessageStreamEventUnion) AsMessageDeltaEvent

func (u MessageStreamEventUnion) AsMessageDeltaEvent() (v MessageDeltaEvent)

func (MessageStreamEventUnion) AsMessageStartEvent

func (u MessageStreamEventUnion) AsMessageStartEvent() (v MessageStartEvent)

func (MessageStreamEventUnion) AsMessageStopEvent

func (u MessageStreamEventUnion) AsMessageStopEvent() (v MessageStopEvent)

func (MessageStreamEventUnion) RawJSON

func (u MessageStreamEventUnion) RawJSON() string

Returns the unmodified JSON received from the API

func (*MessageStreamEventUnion) UnmarshalJSON

func (r *MessageStreamEventUnion) UnmarshalJSON(data []byte) error

type MessageStreamEventUnionDelta

type MessageStreamEventUnionDelta struct {
	// This field is from variant [MessageDeltaEventDelta].
	StopReason string `json:"stop_reason"`
	// This field is from variant [MessageDeltaEventDelta].
	StopSequence string `json:"stop_sequence"`
	// This field is from variant [ContentBlockDeltaEventDeltaUnion].
	Text string `json:"text"`
	Type string `json:"type"`
	// This field is from variant [ContentBlockDeltaEventDeltaUnion].
	PartialJSON string `json:"partial_json"`
	// This field is from variant [ContentBlockDeltaEventDeltaUnion].
	Citation CitationsDeltaCitationUnion `json:"citation"`
	// This field is from variant [ContentBlockDeltaEventDeltaUnion].
	Thinking string `json:"thinking"`
	// This field is from variant [ContentBlockDeltaEventDeltaUnion].
	Signature string `json:"signature"`
	JSON      struct {
		StopReason   resp.Field
		StopSequence resp.Field
		Text         resp.Field
		Type         resp.Field
		PartialJSON  resp.Field
		Citation     resp.Field
		Thinking     resp.Field
		Signature    resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

MessageStreamEventUnionDelta is an implicit subunion of MessageStreamEventUnion. MessageStreamEventUnionDelta provides convenient access to the sub-properties of the union.

For type safety it is recommended to directly use a variant of the MessageStreamEventUnion.

func (*MessageStreamEventUnionDelta) UnmarshalJSON

func (r *MessageStreamEventUnionDelta) UnmarshalJSON(data []byte) error

type MessageTokensCount

type MessageTokensCount struct {
	// The total number of tokens across the provided list of messages, system prompt,
	// and tools.
	InputTokens int64 `json:"input_tokens,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		InputTokens resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (MessageTokensCount) RawJSON

func (r MessageTokensCount) RawJSON() string

Returns the unmodified JSON received from the API

func (*MessageTokensCount) UnmarshalJSON

func (r *MessageTokensCount) UnmarshalJSON(data []byte) error

type MetadataParam

type MetadataParam struct {
	// An external identifier for the user who is associated with the request.
	//
	// This should be a uuid, hash value, or other opaque identifier. Anthropic may use
	// this id to help detect abuse. Do not include any identifying information such as
	// name, email address, or phone number.
	UserID param.Opt[string] `json:"user_id,omitzero"`
	// contains filtered or unexported fields
}

func (MetadataParam) IsPresent

func (f MetadataParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (MetadataParam) MarshalJSON

func (r MetadataParam) MarshalJSON() (data []byte, err error)

type Model

type Model = string

The model that will complete your prompt.\n\nSee [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

const (
	ModelClaude3_7SonnetLatest      Model = "claude-3-7-sonnet-latest"
	ModelClaude3_7Sonnet20250219    Model = "claude-3-7-sonnet-20250219"
	ModelClaude3_5HaikuLatest       Model = "claude-3-5-haiku-latest"
	ModelClaude3_5Haiku20241022     Model = "claude-3-5-haiku-20241022"
	ModelClaude3_5SonnetLatest      Model = "claude-3-5-sonnet-latest"
	ModelClaude3_5Sonnet20241022    Model = "claude-3-5-sonnet-20241022"
	ModelClaude_3_5_Sonnet_20240620 Model = "claude-3-5-sonnet-20240620"
	ModelClaude3OpusLatest          Model = "claude-3-opus-latest"
	ModelClaude_3_Opus_20240229     Model = "claude-3-opus-20240229"
	// Deprecated: Will reach end-of-life on July 21st, 2025. Please migrate to a newer
	// model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for
	// more information.
	ModelClaude_3_Sonnet_20240229 Model = "claude-3-sonnet-20240229"
	ModelClaude_3_Haiku_20240307  Model = "claude-3-haiku-20240307"
	// Deprecated: Will reach end-of-life on July 21st, 2025. Please migrate to a newer
	// model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for
	// more information.
	ModelClaude_2_1 Model = "claude-2.1"
	// Deprecated: Will reach end-of-life on July 21st, 2025. Please migrate to a newer
	// model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for
	// more information.
	ModelClaude_2_0 Model = "claude-2.0"
)

type ModelInfo

type ModelInfo struct {
	// Unique model identifier.
	ID string `json:"id,required"`
	// RFC 3339 datetime string representing the time at which the model was released.
	// May be set to an epoch value if the release date is unknown.
	CreatedAt time.Time `json:"created_at,required" format:"date-time"`
	// A human-readable name for the model.
	DisplayName string `json:"display_name,required"`
	// Object type.
	//
	// For Models, this is always `"model"`.
	Type constant.Model `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		ID          resp.Field
		CreatedAt   resp.Field
		DisplayName resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ModelInfo) RawJSON

func (r ModelInfo) RawJSON() string

Returns the unmodified JSON received from the API

func (*ModelInfo) UnmarshalJSON

func (r *ModelInfo) UnmarshalJSON(data []byte) error

type ModelListParams

type ModelListParams struct {
	// ID of the object to use as a cursor for pagination. When provided, returns the
	// page of results immediately after this object.
	AfterID param.Opt[string] `query:"after_id,omitzero" json:"-"`
	// ID of the object to use as a cursor for pagination. When provided, returns the
	// page of results immediately before this object.
	BeforeID param.Opt[string] `query:"before_id,omitzero" json:"-"`
	// Number of items to return per page.
	//
	// Defaults to `20`. Ranges from `1` to `1000`.
	Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (ModelListParams) IsPresent

func (f ModelListParams) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (ModelListParams) URLQuery

func (r ModelListParams) URLQuery() (v url.Values)

URLQuery serializes ModelListParams's query parameters as `url.Values`.

type ModelService

type ModelService struct {
	Options []option.RequestOption
}

ModelService contains methods and other services that help with interacting with the anthropic API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewModelService method instead.

func NewModelService

func NewModelService(opts ...option.RequestOption) (r ModelService)

NewModelService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*ModelService) Get

func (r *ModelService) Get(ctx context.Context, modelID string, opts ...option.RequestOption) (res *ModelInfo, err error)

Get a specific model.

The Models API response can be used to determine information about a specific model or resolve a model alias to a model ID.

func (*ModelService) List

func (r *ModelService) List(ctx context.Context, query ModelListParams, opts ...option.RequestOption) (res *pagination.Page[ModelInfo], err error)

List available models.

The Models API response can be used to determine which models are available for use in the API. More recently released models are listed first.

func (*ModelService) ListAutoPaging

List available models.

The Models API response can be used to determine which models are available for use in the API. More recently released models are listed first.

type PlainTextSourceParam

type PlainTextSourceParam struct {
	Data string `json:"data,required"`
	// This field can be elided, and will marshal its zero value as "text/plain".
	MediaType constant.TextPlain `json:"media_type,required"`
	// This field can be elided, and will marshal its zero value as "text".
	Type constant.Text `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Data, MediaType, Type are required.

func (PlainTextSourceParam) IsPresent

func (f PlainTextSourceParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (PlainTextSourceParam) MarshalJSON

func (r PlainTextSourceParam) MarshalJSON() (data []byte, err error)

type RedactedThinkingBlock

type RedactedThinkingBlock struct {
	Data string                    `json:"data,required"`
	Type constant.RedactedThinking `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Data        resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (RedactedThinkingBlock) RawJSON

func (r RedactedThinkingBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (RedactedThinkingBlock) ToParam

func (*RedactedThinkingBlock) UnmarshalJSON

func (r *RedactedThinkingBlock) UnmarshalJSON(data []byte) error

type RedactedThinkingBlockParam

type RedactedThinkingBlockParam struct {
	Data string `json:"data,required"`
	// This field can be elided, and will marshal its zero value as
	// "redacted_thinking".
	Type constant.RedactedThinking `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Data, Type are required.

func (RedactedThinkingBlockParam) IsPresent

func (f RedactedThinkingBlockParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (RedactedThinkingBlockParam) MarshalJSON

func (r RedactedThinkingBlockParam) MarshalJSON() (data []byte, err error)

type SignatureDelta

type SignatureDelta struct {
	Signature string                  `json:"signature,required"`
	Type      constant.SignatureDelta `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Signature   resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SignatureDelta) RawJSON

func (r SignatureDelta) RawJSON() string

Returns the unmodified JSON received from the API

func (*SignatureDelta) UnmarshalJSON

func (r *SignatureDelta) UnmarshalJSON(data []byte) error

type TextBlock

type TextBlock struct {
	// Citations supporting the text block.
	//
	// The type of citation returned will depend on the type of document being cited.
	// Citing a PDF results in `page_location`, plain text results in `char_location`,
	// and content document results in `content_block_location`.
	Citations []TextCitationUnion `json:"citations,required"`
	Text      string              `json:"text,required"`
	Type      constant.Text       `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Citations   resp.Field
		Text        resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TextBlock) RawJSON

func (r TextBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (TextBlock) ToParam

func (r TextBlock) ToParam() TextBlockParam

func (*TextBlock) UnmarshalJSON

func (r *TextBlock) UnmarshalJSON(data []byte) error

type TextBlockParam

type TextBlockParam struct {
	Text         string                     `json:"text,required"`
	Citations    []TextCitationParamUnion   `json:"citations,omitzero"`
	CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"`
	// This field can be elided, and will marshal its zero value as "text".
	Type constant.Text `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Text, Type are required.

func (TextBlockParam) IsPresent

func (f TextBlockParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (TextBlockParam) MarshalJSON

func (r TextBlockParam) MarshalJSON() (data []byte, err error)

type TextCitationParamUnion

type TextCitationParamUnion struct {
	OfRequestCharLocationCitation         *CitationCharLocationParam         `json:",omitzero,inline"`
	OfRequestPageLocationCitation         *CitationPageLocationParam         `json:",omitzero,inline"`
	OfRequestContentBlockLocationCitation *CitationContentBlockLocationParam `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (TextCitationParamUnion) GetCitedText

func (u TextCitationParamUnion) GetCitedText() *string

Returns a pointer to the underlying variant's property, if present.

func (TextCitationParamUnion) GetDocumentIndex

func (u TextCitationParamUnion) GetDocumentIndex() *int64

Returns a pointer to the underlying variant's property, if present.

func (TextCitationParamUnion) GetDocumentTitle

func (u TextCitationParamUnion) GetDocumentTitle() *string

Returns a pointer to the underlying variant's property, if present.

func (TextCitationParamUnion) GetEndBlockIndex

func (u TextCitationParamUnion) GetEndBlockIndex() *int64

Returns a pointer to the underlying variant's property, if present.

func (TextCitationParamUnion) GetEndCharIndex

func (u TextCitationParamUnion) GetEndCharIndex() *int64

Returns a pointer to the underlying variant's property, if present.

func (TextCitationParamUnion) GetEndPageNumber

func (u TextCitationParamUnion) GetEndPageNumber() *int64

Returns a pointer to the underlying variant's property, if present.

func (TextCitationParamUnion) GetStartBlockIndex

func (u TextCitationParamUnion) GetStartBlockIndex() *int64

Returns a pointer to the underlying variant's property, if present.

func (TextCitationParamUnion) GetStartCharIndex

func (u TextCitationParamUnion) GetStartCharIndex() *int64

Returns a pointer to the underlying variant's property, if present.

func (TextCitationParamUnion) GetStartPageNumber

func (u TextCitationParamUnion) GetStartPageNumber() *int64

Returns a pointer to the underlying variant's property, if present.

func (TextCitationParamUnion) GetType

func (u TextCitationParamUnion) GetType() *string

Returns a pointer to the underlying variant's property, if present.

func (TextCitationParamUnion) IsPresent

func (u TextCitationParamUnion) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (TextCitationParamUnion) MarshalJSON

func (u TextCitationParamUnion) MarshalJSON() ([]byte, error)

type TextCitationUnion

type TextCitationUnion struct {
	CitedText     string `json:"cited_text"`
	DocumentIndex int64  `json:"document_index"`
	DocumentTitle string `json:"document_title"`
	// This field is from variant [CitationCharLocation].
	EndCharIndex int64 `json:"end_char_index"`
	// This field is from variant [CitationCharLocation].
	StartCharIndex int64 `json:"start_char_index"`
	// Any of "char_location", "page_location", "content_block_location".
	Type string `json:"type"`
	// This field is from variant [CitationPageLocation].
	EndPageNumber int64 `json:"end_page_number"`
	// This field is from variant [CitationPageLocation].
	StartPageNumber int64 `json:"start_page_number"`
	// This field is from variant [CitationContentBlockLocation].
	EndBlockIndex int64 `json:"end_block_index"`
	// This field is from variant [CitationContentBlockLocation].
	StartBlockIndex int64 `json:"start_block_index"`
	JSON            struct {
		CitedText       resp.Field
		DocumentIndex   resp.Field
		DocumentTitle   resp.Field
		EndCharIndex    resp.Field
		StartCharIndex  resp.Field
		Type            resp.Field
		EndPageNumber   resp.Field
		StartPageNumber resp.Field
		EndBlockIndex   resp.Field
		StartBlockIndex resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

TextCitationUnion contains all possible properties and values from CitationCharLocation, CitationPageLocation, CitationContentBlockLocation.

Use the TextCitationUnion.AsAny method to switch on the variant.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (TextCitationUnion) AsAny

func (u TextCitationUnion) AsAny() any

Use the following switch statement to find the correct variant

switch variant := TextCitationUnion.AsAny().(type) {
case CitationCharLocation:
case CitationPageLocation:
case CitationContentBlockLocation:
default:
  fmt.Errorf("no variant present")
}

func (TextCitationUnion) AsResponseCharLocationCitation

func (u TextCitationUnion) AsResponseCharLocationCitation() (v CitationCharLocation)

func (TextCitationUnion) AsResponseContentBlockLocationCitation

func (u TextCitationUnion) AsResponseContentBlockLocationCitation() (v CitationContentBlockLocation)

func (TextCitationUnion) AsResponsePageLocationCitation

func (u TextCitationUnion) AsResponsePageLocationCitation() (v CitationPageLocation)

func (TextCitationUnion) RawJSON

func (u TextCitationUnion) RawJSON() string

Returns the unmodified JSON received from the API

func (*TextCitationUnion) UnmarshalJSON

func (r *TextCitationUnion) UnmarshalJSON(data []byte) error

type TextDelta

type TextDelta struct {
	Text string             `json:"text,required"`
	Type constant.TextDelta `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Text        resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TextDelta) RawJSON

func (r TextDelta) RawJSON() string

Returns the unmodified JSON received from the API

func (*TextDelta) UnmarshalJSON

func (r *TextDelta) UnmarshalJSON(data []byte) error

type ThinkingBlock

type ThinkingBlock struct {
	Signature string            `json:"signature,required"`
	Thinking  string            `json:"thinking,required"`
	Type      constant.Thinking `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Signature   resp.Field
		Thinking    resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ThinkingBlock) RawJSON

func (r ThinkingBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (ThinkingBlock) ToParam

func (r ThinkingBlock) ToParam() ThinkingBlockParam

func (*ThinkingBlock) UnmarshalJSON

func (r *ThinkingBlock) UnmarshalJSON(data []byte) error

type ThinkingBlockParam

type ThinkingBlockParam struct {
	Signature string `json:"signature,required"`
	Thinking  string `json:"thinking,required"`
	// This field can be elided, and will marshal its zero value as "thinking".
	Type constant.Thinking `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Signature, Thinking, Type are required.

func (ThinkingBlockParam) IsPresent

func (f ThinkingBlockParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (ThinkingBlockParam) MarshalJSON

func (r ThinkingBlockParam) MarshalJSON() (data []byte, err error)

type ThinkingConfigDisabledParam

type ThinkingConfigDisabledParam struct {
	// This field can be elided, and will marshal its zero value as "disabled".
	Type constant.Disabled `json:"type,required"`
	// contains filtered or unexported fields
}

The property Type is required.

func (ThinkingConfigDisabledParam) IsPresent

func (f ThinkingConfigDisabledParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (ThinkingConfigDisabledParam) MarshalJSON

func (r ThinkingConfigDisabledParam) MarshalJSON() (data []byte, err error)

type ThinkingConfigEnabledParam

type ThinkingConfigEnabledParam struct {
	// Determines how many tokens Claude can use for its internal reasoning process.
	// Larger budgets can enable more thorough analysis for complex problems, improving
	// response quality.
	//
	// Must be ≥1024 and less than `max_tokens`.
	//
	// See
	// [extended thinking](https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking)
	// for details.
	BudgetTokens int64 `json:"budget_tokens,required"`
	// This field can be elided, and will marshal its zero value as "enabled".
	Type constant.Enabled `json:"type,required"`
	// contains filtered or unexported fields
}

The properties BudgetTokens, Type are required.

func (ThinkingConfigEnabledParam) IsPresent

func (f ThinkingConfigEnabledParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (ThinkingConfigEnabledParam) MarshalJSON

func (r ThinkingConfigEnabledParam) MarshalJSON() (data []byte, err error)

type ThinkingConfigParamUnion

type ThinkingConfigParamUnion struct {
	OfThinkingConfigEnabled  *ThinkingConfigEnabledParam  `json:",omitzero,inline"`
	OfThinkingConfigDisabled *ThinkingConfigDisabledParam `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func ThinkingConfigParamOfThinkingConfigEnabled

func ThinkingConfigParamOfThinkingConfigEnabled(budgetTokens int64) ThinkingConfigParamUnion

func (ThinkingConfigParamUnion) GetBudgetTokens

func (u ThinkingConfigParamUnion) GetBudgetTokens() *int64

Returns a pointer to the underlying variant's property, if present.

func (ThinkingConfigParamUnion) GetType

func (u ThinkingConfigParamUnion) GetType() *string

Returns a pointer to the underlying variant's property, if present.

func (ThinkingConfigParamUnion) IsPresent

func (u ThinkingConfigParamUnion) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (ThinkingConfigParamUnion) MarshalJSON

func (u ThinkingConfigParamUnion) MarshalJSON() ([]byte, error)

type ThinkingDelta

type ThinkingDelta struct {
	Thinking string                 `json:"thinking,required"`
	Type     constant.ThinkingDelta `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		Thinking    resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ThinkingDelta) RawJSON

func (r ThinkingDelta) RawJSON() string

Returns the unmodified JSON received from the API

func (*ThinkingDelta) UnmarshalJSON

func (r *ThinkingDelta) UnmarshalJSON(data []byte) error

type ToolBash20250124Param

type ToolBash20250124Param struct {
	CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"`
	// Name of the tool.
	//
	// This is how the tool will be called by the model and in tool_use blocks.
	//
	// This field can be elided, and will marshal its zero value as "bash".
	Name constant.Bash `json:"name,required"`
	// This field can be elided, and will marshal its zero value as "bash_20250124".
	Type constant.Bash20250124 `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Name, Type are required.

func (ToolBash20250124Param) IsPresent

func (f ToolBash20250124Param) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (ToolBash20250124Param) MarshalJSON

func (r ToolBash20250124Param) MarshalJSON() (data []byte, err error)

type ToolChoiceAnyParam

type ToolChoiceAnyParam struct {
	// Whether to disable parallel tool use.
	//
	// Defaults to `false`. If set to `true`, the model will output exactly one tool
	// use.
	DisableParallelToolUse param.Opt[bool] `json:"disable_parallel_tool_use,omitzero"`
	// This field can be elided, and will marshal its zero value as "any".
	Type constant.Any `json:"type,required"`
	// contains filtered or unexported fields
}

The model will use any available tools.

The property Type is required.

func (ToolChoiceAnyParam) IsPresent

func (f ToolChoiceAnyParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (ToolChoiceAnyParam) MarshalJSON

func (r ToolChoiceAnyParam) MarshalJSON() (data []byte, err error)

type ToolChoiceAutoParam

type ToolChoiceAutoParam struct {
	// Whether to disable parallel tool use.
	//
	// Defaults to `false`. If set to `true`, the model will output at most one tool
	// use.
	DisableParallelToolUse param.Opt[bool] `json:"disable_parallel_tool_use,omitzero"`
	// This field can be elided, and will marshal its zero value as "auto".
	Type constant.Auto `json:"type,required"`
	// contains filtered or unexported fields
}

The model will automatically decide whether to use tools.

The property Type is required.

func (ToolChoiceAutoParam) IsPresent

func (f ToolChoiceAutoParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (ToolChoiceAutoParam) MarshalJSON

func (r ToolChoiceAutoParam) MarshalJSON() (data []byte, err error)

type ToolChoiceNoneParam

type ToolChoiceNoneParam struct {
	// This field can be elided, and will marshal its zero value as "none".
	Type constant.None `json:"type,required"`
	// contains filtered or unexported fields
}

The model will not be allowed to use tools.

The property Type is required.

func (ToolChoiceNoneParam) IsPresent

func (f ToolChoiceNoneParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (ToolChoiceNoneParam) MarshalJSON

func (r ToolChoiceNoneParam) MarshalJSON() (data []byte, err error)

type ToolChoiceToolParam

type ToolChoiceToolParam struct {
	// The name of the tool to use.
	Name string `json:"name,required"`
	// Whether to disable parallel tool use.
	//
	// Defaults to `false`. If set to `true`, the model will output exactly one tool
	// use.
	DisableParallelToolUse param.Opt[bool] `json:"disable_parallel_tool_use,omitzero"`
	// This field can be elided, and will marshal its zero value as "tool".
	Type constant.Tool `json:"type,required"`
	// contains filtered or unexported fields
}

The model will use the specified tool with `tool_choice.name`.

The properties Name, Type are required.

func (ToolChoiceToolParam) IsPresent

func (f ToolChoiceToolParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (ToolChoiceToolParam) MarshalJSON

func (r ToolChoiceToolParam) MarshalJSON() (data []byte, err error)

type ToolChoiceUnionParam

type ToolChoiceUnionParam struct {
	OfToolChoiceAuto *ToolChoiceAutoParam `json:",omitzero,inline"`
	OfToolChoiceAny  *ToolChoiceAnyParam  `json:",omitzero,inline"`
	OfToolChoiceTool *ToolChoiceToolParam `json:",omitzero,inline"`
	OfToolChoiceNone *ToolChoiceNoneParam `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func ToolChoiceParamOfToolChoiceTool

func ToolChoiceParamOfToolChoiceTool(name string) ToolChoiceUnionParam

func (ToolChoiceUnionParam) GetDisableParallelToolUse

func (u ToolChoiceUnionParam) GetDisableParallelToolUse() *bool

Returns a pointer to the underlying variant's property, if present.

func (ToolChoiceUnionParam) GetName

func (u ToolChoiceUnionParam) GetName() *string

Returns a pointer to the underlying variant's property, if present.

func (ToolChoiceUnionParam) GetType

func (u ToolChoiceUnionParam) GetType() *string

Returns a pointer to the underlying variant's property, if present.

func (ToolChoiceUnionParam) IsPresent

func (u ToolChoiceUnionParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (ToolChoiceUnionParam) MarshalJSON

func (u ToolChoiceUnionParam) MarshalJSON() ([]byte, error)

type ToolInputSchemaParam

type ToolInputSchemaParam struct {
	Properties interface{} `json:"properties,omitzero"`
	// This field can be elided, and will marshal its zero value as "object".
	Type        constant.Object        `json:"type,required"`
	ExtraFields map[string]interface{} `json:"-,extras"`
	// contains filtered or unexported fields
}

[JSON schema](https://json-schema.org/draft/2020-12) for this tool's input.

This defines the shape of the `input` that your tool accepts and that the model will produce.

The property Type is required.

func (ToolInputSchemaParam) IsPresent

func (f ToolInputSchemaParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (ToolInputSchemaParam) MarshalJSON

func (r ToolInputSchemaParam) MarshalJSON() (data []byte, err error)

type ToolParam

type ToolParam struct {
	// [JSON schema](https://json-schema.org/draft/2020-12) for this tool's input.
	//
	// This defines the shape of the `input` that your tool accepts and that the model
	// will produce.
	InputSchema ToolInputSchemaParam `json:"input_schema,omitzero,required"`
	// Name of the tool.
	//
	// This is how the tool will be called by the model and in tool_use blocks.
	Name string `json:"name,required"`
	// Description of what this tool does.
	//
	// Tool descriptions should be as detailed as possible. The more information that
	// the model has about what the tool is and how to use it, the better it will
	// perform. You can use natural language descriptions to reinforce important
	// aspects of the tool input JSON schema.
	Description  param.Opt[string]          `json:"description,omitzero"`
	CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"`
	// contains filtered or unexported fields
}

The properties InputSchema, Name are required.

func (ToolParam) IsPresent

func (f ToolParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (ToolParam) MarshalJSON

func (r ToolParam) MarshalJSON() (data []byte, err error)

type ToolResultBlockParam

type ToolResultBlockParam struct {
	ToolUseID    string                             `json:"tool_use_id,required"`
	IsError      param.Opt[bool]                    `json:"is_error,omitzero"`
	CacheControl CacheControlEphemeralParam         `json:"cache_control,omitzero"`
	Content      []ToolResultBlockParamContentUnion `json:"content,omitzero"`
	// This field can be elided, and will marshal its zero value as "tool_result".
	Type constant.ToolResult `json:"type,required"`
	// contains filtered or unexported fields
}

The properties ToolUseID, Type are required.

func (ToolResultBlockParam) IsPresent

func (f ToolResultBlockParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (ToolResultBlockParam) MarshalJSON

func (r ToolResultBlockParam) MarshalJSON() (data []byte, err error)

type ToolResultBlockParamContentUnion

type ToolResultBlockParamContentUnion struct {
	OfRequestTextBlock  *TextBlockParam  `json:",omitzero,inline"`
	OfRequestImageBlock *ImageBlockParam `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (ToolResultBlockParamContentUnion) GetCacheControl

Returns a pointer to the underlying variant's CacheControl property, if present.

func (ToolResultBlockParamContentUnion) GetCitations

Returns a pointer to the underlying variant's property, if present.

func (ToolResultBlockParamContentUnion) GetSource

Returns a pointer to the underlying variant's property, if present.

func (ToolResultBlockParamContentUnion) GetText

Returns a pointer to the underlying variant's property, if present.

func (ToolResultBlockParamContentUnion) GetType

Returns a pointer to the underlying variant's property, if present.

func (ToolResultBlockParamContentUnion) IsPresent

func (u ToolResultBlockParamContentUnion) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (ToolResultBlockParamContentUnion) MarshalJSON

func (u ToolResultBlockParamContentUnion) MarshalJSON() ([]byte, error)

type ToolTextEditor20250124Param

type ToolTextEditor20250124Param struct {
	CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"`
	// Name of the tool.
	//
	// This is how the tool will be called by the model and in tool_use blocks.
	//
	// This field can be elided, and will marshal its zero value as
	// "str_replace_editor".
	Name constant.StrReplaceEditor `json:"name,required"`
	// This field can be elided, and will marshal its zero value as
	// "text_editor_20250124".
	Type constant.TextEditor20250124 `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Name, Type are required.

func (ToolTextEditor20250124Param) IsPresent

func (f ToolTextEditor20250124Param) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (ToolTextEditor20250124Param) MarshalJSON

func (r ToolTextEditor20250124Param) MarshalJSON() (data []byte, err error)

type ToolUnionParam

type ToolUnionParam struct {
	OfTool               *ToolParam                   `json:",omitzero,inline"`
	OfBashTool20250124   *ToolBash20250124Param       `json:",omitzero,inline"`
	OfTextEditor20250124 *ToolTextEditor20250124Param `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func ToolUnionParamOfTool

func ToolUnionParamOfTool(inputSchema ToolInputSchemaParam, name string) ToolUnionParam

func (ToolUnionParam) GetCacheControl

func (u ToolUnionParam) GetCacheControl() *CacheControlEphemeralParam

Returns a pointer to the underlying variant's CacheControl property, if present.

func (ToolUnionParam) GetDescription

func (u ToolUnionParam) GetDescription() *string

Returns a pointer to the underlying variant's property, if present.

func (ToolUnionParam) GetInputSchema

func (u ToolUnionParam) GetInputSchema() *ToolInputSchemaParam

Returns a pointer to the underlying variant's property, if present.

func (ToolUnionParam) GetName

func (u ToolUnionParam) GetName() *string

Returns a pointer to the underlying variant's property, if present.

func (ToolUnionParam) GetType

func (u ToolUnionParam) GetType() *string

Returns a pointer to the underlying variant's property, if present.

func (ToolUnionParam) IsPresent

func (u ToolUnionParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (ToolUnionParam) MarshalJSON

func (u ToolUnionParam) MarshalJSON() ([]byte, error)

type ToolUseBlock

type ToolUseBlock struct {
	ID    string           `json:"id,required"`
	Input json.RawMessage  `json:"input,required"`
	Name  string           `json:"name,required"`
	Type  constant.ToolUse `json:"type,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		ID          resp.Field
		Input       resp.Field
		Name        resp.Field
		Type        resp.Field
		ExtraFields map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ToolUseBlock) RawJSON

func (r ToolUseBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (ToolUseBlock) ToParam

func (r ToolUseBlock) ToParam() ToolUseBlockParam

func (*ToolUseBlock) UnmarshalJSON

func (r *ToolUseBlock) UnmarshalJSON(data []byte) error

type ToolUseBlockParam

type ToolUseBlockParam struct {
	ID           string                     `json:"id,required"`
	Input        interface{}                `json:"input,omitzero,required"`
	Name         string                     `json:"name,required"`
	CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"`
	// This field can be elided, and will marshal its zero value as "tool_use".
	Type constant.ToolUse `json:"type,required"`
	// contains filtered or unexported fields
}

The properties ID, Input, Name, Type are required.

func (ToolUseBlockParam) IsPresent

func (f ToolUseBlockParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (ToolUseBlockParam) MarshalJSON

func (r ToolUseBlockParam) MarshalJSON() (data []byte, err error)

type URLImageSourceParam

type URLImageSourceParam struct {
	URL string `json:"url,required"`
	// This field can be elided, and will marshal its zero value as "url".
	Type constant.URL `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Type, URL are required.

func (URLImageSourceParam) IsPresent

func (f URLImageSourceParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (URLImageSourceParam) MarshalJSON

func (r URLImageSourceParam) MarshalJSON() (data []byte, err error)

type URLPDFSourceParam

type URLPDFSourceParam struct {
	URL string `json:"url,required"`
	// This field can be elided, and will marshal its zero value as "url".
	Type constant.URL `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Type, URL are required.

func (URLPDFSourceParam) IsPresent

func (f URLPDFSourceParam) IsPresent() bool

IsPresent returns true if the field's value is not omitted and not the JSON "null". To check if this field is omitted, use param.IsOmitted.

func (URLPDFSourceParam) MarshalJSON

func (r URLPDFSourceParam) MarshalJSON() (data []byte, err error)

type Usage

type Usage struct {
	// The number of input tokens used to create the cache entry.
	CacheCreationInputTokens int64 `json:"cache_creation_input_tokens,required"`
	// The number of input tokens read from the cache.
	CacheReadInputTokens int64 `json:"cache_read_input_tokens,required"`
	// The number of input tokens which were used.
	InputTokens int64 `json:"input_tokens,required"`
	// The number of output tokens which were used.
	OutputTokens int64 `json:"output_tokens,required"`
	// Metadata for the response, check the presence of optional fields with the
	// [resp.Field.IsPresent] method.
	JSON struct {
		CacheCreationInputTokens resp.Field
		CacheReadInputTokens     resp.Field
		InputTokens              resp.Field
		OutputTokens             resp.Field
		ExtraFields              map[string]resp.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (Usage) RawJSON

func (r Usage) RawJSON() string

Returns the unmodified JSON received from the API

func (*Usage) UnmarshalJSON

func (r *Usage) UnmarshalJSON(data []byte) error

Directories

Path Synopsis
encoding/json
Package json implements encoding and decoding of JSON as defined in RFC 7159.
Package json implements encoding and decoding of JSON as defined in RFC 7159.
encoding/json/shims
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.21, and used by the Go 1.24 encoding/json package.
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.21, and used by the Go 1.24 encoding/json package.
packages

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL