anthropic

package module
v0.0.0-...-63879b0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 33 Imported by: 0

README

Anthropic Go API Library

Go Reference

The Anthropic Go library provides convenient access to the Anthropic REST API from applications written in Go.

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@v1.26.0'

Requirements

This library requires Go 1.22+.

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{
			anthropic.NewUserMessage(anthropic.NewTextBlock("What is a quaternion?")),
		},
		Model: anthropic.ModelClaudeSonnet4_5_20250929,
	})
	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.ModelClaudeSonnet4_5_20250929,
    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.ModelClaudeSonnet4_5_20250929,
    Messages:  messages,
    MaxTokens: 1024,
})

fmt.Printf("%+v\n", message.Content)
System prompts
message, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
    Model:     anthropic.ModelClaudeSonnet4_5_20250929,
    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.ModelClaudeSonnet4_5_20250929,
    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.ModelClaudeSonnet4_5_20250929,
			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 any
				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)
}
Tool helpers

The SDK provides helper functions for defining tools and running automatic conversation loops. Here's a basic example:

package main

import (
	"context"
	"fmt"

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

// GetWeatherInput defines the tool input with jsonschema tags for automatic schema generation
type GetWeatherInput struct {
	City string `json:"city" jsonschema:"required,description=The city name"`
}

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

	// Define a tool - the schema is generated automatically from the struct's jsonschema tags
	weatherTool, err := toolrunner.NewBetaToolFromJSONSchema(
		"get_weather",
		"Get weather for a city",
		func(ctx context.Context, input GetWeatherInput) (anthropic.BetaToolResultBlockParamContentUnion, error) {
			return anthropic.BetaToolResultBlockParamContentUnion{
				OfText: &anthropic.BetaTextBlockParam{
					Text: fmt.Sprintf("The weather in %s is sunny, 72°F", input.City),
				},
			}, nil
		},
	)
	if err != nil {
		panic(err)
	}

	// Create a tool runner that automatically handles the conversation loop
	runner := client.Beta.Messages.NewToolRunner([]anthropic.BetaTool{weatherTool}, anthropic.BetaToolRunnerParams{
		BetaMessageNewParams: anthropic.BetaMessageNewParams{
			Model:     anthropic.ModelClaudeSonnet4_20250514,
			MaxTokens: 1024,
			Messages: []anthropic.BetaMessageParam{
				anthropic.NewBetaUserMessage(anthropic.NewBetaTextBlock("What's the weather in Paris?")),
			},
		},
		MaxIterations: 5,
	})

	// Run until Claude produces a final response
	message, err := runner.RunToCompletion(context.Background())
	if err != nil {
		panic(err)
	}
	fmt.Println(message.Content[0].Text)
}

For more details, see tools.md.

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]. These fields can be set with the provided constructors, anthropic.String(string), anthropic.Int(int64), etc.

Any param.Opt[T], map, slice, struct or string enum uses the tag `json:"...,omitzero"`. Its zero value is considered omitted.

The param.IsOmitted(any) function can confirm the presence of any omitzero field.

p := anthropic.ExampleParams{
	ID:   "id_xxx",                // required property
	Name: anthropic.String("..."), // optional 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
}

To send null instead of a param.Opt[T], use param.Null[T](). To send null instead of a struct T, use param.NullStruct[T]().

p.Name = param.Null[string]()       // 'null' instead of string
p.Point = param.NullStruct[Point]() // 'null' instead of struct

param.IsNull(p.Name)  // true
param.IsNull(p.Point) // true

Request structs contain a .SetExtraFields(map[string]any) method which can send non-conforming fields in the request body. Extra fields overwrite any struct fields with a matching key.

[!WARNING] For security reasons, only use SetExtraFields with trusted data.

To send a custom value instead of a struct, use param.Override[T](value).

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

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

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

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 ordinary value types (not pointers or wrappers). Response structs also include a special JSON field containing metadata about each property.

type Animal struct {
	Name   string `json:"name,nullable"`
	Owners int    `json:"owners"`
	Age    int    `json:"age"`
	JSON   struct {
		Name        respjson.Field
		Owner       respjson.Field
		Age         respjson.Field
		ExtraFields map[string]respjson.Field
	} `json:"-"`
}

To handle optional data, use the .Valid() method on the JSON field. .Valid() returns true if a field is not null, not present, or couldn't be marshaled.

If .Valid() is false, the corresponding field will simply be its zero value.

raw := `{"owners": 1, "name": null}`

var res Animal
json.Unmarshal([]byte(raw), &res)

// Accessing regular fields

res.Owners // 1
res.Name   // ""
res.Age    // 0

// Optional field checks

res.JSON.Owners.Valid() // true
res.JSON.Name.Valid()   // false
res.JSON.Age.Valid()    // false

// Raw JSON values

res.JSON.Owners.Raw()                  // "1"
res.JSON.Name.Raw() == "null"          // true
res.JSON.Name.Raw() == respjson.Null   // true
res.JSON.Age.Raw() == ""               // true
res.JSON.Age.Raw() == respjson.Omitted // true

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 {
	// From variants [Dog], [Cat]
	Owner Person `json:"owner"`
	// From variant [Dog]
	DogBreed string `json:"dog_breed"`
	// From variant [Cat]
	CatBreed string `json:"cat_breed"`
	// ...

	JSON struct {
		Owner respjson.Field
		// ...
	} `json:"-"`
}

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

// Switch on the variant
switch variant := animal.AsAny().(type) {
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"}),
)

The request option option.WithDebugLog(nil) may be helpful while debugging.

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.Messages.Batches.ListAutoPaging(context.TODO(), anthropic.MessageBatchListParams{
	Limit: anthropic.Int(20),
})
// Automatically fetches more pages as needed.
for iter.Next() {
	messageBatch := iter.Current()
	fmt.Printf("%+v\n", messageBatch)
}
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.Messages.Batches.List(context.TODO(), anthropic.MessageBatchListParams{
	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). The error also includes the RequestID from the response headers, which is useful for troubleshooting with Anthropic support.

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{{
		Content: []anthropic.ContentBlockParamUnion{{
			OfText: &anthropic.TextBlockParam{
				Text: "x",
			},
		}},
		Role: anthropic.MessageParamRoleUser,
	}},
	Model: anthropic.ModelClaudeSonnet4_5_20250929,
})
if err != nil {
	var apierr *anthropic.Error
	if errors.As(err, &apierr) {
		println("Request ID:", apierr.RequestID)
		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 (Request-ID: req_xxx) { ... }
}

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{{
			Content: []anthropic.ContentBlockParamUnion{{
				OfText: &anthropic.TextBlockParam{
					Text: "What is a quaternion?",
				},
			}},
			Role: anthropic.MessageParamRoleUser,
		}},
		Model: anthropic.ModelClaudeSonnet4_5_20250929,
	},
	// 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", so we recommend always specifyig a custom content-type with the anthropic.File(reader io.Reader, filename string, contentType string) helper we provide to easily wrap any io.Reader with the appropriate file name and content type.

// A file from the file system
file, err := os.Open("/path/to/file.json")
anthropic.BetaFileUploadParams{
	File: anthropic.File(file, "custom-name.json", "application/json"),
	Betas: []anthropic.AnthropicBeta{anthropic.AnthropicBetaFilesAPI2025_04_14},
}

// A file from a string
anthropic.BetaFileUploadParams{
	File: anthropic.File(strings.NewReader("my file contents"), "custom-name.json", "application/json"),
	Betas: []anthropic.AnthropicBeta{anthropic.AnthropicBetaFilesAPI2025_04_14},
}

The file name and content-type can also be customized by implementing Name() string or ContentType() string on the run-time type of io.Reader. Note that os.File implements Name() string, so a file returned by os.Open will be sent with the file name on disk.

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{{
			Content: []anthropic.ContentBlockParamUnion{{
				OfText: &anthropic.TextBlockParam{
					Text: "What is a quaternion?",
				},
			}},
			Role: anthropic.MessageParamRoleUser,
		}},
		Model: anthropic.ModelClaudeSonnet4_5_20250929,
	},
	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{{
			Content: []anthropic.ContentBlockParamUnion{{
				OfText: &anthropic.TextBlockParam{
					Text: "x",
				},
			}},
			Role: anthropic.MessageParamRoleUser,
		}},
		Model: anthropic.ModelClaudeSonnet4_5_20250929,
	},
	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]any

    // 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).

Bearer Token Authentication

You can also authenticate with Bedrock using bearer tokens instead of AWS credentials. This is useful in corporate environments where teams need access to Bedrock without managing AWS credentials, IAM roles, or account-level permissions.

The simplest approach is to set the AWS_BEARER_TOKEN_BEDROCK environment variable:

package main

import (
	"context"

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

func main() {
	// Automatically uses AWS_BEARER_TOKEN_BEDROCK from the environment.
	// Region defaults to us-east-1 or uses AWS_REGION if set.
	client := anthropic.NewClient(
		bedrock.WithLoadDefaultConfig(context.Background()),
	)
}

To provide a token programmatically, use bedrock.WithConfig with a BearerAuthTokenProvider:

package main

import (
	"context"

	"github.com/anthropics/anthropic-sdk-go"
	"github.com/anthropics/anthropic-sdk-go/bedrock"
	"github.com/aws/aws-sdk-go-v2/aws"
)

func main() {
	cfg := aws.Config{
		Region:                  "us-west-2",
		BearerAuthTokenProvider: bedrock.NewStaticBearerTokenProvider("your-bearer-token"),
	}
	client := anthropic.NewClient(
		bedrock.WithConfig(cfg),
	)
}

Read more about Anthropic and Amazon Bedrock here and about Bedrock API keys 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

View Source
const WebSearchToolRequestErrorErrorCodeInvalidToolInput = WebSearchToolResultErrorCodeInvalidToolInput
View Source
const WebSearchToolRequestErrorErrorCodeMaxUsesExceeded = WebSearchToolResultErrorCodeMaxUsesExceeded
View Source
const WebSearchToolRequestErrorErrorCodeQueryTooLong = WebSearchToolResultErrorCodeQueryTooLong
View Source
const WebSearchToolRequestErrorErrorCodeRequestTooLarge = WebSearchToolResultErrorCodeRequestTooLarge
View Source
const WebSearchToolRequestErrorErrorCodeTooManyRequests = WebSearchToolResultErrorCodeTooManyRequests
View Source
const WebSearchToolRequestErrorErrorCodeUnavailable = WebSearchToolResultErrorCodeUnavailable
View Source
const WebSearchToolResultErrorErrorCodeInvalidToolInput = WebSearchToolResultErrorCodeInvalidToolInput
View Source
const WebSearchToolResultErrorErrorCodeMaxUsesExceeded = WebSearchToolResultErrorCodeMaxUsesExceeded
View Source
const WebSearchToolResultErrorErrorCodeQueryTooLong = WebSearchToolResultErrorCodeQueryTooLong
View Source
const WebSearchToolResultErrorErrorCodeRequestTooLarge = WebSearchToolResultErrorCodeRequestTooLarge
View Source
const WebSearchToolResultErrorErrorCodeTooManyRequests = WebSearchToolResultErrorCodeTooManyRequests
View Source
const WebSearchToolResultErrorErrorCodeUnavailable = WebSearchToolResultErrorCodeUnavailable

Variables

This section is empty.

Functions

func Bool

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

func BoolPtr

func BoolPtr(v bool) *bool

func CalculateNonStreamingTimeout

func CalculateNonStreamingTimeout(maxTokens int, model Model, opts []option.RequestOption) (time.Duration, error)

CalculateNonStreamingTimeout calculates the appropriate timeout for a non-streaming request based on the maximum number of tokens and the model's non-streaming token limit

func DefaultClientOptions

func DefaultClientOptions() []option.RequestOption

DefaultClientOptions read from the environment (ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN, ANTHROPIC_BASE_URL). 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"
	AnthropicBetaFilesAPI2025_04_14                   AnthropicBeta = "files-api-2025-04-14"
	AnthropicBetaMCPClient2025_04_04                  AnthropicBeta = "mcp-client-2025-04-04"
	AnthropicBetaMCPClient2025_11_20                  AnthropicBeta = "mcp-client-2025-11-20"
	AnthropicBetaDevFullThinking2025_05_14            AnthropicBeta = "dev-full-thinking-2025-05-14"
	AnthropicBetaInterleavedThinking2025_05_14        AnthropicBeta = "interleaved-thinking-2025-05-14"
	AnthropicBetaCodeExecution2025_05_22              AnthropicBeta = "code-execution-2025-05-22"
	AnthropicBetaExtendedCacheTTL2025_04_11           AnthropicBeta = "extended-cache-ttl-2025-04-11"
	AnthropicBetaContext1m2025_08_07                  AnthropicBeta = "context-1m-2025-08-07"
	AnthropicBetaContextManagement2025_06_27          AnthropicBeta = "context-management-2025-06-27"
	AnthropicBetaModelContextWindowExceeded2025_08_26 AnthropicBeta = "model-context-window-exceeded-2025-08-26"
	AnthropicBetaSkills2025_10_02                     AnthropicBeta = "skills-2025-10-02"
	AnthropicBetaFastMode2026_02_01                   AnthropicBeta = "fast-mode-2026-02-01"
)

type AuthenticationError

type AuthenticationError = shared.AuthenticationError

This is an alias to an internal type.

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) MarshalJSON

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

func (*Base64ImageSourceParam) UnmarshalJSON

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

type Base64PDFSource

type Base64PDFSource struct {
	Data      string                  `json:"data,required" format:"byte"`
	MediaType constant.ApplicationPDF `json:"media_type,required"`
	Type      constant.Base64         `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		MediaType   respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (Base64PDFSource) RawJSON

func (r Base64PDFSource) RawJSON() string

Returns the unmodified JSON received from the API

func (Base64PDFSource) ToParam

ToParam converts this Base64PDFSource to a Base64PDFSourceParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with Base64PDFSourceParam.Overrides()

func (*Base64PDFSource) UnmarshalJSON

func (r *Base64PDFSource) UnmarshalJSON(data []byte) 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) MarshalJSON

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

func (*Base64PDFSourceParam) UnmarshalJSON

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

type BashCodeExecutionOutputBlock

type BashCodeExecutionOutputBlock struct {
	FileID string                           `json:"file_id,required"`
	Type   constant.BashCodeExecutionOutput `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		FileID      respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BashCodeExecutionOutputBlock) RawJSON

Returns the unmodified JSON received from the API

func (BashCodeExecutionOutputBlock) ToParam

func (*BashCodeExecutionOutputBlock) UnmarshalJSON

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

type BashCodeExecutionOutputBlockParam

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

The properties FileID, Type are required.

func (BashCodeExecutionOutputBlockParam) MarshalJSON

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

func (*BashCodeExecutionOutputBlockParam) UnmarshalJSON

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

type BashCodeExecutionResultBlock

type BashCodeExecutionResultBlock struct {
	Content    []BashCodeExecutionOutputBlock   `json:"content,required"`
	ReturnCode int64                            `json:"return_code,required"`
	Stderr     string                           `json:"stderr,required"`
	Stdout     string                           `json:"stdout,required"`
	Type       constant.BashCodeExecutionResult `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Content     respjson.Field
		ReturnCode  respjson.Field
		Stderr      respjson.Field
		Stdout      respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BashCodeExecutionResultBlock) RawJSON

Returns the unmodified JSON received from the API

func (*BashCodeExecutionResultBlock) UnmarshalJSON

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

type BashCodeExecutionResultBlockParam

type BashCodeExecutionResultBlockParam struct {
	Content    []BashCodeExecutionOutputBlockParam `json:"content,omitzero,required"`
	ReturnCode int64                               `json:"return_code,required"`
	Stderr     string                              `json:"stderr,required"`
	Stdout     string                              `json:"stdout,required"`
	// This field can be elided, and will marshal its zero value as
	// "bash_code_execution_result".
	Type constant.BashCodeExecutionResult `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Content, ReturnCode, Stderr, Stdout, Type are required.

func (BashCodeExecutionResultBlockParam) MarshalJSON

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

func (*BashCodeExecutionResultBlockParam) UnmarshalJSON

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

type BashCodeExecutionToolResultBlock

type BashCodeExecutionToolResultBlock struct {
	Content   BashCodeExecutionToolResultBlockContentUnion `json:"content,required"`
	ToolUseID string                                       `json:"tool_use_id,required"`
	Type      constant.BashCodeExecutionToolResult         `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Content     respjson.Field
		ToolUseID   respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BashCodeExecutionToolResultBlock) RawJSON

Returns the unmodified JSON received from the API

func (BashCodeExecutionToolResultBlock) ToParam

func (*BashCodeExecutionToolResultBlock) UnmarshalJSON

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

type BashCodeExecutionToolResultBlockContentUnion

type BashCodeExecutionToolResultBlockContentUnion struct {
	// This field is from variant [BashCodeExecutionToolResultError].
	ErrorCode BashCodeExecutionToolResultErrorCode `json:"error_code"`
	Type      string                               `json:"type"`
	// This field is from variant [BashCodeExecutionResultBlock].
	Content []BashCodeExecutionOutputBlock `json:"content"`
	// This field is from variant [BashCodeExecutionResultBlock].
	ReturnCode int64 `json:"return_code"`
	// This field is from variant [BashCodeExecutionResultBlock].
	Stderr string `json:"stderr"`
	// This field is from variant [BashCodeExecutionResultBlock].
	Stdout string `json:"stdout"`
	JSON   struct {
		ErrorCode  respjson.Field
		Type       respjson.Field
		Content    respjson.Field
		ReturnCode respjson.Field
		Stderr     respjson.Field
		Stdout     respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

BashCodeExecutionToolResultBlockContentUnion contains all possible properties and values from BashCodeExecutionToolResultError, BashCodeExecutionResultBlock.

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

func (BashCodeExecutionToolResultBlockContentUnion) AsResponseBashCodeExecutionResultBlock

func (u BashCodeExecutionToolResultBlockContentUnion) AsResponseBashCodeExecutionResultBlock() (v BashCodeExecutionResultBlock)

func (BashCodeExecutionToolResultBlockContentUnion) AsResponseBashCodeExecutionToolResultError

func (u BashCodeExecutionToolResultBlockContentUnion) AsResponseBashCodeExecutionToolResultError() (v BashCodeExecutionToolResultError)

func (BashCodeExecutionToolResultBlockContentUnion) RawJSON

Returns the unmodified JSON received from the API

func (*BashCodeExecutionToolResultBlockContentUnion) UnmarshalJSON

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

type BashCodeExecutionToolResultBlockParam

type BashCodeExecutionToolResultBlockParam struct {
	Content   BashCodeExecutionToolResultBlockParamContentUnion `json:"content,omitzero,required"`
	ToolUseID string                                            `json:"tool_use_id,required"`
	// Create a cache control breakpoint at this content block.
	CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"`
	// This field can be elided, and will marshal its zero value as
	// "bash_code_execution_tool_result".
	Type constant.BashCodeExecutionToolResult `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Content, ToolUseID, Type are required.

func (BashCodeExecutionToolResultBlockParam) MarshalJSON

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

func (*BashCodeExecutionToolResultBlockParam) UnmarshalJSON

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

type BashCodeExecutionToolResultBlockParamContentUnion

type BashCodeExecutionToolResultBlockParamContentUnion struct {
	OfRequestBashCodeExecutionToolResultError *BashCodeExecutionToolResultErrorParam `json:",omitzero,inline"`
	OfRequestBashCodeExecutionResultBlock     *BashCodeExecutionResultBlockParam     `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 (BashCodeExecutionToolResultBlockParamContentUnion) GetContent

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

func (BashCodeExecutionToolResultBlockParamContentUnion) GetErrorCode

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

func (BashCodeExecutionToolResultBlockParamContentUnion) GetReturnCode

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

func (BashCodeExecutionToolResultBlockParamContentUnion) GetStderr

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

func (BashCodeExecutionToolResultBlockParamContentUnion) GetStdout

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

func (BashCodeExecutionToolResultBlockParamContentUnion) GetType

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

func (BashCodeExecutionToolResultBlockParamContentUnion) MarshalJSON

func (*BashCodeExecutionToolResultBlockParamContentUnion) UnmarshalJSON

type BashCodeExecutionToolResultError

type BashCodeExecutionToolResultError struct {
	// Any of "invalid_tool_input", "unavailable", "too_many_requests",
	// "execution_time_exceeded", "output_file_too_large".
	ErrorCode BashCodeExecutionToolResultErrorCode      `json:"error_code,required"`
	Type      constant.BashCodeExecutionToolResultError `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ErrorCode   respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BashCodeExecutionToolResultError) RawJSON

Returns the unmodified JSON received from the API

func (*BashCodeExecutionToolResultError) UnmarshalJSON

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

type BashCodeExecutionToolResultErrorCode

type BashCodeExecutionToolResultErrorCode string
const (
	BashCodeExecutionToolResultErrorCodeInvalidToolInput      BashCodeExecutionToolResultErrorCode = "invalid_tool_input"
	BashCodeExecutionToolResultErrorCodeUnavailable           BashCodeExecutionToolResultErrorCode = "unavailable"
	BashCodeExecutionToolResultErrorCodeTooManyRequests       BashCodeExecutionToolResultErrorCode = "too_many_requests"
	BashCodeExecutionToolResultErrorCodeExecutionTimeExceeded BashCodeExecutionToolResultErrorCode = "execution_time_exceeded"
	BashCodeExecutionToolResultErrorCodeOutputFileTooLarge    BashCodeExecutionToolResultErrorCode = "output_file_too_large"
)

type BashCodeExecutionToolResultErrorParam

type BashCodeExecutionToolResultErrorParam struct {
	// Any of "invalid_tool_input", "unavailable", "too_many_requests",
	// "execution_time_exceeded", "output_file_too_large".
	ErrorCode BashCodeExecutionToolResultErrorCode `json:"error_code,omitzero,required"`
	// This field can be elided, and will marshal its zero value as
	// "bash_code_execution_tool_result_error".
	Type constant.BashCodeExecutionToolResultError `json:"type,required"`
	// contains filtered or unexported fields
}

The properties ErrorCode, Type are required.

func (BashCodeExecutionToolResultErrorParam) MarshalJSON

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

func (*BashCodeExecutionToolResultErrorParam) UnmarshalJSON

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

type BetaAPIError

type BetaAPIError struct {
	Message string            `json:"message,required"`
	Type    constant.APIError `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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 BetaAllThinkingTurnsParam

type BetaAllThinkingTurnsParam struct {
	Type constant.All `json:"type,required"`
	// contains filtered or unexported fields
}

This struct has a constant value, construct it with NewBetaAllThinkingTurnsParam.

func NewBetaAllThinkingTurnsParam

func NewBetaAllThinkingTurnsParam() BetaAllThinkingTurnsParam

func (BetaAllThinkingTurnsParam) MarshalJSON

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

func (*BetaAllThinkingTurnsParam) UnmarshalJSON

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

type BetaAuthenticationError

type BetaAuthenticationError struct {
	Message string                       `json:"message,required"`
	Type    constant.AuthenticationError `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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) MarshalJSON

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

func (*BetaBase64ImageSourceParam) UnmarshalJSON

func (r *BetaBase64ImageSourceParam) UnmarshalJSON(data []byte) 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"`
	// Create a cache control breakpoint at this content block.
	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) MarshalJSON

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

func (*BetaBase64PDFBlockParam) UnmarshalJSON

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

type BetaBase64PDFBlockSourceUnionParam

type BetaBase64PDFBlockSourceUnionParam struct {
	OfBase64  *BetaBase64PDFSourceParam    `json:",omitzero,inline"`
	OfText    *BetaPlainTextSourceParam    `json:",omitzero,inline"`
	OfContent *BetaContentBlockSourceParam `json:",omitzero,inline"`
	OfURL     *BetaURLPDFSourceParam       `json:",omitzero,inline"`
	OfFile    *BetaFileDocumentSourceParam `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) GetFileID

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) MarshalJSON

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

func (*BetaBase64PDFBlockSourceUnionParam) UnmarshalJSON

func (u *BetaBase64PDFBlockSourceUnionParam) UnmarshalJSON(data []byte) error

type BetaBase64PDFSource

type BetaBase64PDFSource struct {
	Data      string                  `json:"data,required" format:"byte"`
	MediaType constant.ApplicationPDF `json:"media_type,required"`
	Type      constant.Base64         `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		MediaType   respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaBase64PDFSource) RawJSON

func (r BetaBase64PDFSource) RawJSON() string

Returns the unmodified JSON received from the API

func (BetaBase64PDFSource) ToParam

ToParam converts this BetaBase64PDFSource to a BetaBase64PDFSourceParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with BetaBase64PDFSourceParam.Overrides()

func (*BetaBase64PDFSource) UnmarshalJSON

func (r *BetaBase64PDFSource) UnmarshalJSON(data []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) MarshalJSON

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

func (*BetaBase64PDFSourceParam) UnmarshalJSON

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

type BetaBashCodeExecutionOutputBlock

type BetaBashCodeExecutionOutputBlock struct {
	FileID string                           `json:"file_id,required"`
	Type   constant.BashCodeExecutionOutput `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		FileID      respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaBashCodeExecutionOutputBlock) RawJSON

Returns the unmodified JSON received from the API

func (BetaBashCodeExecutionOutputBlock) ToParam

func (*BetaBashCodeExecutionOutputBlock) UnmarshalJSON

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

type BetaBashCodeExecutionOutputBlockParam

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

The properties FileID, Type are required.

func (BetaBashCodeExecutionOutputBlockParam) MarshalJSON

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

func (*BetaBashCodeExecutionOutputBlockParam) UnmarshalJSON

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

type BetaBashCodeExecutionResultBlock

type BetaBashCodeExecutionResultBlock struct {
	Content    []BetaBashCodeExecutionOutputBlock `json:"content,required"`
	ReturnCode int64                              `json:"return_code,required"`
	Stderr     string                             `json:"stderr,required"`
	Stdout     string                             `json:"stdout,required"`
	Type       constant.BashCodeExecutionResult   `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Content     respjson.Field
		ReturnCode  respjson.Field
		Stderr      respjson.Field
		Stdout      respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaBashCodeExecutionResultBlock) RawJSON

Returns the unmodified JSON received from the API

func (*BetaBashCodeExecutionResultBlock) UnmarshalJSON

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

type BetaBashCodeExecutionResultBlockParam

type BetaBashCodeExecutionResultBlockParam struct {
	Content    []BetaBashCodeExecutionOutputBlockParam `json:"content,omitzero,required"`
	ReturnCode int64                                   `json:"return_code,required"`
	Stderr     string                                  `json:"stderr,required"`
	Stdout     string                                  `json:"stdout,required"`
	// This field can be elided, and will marshal its zero value as
	// "bash_code_execution_result".
	Type constant.BashCodeExecutionResult `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Content, ReturnCode, Stderr, Stdout, Type are required.

func (BetaBashCodeExecutionResultBlockParam) MarshalJSON

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

func (*BetaBashCodeExecutionResultBlockParam) UnmarshalJSON

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

type BetaBashCodeExecutionToolResultBlock

type BetaBashCodeExecutionToolResultBlock struct {
	Content   BetaBashCodeExecutionToolResultBlockContentUnion `json:"content,required"`
	ToolUseID string                                           `json:"tool_use_id,required"`
	Type      constant.BashCodeExecutionToolResult             `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Content     respjson.Field
		ToolUseID   respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaBashCodeExecutionToolResultBlock) RawJSON

Returns the unmodified JSON received from the API

func (BetaBashCodeExecutionToolResultBlock) ToParam

func (*BetaBashCodeExecutionToolResultBlock) UnmarshalJSON

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

type BetaBashCodeExecutionToolResultBlockContentUnion

type BetaBashCodeExecutionToolResultBlockContentUnion struct {
	// This field is from variant [BetaBashCodeExecutionToolResultError].
	ErrorCode BetaBashCodeExecutionToolResultErrorErrorCode `json:"error_code"`
	Type      string                                        `json:"type"`
	// This field is from variant [BetaBashCodeExecutionResultBlock].
	Content []BetaBashCodeExecutionOutputBlock `json:"content"`
	// This field is from variant [BetaBashCodeExecutionResultBlock].
	ReturnCode int64 `json:"return_code"`
	// This field is from variant [BetaBashCodeExecutionResultBlock].
	Stderr string `json:"stderr"`
	// This field is from variant [BetaBashCodeExecutionResultBlock].
	Stdout string `json:"stdout"`
	JSON   struct {
		ErrorCode  respjson.Field
		Type       respjson.Field
		Content    respjson.Field
		ReturnCode respjson.Field
		Stderr     respjson.Field
		Stdout     respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

BetaBashCodeExecutionToolResultBlockContentUnion contains all possible properties and values from BetaBashCodeExecutionToolResultError, BetaBashCodeExecutionResultBlock.

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

func (BetaBashCodeExecutionToolResultBlockContentUnion) AsResponseBashCodeExecutionResultBlock

func (u BetaBashCodeExecutionToolResultBlockContentUnion) AsResponseBashCodeExecutionResultBlock() (v BetaBashCodeExecutionResultBlock)

func (BetaBashCodeExecutionToolResultBlockContentUnion) AsResponseBashCodeExecutionToolResultError

func (u BetaBashCodeExecutionToolResultBlockContentUnion) AsResponseBashCodeExecutionToolResultError() (v BetaBashCodeExecutionToolResultError)

func (BetaBashCodeExecutionToolResultBlockContentUnion) RawJSON

Returns the unmodified JSON received from the API

func (*BetaBashCodeExecutionToolResultBlockContentUnion) UnmarshalJSON

type BetaBashCodeExecutionToolResultBlockParam

type BetaBashCodeExecutionToolResultBlockParam struct {
	Content   BetaBashCodeExecutionToolResultBlockParamContentUnion `json:"content,omitzero,required"`
	ToolUseID string                                                `json:"tool_use_id,required"`
	// Create a cache control breakpoint at this content block.
	CacheControl BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	// This field can be elided, and will marshal its zero value as
	// "bash_code_execution_tool_result".
	Type constant.BashCodeExecutionToolResult `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Content, ToolUseID, Type are required.

func (BetaBashCodeExecutionToolResultBlockParam) MarshalJSON

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

func (*BetaBashCodeExecutionToolResultBlockParam) UnmarshalJSON

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

type BetaBashCodeExecutionToolResultBlockParamContentUnion

type BetaBashCodeExecutionToolResultBlockParamContentUnion struct {
	OfRequestBashCodeExecutionToolResultError *BetaBashCodeExecutionToolResultErrorParam `json:",omitzero,inline"`
	OfRequestBashCodeExecutionResultBlock     *BetaBashCodeExecutionResultBlockParam     `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 (BetaBashCodeExecutionToolResultBlockParamContentUnion) GetContent

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

func (BetaBashCodeExecutionToolResultBlockParamContentUnion) GetErrorCode

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

func (BetaBashCodeExecutionToolResultBlockParamContentUnion) GetReturnCode

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

func (BetaBashCodeExecutionToolResultBlockParamContentUnion) GetStderr

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

func (BetaBashCodeExecutionToolResultBlockParamContentUnion) GetStdout

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

func (BetaBashCodeExecutionToolResultBlockParamContentUnion) GetType

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

func (BetaBashCodeExecutionToolResultBlockParamContentUnion) MarshalJSON

func (*BetaBashCodeExecutionToolResultBlockParamContentUnion) UnmarshalJSON

type BetaBashCodeExecutionToolResultError

type BetaBashCodeExecutionToolResultError struct {
	// Any of "invalid_tool_input", "unavailable", "too_many_requests",
	// "execution_time_exceeded", "output_file_too_large".
	ErrorCode BetaBashCodeExecutionToolResultErrorErrorCode `json:"error_code,required"`
	Type      constant.BashCodeExecutionToolResultError     `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ErrorCode   respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaBashCodeExecutionToolResultError) RawJSON

Returns the unmodified JSON received from the API

func (*BetaBashCodeExecutionToolResultError) UnmarshalJSON

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

type BetaBashCodeExecutionToolResultErrorErrorCode

type BetaBashCodeExecutionToolResultErrorErrorCode string
const (
	BetaBashCodeExecutionToolResultErrorErrorCodeInvalidToolInput      BetaBashCodeExecutionToolResultErrorErrorCode = "invalid_tool_input"
	BetaBashCodeExecutionToolResultErrorErrorCodeUnavailable           BetaBashCodeExecutionToolResultErrorErrorCode = "unavailable"
	BetaBashCodeExecutionToolResultErrorErrorCodeTooManyRequests       BetaBashCodeExecutionToolResultErrorErrorCode = "too_many_requests"
	BetaBashCodeExecutionToolResultErrorErrorCodeExecutionTimeExceeded BetaBashCodeExecutionToolResultErrorErrorCode = "execution_time_exceeded"
	BetaBashCodeExecutionToolResultErrorErrorCodeOutputFileTooLarge    BetaBashCodeExecutionToolResultErrorErrorCode = "output_file_too_large"
)

type BetaBashCodeExecutionToolResultErrorParam

type BetaBashCodeExecutionToolResultErrorParam struct {
	// Any of "invalid_tool_input", "unavailable", "too_many_requests",
	// "execution_time_exceeded", "output_file_too_large".
	ErrorCode BetaBashCodeExecutionToolResultErrorParamErrorCode `json:"error_code,omitzero,required"`
	// This field can be elided, and will marshal its zero value as
	// "bash_code_execution_tool_result_error".
	Type constant.BashCodeExecutionToolResultError `json:"type,required"`
	// contains filtered or unexported fields
}

The properties ErrorCode, Type are required.

func (BetaBashCodeExecutionToolResultErrorParam) MarshalJSON

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

func (*BetaBashCodeExecutionToolResultErrorParam) UnmarshalJSON

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

type BetaBashCodeExecutionToolResultErrorParamErrorCode

type BetaBashCodeExecutionToolResultErrorParamErrorCode string
const (
	BetaBashCodeExecutionToolResultErrorParamErrorCodeInvalidToolInput      BetaBashCodeExecutionToolResultErrorParamErrorCode = "invalid_tool_input"
	BetaBashCodeExecutionToolResultErrorParamErrorCodeUnavailable           BetaBashCodeExecutionToolResultErrorParamErrorCode = "unavailable"
	BetaBashCodeExecutionToolResultErrorParamErrorCodeTooManyRequests       BetaBashCodeExecutionToolResultErrorParamErrorCode = "too_many_requests"
	BetaBashCodeExecutionToolResultErrorParamErrorCodeExecutionTimeExceeded BetaBashCodeExecutionToolResultErrorParamErrorCode = "execution_time_exceeded"
	BetaBashCodeExecutionToolResultErrorParamErrorCodeOutputFileTooLarge    BetaBashCodeExecutionToolResultErrorParamErrorCode = "output_file_too_large"
)

type BetaBillingError

type BetaBillingError struct {
	Message string                `json:"message,required"`
	Type    constant.BillingError `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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 {
	// The time-to-live for the cache control breakpoint.
	//
	// This may be one the following values:
	//
	// - `5m`: 5 minutes
	// - `1h`: 1 hour
	//
	// Defaults to `5m`.
	//
	// Any of "5m", "1h".
	TTL  BetaCacheControlEphemeralTTL `json:"ttl,omitzero"`
	Type constant.Ephemeral           `json:"type,required"`
	// contains filtered or unexported fields
}

This struct has a constant value, construct it with NewBetaCacheControlEphemeralParam.

func NewBetaCacheControlEphemeralParam

func NewBetaCacheControlEphemeralParam() BetaCacheControlEphemeralParam

func (BetaCacheControlEphemeralParam) MarshalJSON

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

func (*BetaCacheControlEphemeralParam) UnmarshalJSON

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

type BetaCacheControlEphemeralTTL

type BetaCacheControlEphemeralTTL string

The time-to-live for the cache control breakpoint.

This may be one the following values:

- `5m`: 5 minutes - `1h`: 1 hour

Defaults to `5m`.

const (
	BetaCacheControlEphemeralTTLTTL5m BetaCacheControlEphemeralTTL = "5m"
	BetaCacheControlEphemeralTTLTTL1h BetaCacheControlEphemeralTTL = "1h"
)

type BetaCacheCreation

type BetaCacheCreation struct {
	// The number of input tokens used to create the 1 hour cache entry.
	Ephemeral1hInputTokens int64 `json:"ephemeral_1h_input_tokens,required"`
	// The number of input tokens used to create the 5 minute cache entry.
	Ephemeral5mInputTokens int64 `json:"ephemeral_5m_input_tokens,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Ephemeral1hInputTokens respjson.Field
		Ephemeral5mInputTokens respjson.Field
		ExtraFields            map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaCacheCreation) RawJSON

func (r BetaCacheCreation) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaCacheCreation) UnmarshalJSON

func (r *BetaCacheCreation) UnmarshalJSON(data []byte) 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"`
	FileID         string                `json:"file_id,required"`
	StartCharIndex int64                 `json:"start_char_index,required"`
	Type           constant.CharLocation `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CitedText      respjson.Field
		DocumentIndex  respjson.Field
		DocumentTitle  respjson.Field
		EndCharIndex   respjson.Field
		FileID         respjson.Field
		StartCharIndex respjson.Field
		Type           respjson.Field
		ExtraFields    map[string]respjson.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) MarshalJSON

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

func (*BetaCitationCharLocationParam) UnmarshalJSON

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

type BetaCitationConfig

type BetaCitationConfig struct {
	Enabled bool `json:"enabled,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Enabled     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaCitationConfig) RawJSON

func (r BetaCitationConfig) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaCitationConfig) UnmarshalJSON

func (r *BetaCitationConfig) UnmarshalJSON(data []byte) 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"`
	FileID          string                        `json:"file_id,required"`
	StartBlockIndex int64                         `json:"start_block_index,required"`
	Type            constant.ContentBlockLocation `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CitedText       respjson.Field
		DocumentIndex   respjson.Field
		DocumentTitle   respjson.Field
		EndBlockIndex   respjson.Field
		FileID          respjson.Field
		StartBlockIndex respjson.Field
		Type            respjson.Field
		ExtraFields     map[string]respjson.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) MarshalJSON

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

func (*BetaCitationContentBlockLocationParam) UnmarshalJSON

func (r *BetaCitationContentBlockLocationParam) UnmarshalJSON(data []byte) 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"`
	FileID          string                `json:"file_id,required"`
	StartPageNumber int64                 `json:"start_page_number,required"`
	Type            constant.PageLocation `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CitedText       respjson.Field
		DocumentIndex   respjson.Field
		DocumentTitle   respjson.Field
		EndPageNumber   respjson.Field
		FileID          respjson.Field
		StartPageNumber respjson.Field
		Type            respjson.Field
		ExtraFields     map[string]respjson.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) MarshalJSON

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

func (*BetaCitationPageLocationParam) UnmarshalJSON

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

type BetaCitationSearchResultLocation

type BetaCitationSearchResultLocation struct {
	CitedText         string                        `json:"cited_text,required"`
	EndBlockIndex     int64                         `json:"end_block_index,required"`
	SearchResultIndex int64                         `json:"search_result_index,required"`
	Source            string                        `json:"source,required"`
	StartBlockIndex   int64                         `json:"start_block_index,required"`
	Title             string                        `json:"title,required"`
	Type              constant.SearchResultLocation `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CitedText         respjson.Field
		EndBlockIndex     respjson.Field
		SearchResultIndex respjson.Field
		Source            respjson.Field
		StartBlockIndex   respjson.Field
		Title             respjson.Field
		Type              respjson.Field
		ExtraFields       map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaCitationSearchResultLocation) RawJSON

Returns the unmodified JSON received from the API

func (*BetaCitationSearchResultLocation) UnmarshalJSON

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

type BetaCitationSearchResultLocationParam

type BetaCitationSearchResultLocationParam struct {
	Title             param.Opt[string] `json:"title,omitzero,required"`
	CitedText         string            `json:"cited_text,required"`
	EndBlockIndex     int64             `json:"end_block_index,required"`
	SearchResultIndex int64             `json:"search_result_index,required"`
	Source            string            `json:"source,required"`
	StartBlockIndex   int64             `json:"start_block_index,required"`
	// This field can be elided, and will marshal its zero value as
	// "search_result_location".
	Type constant.SearchResultLocation `json:"type,required"`
	// contains filtered or unexported fields
}

The properties CitedText, EndBlockIndex, SearchResultIndex, Source, StartBlockIndex, Title, Type are required.

func (BetaCitationSearchResultLocationParam) MarshalJSON

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

func (*BetaCitationSearchResultLocationParam) UnmarshalJSON

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

type BetaCitationWebSearchResultLocationParam

type BetaCitationWebSearchResultLocationParam struct {
	Title          param.Opt[string] `json:"title,omitzero,required"`
	CitedText      string            `json:"cited_text,required"`
	EncryptedIndex string            `json:"encrypted_index,required"`
	URL            string            `json:"url,required"`
	// This field can be elided, and will marshal its zero value as
	// "web_search_result_location".
	Type constant.WebSearchResultLocation `json:"type,required"`
	// contains filtered or unexported fields
}

The properties CitedText, EncryptedIndex, Title, Type, URL are required.

func (BetaCitationWebSearchResultLocationParam) MarshalJSON

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

func (*BetaCitationWebSearchResultLocationParam) UnmarshalJSON

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

type BetaCitationsConfigParam

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

func (BetaCitationsConfigParam) MarshalJSON

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

func (*BetaCitationsConfigParam) UnmarshalJSON

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

type BetaCitationsDelta

type BetaCitationsDelta struct {
	Citation BetaCitationsDeltaCitationUnion `json:"citation,required"`
	Type     constant.CitationsDelta         `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Citation    respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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"`
	FileID       string `json:"file_id"`
	// This field is from variant [BetaCitationCharLocation].
	StartCharIndex int64 `json:"start_char_index"`
	// Any of "char_location", "page_location", "content_block_location",
	// "web_search_result_location", "search_result_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"`
	EndBlockIndex   int64 `json:"end_block_index"`
	StartBlockIndex int64 `json:"start_block_index"`
	// This field is from variant [BetaCitationsWebSearchResultLocation].
	EncryptedIndex string `json:"encrypted_index"`
	Title          string `json:"title"`
	// This field is from variant [BetaCitationsWebSearchResultLocation].
	URL string `json:"url"`
	// This field is from variant [BetaCitationSearchResultLocation].
	SearchResultIndex int64 `json:"search_result_index"`
	// This field is from variant [BetaCitationSearchResultLocation].
	Source string `json:"source"`
	JSON   struct {
		CitedText         respjson.Field
		DocumentIndex     respjson.Field
		DocumentTitle     respjson.Field
		EndCharIndex      respjson.Field
		FileID            respjson.Field
		StartCharIndex    respjson.Field
		Type              respjson.Field
		EndPageNumber     respjson.Field
		StartPageNumber   respjson.Field
		EndBlockIndex     respjson.Field
		StartBlockIndex   respjson.Field
		EncryptedIndex    respjson.Field
		Title             respjson.Field
		URL               respjson.Field
		SearchResultIndex respjson.Field
		Source            respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

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

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

func (u BetaCitationsDeltaCitationUnion) AsAny() anyBetaCitationsDeltaCitation

Use the following switch statement to find the correct variant

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

func (BetaCitationsDeltaCitationUnion) AsCharLocation

func (BetaCitationsDeltaCitationUnion) AsContentBlockLocation

func (BetaCitationsDeltaCitationUnion) AsPageLocation

func (BetaCitationsDeltaCitationUnion) AsSearchResultLocation

func (BetaCitationsDeltaCitationUnion) AsWebSearchResultLocation

func (BetaCitationsDeltaCitationUnion) RawJSON

Returns the unmodified JSON received from the API

func (*BetaCitationsDeltaCitationUnion) UnmarshalJSON

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

type BetaCitationsWebSearchResultLocation

type BetaCitationsWebSearchResultLocation struct {
	CitedText      string                           `json:"cited_text,required"`
	EncryptedIndex string                           `json:"encrypted_index,required"`
	Title          string                           `json:"title,required"`
	Type           constant.WebSearchResultLocation `json:"type,required"`
	URL            string                           `json:"url,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CitedText      respjson.Field
		EncryptedIndex respjson.Field
		Title          respjson.Field
		Type           respjson.Field
		URL            respjson.Field
		ExtraFields    map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaCitationsWebSearchResultLocation) RawJSON

Returns the unmodified JSON received from the API

func (*BetaCitationsWebSearchResultLocation) UnmarshalJSON

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

type BetaClearThinking20251015EditKeepUnionParam

type BetaClearThinking20251015EditKeepUnionParam struct {
	OfThinkingTurns    *BetaThinkingTurnsParam    `json:",omitzero,inline"`
	OfAllThinkingTurns *BetaAllThinkingTurnsParam `json:",omitzero,inline"`
	// Construct this variant with constant.ValueOf[constant.All]()
	OfAll constant.All `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 (BetaClearThinking20251015EditKeepUnionParam) GetType

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

func (BetaClearThinking20251015EditKeepUnionParam) GetValue

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

func (BetaClearThinking20251015EditKeepUnionParam) MarshalJSON

func (*BetaClearThinking20251015EditKeepUnionParam) UnmarshalJSON

func (u *BetaClearThinking20251015EditKeepUnionParam) UnmarshalJSON(data []byte) error

type BetaClearThinking20251015EditParam

type BetaClearThinking20251015EditParam struct {
	// Number of most recent assistant turns to keep thinking blocks for. Older turns
	// will have their thinking blocks removed.
	Keep BetaClearThinking20251015EditKeepUnionParam `json:"keep,omitzero"`
	// This field can be elided, and will marshal its zero value as
	// "clear_thinking_20251015".
	Type constant.ClearThinking20251015 `json:"type,required"`
	// contains filtered or unexported fields
}

The property Type is required.

func (BetaClearThinking20251015EditParam) MarshalJSON

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

func (*BetaClearThinking20251015EditParam) UnmarshalJSON

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

type BetaClearThinking20251015EditResponse

type BetaClearThinking20251015EditResponse struct {
	// Number of input tokens cleared by this edit.
	ClearedInputTokens int64 `json:"cleared_input_tokens,required"`
	// Number of thinking turns that were cleared.
	ClearedThinkingTurns int64 `json:"cleared_thinking_turns,required"`
	// The type of context management edit applied.
	Type constant.ClearThinking20251015 `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ClearedInputTokens   respjson.Field
		ClearedThinkingTurns respjson.Field
		Type                 respjson.Field
		ExtraFields          map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaClearThinking20251015EditResponse) RawJSON

Returns the unmodified JSON received from the API

func (*BetaClearThinking20251015EditResponse) UnmarshalJSON

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

type BetaClearToolUses20250919EditClearToolInputsUnionParam

type BetaClearToolUses20250919EditClearToolInputsUnionParam struct {
	OfBool        param.Opt[bool] `json:",omitzero,inline"`
	OfStringArray []string        `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 (BetaClearToolUses20250919EditClearToolInputsUnionParam) MarshalJSON

func (*BetaClearToolUses20250919EditClearToolInputsUnionParam) UnmarshalJSON

type BetaClearToolUses20250919EditParam

type BetaClearToolUses20250919EditParam struct {
	// Whether to clear all tool inputs (bool) or specific tool inputs to clear (list)
	ClearToolInputs BetaClearToolUses20250919EditClearToolInputsUnionParam `json:"clear_tool_inputs,omitzero"`
	// Tool names whose uses are preserved from clearing
	ExcludeTools []string `json:"exclude_tools,omitzero"`
	// Minimum number of tokens that must be cleared when triggered. Context will only
	// be modified if at least this many tokens can be removed.
	ClearAtLeast BetaInputTokensClearAtLeastParam `json:"clear_at_least,omitzero"`
	// Number of tool uses to retain in the conversation
	Keep BetaToolUsesKeepParam `json:"keep,omitzero"`
	// Condition that triggers the context management strategy
	Trigger BetaClearToolUses20250919EditTriggerUnionParam `json:"trigger,omitzero"`
	// This field can be elided, and will marshal its zero value as
	// "clear_tool_uses_20250919".
	Type constant.ClearToolUses20250919 `json:"type,required"`
	// contains filtered or unexported fields
}

The property Type is required.

func (BetaClearToolUses20250919EditParam) MarshalJSON

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

func (*BetaClearToolUses20250919EditParam) UnmarshalJSON

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

type BetaClearToolUses20250919EditResponse

type BetaClearToolUses20250919EditResponse struct {
	// Number of input tokens cleared by this edit.
	ClearedInputTokens int64 `json:"cleared_input_tokens,required"`
	// Number of tool uses that were cleared.
	ClearedToolUses int64 `json:"cleared_tool_uses,required"`
	// The type of context management edit applied.
	Type constant.ClearToolUses20250919 `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ClearedInputTokens respjson.Field
		ClearedToolUses    respjson.Field
		Type               respjson.Field
		ExtraFields        map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaClearToolUses20250919EditResponse) RawJSON

Returns the unmodified JSON received from the API

func (*BetaClearToolUses20250919EditResponse) UnmarshalJSON

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

type BetaClearToolUses20250919EditTriggerUnionParam

type BetaClearToolUses20250919EditTriggerUnionParam struct {
	OfInputTokens *BetaInputTokensTriggerParam `json:",omitzero,inline"`
	OfToolUses    *BetaToolUsesTriggerParam    `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 (BetaClearToolUses20250919EditTriggerUnionParam) GetType

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

func (BetaClearToolUses20250919EditTriggerUnionParam) GetValue

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

func (BetaClearToolUses20250919EditTriggerUnionParam) MarshalJSON

func (*BetaClearToolUses20250919EditTriggerUnionParam) UnmarshalJSON

type BetaCodeExecutionOutputBlock

type BetaCodeExecutionOutputBlock struct {
	FileID string                       `json:"file_id,required"`
	Type   constant.CodeExecutionOutput `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		FileID      respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaCodeExecutionOutputBlock) RawJSON

Returns the unmodified JSON received from the API

func (BetaCodeExecutionOutputBlock) ToParam

func (*BetaCodeExecutionOutputBlock) UnmarshalJSON

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

type BetaCodeExecutionOutputBlockParam

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

The properties FileID, Type are required.

func (BetaCodeExecutionOutputBlockParam) MarshalJSON

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

func (*BetaCodeExecutionOutputBlockParam) UnmarshalJSON

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

type BetaCodeExecutionResultBlock

type BetaCodeExecutionResultBlock struct {
	Content    []BetaCodeExecutionOutputBlock `json:"content,required"`
	ReturnCode int64                          `json:"return_code,required"`
	Stderr     string                         `json:"stderr,required"`
	Stdout     string                         `json:"stdout,required"`
	Type       constant.CodeExecutionResult   `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Content     respjson.Field
		ReturnCode  respjson.Field
		Stderr      respjson.Field
		Stdout      respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaCodeExecutionResultBlock) RawJSON

Returns the unmodified JSON received from the API

func (*BetaCodeExecutionResultBlock) UnmarshalJSON

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

type BetaCodeExecutionResultBlockParam

type BetaCodeExecutionResultBlockParam struct {
	Content    []BetaCodeExecutionOutputBlockParam `json:"content,omitzero,required"`
	ReturnCode int64                               `json:"return_code,required"`
	Stderr     string                              `json:"stderr,required"`
	Stdout     string                              `json:"stdout,required"`
	// This field can be elided, and will marshal its zero value as
	// "code_execution_result".
	Type constant.CodeExecutionResult `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Content, ReturnCode, Stderr, Stdout, Type are required.

func (BetaCodeExecutionResultBlockParam) MarshalJSON

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

func (*BetaCodeExecutionResultBlockParam) UnmarshalJSON

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

type BetaCodeExecutionTool20250522Param

type BetaCodeExecutionTool20250522Param struct {
	// If true, tool will not be included in initial system prompt. Only loaded when
	// returned via tool_reference from tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// When true, guarantees schema validation on tool names and inputs
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// Create a cache control breakpoint at this content block.
	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 "code_execution".
	Name constant.CodeExecution `json:"name,required"`
	// This field can be elided, and will marshal its zero value as
	// "code_execution_20250522".
	Type constant.CodeExecution20250522 `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Name, Type are required.

func (BetaCodeExecutionTool20250522Param) MarshalJSON

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

func (*BetaCodeExecutionTool20250522Param) UnmarshalJSON

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

type BetaCodeExecutionTool20250825Param

type BetaCodeExecutionTool20250825Param struct {
	// If true, tool will not be included in initial system prompt. Only loaded when
	// returned via tool_reference from tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// When true, guarantees schema validation on tool names and inputs
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// Create a cache control breakpoint at this content block.
	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 "code_execution".
	Name constant.CodeExecution `json:"name,required"`
	// This field can be elided, and will marshal its zero value as
	// "code_execution_20250825".
	Type constant.CodeExecution20250825 `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Name, Type are required.

func (BetaCodeExecutionTool20250825Param) MarshalJSON

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

func (*BetaCodeExecutionTool20250825Param) UnmarshalJSON

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

type BetaCodeExecutionTool20260120Param

type BetaCodeExecutionTool20260120Param struct {
	// If true, tool will not be included in initial system prompt. Only loaded when
	// returned via tool_reference from tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// When true, guarantees schema validation on tool names and inputs
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// Create a cache control breakpoint at this content block.
	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 "code_execution".
	Name constant.CodeExecution `json:"name,required"`
	// This field can be elided, and will marshal its zero value as
	// "code_execution_20260120".
	Type constant.CodeExecution20260120 `json:"type,required"`
	// contains filtered or unexported fields
}

Code execution tool with REPL state persistence (daemon mode + gVisor checkpoint).

The properties Name, Type are required.

func (BetaCodeExecutionTool20260120Param) MarshalJSON

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

func (*BetaCodeExecutionTool20260120Param) UnmarshalJSON

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

type BetaCodeExecutionToolResultBlock

type BetaCodeExecutionToolResultBlock struct {
	// Code execution result with encrypted stdout for PFC + web_search results.
	Content   BetaCodeExecutionToolResultBlockContentUnion `json:"content,required"`
	ToolUseID string                                       `json:"tool_use_id,required"`
	Type      constant.CodeExecutionToolResult             `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Content     respjson.Field
		ToolUseID   respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaCodeExecutionToolResultBlock) RawJSON

Returns the unmodified JSON received from the API

func (BetaCodeExecutionToolResultBlock) ToParam

func (*BetaCodeExecutionToolResultBlock) UnmarshalJSON

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

type BetaCodeExecutionToolResultBlockContentUnion

type BetaCodeExecutionToolResultBlockContentUnion struct {
	// This field is from variant [BetaCodeExecutionToolResultError].
	ErrorCode  BetaCodeExecutionToolResultErrorCode `json:"error_code"`
	Type       string                               `json:"type"`
	Content    []BetaCodeExecutionOutputBlock       `json:"content"`
	ReturnCode int64                                `json:"return_code"`
	Stderr     string                               `json:"stderr"`
	// This field is from variant [BetaCodeExecutionResultBlock].
	Stdout string `json:"stdout"`
	// This field is from variant [BetaEncryptedCodeExecutionResultBlock].
	EncryptedStdout string `json:"encrypted_stdout"`
	JSON            struct {
		ErrorCode       respjson.Field
		Type            respjson.Field
		Content         respjson.Field
		ReturnCode      respjson.Field
		Stderr          respjson.Field
		Stdout          respjson.Field
		EncryptedStdout respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

BetaCodeExecutionToolResultBlockContentUnion contains all possible properties and values from BetaCodeExecutionToolResultError, BetaCodeExecutionResultBlock, BetaEncryptedCodeExecutionResultBlock.

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

func (BetaCodeExecutionToolResultBlockContentUnion) AsResponseCodeExecutionResultBlock

func (u BetaCodeExecutionToolResultBlockContentUnion) AsResponseCodeExecutionResultBlock() (v BetaCodeExecutionResultBlock)

func (BetaCodeExecutionToolResultBlockContentUnion) AsResponseCodeExecutionToolResultError

func (u BetaCodeExecutionToolResultBlockContentUnion) AsResponseCodeExecutionToolResultError() (v BetaCodeExecutionToolResultError)

func (BetaCodeExecutionToolResultBlockContentUnion) AsResponseEncryptedCodeExecutionResultBlock

func (u BetaCodeExecutionToolResultBlockContentUnion) AsResponseEncryptedCodeExecutionResultBlock() (v BetaEncryptedCodeExecutionResultBlock)

func (BetaCodeExecutionToolResultBlockContentUnion) RawJSON

Returns the unmodified JSON received from the API

func (*BetaCodeExecutionToolResultBlockContentUnion) UnmarshalJSON

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

type BetaCodeExecutionToolResultBlockParam

type BetaCodeExecutionToolResultBlockParam struct {
	// Code execution result with encrypted stdout for PFC + web_search results.
	Content   BetaCodeExecutionToolResultBlockParamContentUnion `json:"content,omitzero,required"`
	ToolUseID string                                            `json:"tool_use_id,required"`
	// Create a cache control breakpoint at this content block.
	CacheControl BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	// This field can be elided, and will marshal its zero value as
	// "code_execution_tool_result".
	Type constant.CodeExecutionToolResult `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Content, ToolUseID, Type are required.

func (BetaCodeExecutionToolResultBlockParam) MarshalJSON

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

func (*BetaCodeExecutionToolResultBlockParam) UnmarshalJSON

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

type BetaCodeExecutionToolResultBlockParamContentUnion

type BetaCodeExecutionToolResultBlockParamContentUnion struct {
	OfError                                    *BetaCodeExecutionToolResultErrorParam      `json:",omitzero,inline"`
	OfResultBlock                              *BetaCodeExecutionResultBlockParam          `json:",omitzero,inline"`
	OfRequestEncryptedCodeExecutionResultBlock *BetaEncryptedCodeExecutionResultBlockParam `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 (BetaCodeExecutionToolResultBlockParamContentUnion) GetContent

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

func (BetaCodeExecutionToolResultBlockParamContentUnion) GetEncryptedStdout

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

func (BetaCodeExecutionToolResultBlockParamContentUnion) GetErrorCode

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

func (BetaCodeExecutionToolResultBlockParamContentUnion) GetReturnCode

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

func (BetaCodeExecutionToolResultBlockParamContentUnion) GetStderr

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

func (BetaCodeExecutionToolResultBlockParamContentUnion) GetStdout

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

func (BetaCodeExecutionToolResultBlockParamContentUnion) GetType

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

func (BetaCodeExecutionToolResultBlockParamContentUnion) MarshalJSON

func (*BetaCodeExecutionToolResultBlockParamContentUnion) UnmarshalJSON

type BetaCodeExecutionToolResultError

type BetaCodeExecutionToolResultError struct {
	// Any of "invalid_tool_input", "unavailable", "too_many_requests",
	// "execution_time_exceeded".
	ErrorCode BetaCodeExecutionToolResultErrorCode  `json:"error_code,required"`
	Type      constant.CodeExecutionToolResultError `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ErrorCode   respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaCodeExecutionToolResultError) RawJSON

Returns the unmodified JSON received from the API

func (*BetaCodeExecutionToolResultError) UnmarshalJSON

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

type BetaCodeExecutionToolResultErrorCode

type BetaCodeExecutionToolResultErrorCode string
const (
	BetaCodeExecutionToolResultErrorCodeInvalidToolInput      BetaCodeExecutionToolResultErrorCode = "invalid_tool_input"
	BetaCodeExecutionToolResultErrorCodeUnavailable           BetaCodeExecutionToolResultErrorCode = "unavailable"
	BetaCodeExecutionToolResultErrorCodeTooManyRequests       BetaCodeExecutionToolResultErrorCode = "too_many_requests"
	BetaCodeExecutionToolResultErrorCodeExecutionTimeExceeded BetaCodeExecutionToolResultErrorCode = "execution_time_exceeded"
)

type BetaCodeExecutionToolResultErrorParam

type BetaCodeExecutionToolResultErrorParam struct {
	// Any of "invalid_tool_input", "unavailable", "too_many_requests",
	// "execution_time_exceeded".
	ErrorCode BetaCodeExecutionToolResultErrorCode `json:"error_code,omitzero,required"`
	// This field can be elided, and will marshal its zero value as
	// "code_execution_tool_result_error".
	Type constant.CodeExecutionToolResultError `json:"type,required"`
	// contains filtered or unexported fields
}

The properties ErrorCode, Type are required.

func (BetaCodeExecutionToolResultErrorParam) MarshalJSON

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

func (*BetaCodeExecutionToolResultErrorParam) UnmarshalJSON

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

type BetaCompact20260112EditParam

type BetaCompact20260112EditParam struct {
	// Additional instructions for summarization.
	Instructions param.Opt[string] `json:"instructions,omitzero"`
	// Whether to pause after compaction and return the compaction block to the user.
	PauseAfterCompaction param.Opt[bool] `json:"pause_after_compaction,omitzero"`
	// When to trigger compaction. Defaults to 150000 input tokens.
	Trigger BetaInputTokensTriggerParam `json:"trigger,omitzero"`
	// This field can be elided, and will marshal its zero value as "compact_20260112".
	Type constant.Compact20260112 `json:"type,required"`
	// contains filtered or unexported fields
}

Automatically compact older context when reaching the configured trigger threshold.

The property Type is required.

func (BetaCompact20260112EditParam) MarshalJSON

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

func (*BetaCompact20260112EditParam) UnmarshalJSON

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

type BetaCompactionBlock

type BetaCompactionBlock struct {
	// Summary of compacted content, or null if compaction failed
	Content string              `json:"content,required"`
	Type    constant.Compaction `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Content     respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

A compaction block returned when autocompact is triggered.

When content is None, it indicates the compaction failed to produce a valid summary (e.g., malformed output from the model). Clients may round-trip compaction blocks with null content; the server treats them as no-ops.

func (BetaCompactionBlock) RawJSON

func (r BetaCompactionBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (BetaCompactionBlock) ToParam

func (*BetaCompactionBlock) UnmarshalJSON

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

type BetaCompactionBlockParam

type BetaCompactionBlockParam struct {
	// Summary of previously compacted content, or null if compaction failed
	Content param.Opt[string] `json:"content,omitzero,required"`
	// Create a cache control breakpoint at this content block.
	CacheControl BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	// This field can be elided, and will marshal its zero value as "compaction".
	Type constant.Compaction `json:"type,required"`
	// contains filtered or unexported fields
}

A compaction block containing summary of previous context.

Users should round-trip these blocks from responses to subsequent requests to maintain context across compaction boundaries.

When content is None, the block represents a failed compaction. The server treats these as no-ops. Empty string content is not allowed.

The properties Content, Type are required.

func (BetaCompactionBlockParam) MarshalJSON

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

func (*BetaCompactionBlockParam) UnmarshalJSON

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

type BetaCompactionContentBlockDelta

type BetaCompactionContentBlockDelta struct {
	Content string                   `json:"content,required"`
	Type    constant.CompactionDelta `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Content     respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaCompactionContentBlockDelta) RawJSON

Returns the unmodified JSON received from the API

func (*BetaCompactionContentBlockDelta) UnmarshalJSON

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

type BetaCompactionIterationUsage

type BetaCompactionIterationUsage struct {
	// Breakdown of cached tokens by TTL
	CacheCreation BetaCacheCreation `json:"cache_creation,required"`
	// 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"`
	// Usage for a compaction iteration
	Type constant.Compaction `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CacheCreation            respjson.Field
		CacheCreationInputTokens respjson.Field
		CacheReadInputTokens     respjson.Field
		InputTokens              respjson.Field
		OutputTokens             respjson.Field
		Type                     respjson.Field
		ExtraFields              map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Token usage for a compaction iteration.

func (BetaCompactionIterationUsage) RawJSON

Returns the unmodified JSON received from the API

func (*BetaCompactionIterationUsage) UnmarshalJSON

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

type BetaContainer

type BetaContainer struct {
	// Identifier for the container used in this request
	ID string `json:"id,required"`
	// The time at which the container will expire.
	ExpiresAt time.Time `json:"expires_at,required" format:"date-time"`
	// Skills loaded in the container
	Skills []BetaSkill `json:"skills,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		ExpiresAt   respjson.Field
		Skills      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Information about the container used in the request (for the code execution tool)

func (BetaContainer) RawJSON

func (r BetaContainer) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaContainer) UnmarshalJSON

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

type BetaContainerParams

type BetaContainerParams struct {
	// Container id
	ID param.Opt[string] `json:"id,omitzero"`
	// List of skills to load in the container
	Skills []BetaSkillParams `json:"skills,omitzero"`
	// contains filtered or unexported fields
}

Container parameters with skills to be loaded.

func (BetaContainerParams) MarshalJSON

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

func (*BetaContainerParams) UnmarshalJSON

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

type BetaContainerUploadBlock

type BetaContainerUploadBlock struct {
	FileID string                   `json:"file_id,required"`
	Type   constant.ContainerUpload `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		FileID      respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Response model for a file uploaded to the container.

func (BetaContainerUploadBlock) RawJSON

func (r BetaContainerUploadBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (BetaContainerUploadBlock) ToParam

func (*BetaContainerUploadBlock) UnmarshalJSON

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

type BetaContainerUploadBlockParam

type BetaContainerUploadBlockParam struct {
	FileID string `json:"file_id,required"`
	// Create a cache control breakpoint at this content block.
	CacheControl BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	// This field can be elided, and will marshal its zero value as "container_upload".
	Type constant.ContainerUpload `json:"type,required"`
	// contains filtered or unexported fields
}

A content block that represents a file to be uploaded to the container Files uploaded via this block will be available in the container's input directory.

The properties FileID, Type are required.

func (BetaContainerUploadBlockParam) MarshalJSON

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

func (*BetaContainerUploadBlockParam) UnmarshalJSON

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

type BetaContentBlockParamUnion

type BetaContentBlockParamUnion struct {
	OfText                              *BetaTextBlockParam                              `json:",omitzero,inline"`
	OfImage                             *BetaImageBlockParam                             `json:",omitzero,inline"`
	OfDocument                          *BetaRequestDocumentBlockParam                   `json:",omitzero,inline"`
	OfSearchResult                      *BetaSearchResultBlockParam                      `json:",omitzero,inline"`
	OfThinking                          *BetaThinkingBlockParam                          `json:",omitzero,inline"`
	OfRedactedThinking                  *BetaRedactedThinkingBlockParam                  `json:",omitzero,inline"`
	OfToolUse                           *BetaToolUseBlockParam                           `json:",omitzero,inline"`
	OfToolResult                        *BetaToolResultBlockParam                        `json:",omitzero,inline"`
	OfServerToolUse                     *BetaServerToolUseBlockParam                     `json:",omitzero,inline"`
	OfWebSearchToolResult               *BetaWebSearchToolResultBlockParam               `json:",omitzero,inline"`
	OfWebFetchToolResult                *BetaWebFetchToolResultBlockParam                `json:",omitzero,inline"`
	OfCodeExecutionToolResult           *BetaCodeExecutionToolResultBlockParam           `json:",omitzero,inline"`
	OfBashCodeExecutionToolResult       *BetaBashCodeExecutionToolResultBlockParam       `json:",omitzero,inline"`
	OfTextEditorCodeExecutionToolResult *BetaTextEditorCodeExecutionToolResultBlockParam `json:",omitzero,inline"`
	OfToolSearchToolResult              *BetaToolSearchToolResultBlockParam              `json:",omitzero,inline"`
	OfMCPToolUse                        *BetaMCPToolUseBlockParam                        `json:",omitzero,inline"`
	OfMCPToolResult                     *BetaRequestMCPToolResultBlockParam              `json:",omitzero,inline"`
	OfContainerUpload                   *BetaContainerUploadBlockParam                   `json:",omitzero,inline"`
	OfCompaction                        *BetaCompactionBlockParam                        `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 NewBetaCompactionBlock

func NewBetaCompactionBlock(content string) BetaContentBlockParamUnion

func NewBetaContainerUploadBlock

func NewBetaContainerUploadBlock(fileID string) BetaContentBlockParamUnion

func NewBetaMCPToolResultBlock

func NewBetaMCPToolResultBlock(toolUseID string) BetaContentBlockParamUnion

func NewBetaRedactedThinkingBlock

func NewBetaRedactedThinkingBlock(data string) BetaContentBlockParamUnion

func NewBetaSearchResultBlock

func NewBetaSearchResultBlock(content []BetaTextBlockParam, source string, title string) BetaContentBlockParamUnion

func NewBetaTextBlock

func NewBetaTextBlock(text string) BetaContentBlockParamUnion

func NewBetaThinkingBlock

func NewBetaThinkingBlock(signature string, thinking string) BetaContentBlockParamUnion

func NewBetaToolResultBlock

func NewBetaToolResultBlock(toolUseID string, content string, isError bool) BetaContentBlockParamUnion

func NewBetaToolUseBlock

func NewBetaToolUseBlock(id string, input any, name string) BetaContentBlockParamUnion

func (BetaContentBlockParamUnion) GetCacheControl

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

func (BetaContentBlockParamUnion) GetCaller

func (u BetaContentBlockParamUnion) GetCaller() (res betaContentBlockParamUnionCaller)

Returns a subunion which exports methods to access subproperties

Or use AsAny() to get the underlying value

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

func (u BetaContentBlockParamUnion) GetContent() (res betaContentBlockParamUnionContent)

Returns a subunion which exports methods to access subproperties

Or use AsAny() to get the underlying value

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) GetFileID

func (u BetaContentBlockParamUnion) GetFileID() *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() *any

Returns a pointer to the underlying variant's Input 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) GetServerName

func (u BetaContentBlockParamUnion) GetServerName() *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) MarshalJSON

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

func (*BetaContentBlockParamUnion) UnmarshalJSON

func (u *BetaContentBlockParamUnion) UnmarshalJSON(data []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) MarshalJSON

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

func (*BetaContentBlockSourceContentUnionParam) UnmarshalJSON

func (u *BetaContentBlockSourceContentUnionParam) UnmarshalJSON(data []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) MarshalJSON

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

func (*BetaContentBlockSourceParam) UnmarshalJSON

func (r *BetaContentBlockSourceParam) UnmarshalJSON(data []byte) 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", "thinking", "redacted_thinking", "tool_use", "server_tool_use",
	// "web_search_tool_result", "web_fetch_tool_result", "code_execution_tool_result",
	// "bash_code_execution_tool_result", "text_editor_code_execution_tool_result",
	// "tool_search_tool_result", "mcp_tool_use", "mcp_tool_result",
	// "container_upload", "compaction".
	Type string `json:"type"`
	// 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"`
	ID   string `json:"id"`
	// necessary custom code modification
	Input json.RawMessage `json:"input"`
	Name  string          `json:"name"`
	// This field is a union of [BetaToolUseBlockCallerUnion],
	// [BetaServerToolUseBlockCallerUnion], [BetaWebSearchToolResultBlockCallerUnion],
	// [BetaWebFetchToolResultBlockCallerUnion]
	Caller BetaContentBlockUnionCaller `json:"caller"`
	// This field is a union of [BetaWebSearchToolResultBlockContentUnion],
	// [BetaWebFetchToolResultBlockContentUnion],
	// [BetaCodeExecutionToolResultBlockContentUnion],
	// [BetaBashCodeExecutionToolResultBlockContentUnion],
	// [BetaTextEditorCodeExecutionToolResultBlockContentUnion],
	// [BetaToolSearchToolResultBlockContentUnion],
	// [BetaMCPToolResultBlockContentUnion], [string]
	Content   BetaContentBlockUnionContent `json:"content"`
	ToolUseID string                       `json:"tool_use_id"`
	// This field is from variant [BetaMCPToolUseBlock].
	ServerName string `json:"server_name"`
	// This field is from variant [BetaMCPToolResultBlock].
	IsError bool `json:"is_error"`
	// This field is from variant [BetaContainerUploadBlock].
	FileID string `json:"file_id"`
	JSON   struct {
		Citations  respjson.Field
		Text       respjson.Field
		Type       respjson.Field
		Signature  respjson.Field
		Thinking   respjson.Field
		Data       respjson.Field
		ID         respjson.Field
		Input      respjson.Field
		Name       respjson.Field
		Caller     respjson.Field
		Content    respjson.Field
		ToolUseID  respjson.Field
		ServerName respjson.Field
		IsError    respjson.Field
		FileID     respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

BetaContentBlockUnion contains all possible properties and values from BetaTextBlock, BetaThinkingBlock, BetaRedactedThinkingBlock, BetaToolUseBlock, BetaServerToolUseBlock, BetaWebSearchToolResultBlock, BetaWebFetchToolResultBlock, BetaCodeExecutionToolResultBlock, BetaBashCodeExecutionToolResultBlock, BetaTextEditorCodeExecutionToolResultBlock, BetaToolSearchToolResultBlock, BetaMCPToolUseBlock, BetaMCPToolResultBlock, BetaContainerUploadBlock, BetaCompactionBlock.

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() anyBetaContentBlock

Use the following switch statement to find the correct variant

switch variant := BetaContentBlockUnion.AsAny().(type) {
case anthropic.BetaTextBlock:
case anthropic.BetaThinkingBlock:
case anthropic.BetaRedactedThinkingBlock:
case anthropic.BetaToolUseBlock:
case anthropic.BetaServerToolUseBlock:
case anthropic.BetaWebSearchToolResultBlock:
case anthropic.BetaWebFetchToolResultBlock:
case anthropic.BetaCodeExecutionToolResultBlock:
case anthropic.BetaBashCodeExecutionToolResultBlock:
case anthropic.BetaTextEditorCodeExecutionToolResultBlock:
case anthropic.BetaToolSearchToolResultBlock:
case anthropic.BetaMCPToolUseBlock:
case anthropic.BetaMCPToolResultBlock:
case anthropic.BetaContainerUploadBlock:
case anthropic.BetaCompactionBlock:
default:
  fmt.Errorf("no variant present")
}

func (BetaContentBlockUnion) AsBashCodeExecutionToolResult

func (u BetaContentBlockUnion) AsBashCodeExecutionToolResult() (v BetaBashCodeExecutionToolResultBlock)

func (BetaContentBlockUnion) AsCodeExecutionToolResult

func (u BetaContentBlockUnion) AsCodeExecutionToolResult() (v BetaCodeExecutionToolResultBlock)

func (BetaContentBlockUnion) AsCompaction

func (u BetaContentBlockUnion) AsCompaction() (v BetaCompactionBlock)

func (BetaContentBlockUnion) AsContainerUpload

func (u BetaContentBlockUnion) AsContainerUpload() (v BetaContainerUploadBlock)

func (BetaContentBlockUnion) AsMCPToolResult

func (u BetaContentBlockUnion) AsMCPToolResult() (v BetaMCPToolResultBlock)

func (BetaContentBlockUnion) AsMCPToolUse

func (u BetaContentBlockUnion) AsMCPToolUse() (v BetaMCPToolUseBlock)

func (BetaContentBlockUnion) AsRedactedThinking

func (u BetaContentBlockUnion) AsRedactedThinking() (v BetaRedactedThinkingBlock)

func (BetaContentBlockUnion) AsServerToolUse

func (u BetaContentBlockUnion) AsServerToolUse() (v BetaServerToolUseBlock)

func (BetaContentBlockUnion) AsText

func (u BetaContentBlockUnion) AsText() (v BetaTextBlock)

func (BetaContentBlockUnion) AsTextEditorCodeExecutionToolResult

func (u BetaContentBlockUnion) AsTextEditorCodeExecutionToolResult() (v BetaTextEditorCodeExecutionToolResultBlock)

func (BetaContentBlockUnion) AsThinking

func (u BetaContentBlockUnion) AsThinking() (v BetaThinkingBlock)

func (BetaContentBlockUnion) AsToolSearchToolResult

func (u BetaContentBlockUnion) AsToolSearchToolResult() (v BetaToolSearchToolResultBlock)

func (BetaContentBlockUnion) AsToolUse

func (u BetaContentBlockUnion) AsToolUse() (v BetaToolUseBlock)

func (BetaContentBlockUnion) AsWebFetchToolResult

func (u BetaContentBlockUnion) AsWebFetchToolResult() (v BetaWebFetchToolResultBlock)

func (BetaContentBlockUnion) AsWebSearchToolResult

func (u BetaContentBlockUnion) AsWebSearchToolResult() (v BetaWebSearchToolResultBlock)

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 BetaContentBlockUnionCaller

type BetaContentBlockUnionCaller struct {
	Type   string `json:"type"`
	ToolID string `json:"tool_id"`
	JSON   struct {
		Type   respjson.Field
		ToolID respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

BetaContentBlockUnionCaller is an implicit subunion of BetaContentBlockUnion. BetaContentBlockUnionCaller provides convenient access to the sub-properties of the union.

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

func (*BetaContentBlockUnionCaller) UnmarshalJSON

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

type BetaContentBlockUnionContent

type BetaContentBlockUnionContent struct {
	// This field will be present if the value is a [[]BetaWebSearchResultBlock]
	// instead of an object.
	OfBetaWebSearchResultBlockArray []BetaWebSearchResultBlock `json:",inline"`
	// This field will be present if the value is a [string] instead of an object.
	OfString string `json:",inline"`
	// This field will be present if the value is a [[]BetaTextBlock] instead of an
	// object.
	OfBetaMCPToolResultBlockContent []BetaTextBlock `json:",inline"`
	ErrorCode                       string          `json:"error_code"`
	Type                            string          `json:"type"`
	// This field is a union of [BetaDocumentBlock], [[]BetaCodeExecutionOutputBlock],
	// [[]BetaCodeExecutionOutputBlock], [[]BetaBashCodeExecutionOutputBlock], [string]
	Content BetaContentBlockUnionContentContent `json:"content"`
	// This field is from variant [BetaWebFetchToolResultBlockContentUnion].
	RetrievedAt string `json:"retrieved_at"`
	// This field is from variant [BetaWebFetchToolResultBlockContentUnion].
	URL        string `json:"url"`
	ReturnCode int64  `json:"return_code"`
	Stderr     string `json:"stderr"`
	Stdout     string `json:"stdout"`
	// This field is from variant [BetaCodeExecutionToolResultBlockContentUnion].
	EncryptedStdout string `json:"encrypted_stdout"`
	ErrorMessage    string `json:"error_message"`
	// This field is from variant
	// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].
	FileType BetaTextEditorCodeExecutionViewResultBlockFileType `json:"file_type"`
	// This field is from variant
	// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].
	NumLines int64 `json:"num_lines"`
	// This field is from variant
	// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].
	StartLine int64 `json:"start_line"`
	// This field is from variant
	// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].
	TotalLines int64 `json:"total_lines"`
	// This field is from variant
	// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].
	IsFileUpdate bool `json:"is_file_update"`
	// This field is from variant
	// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].
	Lines []string `json:"lines"`
	// This field is from variant
	// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].
	NewLines int64 `json:"new_lines"`
	// This field is from variant
	// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].
	NewStart int64 `json:"new_start"`
	// This field is from variant
	// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].
	OldLines int64 `json:"old_lines"`
	// This field is from variant
	// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].
	OldStart int64 `json:"old_start"`
	// This field is from variant [BetaToolSearchToolResultBlockContentUnion].
	ToolReferences []BetaToolReferenceBlock `json:"tool_references"`
	JSON           struct {
		OfBetaWebSearchResultBlockArray respjson.Field
		OfString                        respjson.Field
		OfBetaMCPToolResultBlockContent respjson.Field
		ErrorCode                       respjson.Field
		Type                            respjson.Field
		Content                         respjson.Field
		RetrievedAt                     respjson.Field
		URL                             respjson.Field
		ReturnCode                      respjson.Field
		Stderr                          respjson.Field
		Stdout                          respjson.Field
		EncryptedStdout                 respjson.Field
		ErrorMessage                    respjson.Field
		FileType                        respjson.Field
		NumLines                        respjson.Field
		StartLine                       respjson.Field
		TotalLines                      respjson.Field
		IsFileUpdate                    respjson.Field
		Lines                           respjson.Field
		NewLines                        respjson.Field
		NewStart                        respjson.Field
		OldLines                        respjson.Field
		OldStart                        respjson.Field
		ToolReferences                  respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

BetaContentBlockUnionContent is an implicit subunion of BetaContentBlockUnion. BetaContentBlockUnionContent provides convenient access to the sub-properties of the union.

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

If the underlying value is not a json object, one of the following properties will be valid: OfBetaWebSearchResultBlockArray OfString OfBetaMCPToolResultBlockContent]

func (*BetaContentBlockUnionContent) UnmarshalJSON

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

type BetaContentBlockUnionContentContent

type BetaContentBlockUnionContentContent struct {
	// This field will be present if the value is a [[]BetaCodeExecutionOutputBlock]
	// instead of an object.
	OfContent []BetaCodeExecutionOutputBlock `json:",inline"`
	// This field will be present if the value is a [string] instead of an object.
	OfString string `json:",inline"`
	// This field is from variant [BetaDocumentBlock].
	Citations BetaCitationConfig `json:"citations"`
	// This field is from variant [BetaDocumentBlock].
	Source BetaDocumentBlockSourceUnion `json:"source"`
	// This field is from variant [BetaDocumentBlock].
	Title string `json:"title"`
	// This field is from variant [BetaDocumentBlock].
	Type constant.Document `json:"type"`
	JSON struct {
		OfContent respjson.Field
		OfString  respjson.Field
		Citations respjson.Field
		Source    respjson.Field
		Title     respjson.Field
		Type      respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

BetaContentBlockUnionContentContent is an implicit subunion of BetaContentBlockUnion. BetaContentBlockUnionContentContent provides convenient access to the sub-properties of the union.

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

If the underlying value is not a json object, one of the following properties will be valid: OfContent OfString]

func (*BetaContentBlockUnionContentContent) UnmarshalJSON

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

type BetaContextManagementConfigEditUnionParam

type BetaContextManagementConfigEditUnionParam struct {
	OfClearToolUses20250919 *BetaClearToolUses20250919EditParam `json:",omitzero,inline"`
	OfClearThinking20251015 *BetaClearThinking20251015EditParam `json:",omitzero,inline"`
	OfCompact20260112       *BetaCompact20260112EditParam       `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 (BetaContextManagementConfigEditUnionParam) GetClearAtLeast

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

func (BetaContextManagementConfigEditUnionParam) GetClearToolInputs

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

func (BetaContextManagementConfigEditUnionParam) GetExcludeTools

func (u BetaContextManagementConfigEditUnionParam) GetExcludeTools() []string

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

func (BetaContextManagementConfigEditUnionParam) GetInstructions

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

func (BetaContextManagementConfigEditUnionParam) GetKeep

func (u BetaContextManagementConfigEditUnionParam) GetKeep() (res betaContextManagementConfigEditUnionParamKeep)

Returns a subunion which exports methods to access subproperties

Or use AsAny() to get the underlying value

func (BetaContextManagementConfigEditUnionParam) GetPauseAfterCompaction

func (u BetaContextManagementConfigEditUnionParam) GetPauseAfterCompaction() *bool

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

func (BetaContextManagementConfigEditUnionParam) GetType

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

func (BetaContextManagementConfigEditUnionParam) MarshalJSON

func (*BetaContextManagementConfigEditUnionParam) UnmarshalJSON

func (u *BetaContextManagementConfigEditUnionParam) UnmarshalJSON(data []byte) error

type BetaContextManagementConfigParam

type BetaContextManagementConfigParam struct {
	// List of context management edits to apply
	Edits []BetaContextManagementConfigEditUnionParam `json:"edits,omitzero"`
	// contains filtered or unexported fields
}

func (BetaContextManagementConfigParam) MarshalJSON

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

func (*BetaContextManagementConfigParam) UnmarshalJSON

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

type BetaContextManagementResponse

type BetaContextManagementResponse struct {
	// List of context management edits that were applied.
	AppliedEdits []BetaContextManagementResponseAppliedEditUnion `json:"applied_edits,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AppliedEdits respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaContextManagementResponse) RawJSON

Returns the unmodified JSON received from the API

func (*BetaContextManagementResponse) UnmarshalJSON

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

type BetaContextManagementResponseAppliedEditUnion

type BetaContextManagementResponseAppliedEditUnion struct {
	ClearedInputTokens int64 `json:"cleared_input_tokens"`
	// This field is from variant [BetaClearToolUses20250919EditResponse].
	ClearedToolUses int64 `json:"cleared_tool_uses"`
	// Any of "clear_tool_uses_20250919", "clear_thinking_20251015".
	Type string `json:"type"`
	// This field is from variant [BetaClearThinking20251015EditResponse].
	ClearedThinkingTurns int64 `json:"cleared_thinking_turns"`
	JSON                 struct {
		ClearedInputTokens   respjson.Field
		ClearedToolUses      respjson.Field
		Type                 respjson.Field
		ClearedThinkingTurns respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

BetaContextManagementResponseAppliedEditUnion contains all possible properties and values from BetaClearToolUses20250919EditResponse, BetaClearThinking20251015EditResponse.

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

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

func (BetaContextManagementResponseAppliedEditUnion) AsAny

func (u BetaContextManagementResponseAppliedEditUnion) AsAny() anyBetaContextManagementResponseAppliedEdit

Use the following switch statement to find the correct variant

switch variant := BetaContextManagementResponseAppliedEditUnion.AsAny().(type) {
case anthropic.BetaClearToolUses20250919EditResponse:
case anthropic.BetaClearThinking20251015EditResponse:
default:
  fmt.Errorf("no variant present")
}

func (BetaContextManagementResponseAppliedEditUnion) AsClearThinking20251015

func (BetaContextManagementResponseAppliedEditUnion) AsClearToolUses20250919

func (BetaContextManagementResponseAppliedEditUnion) RawJSON

Returns the unmodified JSON received from the API

func (*BetaContextManagementResponseAppliedEditUnion) UnmarshalJSON

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

type BetaCountTokensContextManagementResponse

type BetaCountTokensContextManagementResponse struct {
	// The original token count before context management was applied
	OriginalInputTokens int64 `json:"original_input_tokens,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		OriginalInputTokens respjson.Field
		ExtraFields         map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaCountTokensContextManagementResponse) RawJSON

Returns the unmodified JSON received from the API

func (*BetaCountTokensContextManagementResponse) UnmarshalJSON

func (r *BetaCountTokensContextManagementResponse) 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"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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 BetaDirectCaller

type BetaDirectCaller struct {
	Type constant.Direct `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Tool invocation directly from the model.

func (BetaDirectCaller) RawJSON

func (r BetaDirectCaller) RawJSON() string

Returns the unmodified JSON received from the API

func (BetaDirectCaller) ToParam

ToParam converts this BetaDirectCaller to a BetaDirectCallerParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with BetaDirectCallerParam.Overrides()

func (*BetaDirectCaller) UnmarshalJSON

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

type BetaDirectCallerParam

type BetaDirectCallerParam struct {
	Type constant.Direct `json:"type,required"`
	// contains filtered or unexported fields
}

Tool invocation directly from the model.

This struct has a constant value, construct it with NewBetaDirectCallerParam.

func NewBetaDirectCallerParam

func NewBetaDirectCallerParam() BetaDirectCallerParam

func (BetaDirectCallerParam) MarshalJSON

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

func (*BetaDirectCallerParam) UnmarshalJSON

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

type BetaDocumentBlock

type BetaDocumentBlock struct {
	// Citation configuration for the document
	Citations BetaCitationConfig           `json:"citations,required"`
	Source    BetaDocumentBlockSourceUnion `json:"source,required"`
	// The title of the document
	Title string            `json:"title,required"`
	Type  constant.Document `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Citations   respjson.Field
		Source      respjson.Field
		Title       respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaDocumentBlock) RawJSON

func (r BetaDocumentBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaDocumentBlock) UnmarshalJSON

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

type BetaDocumentBlockSourceUnion

type BetaDocumentBlockSourceUnion struct {
	Data      string `json:"data"`
	MediaType string `json:"media_type"`
	// Any of "base64", "text".
	Type string `json:"type"`
	JSON struct {
		Data      respjson.Field
		MediaType respjson.Field
		Type      respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

BetaDocumentBlockSourceUnion contains all possible properties and values from BetaBase64PDFSource, BetaPlainTextSource.

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

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

func (BetaDocumentBlockSourceUnion) AsAny

func (u BetaDocumentBlockSourceUnion) AsAny() anyBetaDocumentBlockSource

Use the following switch statement to find the correct variant

switch variant := BetaDocumentBlockSourceUnion.AsAny().(type) {
case anthropic.BetaBase64PDFSource:
case anthropic.BetaPlainTextSource:
default:
  fmt.Errorf("no variant present")
}

func (BetaDocumentBlockSourceUnion) AsBase64

func (BetaDocumentBlockSourceUnion) AsText

func (BetaDocumentBlockSourceUnion) RawJSON

Returns the unmodified JSON received from the API

func (*BetaDocumentBlockSourceUnion) UnmarshalJSON

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

type BetaEncryptedCodeExecutionResultBlock

type BetaEncryptedCodeExecutionResultBlock struct {
	Content         []BetaCodeExecutionOutputBlock        `json:"content,required"`
	EncryptedStdout string                                `json:"encrypted_stdout,required"`
	ReturnCode      int64                                 `json:"return_code,required"`
	Stderr          string                                `json:"stderr,required"`
	Type            constant.EncryptedCodeExecutionResult `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Content         respjson.Field
		EncryptedStdout respjson.Field
		ReturnCode      respjson.Field
		Stderr          respjson.Field
		Type            respjson.Field
		ExtraFields     map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Code execution result with encrypted stdout for PFC + web_search results.

func (BetaEncryptedCodeExecutionResultBlock) RawJSON

Returns the unmodified JSON received from the API

func (*BetaEncryptedCodeExecutionResultBlock) UnmarshalJSON

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

type BetaEncryptedCodeExecutionResultBlockParam

type BetaEncryptedCodeExecutionResultBlockParam struct {
	Content         []BetaCodeExecutionOutputBlockParam `json:"content,omitzero,required"`
	EncryptedStdout string                              `json:"encrypted_stdout,required"`
	ReturnCode      int64                               `json:"return_code,required"`
	Stderr          string                              `json:"stderr,required"`
	// This field can be elided, and will marshal its zero value as
	// "encrypted_code_execution_result".
	Type constant.EncryptedCodeExecutionResult `json:"type,required"`
	// contains filtered or unexported fields
}

Code execution result with encrypted stdout for PFC + web_search results.

The properties Content, EncryptedStdout, ReturnCode, Stderr, Type are required.

func (BetaEncryptedCodeExecutionResultBlockParam) MarshalJSON

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

func (*BetaEncryptedCodeExecutionResultBlockParam) UnmarshalJSON

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

type BetaErrorResponse

type BetaErrorResponse struct {
	Error     BetaErrorUnion `json:"error,required"`
	RequestID string         `json:"request_id,required"`
	Type      constant.Error `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Error       respjson.Field
		RequestID   respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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 respjson.Field
		Type    respjson.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() anyBetaError

Use the following switch statement to find the correct variant

switch variant := BetaErrorUnion.AsAny().(type) {
case anthropic.BetaInvalidRequestError:
case anthropic.BetaAuthenticationError:
case anthropic.BetaBillingError:
case anthropic.BetaPermissionError:
case anthropic.BetaNotFoundError:
case anthropic.BetaRateLimitError:
case anthropic.BetaGatewayTimeoutError:
case anthropic.BetaAPIError:
case anthropic.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) 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) AsTimeoutError

func (u BetaErrorUnion) AsTimeoutError() (v BetaGatewayTimeoutError)

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 BetaFileDeleteParams

type BetaFileDeleteParams 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
}

type BetaFileDocumentSourceParam

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

The properties FileID, Type are required.

func (BetaFileDocumentSourceParam) MarshalJSON

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

func (*BetaFileDocumentSourceParam) UnmarshalJSON

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

type BetaFileDownloadParams

type BetaFileDownloadParams 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
}

type BetaFileGetMetadataParams

type BetaFileGetMetadataParams 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
}

type BetaFileImageSourceParam

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

The properties FileID, Type are required.

func (BetaFileImageSourceParam) MarshalJSON

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

func (*BetaFileImageSourceParam) UnmarshalJSON

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

type BetaFileListParams

type BetaFileListParams 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 (BetaFileListParams) URLQuery

func (r BetaFileListParams) URLQuery() (v url.Values, err error)

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

type BetaFileService

type BetaFileService struct {
	Options []option.RequestOption
}

BetaFileService 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 NewBetaFileService method instead.

func NewBetaFileService

func NewBetaFileService(opts ...option.RequestOption) (r BetaFileService)

NewBetaFileService 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 (*BetaFileService) Delete

func (r *BetaFileService) Delete(ctx context.Context, fileID string, body BetaFileDeleteParams, opts ...option.RequestOption) (res *DeletedFile, err error)

Delete File

func (*BetaFileService) Download

func (r *BetaFileService) Download(ctx context.Context, fileID string, query BetaFileDownloadParams, opts ...option.RequestOption) (res *http.Response, err error)

Download File

func (*BetaFileService) GetMetadata

func (r *BetaFileService) GetMetadata(ctx context.Context, fileID string, query BetaFileGetMetadataParams, opts ...option.RequestOption) (res *FileMetadata, err error)

Get File Metadata

func (*BetaFileService) List

List Files

func (*BetaFileService) ListAutoPaging

List Files

func (*BetaFileService) Upload

func (r *BetaFileService) Upload(ctx context.Context, params BetaFileUploadParams, opts ...option.RequestOption) (res *FileMetadata, err error)

Upload File

type BetaFileUploadParams

type BetaFileUploadParams struct {
	// The file to upload
	File io.Reader `json:"file,omitzero,required" format:"binary"`
	// 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 (BetaFileUploadParams) MarshalMultipart

func (r BetaFileUploadParams) MarshalMultipart() (data []byte, contentType string, err error)

type BetaGatewayTimeoutError

type BetaGatewayTimeoutError struct {
	Message string                `json:"message,required"`
	Type    constant.TimeoutError `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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"`
	// Create a cache control breakpoint at this content block.
	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) MarshalJSON

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

func (*BetaImageBlockParam) UnmarshalJSON

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

type BetaImageBlockParamSourceUnion

type BetaImageBlockParamSourceUnion struct {
	OfBase64 *BetaBase64ImageSourceParam `json:",omitzero,inline"`
	OfURL    *BetaURLImageSourceParam    `json:",omitzero,inline"`
	OfFile   *BetaFileImageSourceParam   `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) GetFileID

func (u BetaImageBlockParamSourceUnion) GetFileID() *string

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) MarshalJSON

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

func (*BetaImageBlockParamSourceUnion) UnmarshalJSON

func (u *BetaImageBlockParamSourceUnion) UnmarshalJSON(data []byte) error

type BetaInputJSONDelta

type BetaInputJSONDelta struct {
	PartialJSON string                  `json:"partial_json,required"`
	Type        constant.InputJSONDelta `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		PartialJSON respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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 BetaInputTokensClearAtLeastParam

type BetaInputTokensClearAtLeastParam struct {
	Value int64 `json:"value,required"`
	// This field can be elided, and will marshal its zero value as "input_tokens".
	Type constant.InputTokens `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Type, Value are required.

func (BetaInputTokensClearAtLeastParam) MarshalJSON

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

func (*BetaInputTokensClearAtLeastParam) UnmarshalJSON

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

type BetaInputTokensTriggerParam

type BetaInputTokensTriggerParam struct {
	Value int64 `json:"value,required"`
	// This field can be elided, and will marshal its zero value as "input_tokens".
	Type constant.InputTokens `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Type, Value are required.

func (BetaInputTokensTriggerParam) MarshalJSON

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

func (*BetaInputTokensTriggerParam) UnmarshalJSON

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

type BetaInvalidRequestError

type BetaInvalidRequestError struct {
	Message string                       `json:"message,required"`
	Type    constant.InvalidRequestError `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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 BetaIterationsUsage

type BetaIterationsUsage []BetaIterationsUsageItemUnion

type BetaIterationsUsageItemUnion

type BetaIterationsUsageItemUnion struct {
	// This field is from variant [BetaMessageIterationUsage].
	CacheCreation            BetaCacheCreation `json:"cache_creation"`
	CacheCreationInputTokens int64             `json:"cache_creation_input_tokens"`
	CacheReadInputTokens     int64             `json:"cache_read_input_tokens"`
	InputTokens              int64             `json:"input_tokens"`
	OutputTokens             int64             `json:"output_tokens"`
	Type                     string            `json:"type"`
	JSON                     struct {
		CacheCreation            respjson.Field
		CacheCreationInputTokens respjson.Field
		CacheReadInputTokens     respjson.Field
		InputTokens              respjson.Field
		OutputTokens             respjson.Field
		Type                     respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

BetaIterationsUsageItemUnion contains all possible properties and values from BetaMessageIterationUsage, BetaCompactionIterationUsage.

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

func (BetaIterationsUsageItemUnion) AsCompactionIterationUsage

func (u BetaIterationsUsageItemUnion) AsCompactionIterationUsage() (v BetaCompactionIterationUsage)

func (BetaIterationsUsageItemUnion) AsMessageIterationUsage

func (u BetaIterationsUsageItemUnion) AsMessageIterationUsage() (v BetaMessageIterationUsage)

func (BetaIterationsUsageItemUnion) RawJSON

Returns the unmodified JSON received from the API

func (*BetaIterationsUsageItemUnion) UnmarshalJSON

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

type BetaJSONOutputFormatParam

type BetaJSONOutputFormatParam struct {
	// The JSON schema of the format
	Schema map[string]any `json:"schema,omitzero,required"`
	// This field can be elided, and will marshal its zero value as "json_schema".
	Type constant.JSONSchema `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Schema, Type are required.

func BetaJSONSchemaOutputFormat

func BetaJSONSchemaOutputFormat(jsonSchema map[string]any) BetaJSONOutputFormatParam

BetaJSONSchemaOutputFormat creates a BetaJSONOutputFormatParam from a JSON schema map. It transforms the schema to ensure compatibility with Anthropic's JSON schema requirements.

Example:

schema := map[string]any{
    "type": "object",
    "properties": map[string]any{
        "name": map[string]any{"type": "string"},
        "age": map[string]any{"type": "integer", "minimum": 0},
    },
    "required": []string{"name"},
}
outputFormat := BetaJSONSchemaOutputFormat(schema)

msg, _ := client.Beta.Messages.New(ctx, anthropic.BetaMessageNewParams{
    Model: anthropic.Model("claude-sonnet-4-5"),
    Messages: anthropic.F([]anthropic.BetaMessageParam{...}),
    MaxTokens: 1024,
    OutputFormat: outputFormat,
})

func (BetaJSONOutputFormatParam) MarshalJSON

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

func (*BetaJSONOutputFormatParam) UnmarshalJSON

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

type BetaMCPToolConfigParam

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

Configuration for a specific tool in an MCP toolset.

func (BetaMCPToolConfigParam) MarshalJSON

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

func (*BetaMCPToolConfigParam) UnmarshalJSON

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

type BetaMCPToolDefaultConfigParam

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

Default configuration for tools in an MCP toolset.

func (BetaMCPToolDefaultConfigParam) MarshalJSON

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

func (*BetaMCPToolDefaultConfigParam) UnmarshalJSON

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

type BetaMCPToolResultBlock

type BetaMCPToolResultBlock struct {
	Content   BetaMCPToolResultBlockContentUnion `json:"content,required"`
	IsError   bool                               `json:"is_error,required"`
	ToolUseID string                             `json:"tool_use_id,required"`
	Type      constant.MCPToolResult             `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Content     respjson.Field
		IsError     respjson.Field
		ToolUseID   respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaMCPToolResultBlock) RawJSON

func (r BetaMCPToolResultBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (BetaMCPToolResultBlock) ToParam

func (*BetaMCPToolResultBlock) UnmarshalJSON

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

type BetaMCPToolResultBlockContentUnion

type BetaMCPToolResultBlockContentUnion struct {
	// This field will be present if the value is a [string] instead of an object.
	OfString string `json:",inline"`
	// This field will be present if the value is a [[]BetaTextBlock] instead of an
	// object.
	OfBetaMCPToolResultBlockContent []BetaTextBlock `json:",inline"`
	JSON                            struct {
		OfString                        respjson.Field
		OfBetaMCPToolResultBlockContent respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

BetaMCPToolResultBlockContentUnion contains all possible properties and values from [string], [[]BetaTextBlock].

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

If the underlying value is not a json object, one of the following properties will be valid: OfString OfBetaMCPToolResultBlockContent]

func (BetaMCPToolResultBlockContentUnion) AsBetaMCPToolResultBlockContent

func (u BetaMCPToolResultBlockContentUnion) AsBetaMCPToolResultBlockContent() (v []BetaTextBlock)

func (BetaMCPToolResultBlockContentUnion) AsString

func (u BetaMCPToolResultBlockContentUnion) AsString() (v string)

func (BetaMCPToolResultBlockContentUnion) RawJSON

Returns the unmodified JSON received from the API

func (*BetaMCPToolResultBlockContentUnion) UnmarshalJSON

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

type BetaMCPToolUseBlock

type BetaMCPToolUseBlock struct {
	ID    string `json:"id,required"`
	Input any    `json:"input,required"`
	// The name of the MCP tool
	Name string `json:"name,required"`
	// The name of the MCP server
	ServerName string              `json:"server_name,required"`
	Type       constant.MCPToolUse `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Input       respjson.Field
		Name        respjson.Field
		ServerName  respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaMCPToolUseBlock) RawJSON

func (r BetaMCPToolUseBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (BetaMCPToolUseBlock) ToParam

func (*BetaMCPToolUseBlock) UnmarshalJSON

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

type BetaMCPToolUseBlockParam

type BetaMCPToolUseBlockParam struct {
	ID    string `json:"id,required"`
	Input any    `json:"input,omitzero,required"`
	Name  string `json:"name,required"`
	// The name of the MCP server
	ServerName string `json:"server_name,required"`
	// Create a cache control breakpoint at this content block.
	CacheControl BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	// This field can be elided, and will marshal its zero value as "mcp_tool_use".
	Type constant.MCPToolUse `json:"type,required"`
	// contains filtered or unexported fields
}

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

func (BetaMCPToolUseBlockParam) MarshalJSON

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

func (*BetaMCPToolUseBlockParam) UnmarshalJSON

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

type BetaMCPToolsetParam

type BetaMCPToolsetParam struct {
	// Name of the MCP server to configure tools for
	MCPServerName string `json:"mcp_server_name,required"`
	// Configuration overrides for specific tools, keyed by tool name
	Configs map[string]BetaMCPToolConfigParam `json:"configs,omitzero"`
	// Create a cache control breakpoint at this content block.
	CacheControl BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	// Default configuration applied to all tools from this server
	DefaultConfig BetaMCPToolDefaultConfigParam `json:"default_config,omitzero"`
	// This field can be elided, and will marshal its zero value as "mcp_toolset".
	Type constant.MCPToolset `json:"type,required"`
	// contains filtered or unexported fields
}

Configuration for a group of tools from an MCP server.

Allows configuring enabled status and defer_loading for all tools from an MCP server, with optional per-tool overrides.

The properties MCPServerName, Type are required.

func (BetaMCPToolsetParam) MarshalJSON

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

func (*BetaMCPToolsetParam) UnmarshalJSON

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

type BetaMemoryTool20250818CommandUnion

type BetaMemoryTool20250818CommandUnion struct {
	// Any of "view", "create", "str_replace", "insert", "delete", "rename".
	Command string `json:"command"`
	Path    string `json:"path"`
	// This field is from variant [BetaMemoryTool20250818ViewCommand].
	ViewRange []int64 `json:"view_range"`
	// This field is from variant [BetaMemoryTool20250818CreateCommand].
	FileText string `json:"file_text"`
	// This field is from variant [BetaMemoryTool20250818StrReplaceCommand].
	NewStr string `json:"new_str"`
	// This field is from variant [BetaMemoryTool20250818StrReplaceCommand].
	OldStr string `json:"old_str"`
	// This field is from variant [BetaMemoryTool20250818InsertCommand].
	InsertLine int64 `json:"insert_line"`
	// This field is from variant [BetaMemoryTool20250818InsertCommand].
	InsertText string `json:"insert_text"`
	// This field is from variant [BetaMemoryTool20250818RenameCommand].
	NewPath string `json:"new_path"`
	// This field is from variant [BetaMemoryTool20250818RenameCommand].
	OldPath string `json:"old_path"`
	JSON    struct {
		Command    respjson.Field
		Path       respjson.Field
		ViewRange  respjson.Field
		FileText   respjson.Field
		NewStr     respjson.Field
		OldStr     respjson.Field
		InsertLine respjson.Field
		InsertText respjson.Field
		NewPath    respjson.Field
		OldPath    respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

BetaMemoryTool20250818CommandUnion contains all possible properties and values from BetaMemoryTool20250818ViewCommand, BetaMemoryTool20250818CreateCommand, BetaMemoryTool20250818StrReplaceCommand, BetaMemoryTool20250818InsertCommand, BetaMemoryTool20250818DeleteCommand, BetaMemoryTool20250818RenameCommand.

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

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

func (BetaMemoryTool20250818CommandUnion) AsAny

func (u BetaMemoryTool20250818CommandUnion) AsAny() anyBetaMemoryTool20250818Command

Use the following switch statement to find the correct variant

switch variant := BetaMemoryTool20250818CommandUnion.AsAny().(type) {
case anthropic.BetaMemoryTool20250818ViewCommand:
case anthropic.BetaMemoryTool20250818CreateCommand:
case anthropic.BetaMemoryTool20250818StrReplaceCommand:
case anthropic.BetaMemoryTool20250818InsertCommand:
case anthropic.BetaMemoryTool20250818DeleteCommand:
case anthropic.BetaMemoryTool20250818RenameCommand:
default:
  fmt.Errorf("no variant present")
}

func (BetaMemoryTool20250818CommandUnion) AsCreate

func (BetaMemoryTool20250818CommandUnion) AsDelete

func (BetaMemoryTool20250818CommandUnion) AsInsert

func (BetaMemoryTool20250818CommandUnion) AsRename

func (BetaMemoryTool20250818CommandUnion) AsStrReplace

func (BetaMemoryTool20250818CommandUnion) AsView

func (BetaMemoryTool20250818CommandUnion) RawJSON

Returns the unmodified JSON received from the API

func (*BetaMemoryTool20250818CommandUnion) UnmarshalJSON

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

type BetaMemoryTool20250818CreateCommand

type BetaMemoryTool20250818CreateCommand struct {
	// Command type identifier
	Command constant.Create `json:"command,required"`
	// Content to write to the file
	FileText string `json:"file_text,required"`
	// Path where the file should be created
	Path string `json:"path,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Command     respjson.Field
		FileText    respjson.Field
		Path        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaMemoryTool20250818CreateCommand) RawJSON

Returns the unmodified JSON received from the API

func (*BetaMemoryTool20250818CreateCommand) UnmarshalJSON

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

type BetaMemoryTool20250818DeleteCommand

type BetaMemoryTool20250818DeleteCommand struct {
	// Command type identifier
	Command constant.Delete `json:"command,required"`
	// Path to the file or directory to delete
	Path string `json:"path,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Command     respjson.Field
		Path        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaMemoryTool20250818DeleteCommand) RawJSON

Returns the unmodified JSON received from the API

func (*BetaMemoryTool20250818DeleteCommand) UnmarshalJSON

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

type BetaMemoryTool20250818InsertCommand

type BetaMemoryTool20250818InsertCommand struct {
	// Command type identifier
	Command constant.Insert `json:"command,required"`
	// Line number where text should be inserted
	InsertLine int64 `json:"insert_line,required"`
	// Text to insert at the specified line
	InsertText string `json:"insert_text,required"`
	// Path to the file where text should be inserted
	Path string `json:"path,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Command     respjson.Field
		InsertLine  respjson.Field
		InsertText  respjson.Field
		Path        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaMemoryTool20250818InsertCommand) RawJSON

Returns the unmodified JSON received from the API

func (*BetaMemoryTool20250818InsertCommand) UnmarshalJSON

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

type BetaMemoryTool20250818Param

type BetaMemoryTool20250818Param struct {
	// If true, tool will not be included in initial system prompt. Only loaded when
	// returned via tool_reference from tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// When true, guarantees schema validation on tool names and inputs
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// Create a cache control breakpoint at this content block.
	CacheControl  BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	InputExamples []map[string]any               `json:"input_examples,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 "memory".
	Name constant.Memory `json:"name,required"`
	// This field can be elided, and will marshal its zero value as "memory_20250818".
	Type constant.Memory20250818 `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Name, Type are required.

func (BetaMemoryTool20250818Param) MarshalJSON

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

func (*BetaMemoryTool20250818Param) UnmarshalJSON

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

type BetaMemoryTool20250818RenameCommand

type BetaMemoryTool20250818RenameCommand struct {
	// Command type identifier
	Command constant.Rename `json:"command,required"`
	// New path for the file or directory
	NewPath string `json:"new_path,required"`
	// Current path of the file or directory
	OldPath string `json:"old_path,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Command     respjson.Field
		NewPath     respjson.Field
		OldPath     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaMemoryTool20250818RenameCommand) RawJSON

Returns the unmodified JSON received from the API

func (*BetaMemoryTool20250818RenameCommand) UnmarshalJSON

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

type BetaMemoryTool20250818StrReplaceCommand

type BetaMemoryTool20250818StrReplaceCommand struct {
	// Command type identifier
	Command constant.StrReplace `json:"command,required"`
	// Text to replace with
	NewStr string `json:"new_str,required"`
	// Text to search for and replace
	OldStr string `json:"old_str,required"`
	// Path to the file where text should be replaced
	Path string `json:"path,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Command     respjson.Field
		NewStr      respjson.Field
		OldStr      respjson.Field
		Path        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaMemoryTool20250818StrReplaceCommand) RawJSON

Returns the unmodified JSON received from the API

func (*BetaMemoryTool20250818StrReplaceCommand) UnmarshalJSON

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

type BetaMemoryTool20250818ViewCommand

type BetaMemoryTool20250818ViewCommand struct {
	// Command type identifier
	Command constant.View `json:"command,required"`
	// Path to directory or file to view
	Path string `json:"path,required"`
	// Optional line range for viewing specific lines
	ViewRange []int64 `json:"view_range"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Command     respjson.Field
		Path        respjson.Field
		ViewRange   respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaMemoryTool20250818ViewCommand) RawJSON

Returns the unmodified JSON received from the API

func (*BetaMemoryTool20250818ViewCommand) UnmarshalJSON

func (r *BetaMemoryTool20250818ViewCommand) 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"`
	// Information about the container used in the request (for the code execution
	// tool)
	Container BetaContainer `json:"container,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"`
	// Context management response.
	//
	// Information about context management strategies applied during the request.
	ContextManagement BetaContextManagementResponse `json:"context_management,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
	//   - `"pause_turn"`: we paused a long-running turn. You may provide the response
	//     back as-is in a subsequent request to let the model continue.
	//   - `"refusal"`: when streaming classifiers intervene to handle potential policy
	//     violations
	//
	// 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", "pause_turn",
	// "compaction", "refusal", "model_context_window_exceeded".
	StopReason BetaStopReason `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"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID                respjson.Field
		Container         respjson.Field
		Content           respjson.Field
		ContextManagement respjson.Field
		Model             respjson.Field
		Role              respjson.Field
		StopReason        respjson.Field
		StopSequence      respjson.Field
		Type              respjson.Field
		Usage             respjson.Field
		ExtraFields       map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (*BetaMessage) Accumulate

func (acc *BetaMessage) Accumulate(event BetaRawMessageStreamEventUnion) 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 (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"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID                respjson.Field
		ArchivedAt        respjson.Field
		CancelInitiatedAt respjson.Field
		CreatedAt         respjson.Field
		EndedAt           respjson.Field
		ExpiresAt         respjson.Field
		ProcessingStatus  respjson.Field
		RequestCounts     respjson.Field
		ResultsURL        respjson.Field
		Type              respjson.Field
		ExtraFields       map[string]respjson.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
}

type BetaMessageBatchCanceledResult

type BetaMessageBatchCanceledResult struct {
	Type constant.Canceled `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.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
}

type BetaMessageBatchErroredResult

type BetaMessageBatchErroredResult struct {
	Error BetaErrorResponse `json:"error,required"`
	Type  constant.Errored  `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Error       respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.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
}

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"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CustomID    respjson.Field
		Result      respjson.Field
		ExtraFields map[string]respjson.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) URLQuery

func (r BetaMessageBatchListParams) URLQuery() (v url.Values, err error)

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) MarshalJSON

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

func (*BetaMessageBatchNewParams) UnmarshalJSON

func (r *BetaMessageBatchNewParams) UnmarshalJSON(data []byte) 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](https://docs.claude.com/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) MarshalJSON

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

func (*BetaMessageBatchNewParamsRequest) UnmarshalJSON

func (r *BetaMessageBatchNewParamsRequest) UnmarshalJSON(data []byte) 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.claude.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" }] }
	// “`
	//
	// See [input examples](https://docs.claude.com/en/api/messages-examples).
	//
	// Note that if you want to include a
	// [system prompt](https://docs.claude.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.
	//
	// There is a limit of 100,000 messages in a single request.
	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"`
	// Specifies the geographic region for inference processing. If not specified, the
	// workspace's `default_inference_geo` is used.
	InferenceGeo param.Opt[string] `json:"inference_geo,omitzero"`
	// Whether to incrementally stream the response using server-sent events.
	//
	// See [streaming](https://docs.claude.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"`
	// Container identifier for reuse across requests.
	Container BetaMessageBatchNewParamsRequestParamsContainerUnion `json:"container,omitzero"`
	// The inference speed mode for this request. `"fast"` enables high
	// output-tokens-per-second inference.
	//
	// Any of "standard", "fast".
	Speed string `json:"speed,omitzero"`
	// Top-level cache control automatically applies a cache_control marker to the last
	// cacheable block in the request.
	CacheControl BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	// Context management configuration.
	//
	// This allows you to control how Claude manages context across multiple requests,
	// such as whether to clear function results or not.
	ContextManagement BetaContextManagementConfigParam `json:"context_management,omitzero"`
	// MCP servers to be utilized in this request
	MCPServers []BetaRequestMCPServerURLDefinitionParam `json:"mcp_servers,omitzero"`
	// An object describing metadata about the request.
	Metadata BetaMetadataParam `json:"metadata,omitzero"`
	// Configuration options for the model's output, such as the output format.
	OutputConfig BetaOutputConfigParam `json:"output_config,omitzero"`
	// Deprecated: Use `output_config.format` instead. See
	// [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)
	//
	// A schema to specify Claude's output format in responses. This parameter will be
	// removed in a future release.
	//
	// Deprecated: deprecated
	OutputFormat BetaJSONOutputFormatParam `json:"output_format,omitzero"`
	// Determines whether to use priority capacity (if available) or standard capacity
	// for this request.
	//
	// Anthropic offers different levels of service for your API requests. See
	// [service-tiers](https://docs.claude.com/en/api/service-tiers) for details.
	//
	// Any of "auto", "standard_only".
	ServiceTier string `json:"service_tier,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.claude.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.claude.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.
	//
	// There are two types of tools: **client tools** and **server tools**. The
	// behavior described below applies to client tools. For
	// [server tools](https://docs.claude.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
	// see their individual documentation as each has its own behavior (e.g., the
	// [web search tool](https://docs.claude.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
	//
	// 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.claude.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](https://docs.claude.com/en/api/messages) for full documentation on available parameters.

The properties MaxTokens, Messages, Model are required.

func (BetaMessageBatchNewParamsRequestParams) MarshalJSON

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

func (*BetaMessageBatchNewParamsRequestParams) UnmarshalJSON

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

type BetaMessageBatchNewParamsRequestParamsContainerUnion

type BetaMessageBatchNewParamsRequestParamsContainerUnion struct {
	OfContainers *BetaContainerParams `json:",omitzero,inline"`
	OfString     param.Opt[string]    `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 (BetaMessageBatchNewParamsRequestParamsContainerUnion) MarshalJSON

func (*BetaMessageBatchNewParamsRequestParamsContainerUnion) UnmarshalJSON

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"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Canceled    respjson.Field
		Errored     respjson.Field
		Expired     respjson.Field
		Processing  respjson.Field
		Succeeded   respjson.Field
		ExtraFields map[string]respjson.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 respjson.Field
		Type    respjson.Field
		Error   respjson.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() anyBetaMessageBatchResult

Use the following switch statement to find the correct variant

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

func (BetaMessageBatchResultUnion) AsCanceled

func (BetaMessageBatchResultUnion) AsErrored

func (BetaMessageBatchResultUnion) AsExpired

func (BetaMessageBatchResultUnion) AsSucceeded

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
}

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](https://docs.claude.com/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](https://docs.claude.com/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](https://docs.claude.com/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](https://docs.claude.com/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](https://docs.claude.com/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](https://docs.claude.com/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](https://docs.claude.com/en/docs/build-with-claude/batch-processing)

type BetaMessageBatchSucceededResult

type BetaMessageBatchSucceededResult struct {
	Message BetaMessage        `json:"message,required"`
	Type    constant.Succeeded `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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" }] }
	// “`
	//
	// See [input examples](https://docs.claude.com/en/api/messages-examples).
	//
	// Note that if you want to include a
	// [system prompt](https://docs.claude.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.
	//
	// There is a limit of 100,000 messages in a single request.
	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"`
	// The inference speed mode for this request. `"fast"` enables high
	// output-tokens-per-second inference.
	//
	// Any of "standard", "fast".
	Speed BetaMessageCountTokensParamsSpeed `json:"speed,omitzero"`
	// Top-level cache control automatically applies a cache_control marker to the last
	// cacheable block in the request.
	CacheControl BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	// Context management configuration.
	//
	// This allows you to control how Claude manages context across multiple requests,
	// such as whether to clear function results or not.
	ContextManagement BetaContextManagementConfigParam `json:"context_management,omitzero"`
	// MCP servers to be utilized in this request
	MCPServers []BetaRequestMCPServerURLDefinitionParam `json:"mcp_servers,omitzero"`
	// Configuration options for the model's output, such as the output format.
	OutputConfig BetaOutputConfigParam `json:"output_config,omitzero"`
	// Deprecated: Use `output_config.format` instead. See
	// [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)
	//
	// A schema to specify Claude's output format in responses. This parameter will be
	// removed in a future release.
	OutputFormat BetaJSONOutputFormatParam `json:"output_format,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.claude.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.claude.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.
	//
	// There are two types of tools: **client tools** and **server tools**. The
	// behavior described below applies to client tools. For
	// [server tools](https://docs.claude.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
	// see their individual documentation as each has its own behavior (e.g., the
	// [web search tool](https://docs.claude.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
	//
	// 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.claude.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) MarshalJSON

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

func (*BetaMessageCountTokensParams) UnmarshalJSON

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

type BetaMessageCountTokensParamsSpeed

type BetaMessageCountTokensParamsSpeed string

The inference speed mode for this request. `"fast"` enables high output-tokens-per-second inference.

const (
	BetaMessageCountTokensParamsSpeedStandard BetaMessageCountTokensParamsSpeed = "standard"
	BetaMessageCountTokensParamsSpeedFast     BetaMessageCountTokensParamsSpeed = "fast"
)

type BetaMessageCountTokensParamsSystemUnion

type BetaMessageCountTokensParamsSystemUnion struct {
	OfString             param.Opt[string]    `json:",omitzero,inline"`
	OfBetaTextBlockArray []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) MarshalJSON

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

func (*BetaMessageCountTokensParamsSystemUnion) UnmarshalJSON

func (u *BetaMessageCountTokensParamsSystemUnion) UnmarshalJSON(data []byte) error

type BetaMessageCountTokensParamsToolUnion

type BetaMessageCountTokensParamsToolUnion struct {
	OfTool                        *BetaToolParam                        `json:",omitzero,inline"`
	OfBashTool20241022            *BetaToolBash20241022Param            `json:",omitzero,inline"`
	OfBashTool20250124            *BetaToolBash20250124Param            `json:",omitzero,inline"`
	OfCodeExecutionTool20250522   *BetaCodeExecutionTool20250522Param   `json:",omitzero,inline"`
	OfCodeExecutionTool20250825   *BetaCodeExecutionTool20250825Param   `json:",omitzero,inline"`
	OfCodeExecutionTool20260120   *BetaCodeExecutionTool20260120Param   `json:",omitzero,inline"`
	OfComputerUseTool20241022     *BetaToolComputerUse20241022Param     `json:",omitzero,inline"`
	OfMemoryTool20250818          *BetaMemoryTool20250818Param          `json:",omitzero,inline"`
	OfComputerUseTool20250124     *BetaToolComputerUse20250124Param     `json:",omitzero,inline"`
	OfTextEditor20241022          *BetaToolTextEditor20241022Param      `json:",omitzero,inline"`
	OfComputerUseTool20251124     *BetaToolComputerUse20251124Param     `json:",omitzero,inline"`
	OfTextEditor20250124          *BetaToolTextEditor20250124Param      `json:",omitzero,inline"`
	OfTextEditor20250429          *BetaToolTextEditor20250429Param      `json:",omitzero,inline"`
	OfTextEditor20250728          *BetaToolTextEditor20250728Param      `json:",omitzero,inline"`
	OfWebSearchTool20250305       *BetaWebSearchTool20250305Param       `json:",omitzero,inline"`
	OfWebFetchTool20250910        *BetaWebFetchTool20250910Param        `json:",omitzero,inline"`
	OfWebSearchTool20260209       *BetaWebSearchTool20260209Param       `json:",omitzero,inline"`
	OfWebFetchTool20260209        *BetaWebFetchTool20260209Param        `json:",omitzero,inline"`
	OfToolSearchToolBm25_20251119 *BetaToolSearchToolBm25_20251119Param `json:",omitzero,inline"`
	OfToolSearchToolRegex20251119 *BetaToolSearchToolRegex20251119Param `json:",omitzero,inline"`
	OfMCPToolset                  *BetaMCPToolsetParam                  `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) GetAllowedCallers

func (u BetaMessageCountTokensParamsToolUnion) GetAllowedCallers() []string

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

func (BetaMessageCountTokensParamsToolUnion) GetAllowedDomains

func (u BetaMessageCountTokensParamsToolUnion) GetAllowedDomains() []string

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

func (BetaMessageCountTokensParamsToolUnion) GetBlockedDomains

func (u BetaMessageCountTokensParamsToolUnion) GetBlockedDomains() []string

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

func (BetaMessageCountTokensParamsToolUnion) GetCacheControl

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

func (BetaMessageCountTokensParamsToolUnion) GetCitations

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

func (BetaMessageCountTokensParamsToolUnion) GetConfigs

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

func (BetaMessageCountTokensParamsToolUnion) GetDefaultConfig

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

func (BetaMessageCountTokensParamsToolUnion) GetDeferLoading

func (u BetaMessageCountTokensParamsToolUnion) GetDeferLoading() *bool

Returns a pointer to the underlying variant's 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) GetEagerInputStreaming

func (u BetaMessageCountTokensParamsToolUnion) GetEagerInputStreaming() *bool

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

func (BetaMessageCountTokensParamsToolUnion) GetEnableZoom

func (u BetaMessageCountTokensParamsToolUnion) GetEnableZoom() *bool

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

func (BetaMessageCountTokensParamsToolUnion) GetInputExamples

func (u BetaMessageCountTokensParamsToolUnion) GetInputExamples() []map[string]any

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

func (BetaMessageCountTokensParamsToolUnion) GetInputSchema

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

func (BetaMessageCountTokensParamsToolUnion) GetMCPServerName

func (u BetaMessageCountTokensParamsToolUnion) GetMCPServerName() *string

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

func (BetaMessageCountTokensParamsToolUnion) GetMaxCharacters

func (u BetaMessageCountTokensParamsToolUnion) GetMaxCharacters() *int64

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

func (BetaMessageCountTokensParamsToolUnion) GetMaxContentTokens

func (u BetaMessageCountTokensParamsToolUnion) GetMaxContentTokens() *int64

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

func (BetaMessageCountTokensParamsToolUnion) GetMaxUses

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) GetStrict

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) GetUserLocation

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

func (BetaMessageCountTokensParamsToolUnion) MarshalJSON

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

func (*BetaMessageCountTokensParamsToolUnion) UnmarshalJSON

func (u *BetaMessageCountTokensParamsToolUnion) UnmarshalJSON(data []byte) error

type BetaMessageDeltaUsage

type BetaMessageDeltaUsage struct {
	// The cumulative number of input tokens used to create the cache entry.
	CacheCreationInputTokens int64 `json:"cache_creation_input_tokens,required"`
	// The cumulative number of input tokens read from the cache.
	CacheReadInputTokens int64 `json:"cache_read_input_tokens,required"`
	// The cumulative number of input tokens which were used.
	InputTokens int64 `json:"input_tokens,required"`
	// Per-iteration token usage breakdown.
	//
	// Each entry represents one sampling iteration, with its own input/output token
	// counts and cache statistics. This allows you to:
	//
	// - Determine which iterations exceeded long context thresholds (>=200k tokens)
	// - Calculate the true context window size from the last iteration
	// - Understand token accumulation across server-side tool use loops
	Iterations BetaIterationsUsage `json:"iterations,required"`
	// The cumulative number of output tokens which were used.
	OutputTokens int64 `json:"output_tokens,required"`
	// The number of server tool requests.
	ServerToolUse BetaServerToolUsage `json:"server_tool_use,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CacheCreationInputTokens respjson.Field
		CacheReadInputTokens     respjson.Field
		InputTokens              respjson.Field
		Iterations               respjson.Field
		OutputTokens             respjson.Field
		ServerToolUse            respjson.Field
		ExtraFields              map[string]respjson.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 BetaMessageIterationUsage

type BetaMessageIterationUsage struct {
	// Breakdown of cached tokens by TTL
	CacheCreation BetaCacheCreation `json:"cache_creation,required"`
	// 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"`
	// Usage for a sampling iteration
	Type constant.Message `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CacheCreation            respjson.Field
		CacheCreationInputTokens respjson.Field
		CacheReadInputTokens     respjson.Field
		InputTokens              respjson.Field
		OutputTokens             respjson.Field
		Type                     respjson.Field
		ExtraFields              map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Token usage for a sampling iteration.

func (BetaMessageIterationUsage) RawJSON

func (r BetaMessageIterationUsage) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaMessageIterationUsage) UnmarshalJSON

func (r *BetaMessageIterationUsage) 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.claude.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" }] }
	// “`
	//
	// See [input examples](https://docs.claude.com/en/api/messages-examples).
	//
	// Note that if you want to include a
	// [system prompt](https://docs.claude.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.
	//
	// There is a limit of 100,000 messages in a single request.
	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"`
	// Specifies the geographic region for inference processing. If not specified, the
	// workspace's `default_inference_geo` is used.
	InferenceGeo param.Opt[string] `json:"inference_geo,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"`
	// Container identifier for reuse across requests.
	Container BetaMessageNewParamsContainerUnion `json:"container,omitzero"`
	// The inference speed mode for this request. `"fast"` enables high
	// output-tokens-per-second inference.
	//
	// Any of "standard", "fast".
	Speed BetaMessageNewParamsSpeed `json:"speed,omitzero"`
	// Top-level cache control automatically applies a cache_control marker to the last
	// cacheable block in the request.
	CacheControl BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	// Context management configuration.
	//
	// This allows you to control how Claude manages context across multiple requests,
	// such as whether to clear function results or not.
	ContextManagement BetaContextManagementConfigParam `json:"context_management,omitzero"`
	// MCP servers to be utilized in this request
	MCPServers []BetaRequestMCPServerURLDefinitionParam `json:"mcp_servers,omitzero"`
	// An object describing metadata about the request.
	Metadata BetaMetadataParam `json:"metadata,omitzero"`
	// Configuration options for the model's output, such as the output format.
	OutputConfig BetaOutputConfigParam `json:"output_config,omitzero"`
	// Deprecated: Use `output_config.format` instead. See
	// [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)
	//
	// A schema to specify Claude's output format in responses. This parameter will be
	// removed in a future release.
	OutputFormat BetaJSONOutputFormatParam `json:"output_format,omitzero"`
	// Determines whether to use priority capacity (if available) or standard capacity
	// for this request.
	//
	// Anthropic offers different levels of service for your API requests. See
	// [service-tiers](https://docs.claude.com/en/api/service-tiers) for details.
	//
	// Any of "auto", "standard_only".
	ServiceTier BetaMessageNewParamsServiceTier `json:"service_tier,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.claude.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.claude.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.
	//
	// There are two types of tools: **client tools** and **server tools**. The
	// behavior described below applies to client tools. For
	// [server tools](https://docs.claude.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
	// see their individual documentation as each has its own behavior (e.g., the
	// [web search tool](https://docs.claude.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
	//
	// 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.claude.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) MarshalJSON

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

func (*BetaMessageNewParams) UnmarshalJSON

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

type BetaMessageNewParamsContainerUnion

type BetaMessageNewParamsContainerUnion struct {
	OfContainers *BetaContainerParams `json:",omitzero,inline"`
	OfString     param.Opt[string]    `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 (BetaMessageNewParamsContainerUnion) MarshalJSON

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

func (*BetaMessageNewParamsContainerUnion) UnmarshalJSON

func (u *BetaMessageNewParamsContainerUnion) UnmarshalJSON(data []byte) error

type BetaMessageNewParamsServiceTier

type BetaMessageNewParamsServiceTier string

Determines whether to use priority capacity (if available) or standard capacity for this request.

Anthropic offers different levels of service for your API requests. See [service-tiers](https://docs.claude.com/en/api/service-tiers) for details.

const (
	BetaMessageNewParamsServiceTierAuto         BetaMessageNewParamsServiceTier = "auto"
	BetaMessageNewParamsServiceTierStandardOnly BetaMessageNewParamsServiceTier = "standard_only"
)

type BetaMessageNewParamsSpeed

type BetaMessageNewParamsSpeed string

The inference speed mode for this request. `"fast"` enables high output-tokens-per-second inference.

const (
	BetaMessageNewParamsSpeedStandard BetaMessageNewParamsSpeed = "standard"
	BetaMessageNewParamsSpeedFast     BetaMessageNewParamsSpeed = "fast"
)

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 NewBetaUserMessage

func NewBetaUserMessage(blocks ...BetaContentBlockParamUnion) BetaMessageParam

func (BetaMessageParam) MarshalJSON

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

func (*BetaMessageParam) UnmarshalJSON

func (r *BetaMessageParam) UnmarshalJSON(data []byte) 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](https://docs.claude.com/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](https://docs.claude.com/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](https://docs.claude.com/en/docs/initial-setup)

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

func (*BetaMessageService) NewToolRunner

func (r *BetaMessageService) NewToolRunner(tools []BetaTool, params BetaToolRunnerParams, opts ...option.RequestOption) *BetaToolRunner

NewToolRunner creates a BetaToolRunner that automatically handles the loop between the model generating tool calls, executing those tool calls, and sending the results back to the model until a final answer is produced or the maximum number of iterations is reached.

func (*BetaMessageService) NewToolRunnerStreaming

func (r *BetaMessageService) NewToolRunnerStreaming(tools []BetaTool, params BetaToolRunnerParams, opts ...option.RequestOption) *BetaToolRunnerStreaming

NewToolRunnerStreaming creates a BetaToolRunnerStreaming that automatically handles the loop between the model generating tool calls, executing those tool calls, and sending the results back to the model using streaming API calls until a final answer is produced or the maximum number of iterations is reached.

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 {
	// Information about context management applied to the message.
	ContextManagement BetaCountTokensContextManagementResponse `json:"context_management,required"`
	// The total number of tokens across the provided list of messages, system prompt,
	// and tools.
	InputTokens int64 `json:"input_tokens,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ContextManagement respjson.Field
		InputTokens       respjson.Field
		ExtraFields       map[string]respjson.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) MarshalJSON

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

func (*BetaMetadataParam) UnmarshalJSON

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

type BetaModelGetParams

type BetaModelGetParams 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
}

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"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		CreatedAt   respjson.Field
		DisplayName respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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:"-"`
	// 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 (BetaModelListParams) URLQuery

func (r BetaModelListParams) URLQuery() (v url.Values, err error)

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, query BetaModelGetParams, 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"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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 BetaOutputConfigEffort

type BetaOutputConfigEffort string

All possible effort levels.

const (
	BetaOutputConfigEffortLow    BetaOutputConfigEffort = "low"
	BetaOutputConfigEffortMedium BetaOutputConfigEffort = "medium"
	BetaOutputConfigEffortHigh   BetaOutputConfigEffort = "high"
	BetaOutputConfigEffortMax    BetaOutputConfigEffort = "max"
)

type BetaOutputConfigParam

type BetaOutputConfigParam struct {
	// All possible effort levels.
	//
	// Any of "low", "medium", "high", "max".
	Effort BetaOutputConfigEffort `json:"effort,omitzero"`
	// A schema to specify Claude's output format in responses. See
	// [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)
	Format BetaJSONOutputFormatParam `json:"format,omitzero"`
	// contains filtered or unexported fields
}

func (BetaOutputConfigParam) MarshalJSON

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

func (*BetaOutputConfigParam) UnmarshalJSON

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

type BetaOverloadedError

type BetaOverloadedError struct {
	Message string                   `json:"message,required"`
	Type    constant.OverloadedError `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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 BetaPlainTextSource

type BetaPlainTextSource struct {
	Data      string             `json:"data,required"`
	MediaType constant.TextPlain `json:"media_type,required"`
	Type      constant.Text      `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		MediaType   respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaPlainTextSource) RawJSON

func (r BetaPlainTextSource) RawJSON() string

Returns the unmodified JSON received from the API

func (BetaPlainTextSource) ToParam

ToParam converts this BetaPlainTextSource to a BetaPlainTextSourceParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with BetaPlainTextSourceParam.Overrides()

func (*BetaPlainTextSource) UnmarshalJSON

func (r *BetaPlainTextSource) 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) MarshalJSON

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

func (*BetaPlainTextSourceParam) UnmarshalJSON

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

type BetaRateLimitError

type BetaRateLimitError struct {
	Message string                  `json:"message,required"`
	Type    constant.RateLimitError `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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 BetaRawContentBlockDeltaUnion `json:"delta,required"`
	Index int64                         `json:"index,required"`
	Type  constant.ContentBlockDelta    `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Delta       respjson.Field
		Index       respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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 BetaRawContentBlockDeltaUnion

type BetaRawContentBlockDeltaUnion struct {
	// This field is from variant [BetaTextDelta].
	Text string `json:"text"`
	// Any of "text_delta", "input_json_delta", "citations_delta", "thinking_delta",
	// "signature_delta", "compaction_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"`
	// This field is from variant [BetaCompactionContentBlockDelta].
	Content string `json:"content"`
	JSON    struct {
		Text        respjson.Field
		Type        respjson.Field
		PartialJSON respjson.Field
		Citation    respjson.Field
		Thinking    respjson.Field
		Signature   respjson.Field
		Content     respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

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

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

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

func (BetaRawContentBlockDeltaUnion) AsAny

func (u BetaRawContentBlockDeltaUnion) AsAny() anyBetaRawContentBlockDelta

Use the following switch statement to find the correct variant

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

func (BetaRawContentBlockDeltaUnion) AsCitationsDelta

func (u BetaRawContentBlockDeltaUnion) AsCitationsDelta() (v BetaCitationsDelta)

func (BetaRawContentBlockDeltaUnion) AsCompactionDelta

func (BetaRawContentBlockDeltaUnion) AsInputJSONDelta

func (u BetaRawContentBlockDeltaUnion) AsInputJSONDelta() (v BetaInputJSONDelta)

func (BetaRawContentBlockDeltaUnion) AsSignatureDelta

func (u BetaRawContentBlockDeltaUnion) AsSignatureDelta() (v BetaSignatureDelta)

func (BetaRawContentBlockDeltaUnion) AsTextDelta

func (u BetaRawContentBlockDeltaUnion) AsTextDelta() (v BetaTextDelta)

func (BetaRawContentBlockDeltaUnion) AsThinkingDelta

func (u BetaRawContentBlockDeltaUnion) AsThinkingDelta() (v BetaThinkingDelta)

func (BetaRawContentBlockDeltaUnion) RawJSON

Returns the unmodified JSON received from the API

func (*BetaRawContentBlockDeltaUnion) UnmarshalJSON

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

type BetaRawContentBlockStartEvent

type BetaRawContentBlockStartEvent struct {
	// Response model for a file uploaded to the container.
	ContentBlock BetaRawContentBlockStartEventContentBlockUnion `json:"content_block,required"`
	Index        int64                                          `json:"index,required"`
	Type         constant.ContentBlockStart                     `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ContentBlock respjson.Field
		Index        respjson.Field
		Type         respjson.Field
		ExtraFields  map[string]respjson.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", "thinking", "redacted_thinking", "tool_use", "server_tool_use",
	// "web_search_tool_result", "web_fetch_tool_result", "code_execution_tool_result",
	// "bash_code_execution_tool_result", "text_editor_code_execution_tool_result",
	// "tool_search_tool_result", "mcp_tool_use", "mcp_tool_result",
	// "container_upload", "compaction".
	Type string `json:"type"`
	// 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"`
	ID    string `json:"id"`
	Input any    `json:"input"`
	Name  string `json:"name"`
	// This field is a union of [BetaToolUseBlockCallerUnion],
	// [BetaServerToolUseBlockCallerUnion], [BetaWebSearchToolResultBlockCallerUnion],
	// [BetaWebFetchToolResultBlockCallerUnion]
	Caller BetaRawContentBlockStartEventContentBlockUnionCaller `json:"caller"`
	// This field is a union of [BetaWebSearchToolResultBlockContentUnion],
	// [BetaWebFetchToolResultBlockContentUnion],
	// [BetaCodeExecutionToolResultBlockContentUnion],
	// [BetaBashCodeExecutionToolResultBlockContentUnion],
	// [BetaTextEditorCodeExecutionToolResultBlockContentUnion],
	// [BetaToolSearchToolResultBlockContentUnion],
	// [BetaMCPToolResultBlockContentUnion], [string]
	Content   BetaRawContentBlockStartEventContentBlockUnionContent `json:"content"`
	ToolUseID string                                                `json:"tool_use_id"`
	// This field is from variant [BetaMCPToolUseBlock].
	ServerName string `json:"server_name"`
	// This field is from variant [BetaMCPToolResultBlock].
	IsError bool `json:"is_error"`
	// This field is from variant [BetaContainerUploadBlock].
	FileID string `json:"file_id"`
	JSON   struct {
		Citations  respjson.Field
		Text       respjson.Field
		Type       respjson.Field
		Signature  respjson.Field
		Thinking   respjson.Field
		Data       respjson.Field
		ID         respjson.Field
		Input      respjson.Field
		Name       respjson.Field
		Caller     respjson.Field
		Content    respjson.Field
		ToolUseID  respjson.Field
		ServerName respjson.Field
		IsError    respjson.Field
		FileID     respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

BetaRawContentBlockStartEventContentBlockUnion contains all possible properties and values from BetaTextBlock, BetaThinkingBlock, BetaRedactedThinkingBlock, BetaToolUseBlock, BetaServerToolUseBlock, BetaWebSearchToolResultBlock, BetaWebFetchToolResultBlock, BetaCodeExecutionToolResultBlock, BetaBashCodeExecutionToolResultBlock, BetaTextEditorCodeExecutionToolResultBlock, BetaToolSearchToolResultBlock, BetaMCPToolUseBlock, BetaMCPToolResultBlock, BetaContainerUploadBlock, BetaCompactionBlock.

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

func (u BetaRawContentBlockStartEventContentBlockUnion) AsAny() anyBetaRawContentBlockStartEventContentBlock

Use the following switch statement to find the correct variant

switch variant := BetaRawContentBlockStartEventContentBlockUnion.AsAny().(type) {
case anthropic.BetaTextBlock:
case anthropic.BetaThinkingBlock:
case anthropic.BetaRedactedThinkingBlock:
case anthropic.BetaToolUseBlock:
case anthropic.BetaServerToolUseBlock:
case anthropic.BetaWebSearchToolResultBlock:
case anthropic.BetaWebFetchToolResultBlock:
case anthropic.BetaCodeExecutionToolResultBlock:
case anthropic.BetaBashCodeExecutionToolResultBlock:
case anthropic.BetaTextEditorCodeExecutionToolResultBlock:
case anthropic.BetaToolSearchToolResultBlock:
case anthropic.BetaMCPToolUseBlock:
case anthropic.BetaMCPToolResultBlock:
case anthropic.BetaContainerUploadBlock:
case anthropic.BetaCompactionBlock:
default:
  fmt.Errorf("no variant present")
}

func (BetaRawContentBlockStartEventContentBlockUnion) AsBashCodeExecutionToolResult

func (BetaRawContentBlockStartEventContentBlockUnion) AsCodeExecutionToolResult

func (BetaRawContentBlockStartEventContentBlockUnion) AsCompaction

func (BetaRawContentBlockStartEventContentBlockUnion) AsContainerUpload

func (BetaRawContentBlockStartEventContentBlockUnion) AsMCPToolResult

func (BetaRawContentBlockStartEventContentBlockUnion) AsMCPToolUse

func (BetaRawContentBlockStartEventContentBlockUnion) AsRedactedThinking

func (BetaRawContentBlockStartEventContentBlockUnion) AsServerToolUse

func (BetaRawContentBlockStartEventContentBlockUnion) AsText

func (BetaRawContentBlockStartEventContentBlockUnion) AsTextEditorCodeExecutionToolResult

func (BetaRawContentBlockStartEventContentBlockUnion) AsThinking

func (BetaRawContentBlockStartEventContentBlockUnion) AsToolSearchToolResult

func (BetaRawContentBlockStartEventContentBlockUnion) AsToolUse

func (BetaRawContentBlockStartEventContentBlockUnion) AsWebFetchToolResult

func (BetaRawContentBlockStartEventContentBlockUnion) AsWebSearchToolResult

func (BetaRawContentBlockStartEventContentBlockUnion) RawJSON

Returns the unmodified JSON received from the API

func (*BetaRawContentBlockStartEventContentBlockUnion) UnmarshalJSON

type BetaRawContentBlockStartEventContentBlockUnionCaller

type BetaRawContentBlockStartEventContentBlockUnionCaller struct {
	Type   string `json:"type"`
	ToolID string `json:"tool_id"`
	JSON   struct {
		Type   respjson.Field
		ToolID respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

BetaRawContentBlockStartEventContentBlockUnionCaller is an implicit subunion of BetaRawContentBlockStartEventContentBlockUnion. BetaRawContentBlockStartEventContentBlockUnionCaller provides convenient access to the sub-properties of the union.

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

func (*BetaRawContentBlockStartEventContentBlockUnionCaller) UnmarshalJSON

type BetaRawContentBlockStartEventContentBlockUnionContent

type BetaRawContentBlockStartEventContentBlockUnionContent struct {
	// This field will be present if the value is a [[]BetaWebSearchResultBlock]
	// instead of an object.
	OfBetaWebSearchResultBlockArray []BetaWebSearchResultBlock `json:",inline"`
	// This field will be present if the value is a [string] instead of an object.
	OfString string `json:",inline"`
	// This field will be present if the value is a [[]BetaTextBlock] instead of an
	// object.
	OfBetaMCPToolResultBlockContent []BetaTextBlock `json:",inline"`
	ErrorCode                       string          `json:"error_code"`
	Type                            string          `json:"type"`
	// This field is a union of [BetaDocumentBlock], [[]BetaCodeExecutionOutputBlock],
	// [[]BetaCodeExecutionOutputBlock], [[]BetaBashCodeExecutionOutputBlock], [string]
	Content BetaRawContentBlockStartEventContentBlockUnionContentContent `json:"content"`
	// This field is from variant [BetaWebFetchToolResultBlockContentUnion].
	RetrievedAt string `json:"retrieved_at"`
	// This field is from variant [BetaWebFetchToolResultBlockContentUnion].
	URL        string `json:"url"`
	ReturnCode int64  `json:"return_code"`
	Stderr     string `json:"stderr"`
	Stdout     string `json:"stdout"`
	// This field is from variant [BetaCodeExecutionToolResultBlockContentUnion].
	EncryptedStdout string `json:"encrypted_stdout"`
	ErrorMessage    string `json:"error_message"`
	// This field is from variant
	// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].
	FileType BetaTextEditorCodeExecutionViewResultBlockFileType `json:"file_type"`
	// This field is from variant
	// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].
	NumLines int64 `json:"num_lines"`
	// This field is from variant
	// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].
	StartLine int64 `json:"start_line"`
	// This field is from variant
	// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].
	TotalLines int64 `json:"total_lines"`
	// This field is from variant
	// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].
	IsFileUpdate bool `json:"is_file_update"`
	// This field is from variant
	// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].
	Lines []string `json:"lines"`
	// This field is from variant
	// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].
	NewLines int64 `json:"new_lines"`
	// This field is from variant
	// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].
	NewStart int64 `json:"new_start"`
	// This field is from variant
	// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].
	OldLines int64 `json:"old_lines"`
	// This field is from variant
	// [BetaTextEditorCodeExecutionToolResultBlockContentUnion].
	OldStart int64 `json:"old_start"`
	// This field is from variant [BetaToolSearchToolResultBlockContentUnion].
	ToolReferences []BetaToolReferenceBlock `json:"tool_references"`
	JSON           struct {
		OfBetaWebSearchResultBlockArray respjson.Field
		OfString                        respjson.Field
		OfBetaMCPToolResultBlockContent respjson.Field
		ErrorCode                       respjson.Field
		Type                            respjson.Field
		Content                         respjson.Field
		RetrievedAt                     respjson.Field
		URL                             respjson.Field
		ReturnCode                      respjson.Field
		Stderr                          respjson.Field
		Stdout                          respjson.Field
		EncryptedStdout                 respjson.Field
		ErrorMessage                    respjson.Field
		FileType                        respjson.Field
		NumLines                        respjson.Field
		StartLine                       respjson.Field
		TotalLines                      respjson.Field
		IsFileUpdate                    respjson.Field
		Lines                           respjson.Field
		NewLines                        respjson.Field
		NewStart                        respjson.Field
		OldLines                        respjson.Field
		OldStart                        respjson.Field
		ToolReferences                  respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

BetaRawContentBlockStartEventContentBlockUnionContent is an implicit subunion of BetaRawContentBlockStartEventContentBlockUnion. BetaRawContentBlockStartEventContentBlockUnionContent provides convenient access to the sub-properties of the union.

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

If the underlying value is not a json object, one of the following properties will be valid: OfBetaWebSearchResultBlockArray OfString OfBetaMCPToolResultBlockContent]

func (*BetaRawContentBlockStartEventContentBlockUnionContent) UnmarshalJSON

type BetaRawContentBlockStartEventContentBlockUnionContentContent

type BetaRawContentBlockStartEventContentBlockUnionContentContent struct {
	// This field will be present if the value is a [[]BetaCodeExecutionOutputBlock]
	// instead of an object.
	OfContent []BetaCodeExecutionOutputBlock `json:",inline"`
	// This field will be present if the value is a [string] instead of an object.
	OfString string `json:",inline"`
	// This field is from variant [BetaDocumentBlock].
	Citations BetaCitationConfig `json:"citations"`
	// This field is from variant [BetaDocumentBlock].
	Source BetaDocumentBlockSourceUnion `json:"source"`
	// This field is from variant [BetaDocumentBlock].
	Title string `json:"title"`
	// This field is from variant [BetaDocumentBlock].
	Type constant.Document `json:"type"`
	JSON struct {
		OfContent respjson.Field
		OfString  respjson.Field
		Citations respjson.Field
		Source    respjson.Field
		Title     respjson.Field
		Type      respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

BetaRawContentBlockStartEventContentBlockUnionContentContent is an implicit subunion of BetaRawContentBlockStartEventContentBlockUnion. BetaRawContentBlockStartEventContentBlockUnionContentContent provides convenient access to the sub-properties of the union.

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

If the underlying value is not a json object, one of the following properties will be valid: OfContent OfString]

func (*BetaRawContentBlockStartEventContentBlockUnionContentContent) UnmarshalJSON

type BetaRawContentBlockStopEvent

type BetaRawContentBlockStopEvent struct {
	Index int64                     `json:"index,required"`
	Type  constant.ContentBlockStop `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Index       respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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 {
	// Information about context management strategies applied during the request
	ContextManagement BetaContextManagementResponse `json:"context_management,required"`
	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"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ContextManagement respjson.Field
		Delta             respjson.Field
		Type              respjson.Field
		Usage             respjson.Field
		ExtraFields       map[string]respjson.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 {
	// Information about the container used in the request (for the code execution
	// tool)
	Container BetaContainer `json:"container,required"`
	// Any of "end_turn", "max_tokens", "stop_sequence", "tool_use", "pause_turn",
	// "compaction", "refusal", "model_context_window_exceeded".
	StopReason   BetaStopReason `json:"stop_reason,required"`
	StopSequence string         `json:"stop_sequence,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Container    respjson.Field
		StopReason   respjson.Field
		StopSequence respjson.Field
		ExtraFields  map[string]respjson.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"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.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 from variant [BetaRawMessageDeltaEvent].
	ContextManagement BetaContextManagementResponse `json:"context_management"`
	// This field is a union of [BetaRawMessageDeltaEventDelta],
	// [BetaRawContentBlockDeltaUnion]
	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           respjson.Field
		Type              respjson.Field
		ContextManagement respjson.Field
		Delta             respjson.Field
		Usage             respjson.Field
		ContentBlock      respjson.Field
		Index             respjson.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

func (u BetaRawMessageStreamEventUnion) AsAny() anyBetaRawMessageStreamEvent

Use the following switch statement to find the correct variant

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

func (BetaRawMessageStreamEventUnion) AsContentBlockDelta

func (BetaRawMessageStreamEventUnion) AsContentBlockStart

func (BetaRawMessageStreamEventUnion) AsContentBlockStop

func (BetaRawMessageStreamEventUnion) AsMessageDelta

func (BetaRawMessageStreamEventUnion) AsMessageStart

func (BetaRawMessageStreamEventUnion) AsMessageStop

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].
	Container BetaContainer `json:"container"`
	// This field is from variant [BetaRawMessageDeltaEventDelta].
	StopReason BetaStopReason `json:"stop_reason"`
	// This field is from variant [BetaRawMessageDeltaEventDelta].
	StopSequence string `json:"stop_sequence"`
	// This field is from variant [BetaRawContentBlockDeltaUnion].
	Text string `json:"text"`
	Type string `json:"type"`
	// This field is from variant [BetaRawContentBlockDeltaUnion].
	PartialJSON string `json:"partial_json"`
	// This field is from variant [BetaRawContentBlockDeltaUnion].
	Citation BetaCitationsDeltaCitationUnion `json:"citation"`
	// This field is from variant [BetaRawContentBlockDeltaUnion].
	Thinking string `json:"thinking"`
	// This field is from variant [BetaRawContentBlockDeltaUnion].
	Signature string `json:"signature"`
	// This field is from variant [BetaRawContentBlockDeltaUnion].
	Content string `json:"content"`
	JSON    struct {
		Container    respjson.Field
		StopReason   respjson.Field
		StopSequence respjson.Field
		Text         respjson.Field
		Type         respjson.Field
		PartialJSON  respjson.Field
		Citation     respjson.Field
		Thinking     respjson.Field
		Signature    respjson.Field
		Content      respjson.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"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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) MarshalJSON

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

func (*BetaRedactedThinkingBlockParam) UnmarshalJSON

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

type BetaRequestDocumentBlockParam

type BetaRequestDocumentBlockParam struct {
	Source  BetaRequestDocumentBlockSourceUnionParam `json:"source,omitzero,required"`
	Context param.Opt[string]                        `json:"context,omitzero"`
	Title   param.Opt[string]                        `json:"title,omitzero"`
	// Create a cache control breakpoint at this content block.
	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 (BetaRequestDocumentBlockParam) MarshalJSON

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

func (*BetaRequestDocumentBlockParam) UnmarshalJSON

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

type BetaRequestDocumentBlockSourceUnionParam

type BetaRequestDocumentBlockSourceUnionParam struct {
	OfBase64  *BetaBase64PDFSourceParam    `json:",omitzero,inline"`
	OfText    *BetaPlainTextSourceParam    `json:",omitzero,inline"`
	OfContent *BetaContentBlockSourceParam `json:",omitzero,inline"`
	OfURL     *BetaURLPDFSourceParam       `json:",omitzero,inline"`
	OfFile    *BetaFileDocumentSourceParam `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 (BetaRequestDocumentBlockSourceUnionParam) GetContent

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

func (BetaRequestDocumentBlockSourceUnionParam) GetData

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

func (BetaRequestDocumentBlockSourceUnionParam) GetFileID

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

func (BetaRequestDocumentBlockSourceUnionParam) GetMediaType

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

func (BetaRequestDocumentBlockSourceUnionParam) GetType

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

func (BetaRequestDocumentBlockSourceUnionParam) GetURL

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

func (BetaRequestDocumentBlockSourceUnionParam) MarshalJSON

func (*BetaRequestDocumentBlockSourceUnionParam) UnmarshalJSON

func (u *BetaRequestDocumentBlockSourceUnionParam) UnmarshalJSON(data []byte) error

type BetaRequestMCPServerToolConfigurationParam

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

func (BetaRequestMCPServerToolConfigurationParam) MarshalJSON

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

func (*BetaRequestMCPServerToolConfigurationParam) UnmarshalJSON

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

type BetaRequestMCPServerURLDefinitionParam

type BetaRequestMCPServerURLDefinitionParam struct {
	Name               string                                     `json:"name,required"`
	URL                string                                     `json:"url,required"`
	AuthorizationToken param.Opt[string]                          `json:"authorization_token,omitzero"`
	ToolConfiguration  BetaRequestMCPServerToolConfigurationParam `json:"tool_configuration,omitzero"`
	// 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 Name, Type, URL are required.

func (BetaRequestMCPServerURLDefinitionParam) MarshalJSON

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

func (*BetaRequestMCPServerURLDefinitionParam) UnmarshalJSON

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

type BetaRequestMCPToolResultBlockParam

type BetaRequestMCPToolResultBlockParam struct {
	ToolUseID string          `json:"tool_use_id,required"`
	IsError   param.Opt[bool] `json:"is_error,omitzero"`
	// Create a cache control breakpoint at this content block.
	CacheControl BetaCacheControlEphemeralParam                 `json:"cache_control,omitzero"`
	Content      BetaRequestMCPToolResultBlockParamContentUnion `json:"content,omitzero"`
	// This field can be elided, and will marshal its zero value as "mcp_tool_result".
	Type constant.MCPToolResult `json:"type,required"`
	// contains filtered or unexported fields
}

The properties ToolUseID, Type are required.

func (BetaRequestMCPToolResultBlockParam) MarshalJSON

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

func (*BetaRequestMCPToolResultBlockParam) UnmarshalJSON

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

type BetaRequestMCPToolResultBlockParamContentUnion

type BetaRequestMCPToolResultBlockParamContentUnion struct {
	OfString                        param.Opt[string]    `json:",omitzero,inline"`
	OfBetaMCPToolResultBlockContent []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 (BetaRequestMCPToolResultBlockParamContentUnion) MarshalJSON

func (*BetaRequestMCPToolResultBlockParamContentUnion) UnmarshalJSON

type BetaSearchResultBlockParam

type BetaSearchResultBlockParam struct {
	Content []BetaTextBlockParam `json:"content,omitzero,required"`
	Source  string               `json:"source,required"`
	Title   string               `json:"title,required"`
	// Create a cache control breakpoint at this content block.
	CacheControl BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	Citations    BetaCitationsConfigParam       `json:"citations,omitzero"`
	// This field can be elided, and will marshal its zero value as "search_result".
	Type constant.SearchResult `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Content, Source, Title, Type are required.

func (BetaSearchResultBlockParam) MarshalJSON

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

func (*BetaSearchResultBlockParam) UnmarshalJSON

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

type BetaServerToolCaller

type BetaServerToolCaller struct {
	ToolID string                         `json:"tool_id,required"`
	Type   constant.CodeExecution20250825 `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ToolID      respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Tool invocation generated by a server-side tool.

func (BetaServerToolCaller) RawJSON

func (r BetaServerToolCaller) RawJSON() string

Returns the unmodified JSON received from the API

func (BetaServerToolCaller) ToParam

ToParam converts this BetaServerToolCaller to a BetaServerToolCallerParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with BetaServerToolCallerParam.Overrides()

func (*BetaServerToolCaller) UnmarshalJSON

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

type BetaServerToolCaller20260120

type BetaServerToolCaller20260120 struct {
	ToolID string                         `json:"tool_id,required"`
	Type   constant.CodeExecution20260120 `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ToolID      respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaServerToolCaller20260120) RawJSON

Returns the unmodified JSON received from the API

func (BetaServerToolCaller20260120) ToParam

ToParam converts this BetaServerToolCaller20260120 to a BetaServerToolCaller20260120Param.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with BetaServerToolCaller20260120Param.Overrides()

func (*BetaServerToolCaller20260120) UnmarshalJSON

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

type BetaServerToolCaller20260120Param

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

The properties ToolID, Type are required.

func (BetaServerToolCaller20260120Param) MarshalJSON

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

func (*BetaServerToolCaller20260120Param) UnmarshalJSON

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

type BetaServerToolCallerParam

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

Tool invocation generated by a server-side tool.

The properties ToolID, Type are required.

func (BetaServerToolCallerParam) MarshalJSON

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

func (*BetaServerToolCallerParam) UnmarshalJSON

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

type BetaServerToolUsage

type BetaServerToolUsage struct {
	// The number of web fetch tool requests.
	WebFetchRequests int64 `json:"web_fetch_requests,required"`
	// The number of web search tool requests.
	WebSearchRequests int64 `json:"web_search_requests,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		WebFetchRequests  respjson.Field
		WebSearchRequests respjson.Field
		ExtraFields       map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaServerToolUsage) RawJSON

func (r BetaServerToolUsage) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaServerToolUsage) UnmarshalJSON

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

type BetaServerToolUseBlock

type BetaServerToolUseBlock struct {
	ID    string `json:"id,required"`
	Input any    `json:"input,required"`
	// Any of "web_search", "web_fetch", "code_execution", "bash_code_execution",
	// "text_editor_code_execution", "tool_search_tool_regex", "tool_search_tool_bm25".
	Name BetaServerToolUseBlockName `json:"name,required"`
	Type constant.ServerToolUse     `json:"type,required"`
	// Tool invocation directly from the model.
	Caller BetaServerToolUseBlockCallerUnion `json:"caller"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Input       respjson.Field
		Name        respjson.Field
		Type        respjson.Field
		Caller      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaServerToolUseBlock) RawJSON

func (r BetaServerToolUseBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (BetaServerToolUseBlock) ToParam

func (*BetaServerToolUseBlock) UnmarshalJSON

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

type BetaServerToolUseBlockCallerUnion

type BetaServerToolUseBlockCallerUnion struct {
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	Type   string `json:"type"`
	ToolID string `json:"tool_id"`
	JSON   struct {
		Type   respjson.Field
		ToolID respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

BetaServerToolUseBlockCallerUnion contains all possible properties and values from BetaDirectCaller, BetaServerToolCaller, BetaServerToolCaller20260120.

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

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

func (BetaServerToolUseBlockCallerUnion) AsAny

func (u BetaServerToolUseBlockCallerUnion) AsAny() anyBetaServerToolUseBlockCaller

Use the following switch statement to find the correct variant

switch variant := BetaServerToolUseBlockCallerUnion.AsAny().(type) {
case anthropic.BetaDirectCaller:
case anthropic.BetaServerToolCaller:
case anthropic.BetaServerToolCaller20260120:
default:
  fmt.Errorf("no variant present")
}

func (BetaServerToolUseBlockCallerUnion) AsCodeExecution20250825

func (u BetaServerToolUseBlockCallerUnion) AsCodeExecution20250825() (v BetaServerToolCaller)

func (BetaServerToolUseBlockCallerUnion) AsCodeExecution20260120

func (u BetaServerToolUseBlockCallerUnion) AsCodeExecution20260120() (v BetaServerToolCaller20260120)

func (BetaServerToolUseBlockCallerUnion) AsDirect

func (BetaServerToolUseBlockCallerUnion) RawJSON

Returns the unmodified JSON received from the API

func (*BetaServerToolUseBlockCallerUnion) UnmarshalJSON

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

type BetaServerToolUseBlockName

type BetaServerToolUseBlockName string
const (
	BetaServerToolUseBlockNameWebSearch               BetaServerToolUseBlockName = "web_search"
	BetaServerToolUseBlockNameWebFetch                BetaServerToolUseBlockName = "web_fetch"
	BetaServerToolUseBlockNameCodeExecution           BetaServerToolUseBlockName = "code_execution"
	BetaServerToolUseBlockNameBashCodeExecution       BetaServerToolUseBlockName = "bash_code_execution"
	BetaServerToolUseBlockNameTextEditorCodeExecution BetaServerToolUseBlockName = "text_editor_code_execution"
	BetaServerToolUseBlockNameToolSearchToolRegex     BetaServerToolUseBlockName = "tool_search_tool_regex"
	BetaServerToolUseBlockNameToolSearchToolBm25      BetaServerToolUseBlockName = "tool_search_tool_bm25"
)

type BetaServerToolUseBlockParam

type BetaServerToolUseBlockParam struct {
	ID    string `json:"id,required"`
	Input any    `json:"input,omitzero,required"`
	// Any of "web_search", "web_fetch", "code_execution", "bash_code_execution",
	// "text_editor_code_execution", "tool_search_tool_regex", "tool_search_tool_bm25".
	Name BetaServerToolUseBlockParamName `json:"name,omitzero,required"`
	// Create a cache control breakpoint at this content block.
	CacheControl BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	// Tool invocation directly from the model.
	Caller BetaServerToolUseBlockParamCallerUnion `json:"caller,omitzero"`
	// This field can be elided, and will marshal its zero value as "server_tool_use".
	Type constant.ServerToolUse `json:"type,required"`
	// contains filtered or unexported fields
}

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

func (BetaServerToolUseBlockParam) MarshalJSON

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

func (*BetaServerToolUseBlockParam) UnmarshalJSON

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

type BetaServerToolUseBlockParamCallerUnion

type BetaServerToolUseBlockParamCallerUnion struct {
	OfDirect                *BetaDirectCallerParam             `json:",omitzero,inline"`
	OfCodeExecution20250825 *BetaServerToolCallerParam         `json:",omitzero,inline"`
	OfCodeExecution20260120 *BetaServerToolCaller20260120Param `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 (BetaServerToolUseBlockParamCallerUnion) GetToolID

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

func (BetaServerToolUseBlockParamCallerUnion) GetType

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

func (BetaServerToolUseBlockParamCallerUnion) MarshalJSON

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

func (*BetaServerToolUseBlockParamCallerUnion) UnmarshalJSON

func (u *BetaServerToolUseBlockParamCallerUnion) UnmarshalJSON(data []byte) error

type BetaServerToolUseBlockParamName

type BetaServerToolUseBlockParamName string
const (
	BetaServerToolUseBlockParamNameWebSearch               BetaServerToolUseBlockParamName = "web_search"
	BetaServerToolUseBlockParamNameWebFetch                BetaServerToolUseBlockParamName = "web_fetch"
	BetaServerToolUseBlockParamNameCodeExecution           BetaServerToolUseBlockParamName = "code_execution"
	BetaServerToolUseBlockParamNameBashCodeExecution       BetaServerToolUseBlockParamName = "bash_code_execution"
	BetaServerToolUseBlockParamNameTextEditorCodeExecution BetaServerToolUseBlockParamName = "text_editor_code_execution"
	BetaServerToolUseBlockParamNameToolSearchToolRegex     BetaServerToolUseBlockParamName = "tool_search_tool_regex"
	BetaServerToolUseBlockParamNameToolSearchToolBm25      BetaServerToolUseBlockParamName = "tool_search_tool_bm25"
)

type BetaService

type BetaService struct {
	Options  []option.RequestOption
	Models   BetaModelService
	Messages BetaMessageService
	Files    BetaFileService
	Skills   BetaSkillService
}

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"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Signature   respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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 BetaSkill

type BetaSkill struct {
	// Skill ID
	SkillID string `json:"skill_id,required"`
	// Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)
	//
	// Any of "anthropic", "custom".
	Type BetaSkillType `json:"type,required"`
	// Skill version or 'latest' for most recent version
	Version string `json:"version,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		SkillID     respjson.Field
		Type        respjson.Field
		Version     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

A skill that was loaded in a container (response model).

func (BetaSkill) RawJSON

func (r BetaSkill) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaSkill) UnmarshalJSON

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

type BetaSkillDeleteParams

type BetaSkillDeleteParams 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
}

type BetaSkillDeleteResponse

type BetaSkillDeleteResponse struct {
	// Unique identifier for the skill.
	//
	// The format and length of IDs may change over time.
	ID string `json:"id,required"`
	// Deleted object type.
	//
	// For Skills, this is always `"skill_deleted"`.
	Type string `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaSkillDeleteResponse) RawJSON

func (r BetaSkillDeleteResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaSkillDeleteResponse) UnmarshalJSON

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

type BetaSkillGetParams

type BetaSkillGetParams 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
}

type BetaSkillGetResponse

type BetaSkillGetResponse struct {
	// Unique identifier for the skill.
	//
	// The format and length of IDs may change over time.
	ID string `json:"id,required"`
	// ISO 8601 timestamp of when the skill was created.
	CreatedAt string `json:"created_at,required"`
	// Display title for the skill.
	//
	// This is a human-readable label that is not included in the prompt sent to the
	// model.
	DisplayTitle string `json:"display_title,required"`
	// The latest version identifier for the skill.
	//
	// This represents the most recent version of the skill that has been created.
	LatestVersion string `json:"latest_version,required"`
	// Source of the skill.
	//
	// This may be one of the following values:
	//
	// - `"custom"`: the skill was created by a user
	// - `"anthropic"`: the skill was created by Anthropic
	Source string `json:"source,required"`
	// Object type.
	//
	// For Skills, this is always `"skill"`.
	Type string `json:"type,required"`
	// ISO 8601 timestamp of when the skill was last updated.
	UpdatedAt string `json:"updated_at,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID            respjson.Field
		CreatedAt     respjson.Field
		DisplayTitle  respjson.Field
		LatestVersion respjson.Field
		Source        respjson.Field
		Type          respjson.Field
		UpdatedAt     respjson.Field
		ExtraFields   map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaSkillGetResponse) RawJSON

func (r BetaSkillGetResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaSkillGetResponse) UnmarshalJSON

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

type BetaSkillListParams

type BetaSkillListParams struct {
	// Pagination token for fetching a specific page of results.
	//
	// Pass the value from a previous response's `next_page` field to get the next page
	// of results.
	Page param.Opt[string] `query:"page,omitzero" json:"-"`
	// Filter skills by source.
	//
	// If provided, only skills from the specified source will be returned:
	//
	// - `"custom"`: only return user-created skills
	// - `"anthropic"`: only return Anthropic-created skills
	Source param.Opt[string] `query:"source,omitzero" json:"-"`
	// Number of results to return per page.
	//
	// Maximum value is 100. Defaults to 20.
	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 (BetaSkillListParams) URLQuery

func (r BetaSkillListParams) URLQuery() (v url.Values, err error)

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

type BetaSkillListResponse

type BetaSkillListResponse struct {
	// Unique identifier for the skill.
	//
	// The format and length of IDs may change over time.
	ID string `json:"id,required"`
	// ISO 8601 timestamp of when the skill was created.
	CreatedAt string `json:"created_at,required"`
	// Display title for the skill.
	//
	// This is a human-readable label that is not included in the prompt sent to the
	// model.
	DisplayTitle string `json:"display_title,required"`
	// The latest version identifier for the skill.
	//
	// This represents the most recent version of the skill that has been created.
	LatestVersion string `json:"latest_version,required"`
	// Source of the skill.
	//
	// This may be one of the following values:
	//
	// - `"custom"`: the skill was created by a user
	// - `"anthropic"`: the skill was created by Anthropic
	Source string `json:"source,required"`
	// Object type.
	//
	// For Skills, this is always `"skill"`.
	Type string `json:"type,required"`
	// ISO 8601 timestamp of when the skill was last updated.
	UpdatedAt string `json:"updated_at,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID            respjson.Field
		CreatedAt     respjson.Field
		DisplayTitle  respjson.Field
		LatestVersion respjson.Field
		Source        respjson.Field
		Type          respjson.Field
		UpdatedAt     respjson.Field
		ExtraFields   map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaSkillListResponse) RawJSON

func (r BetaSkillListResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaSkillListResponse) UnmarshalJSON

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

type BetaSkillNewParams

type BetaSkillNewParams struct {
	// Display title for the skill.
	//
	// This is a human-readable label that is not included in the prompt sent to the
	// model.
	DisplayTitle param.Opt[string] `json:"display_title,omitzero"`
	// Files to upload for the skill.
	//
	// All files must be in the same top-level directory and must include a SKILL.md
	// file at the root of that directory.
	Files []io.Reader `json:"files,omitzero" format:"binary"`
	// 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 (BetaSkillNewParams) MarshalMultipart

func (r BetaSkillNewParams) MarshalMultipart() (data []byte, contentType string, err error)

type BetaSkillNewResponse

type BetaSkillNewResponse struct {
	// Unique identifier for the skill.
	//
	// The format and length of IDs may change over time.
	ID string `json:"id,required"`
	// ISO 8601 timestamp of when the skill was created.
	CreatedAt string `json:"created_at,required"`
	// Display title for the skill.
	//
	// This is a human-readable label that is not included in the prompt sent to the
	// model.
	DisplayTitle string `json:"display_title,required"`
	// The latest version identifier for the skill.
	//
	// This represents the most recent version of the skill that has been created.
	LatestVersion string `json:"latest_version,required"`
	// Source of the skill.
	//
	// This may be one of the following values:
	//
	// - `"custom"`: the skill was created by a user
	// - `"anthropic"`: the skill was created by Anthropic
	Source string `json:"source,required"`
	// Object type.
	//
	// For Skills, this is always `"skill"`.
	Type string `json:"type,required"`
	// ISO 8601 timestamp of when the skill was last updated.
	UpdatedAt string `json:"updated_at,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID            respjson.Field
		CreatedAt     respjson.Field
		DisplayTitle  respjson.Field
		LatestVersion respjson.Field
		Source        respjson.Field
		Type          respjson.Field
		UpdatedAt     respjson.Field
		ExtraFields   map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaSkillNewResponse) RawJSON

func (r BetaSkillNewResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaSkillNewResponse) UnmarshalJSON

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

type BetaSkillParams

type BetaSkillParams struct {
	// Skill ID
	SkillID string `json:"skill_id,required"`
	// Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)
	//
	// Any of "anthropic", "custom".
	Type BetaSkillParamsType `json:"type,omitzero,required"`
	// Skill version or 'latest' for most recent version
	Version param.Opt[string] `json:"version,omitzero"`
	// contains filtered or unexported fields
}

Specification for a skill to be loaded in a container (request model).

The properties SkillID, Type are required.

func (BetaSkillParams) MarshalJSON

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

func (*BetaSkillParams) UnmarshalJSON

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

type BetaSkillParamsType

type BetaSkillParamsType string

Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)

const (
	BetaSkillParamsTypeAnthropic BetaSkillParamsType = "anthropic"
	BetaSkillParamsTypeCustom    BetaSkillParamsType = "custom"
)

type BetaSkillService

type BetaSkillService struct {
	Options  []option.RequestOption
	Versions BetaSkillVersionService
}

BetaSkillService 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 NewBetaSkillService method instead.

func NewBetaSkillService

func NewBetaSkillService(opts ...option.RequestOption) (r BetaSkillService)

NewBetaSkillService 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 (*BetaSkillService) Delete

Delete Skill

func (*BetaSkillService) Get

func (r *BetaSkillService) Get(ctx context.Context, skillID string, query BetaSkillGetParams, opts ...option.RequestOption) (res *BetaSkillGetResponse, err error)

Get Skill

func (*BetaSkillService) List

List Skills

func (*BetaSkillService) ListAutoPaging

List Skills

func (*BetaSkillService) New

Create Skill

type BetaSkillType

type BetaSkillType string

Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)

const (
	BetaSkillTypeAnthropic BetaSkillType = "anthropic"
	BetaSkillTypeCustom    BetaSkillType = "custom"
)

type BetaSkillVersionDeleteParams

type BetaSkillVersionDeleteParams struct {
	// Unique identifier for the skill.
	//
	// The format and length of IDs may change over time.
	SkillID string `path:"skill_id,required" 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
}

type BetaSkillVersionDeleteResponse

type BetaSkillVersionDeleteResponse struct {
	// Version identifier for the skill.
	//
	// Each version is identified by a Unix epoch timestamp (e.g., "1759178010641129").
	ID string `json:"id,required"`
	// Deleted object type.
	//
	// For Skill Versions, this is always `"skill_version_deleted"`.
	Type string `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaSkillVersionDeleteResponse) RawJSON

Returns the unmodified JSON received from the API

func (*BetaSkillVersionDeleteResponse) UnmarshalJSON

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

type BetaSkillVersionGetParams

type BetaSkillVersionGetParams struct {
	// Unique identifier for the skill.
	//
	// The format and length of IDs may change over time.
	SkillID string `path:"skill_id,required" 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
}

type BetaSkillVersionGetResponse

type BetaSkillVersionGetResponse struct {
	// Unique identifier for the skill version.
	//
	// The format and length of IDs may change over time.
	ID string `json:"id,required"`
	// ISO 8601 timestamp of when the skill version was created.
	CreatedAt string `json:"created_at,required"`
	// Description of the skill version.
	//
	// This is extracted from the SKILL.md file in the skill upload.
	Description string `json:"description,required"`
	// Directory name of the skill version.
	//
	// This is the top-level directory name that was extracted from the uploaded files.
	Directory string `json:"directory,required"`
	// Human-readable name of the skill version.
	//
	// This is extracted from the SKILL.md file in the skill upload.
	Name string `json:"name,required"`
	// Identifier for the skill that this version belongs to.
	SkillID string `json:"skill_id,required"`
	// Object type.
	//
	// For Skill Versions, this is always `"skill_version"`.
	Type string `json:"type,required"`
	// Version identifier for the skill.
	//
	// Each version is identified by a Unix epoch timestamp (e.g., "1759178010641129").
	Version string `json:"version,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		CreatedAt   respjson.Field
		Description respjson.Field
		Directory   respjson.Field
		Name        respjson.Field
		SkillID     respjson.Field
		Type        respjson.Field
		Version     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaSkillVersionGetResponse) RawJSON

func (r BetaSkillVersionGetResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaSkillVersionGetResponse) UnmarshalJSON

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

type BetaSkillVersionListParams

type BetaSkillVersionListParams struct {
	// Number of items to return per page.
	//
	// Defaults to `20`. Ranges from `1` to `1000`.
	Limit param.Opt[int64] `query:"limit,omitzero" json:"-"`
	// Optionally set to the `next_page` token from the previous response.
	Page param.Opt[string] `query:"page,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 (BetaSkillVersionListParams) URLQuery

func (r BetaSkillVersionListParams) URLQuery() (v url.Values, err error)

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

type BetaSkillVersionListResponse

type BetaSkillVersionListResponse struct {
	// Unique identifier for the skill version.
	//
	// The format and length of IDs may change over time.
	ID string `json:"id,required"`
	// ISO 8601 timestamp of when the skill version was created.
	CreatedAt string `json:"created_at,required"`
	// Description of the skill version.
	//
	// This is extracted from the SKILL.md file in the skill upload.
	Description string `json:"description,required"`
	// Directory name of the skill version.
	//
	// This is the top-level directory name that was extracted from the uploaded files.
	Directory string `json:"directory,required"`
	// Human-readable name of the skill version.
	//
	// This is extracted from the SKILL.md file in the skill upload.
	Name string `json:"name,required"`
	// Identifier for the skill that this version belongs to.
	SkillID string `json:"skill_id,required"`
	// Object type.
	//
	// For Skill Versions, this is always `"skill_version"`.
	Type string `json:"type,required"`
	// Version identifier for the skill.
	//
	// Each version is identified by a Unix epoch timestamp (e.g., "1759178010641129").
	Version string `json:"version,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		CreatedAt   respjson.Field
		Description respjson.Field
		Directory   respjson.Field
		Name        respjson.Field
		SkillID     respjson.Field
		Type        respjson.Field
		Version     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaSkillVersionListResponse) RawJSON

Returns the unmodified JSON received from the API

func (*BetaSkillVersionListResponse) UnmarshalJSON

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

type BetaSkillVersionNewParams

type BetaSkillVersionNewParams struct {
	// Files to upload for the skill.
	//
	// All files must be in the same top-level directory and must include a SKILL.md
	// file at the root of that directory.
	Files []io.Reader `json:"files,omitzero" format:"binary"`
	// 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 (BetaSkillVersionNewParams) MarshalMultipart

func (r BetaSkillVersionNewParams) MarshalMultipart() (data []byte, contentType string, err error)

type BetaSkillVersionNewResponse

type BetaSkillVersionNewResponse struct {
	// Unique identifier for the skill version.
	//
	// The format and length of IDs may change over time.
	ID string `json:"id,required"`
	// ISO 8601 timestamp of when the skill version was created.
	CreatedAt string `json:"created_at,required"`
	// Description of the skill version.
	//
	// This is extracted from the SKILL.md file in the skill upload.
	Description string `json:"description,required"`
	// Directory name of the skill version.
	//
	// This is the top-level directory name that was extracted from the uploaded files.
	Directory string `json:"directory,required"`
	// Human-readable name of the skill version.
	//
	// This is extracted from the SKILL.md file in the skill upload.
	Name string `json:"name,required"`
	// Identifier for the skill that this version belongs to.
	SkillID string `json:"skill_id,required"`
	// Object type.
	//
	// For Skill Versions, this is always `"skill_version"`.
	Type string `json:"type,required"`
	// Version identifier for the skill.
	//
	// Each version is identified by a Unix epoch timestamp (e.g., "1759178010641129").
	Version string `json:"version,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		CreatedAt   respjson.Field
		Description respjson.Field
		Directory   respjson.Field
		Name        respjson.Field
		SkillID     respjson.Field
		Type        respjson.Field
		Version     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaSkillVersionNewResponse) RawJSON

func (r BetaSkillVersionNewResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaSkillVersionNewResponse) UnmarshalJSON

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

type BetaSkillVersionService

type BetaSkillVersionService struct {
	Options []option.RequestOption
}

BetaSkillVersionService 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 NewBetaSkillVersionService method instead.

func NewBetaSkillVersionService

func NewBetaSkillVersionService(opts ...option.RequestOption) (r BetaSkillVersionService)

NewBetaSkillVersionService 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 (*BetaSkillVersionService) Delete

Delete Skill Version

func (*BetaSkillVersionService) Get

Get Skill Version

func (*BetaSkillVersionService) List

List Skill Versions

func (*BetaSkillVersionService) ListAutoPaging

List Skill Versions

func (*BetaSkillVersionService) New

Create Skill Version

type BetaStopReason

type BetaStopReason string
const (
	BetaStopReasonEndTurn                    BetaStopReason = "end_turn"
	BetaStopReasonMaxTokens                  BetaStopReason = "max_tokens"
	BetaStopReasonStopSequence               BetaStopReason = "stop_sequence"
	BetaStopReasonToolUse                    BetaStopReason = "tool_use"
	BetaStopReasonPauseTurn                  BetaStopReason = "pause_turn"
	BetaStopReasonCompaction                 BetaStopReason = "compaction"
	BetaStopReasonRefusal                    BetaStopReason = "refusal"
	BetaStopReasonModelContextWindowExceeded BetaStopReason = "model_context_window_exceeded"
)

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"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Citations   respjson.Field
		Text        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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"`
	// Create a cache control breakpoint at this content block.
	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) MarshalJSON

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

func (*BetaTextBlockParam) UnmarshalJSON

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

type BetaTextCitationParamUnion

type BetaTextCitationParamUnion struct {
	OfCharLocation            *BetaCitationCharLocationParam            `json:",omitzero,inline"`
	OfPageLocation            *BetaCitationPageLocationParam            `json:",omitzero,inline"`
	OfContentBlockLocation    *BetaCitationContentBlockLocationParam    `json:",omitzero,inline"`
	OfWebSearchResultLocation *BetaCitationWebSearchResultLocationParam `json:",omitzero,inline"`
	OfSearchResultLocation    *BetaCitationSearchResultLocationParam    `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) GetEncryptedIndex

func (u BetaTextCitationParamUnion) GetEncryptedIndex() *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) GetSearchResultIndex

func (u BetaTextCitationParamUnion) GetSearchResultIndex() *int64

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

func (BetaTextCitationParamUnion) GetSource

func (u BetaTextCitationParamUnion) GetSource() *string

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) GetTitle

func (u BetaTextCitationParamUnion) GetTitle() *string

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) GetURL

func (u BetaTextCitationParamUnion) GetURL() *string

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

func (BetaTextCitationParamUnion) MarshalJSON

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

func (*BetaTextCitationParamUnion) UnmarshalJSON

func (u *BetaTextCitationParamUnion) UnmarshalJSON(data []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"`
	FileID       string `json:"file_id"`
	// This field is from variant [BetaCitationCharLocation].
	StartCharIndex int64 `json:"start_char_index"`
	// Any of "char_location", "page_location", "content_block_location",
	// "web_search_result_location", "search_result_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"`
	EndBlockIndex   int64 `json:"end_block_index"`
	StartBlockIndex int64 `json:"start_block_index"`
	// This field is from variant [BetaCitationsWebSearchResultLocation].
	EncryptedIndex string `json:"encrypted_index"`
	Title          string `json:"title"`
	// This field is from variant [BetaCitationsWebSearchResultLocation].
	URL string `json:"url"`
	// This field is from variant [BetaCitationSearchResultLocation].
	SearchResultIndex int64 `json:"search_result_index"`
	// This field is from variant [BetaCitationSearchResultLocation].
	Source string `json:"source"`
	JSON   struct {
		CitedText         respjson.Field
		DocumentIndex     respjson.Field
		DocumentTitle     respjson.Field
		EndCharIndex      respjson.Field
		FileID            respjson.Field
		StartCharIndex    respjson.Field
		Type              respjson.Field
		EndPageNumber     respjson.Field
		StartPageNumber   respjson.Field
		EndBlockIndex     respjson.Field
		StartBlockIndex   respjson.Field
		EncryptedIndex    respjson.Field
		Title             respjson.Field
		URL               respjson.Field
		SearchResultIndex respjson.Field
		Source            respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

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

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() anyBetaTextCitation

Use the following switch statement to find the correct variant

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

func (BetaTextCitationUnion) AsCharLocation

func (u BetaTextCitationUnion) AsCharLocation() (v BetaCitationCharLocation)

func (BetaTextCitationUnion) AsContentBlockLocation

func (u BetaTextCitationUnion) AsContentBlockLocation() (v BetaCitationContentBlockLocation)

func (BetaTextCitationUnion) AsPageLocation

func (u BetaTextCitationUnion) AsPageLocation() (v BetaCitationPageLocation)

func (BetaTextCitationUnion) AsSearchResultLocation

func (u BetaTextCitationUnion) AsSearchResultLocation() (v BetaCitationSearchResultLocation)

func (BetaTextCitationUnion) AsWebSearchResultLocation

func (u BetaTextCitationUnion) AsWebSearchResultLocation() (v BetaCitationsWebSearchResultLocation)

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"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Text        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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 BetaTextEditorCodeExecutionCreateResultBlock

type BetaTextEditorCodeExecutionCreateResultBlock struct {
	IsFileUpdate bool                                         `json:"is_file_update,required"`
	Type         constant.TextEditorCodeExecutionCreateResult `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		IsFileUpdate respjson.Field
		Type         respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaTextEditorCodeExecutionCreateResultBlock) RawJSON

Returns the unmodified JSON received from the API

func (*BetaTextEditorCodeExecutionCreateResultBlock) UnmarshalJSON

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

type BetaTextEditorCodeExecutionCreateResultBlockParam

type BetaTextEditorCodeExecutionCreateResultBlockParam struct {
	IsFileUpdate bool `json:"is_file_update,required"`
	// This field can be elided, and will marshal its zero value as
	// "text_editor_code_execution_create_result".
	Type constant.TextEditorCodeExecutionCreateResult `json:"type,required"`
	// contains filtered or unexported fields
}

The properties IsFileUpdate, Type are required.

func (BetaTextEditorCodeExecutionCreateResultBlockParam) MarshalJSON

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

func (*BetaTextEditorCodeExecutionCreateResultBlockParam) UnmarshalJSON

type BetaTextEditorCodeExecutionStrReplaceResultBlock

type BetaTextEditorCodeExecutionStrReplaceResultBlock struct {
	Lines    []string                                         `json:"lines,required"`
	NewLines int64                                            `json:"new_lines,required"`
	NewStart int64                                            `json:"new_start,required"`
	OldLines int64                                            `json:"old_lines,required"`
	OldStart int64                                            `json:"old_start,required"`
	Type     constant.TextEditorCodeExecutionStrReplaceResult `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Lines       respjson.Field
		NewLines    respjson.Field
		NewStart    respjson.Field
		OldLines    respjson.Field
		OldStart    respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaTextEditorCodeExecutionStrReplaceResultBlock) RawJSON

Returns the unmodified JSON received from the API

func (*BetaTextEditorCodeExecutionStrReplaceResultBlock) UnmarshalJSON

type BetaTextEditorCodeExecutionStrReplaceResultBlockParam

type BetaTextEditorCodeExecutionStrReplaceResultBlockParam struct {
	NewLines param.Opt[int64] `json:"new_lines,omitzero"`
	NewStart param.Opt[int64] `json:"new_start,omitzero"`
	OldLines param.Opt[int64] `json:"old_lines,omitzero"`
	OldStart param.Opt[int64] `json:"old_start,omitzero"`
	Lines    []string         `json:"lines,omitzero"`
	// This field can be elided, and will marshal its zero value as
	// "text_editor_code_execution_str_replace_result".
	Type constant.TextEditorCodeExecutionStrReplaceResult `json:"type,required"`
	// contains filtered or unexported fields
}

The property Type is required.

func (BetaTextEditorCodeExecutionStrReplaceResultBlockParam) MarshalJSON

func (*BetaTextEditorCodeExecutionStrReplaceResultBlockParam) UnmarshalJSON

type BetaTextEditorCodeExecutionToolResultBlock

type BetaTextEditorCodeExecutionToolResultBlock struct {
	Content   BetaTextEditorCodeExecutionToolResultBlockContentUnion `json:"content,required"`
	ToolUseID string                                                 `json:"tool_use_id,required"`
	Type      constant.TextEditorCodeExecutionToolResult             `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Content     respjson.Field
		ToolUseID   respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaTextEditorCodeExecutionToolResultBlock) RawJSON

Returns the unmodified JSON received from the API

func (BetaTextEditorCodeExecutionToolResultBlock) ToParam

func (*BetaTextEditorCodeExecutionToolResultBlock) UnmarshalJSON

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

type BetaTextEditorCodeExecutionToolResultBlockContentUnion

type BetaTextEditorCodeExecutionToolResultBlockContentUnion struct {
	// This field is from variant [BetaTextEditorCodeExecutionToolResultError].
	ErrorCode BetaTextEditorCodeExecutionToolResultErrorErrorCode `json:"error_code"`
	// This field is from variant [BetaTextEditorCodeExecutionToolResultError].
	ErrorMessage string `json:"error_message"`
	Type         string `json:"type"`
	// This field is from variant [BetaTextEditorCodeExecutionViewResultBlock].
	Content string `json:"content"`
	// This field is from variant [BetaTextEditorCodeExecutionViewResultBlock].
	FileType BetaTextEditorCodeExecutionViewResultBlockFileType `json:"file_type"`
	// This field is from variant [BetaTextEditorCodeExecutionViewResultBlock].
	NumLines int64 `json:"num_lines"`
	// This field is from variant [BetaTextEditorCodeExecutionViewResultBlock].
	StartLine int64 `json:"start_line"`
	// This field is from variant [BetaTextEditorCodeExecutionViewResultBlock].
	TotalLines int64 `json:"total_lines"`
	// This field is from variant [BetaTextEditorCodeExecutionCreateResultBlock].
	IsFileUpdate bool `json:"is_file_update"`
	// This field is from variant [BetaTextEditorCodeExecutionStrReplaceResultBlock].
	Lines []string `json:"lines"`
	// This field is from variant [BetaTextEditorCodeExecutionStrReplaceResultBlock].
	NewLines int64 `json:"new_lines"`
	// This field is from variant [BetaTextEditorCodeExecutionStrReplaceResultBlock].
	NewStart int64 `json:"new_start"`
	// This field is from variant [BetaTextEditorCodeExecutionStrReplaceResultBlock].
	OldLines int64 `json:"old_lines"`
	// This field is from variant [BetaTextEditorCodeExecutionStrReplaceResultBlock].
	OldStart int64 `json:"old_start"`
	JSON     struct {
		ErrorCode    respjson.Field
		ErrorMessage respjson.Field
		Type         respjson.Field
		Content      respjson.Field
		FileType     respjson.Field
		NumLines     respjson.Field
		StartLine    respjson.Field
		TotalLines   respjson.Field
		IsFileUpdate respjson.Field
		Lines        respjson.Field
		NewLines     respjson.Field
		NewStart     respjson.Field
		OldLines     respjson.Field
		OldStart     respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

BetaTextEditorCodeExecutionToolResultBlockContentUnion contains all possible properties and values from BetaTextEditorCodeExecutionToolResultError, BetaTextEditorCodeExecutionViewResultBlock, BetaTextEditorCodeExecutionCreateResultBlock, BetaTextEditorCodeExecutionStrReplaceResultBlock.

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

func (BetaTextEditorCodeExecutionToolResultBlockContentUnion) AsResponseTextEditorCodeExecutionCreateResultBlock

func (u BetaTextEditorCodeExecutionToolResultBlockContentUnion) AsResponseTextEditorCodeExecutionCreateResultBlock() (v BetaTextEditorCodeExecutionCreateResultBlock)

func (BetaTextEditorCodeExecutionToolResultBlockContentUnion) AsResponseTextEditorCodeExecutionStrReplaceResultBlock

func (u BetaTextEditorCodeExecutionToolResultBlockContentUnion) AsResponseTextEditorCodeExecutionStrReplaceResultBlock() (v BetaTextEditorCodeExecutionStrReplaceResultBlock)

func (BetaTextEditorCodeExecutionToolResultBlockContentUnion) AsResponseTextEditorCodeExecutionToolResultError

func (u BetaTextEditorCodeExecutionToolResultBlockContentUnion) AsResponseTextEditorCodeExecutionToolResultError() (v BetaTextEditorCodeExecutionToolResultError)

func (BetaTextEditorCodeExecutionToolResultBlockContentUnion) AsResponseTextEditorCodeExecutionViewResultBlock

func (u BetaTextEditorCodeExecutionToolResultBlockContentUnion) AsResponseTextEditorCodeExecutionViewResultBlock() (v BetaTextEditorCodeExecutionViewResultBlock)

func (BetaTextEditorCodeExecutionToolResultBlockContentUnion) RawJSON

Returns the unmodified JSON received from the API

func (*BetaTextEditorCodeExecutionToolResultBlockContentUnion) UnmarshalJSON

type BetaTextEditorCodeExecutionToolResultBlockParam

type BetaTextEditorCodeExecutionToolResultBlockParam struct {
	Content   BetaTextEditorCodeExecutionToolResultBlockParamContentUnion `json:"content,omitzero,required"`
	ToolUseID string                                                      `json:"tool_use_id,required"`
	// Create a cache control breakpoint at this content block.
	CacheControl BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	// This field can be elided, and will marshal its zero value as
	// "text_editor_code_execution_tool_result".
	Type constant.TextEditorCodeExecutionToolResult `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Content, ToolUseID, Type are required.

func (BetaTextEditorCodeExecutionToolResultBlockParam) MarshalJSON

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

func (*BetaTextEditorCodeExecutionToolResultBlockParam) UnmarshalJSON

type BetaTextEditorCodeExecutionToolResultBlockParamContentUnion

type BetaTextEditorCodeExecutionToolResultBlockParamContentUnion struct {
	OfRequestTextEditorCodeExecutionToolResultError       *BetaTextEditorCodeExecutionToolResultErrorParam       `json:",omitzero,inline"`
	OfRequestTextEditorCodeExecutionViewResultBlock       *BetaTextEditorCodeExecutionViewResultBlockParam       `json:",omitzero,inline"`
	OfRequestTextEditorCodeExecutionCreateResultBlock     *BetaTextEditorCodeExecutionCreateResultBlockParam     `json:",omitzero,inline"`
	OfRequestTextEditorCodeExecutionStrReplaceResultBlock *BetaTextEditorCodeExecutionStrReplaceResultBlockParam `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 (BetaTextEditorCodeExecutionToolResultBlockParamContentUnion) GetContent

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

func (BetaTextEditorCodeExecutionToolResultBlockParamContentUnion) GetErrorCode

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

func (BetaTextEditorCodeExecutionToolResultBlockParamContentUnion) GetErrorMessage

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

func (BetaTextEditorCodeExecutionToolResultBlockParamContentUnion) GetFileType

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

func (BetaTextEditorCodeExecutionToolResultBlockParamContentUnion) GetIsFileUpdate

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

func (BetaTextEditorCodeExecutionToolResultBlockParamContentUnion) GetLines

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

func (BetaTextEditorCodeExecutionToolResultBlockParamContentUnion) GetNewLines

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

func (BetaTextEditorCodeExecutionToolResultBlockParamContentUnion) GetNewStart

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

func (BetaTextEditorCodeExecutionToolResultBlockParamContentUnion) GetNumLines

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

func (BetaTextEditorCodeExecutionToolResultBlockParamContentUnion) GetOldLines

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

func (BetaTextEditorCodeExecutionToolResultBlockParamContentUnion) GetOldStart

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

func (BetaTextEditorCodeExecutionToolResultBlockParamContentUnion) GetStartLine

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

func (BetaTextEditorCodeExecutionToolResultBlockParamContentUnion) GetTotalLines

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

func (BetaTextEditorCodeExecutionToolResultBlockParamContentUnion) GetType

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

func (BetaTextEditorCodeExecutionToolResultBlockParamContentUnion) MarshalJSON

func (*BetaTextEditorCodeExecutionToolResultBlockParamContentUnion) UnmarshalJSON

type BetaTextEditorCodeExecutionToolResultError

type BetaTextEditorCodeExecutionToolResultError struct {
	// Any of "invalid_tool_input", "unavailable", "too_many_requests",
	// "execution_time_exceeded", "file_not_found".
	ErrorCode    BetaTextEditorCodeExecutionToolResultErrorErrorCode `json:"error_code,required"`
	ErrorMessage string                                              `json:"error_message,required"`
	Type         constant.TextEditorCodeExecutionToolResultError     `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ErrorCode    respjson.Field
		ErrorMessage respjson.Field
		Type         respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaTextEditorCodeExecutionToolResultError) RawJSON

Returns the unmodified JSON received from the API

func (*BetaTextEditorCodeExecutionToolResultError) UnmarshalJSON

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

type BetaTextEditorCodeExecutionToolResultErrorErrorCode

type BetaTextEditorCodeExecutionToolResultErrorErrorCode string
const (
	BetaTextEditorCodeExecutionToolResultErrorErrorCodeInvalidToolInput      BetaTextEditorCodeExecutionToolResultErrorErrorCode = "invalid_tool_input"
	BetaTextEditorCodeExecutionToolResultErrorErrorCodeUnavailable           BetaTextEditorCodeExecutionToolResultErrorErrorCode = "unavailable"
	BetaTextEditorCodeExecutionToolResultErrorErrorCodeTooManyRequests       BetaTextEditorCodeExecutionToolResultErrorErrorCode = "too_many_requests"
	BetaTextEditorCodeExecutionToolResultErrorErrorCodeExecutionTimeExceeded BetaTextEditorCodeExecutionToolResultErrorErrorCode = "execution_time_exceeded"
	BetaTextEditorCodeExecutionToolResultErrorErrorCodeFileNotFound          BetaTextEditorCodeExecutionToolResultErrorErrorCode = "file_not_found"
)

type BetaTextEditorCodeExecutionToolResultErrorParam

type BetaTextEditorCodeExecutionToolResultErrorParam struct {
	// Any of "invalid_tool_input", "unavailable", "too_many_requests",
	// "execution_time_exceeded", "file_not_found".
	ErrorCode    BetaTextEditorCodeExecutionToolResultErrorParamErrorCode `json:"error_code,omitzero,required"`
	ErrorMessage param.Opt[string]                                        `json:"error_message,omitzero"`
	// This field can be elided, and will marshal its zero value as
	// "text_editor_code_execution_tool_result_error".
	Type constant.TextEditorCodeExecutionToolResultError `json:"type,required"`
	// contains filtered or unexported fields
}

The properties ErrorCode, Type are required.

func (BetaTextEditorCodeExecutionToolResultErrorParam) MarshalJSON

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

func (*BetaTextEditorCodeExecutionToolResultErrorParam) UnmarshalJSON

type BetaTextEditorCodeExecutionToolResultErrorParamErrorCode

type BetaTextEditorCodeExecutionToolResultErrorParamErrorCode string
const (
	BetaTextEditorCodeExecutionToolResultErrorParamErrorCodeInvalidToolInput      BetaTextEditorCodeExecutionToolResultErrorParamErrorCode = "invalid_tool_input"
	BetaTextEditorCodeExecutionToolResultErrorParamErrorCodeUnavailable           BetaTextEditorCodeExecutionToolResultErrorParamErrorCode = "unavailable"
	BetaTextEditorCodeExecutionToolResultErrorParamErrorCodeTooManyRequests       BetaTextEditorCodeExecutionToolResultErrorParamErrorCode = "too_many_requests"
	BetaTextEditorCodeExecutionToolResultErrorParamErrorCodeExecutionTimeExceeded BetaTextEditorCodeExecutionToolResultErrorParamErrorCode = "execution_time_exceeded"
	BetaTextEditorCodeExecutionToolResultErrorParamErrorCodeFileNotFound          BetaTextEditorCodeExecutionToolResultErrorParamErrorCode = "file_not_found"
)

type BetaTextEditorCodeExecutionViewResultBlock

type BetaTextEditorCodeExecutionViewResultBlock struct {
	Content string `json:"content,required"`
	// Any of "text", "image", "pdf".
	FileType   BetaTextEditorCodeExecutionViewResultBlockFileType `json:"file_type,required"`
	NumLines   int64                                              `json:"num_lines,required"`
	StartLine  int64                                              `json:"start_line,required"`
	TotalLines int64                                              `json:"total_lines,required"`
	Type       constant.TextEditorCodeExecutionViewResult         `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Content     respjson.Field
		FileType    respjson.Field
		NumLines    respjson.Field
		StartLine   respjson.Field
		TotalLines  respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaTextEditorCodeExecutionViewResultBlock) RawJSON

Returns the unmodified JSON received from the API

func (*BetaTextEditorCodeExecutionViewResultBlock) UnmarshalJSON

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

type BetaTextEditorCodeExecutionViewResultBlockFileType

type BetaTextEditorCodeExecutionViewResultBlockFileType string
const (
	BetaTextEditorCodeExecutionViewResultBlockFileTypeText  BetaTextEditorCodeExecutionViewResultBlockFileType = "text"
	BetaTextEditorCodeExecutionViewResultBlockFileTypeImage BetaTextEditorCodeExecutionViewResultBlockFileType = "image"
	BetaTextEditorCodeExecutionViewResultBlockFileTypePDF   BetaTextEditorCodeExecutionViewResultBlockFileType = "pdf"
)

type BetaTextEditorCodeExecutionViewResultBlockParam

type BetaTextEditorCodeExecutionViewResultBlockParam struct {
	Content string `json:"content,required"`
	// Any of "text", "image", "pdf".
	FileType   BetaTextEditorCodeExecutionViewResultBlockParamFileType `json:"file_type,omitzero,required"`
	NumLines   param.Opt[int64]                                        `json:"num_lines,omitzero"`
	StartLine  param.Opt[int64]                                        `json:"start_line,omitzero"`
	TotalLines param.Opt[int64]                                        `json:"total_lines,omitzero"`
	// This field can be elided, and will marshal its zero value as
	// "text_editor_code_execution_view_result".
	Type constant.TextEditorCodeExecutionViewResult `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Content, FileType, Type are required.

func (BetaTextEditorCodeExecutionViewResultBlockParam) MarshalJSON

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

func (*BetaTextEditorCodeExecutionViewResultBlockParam) UnmarshalJSON

type BetaTextEditorCodeExecutionViewResultBlockParamFileType

type BetaTextEditorCodeExecutionViewResultBlockParamFileType string
const (
	BetaTextEditorCodeExecutionViewResultBlockParamFileTypeText  BetaTextEditorCodeExecutionViewResultBlockParamFileType = "text"
	BetaTextEditorCodeExecutionViewResultBlockParamFileTypeImage BetaTextEditorCodeExecutionViewResultBlockParamFileType = "image"
	BetaTextEditorCodeExecutionViewResultBlockParamFileTypePDF   BetaTextEditorCodeExecutionViewResultBlockParamFileType = "pdf"
)

type BetaThinkingBlock

type BetaThinkingBlock struct {
	Signature string            `json:"signature,required"`
	Thinking  string            `json:"thinking,required"`
	Type      constant.Thinking `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Signature   respjson.Field
		Thinking    respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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) MarshalJSON

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

func (*BetaThinkingBlockParam) UnmarshalJSON

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

type BetaThinkingConfigAdaptiveParam

type BetaThinkingConfigAdaptiveParam struct {
	Type constant.Adaptive `json:"type,required"`
	// contains filtered or unexported fields
}

This struct has a constant value, construct it with NewBetaThinkingConfigAdaptiveParam.

func NewBetaThinkingConfigAdaptiveParam

func NewBetaThinkingConfigAdaptiveParam() BetaThinkingConfigAdaptiveParam

func (BetaThinkingConfigAdaptiveParam) MarshalJSON

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

func (*BetaThinkingConfigAdaptiveParam) UnmarshalJSON

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

type BetaThinkingConfigDisabledParam

type BetaThinkingConfigDisabledParam struct {
	Type constant.Disabled `json:"type,required"`
	// contains filtered or unexported fields
}

This struct has a constant value, construct it with NewBetaThinkingConfigDisabledParam.

func NewBetaThinkingConfigDisabledParam

func NewBetaThinkingConfigDisabledParam() BetaThinkingConfigDisabledParam

func (BetaThinkingConfigDisabledParam) MarshalJSON

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

func (*BetaThinkingConfigDisabledParam) UnmarshalJSON

func (r *BetaThinkingConfigDisabledParam) UnmarshalJSON(data []byte) 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.claude.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) MarshalJSON

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

func (*BetaThinkingConfigEnabledParam) UnmarshalJSON

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

type BetaThinkingConfigParamUnion

type BetaThinkingConfigParamUnion struct {
	OfEnabled  *BetaThinkingConfigEnabledParam  `json:",omitzero,inline"`
	OfDisabled *BetaThinkingConfigDisabledParam `json:",omitzero,inline"`
	OfAdaptive *BetaThinkingConfigAdaptiveParam `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 BetaThinkingConfigParamOfEnabled

func BetaThinkingConfigParamOfEnabled(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) MarshalJSON

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

func (*BetaThinkingConfigParamUnion) UnmarshalJSON

func (u *BetaThinkingConfigParamUnion) UnmarshalJSON(data []byte) error

type BetaThinkingDelta

type BetaThinkingDelta struct {
	Thinking string                 `json:"thinking,required"`
	Type     constant.ThinkingDelta `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Thinking    respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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 BetaThinkingTurnsParam

type BetaThinkingTurnsParam struct {
	Value int64 `json:"value,required"`
	// This field can be elided, and will marshal its zero value as "thinking_turns".
	Type constant.ThinkingTurns `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Type, Value are required.

func (BetaThinkingTurnsParam) MarshalJSON

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

func (*BetaThinkingTurnsParam) UnmarshalJSON

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

type BetaTool

type BetaTool interface {
	// Name returns the tool's name
	Name() string
	// Description returns the tool's description
	Description() string
	// InputSchema returns the JSON schema for the tool's input
	InputSchema() BetaToolInputSchemaParam
	// Execute runs the tool with raw JSON input and returns the result
	Execute(ctx context.Context, input json.RawMessage) (BetaToolResultBlockParamContentUnion, error)
}

BetaTool represents a tool that can be executed by the BetaToolRunner.

type BetaToolBash20241022Param

type BetaToolBash20241022Param struct {
	// If true, tool will not be included in initial system prompt. Only loaded when
	// returned via tool_reference from tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// When true, guarantees schema validation on tool names and inputs
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// Create a cache control breakpoint at this content block.
	CacheControl  BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	InputExamples []map[string]any               `json:"input_examples,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) MarshalJSON

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

func (*BetaToolBash20241022Param) UnmarshalJSON

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

type BetaToolBash20250124Param

type BetaToolBash20250124Param struct {
	// If true, tool will not be included in initial system prompt. Only loaded when
	// returned via tool_reference from tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// When true, guarantees schema validation on tool names and inputs
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// Create a cache control breakpoint at this content block.
	CacheControl  BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	InputExamples []map[string]any               `json:"input_examples,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) MarshalJSON

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

func (*BetaToolBash20250124Param) UnmarshalJSON

func (r *BetaToolBash20250124Param) UnmarshalJSON(data []byte) 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) MarshalJSON

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

func (*BetaToolChoiceAnyParam) UnmarshalJSON

func (r *BetaToolChoiceAnyParam) UnmarshalJSON(data []byte) 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) MarshalJSON

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

func (*BetaToolChoiceAutoParam) UnmarshalJSON

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

type BetaToolChoiceNoneParam

type BetaToolChoiceNoneParam struct {
	Type constant.None `json:"type,required"`
	// contains filtered or unexported fields
}

The model will not be allowed to use tools.

This struct has a constant value, construct it with NewBetaToolChoiceNoneParam.

func NewBetaToolChoiceNoneParam

func NewBetaToolChoiceNoneParam() BetaToolChoiceNoneParam

func (BetaToolChoiceNoneParam) MarshalJSON

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

func (*BetaToolChoiceNoneParam) UnmarshalJSON

func (r *BetaToolChoiceNoneParam) UnmarshalJSON(data []byte) 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) MarshalJSON

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

func (*BetaToolChoiceToolParam) UnmarshalJSON

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

type BetaToolChoiceUnionParam

type BetaToolChoiceUnionParam struct {
	OfAuto *BetaToolChoiceAutoParam `json:",omitzero,inline"`
	OfAny  *BetaToolChoiceAnyParam  `json:",omitzero,inline"`
	OfTool *BetaToolChoiceToolParam `json:",omitzero,inline"`
	OfNone *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 BetaToolChoiceParamOfTool

func BetaToolChoiceParamOfTool(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) MarshalJSON

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

func (*BetaToolChoiceUnionParam) UnmarshalJSON

func (u *BetaToolChoiceUnionParam) UnmarshalJSON(data []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"`
	// If true, tool will not be included in initial system prompt. Only loaded when
	// returned via tool_reference from tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// When true, guarantees schema validation on tool names and inputs
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// Create a cache control breakpoint at this content block.
	CacheControl  BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	InputExamples []map[string]any               `json:"input_examples,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) MarshalJSON

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

func (*BetaToolComputerUse20241022Param) UnmarshalJSON

func (r *BetaToolComputerUse20241022Param) UnmarshalJSON(data []byte) 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"`
	// If true, tool will not be included in initial system prompt. Only loaded when
	// returned via tool_reference from tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// When true, guarantees schema validation on tool names and inputs
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// Create a cache control breakpoint at this content block.
	CacheControl  BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	InputExamples []map[string]any               `json:"input_examples,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) MarshalJSON

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

func (*BetaToolComputerUse20250124Param) UnmarshalJSON

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

type BetaToolComputerUse20251124Param

type BetaToolComputerUse20251124Param 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"`
	// If true, tool will not be included in initial system prompt. Only loaded when
	// returned via tool_reference from tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// Whether to enable an action to take a zoomed-in screenshot of the screen.
	EnableZoom param.Opt[bool] `json:"enable_zoom,omitzero"`
	// When true, guarantees schema validation on tool names and inputs
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// Create a cache control breakpoint at this content block.
	CacheControl  BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	InputExamples []map[string]any               `json:"input_examples,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_20251124".
	Type constant.Computer20251124 `json:"type,required"`
	// contains filtered or unexported fields
}

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

func (BetaToolComputerUse20251124Param) MarshalJSON

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

func (*BetaToolComputerUse20251124Param) UnmarshalJSON

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

type BetaToolInputSchemaParam

type BetaToolInputSchemaParam struct {
	Properties any      `json:"properties,omitzero"`
	Required   []string `json:"required,omitzero"`
	// This field can be elided, and will marshal its zero value as "object".
	Type        constant.Object `json:"type,required"`
	ExtraFields map[string]any  `json:"-"`
	// 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 BetaToolInputSchema

func BetaToolInputSchema(jsonSchema map[string]any) BetaToolInputSchemaParam

BetaToolInputSchema creates a BetaToolInputSchemaParam from a JSON schema map. It transforms the schema to ensure compatibility with Anthropic's tool calling requirements.

func (BetaToolInputSchemaParam) MarshalJSON

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

func (*BetaToolInputSchemaParam) UnmarshalJSON

func (r *BetaToolInputSchemaParam) UnmarshalJSON(data []byte) 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"`
	// Enable eager input streaming for this tool. When true, tool input parameters
	// will be streamed incrementally as they are generated, and types will be inferred
	// on-the-fly rather than buffering the full JSON output. When false, streaming is
	// disabled for this tool even if the fine-grained-tool-streaming beta is active.
	// When null (default), uses the default behavior based on beta headers.
	EagerInputStreaming param.Opt[bool] `json:"eager_input_streaming,omitzero"`
	// If true, tool will not be included in initial system prompt. Only loaded when
	// returned via tool_reference from tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// 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"`
	// When true, guarantees schema validation on tool names and inputs
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// Any of "custom".
	Type BetaToolType `json:"type,omitzero"`
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// Create a cache control breakpoint at this content block.
	CacheControl  BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	InputExamples []map[string]any               `json:"input_examples,omitzero"`
	// contains filtered or unexported fields
}

The properties InputSchema, Name are required.

func (BetaToolParam) MarshalJSON

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

func (*BetaToolParam) UnmarshalJSON

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

type BetaToolReferenceBlock

type BetaToolReferenceBlock struct {
	ToolName string                 `json:"tool_name,required"`
	Type     constant.ToolReference `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ToolName    respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaToolReferenceBlock) RawJSON

func (r BetaToolReferenceBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (BetaToolReferenceBlock) ToParam

func (*BetaToolReferenceBlock) UnmarshalJSON

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

type BetaToolReferenceBlockParam

type BetaToolReferenceBlockParam struct {
	ToolName string `json:"tool_name,required"`
	// Create a cache control breakpoint at this content block.
	CacheControl BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	// This field can be elided, and will marshal its zero value as "tool_reference".
	Type constant.ToolReference `json:"type,required"`
	// contains filtered or unexported fields
}

Tool reference block that can be included in tool_result content.

The properties ToolName, Type are required.

func (BetaToolReferenceBlockParam) MarshalJSON

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

func (*BetaToolReferenceBlockParam) UnmarshalJSON

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

type BetaToolResultBlockParam

type BetaToolResultBlockParam struct {
	ToolUseID string          `json:"tool_use_id,required"`
	IsError   param.Opt[bool] `json:"is_error,omitzero"`
	// Create a cache control breakpoint at this content block.
	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 NewBetaToolResultTextBlockParam

func NewBetaToolResultTextBlockParam(toolUseID string, text string, isError bool) BetaToolResultBlockParam

func (BetaToolResultBlockParam) MarshalJSON

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

func (*BetaToolResultBlockParam) UnmarshalJSON

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

type BetaToolResultBlockParamContentUnion

type BetaToolResultBlockParamContentUnion struct {
	OfText          *BetaTextBlockParam            `json:",omitzero,inline"`
	OfImage         *BetaImageBlockParam           `json:",omitzero,inline"`
	OfSearchResult  *BetaSearchResultBlockParam    `json:",omitzero,inline"`
	OfDocument      *BetaRequestDocumentBlockParam `json:",omitzero,inline"`
	OfToolReference *BetaToolReferenceBlockParam   `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

func (u BetaToolResultBlockParamContentUnion) GetCitations() (res betaToolResultBlockParamContentUnionCitations)

Returns a subunion which exports methods to access subproperties

Or use AsAny() to get the underlying value

func (BetaToolResultBlockParamContentUnion) GetContent

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

func (BetaToolResultBlockParamContentUnion) GetContext

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

func (BetaToolResultBlockParamContentUnion) GetSource

func (u BetaToolResultBlockParamContentUnion) GetSource() (res betaToolResultBlockParamContentUnionSource)

Returns a subunion which exports methods to access subproperties

Or use AsAny() to get the underlying value

func (BetaToolResultBlockParamContentUnion) GetText

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

func (BetaToolResultBlockParamContentUnion) GetTitle

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

func (BetaToolResultBlockParamContentUnion) GetToolName

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) MarshalJSON

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

func (*BetaToolResultBlockParamContentUnion) UnmarshalJSON

func (u *BetaToolResultBlockParamContentUnion) UnmarshalJSON(data []byte) error

type BetaToolRunner

type BetaToolRunner struct {
	// contains filtered or unexported fields
}

BetaToolRunner manages the automatic conversation loop between the assistant and tools using non-streaming API calls. It implements an iterator pattern for processing conversation turns.

A BetaToolRunner is NOT safe for concurrent use. All methods must be called from a single goroutine. However, tool handlers ARE called concurrently when multiple tools are invoked in a single turn - ensure your handlers are thread-safe.

func (*BetaToolRunner) All

All returns an iterator that yields all messages until the conversation completes. This is a convenience method for iterating over the entire conversation.

Example usage:

for message, err := range runner.All(ctx) {
    if err != nil {
        return err
    }
    // process message
}

func (*BetaToolRunner) AppendMessages

func (b *BetaToolRunner) AppendMessages(messages ...BetaMessageParam)

AppendMessages adds messages to the conversation history. This is a convenience method equivalent to:

runner.Params.Messages = append(runner.Params.Messages, messages...)

func (*BetaToolRunner) Err

func (b *BetaToolRunner) Err() error

Err returns the last error that occurred during iteration, if any. This is useful when using All() or AllStreaming() to check for errors after the iteration completes.

func (*BetaToolRunner) IsCompleted

func (b *BetaToolRunner) IsCompleted() bool

IsCompleted returns true if the conversation has finished, either because the model stopped using tools or the maximum iteration limit was reached.

func (*BetaToolRunner) IterationCount

func (b *BetaToolRunner) IterationCount() int

IterationCount returns the number of API calls made so far. This is incremented each time a turn makes an API call.

func (*BetaToolRunner) LastMessage

func (b *BetaToolRunner) LastMessage() *BetaMessage

LastMessage returns the most recent assistant message, or nil if no messages have been received yet.

func (*BetaToolRunner) Messages

func (b *BetaToolRunner) Messages() []BetaMessageParam

Messages returns a copy of the current conversation history. The returned slice can be safely modified without affecting the runner's state.

func (*BetaToolRunner) NextMessage

func (r *BetaToolRunner) NextMessage(ctx context.Context) (*BetaMessage, error)

NextMessage advances the conversation by one turn. It executes any pending tool calls from the previous message, then makes an API call to get the model's next response.

Returns:

  • (message, nil) on success with the assistant's response
  • (nil, nil) when the conversation is complete (no more tool calls or max iterations reached)
  • (nil, error) if an error occurred during tool execution or API call

func (*BetaToolRunner) RunToCompletion

func (r *BetaToolRunner) RunToCompletion(ctx context.Context) (*BetaMessage, error)

RunToCompletion repeatedly calls NextMessage until the conversation is complete, either because the model stopped using tools or the maximum iteration limit was reached.

Returns the final assistant message and any error that occurred.

type BetaToolRunnerParams

type BetaToolRunnerParams struct {
	BetaMessageNewParams
	// MaxIterations limits the number of API calls. When set to 0 (the default),
	// there is no limit and the runner continues until the model stops using tools.
	MaxIterations int
}

BetaToolRunnerParams contains parameters for creating a BetaToolRunner or BetaToolRunnerStreaming.

type BetaToolRunnerStreaming

type BetaToolRunnerStreaming struct {
	// contains filtered or unexported fields
}

BetaToolRunnerStreaming manages the automatic conversation loop between the assistant and tools using streaming API calls. It implements an iterator pattern for processing streaming events across conversation turns.

A BetaToolRunnerStreaming is NOT safe for concurrent use. All methods must be called from a single goroutine. However, tool handlers ARE called concurrently when multiple tools are invoked in a single turn - ensure your handlers are thread-safe.

func (*BetaToolRunnerStreaming) AllStreaming

AllStreaming returns an iterator of iterators, where each inner iterator yields streaming events for a single turn of the conversation. The outer iterator continues until the conversation completes.

Example usage:

for events, err := range runner.AllStreaming(ctx) {
    if err != nil {
        return err
    }
    for event, err := range events {
        if err != nil {
            return err
        }
        // process streaming event
    }
}

func (*BetaToolRunnerStreaming) AppendMessages

func (b *BetaToolRunnerStreaming) AppendMessages(messages ...BetaMessageParam)

AppendMessages adds messages to the conversation history. This is a convenience method equivalent to:

runner.Params.Messages = append(runner.Params.Messages, messages...)

func (*BetaToolRunnerStreaming) Err

func (b *BetaToolRunnerStreaming) Err() error

Err returns the last error that occurred during iteration, if any. This is useful when using All() or AllStreaming() to check for errors after the iteration completes.

func (*BetaToolRunnerStreaming) IsCompleted

func (b *BetaToolRunnerStreaming) IsCompleted() bool

IsCompleted returns true if the conversation has finished, either because the model stopped using tools or the maximum iteration limit was reached.

func (*BetaToolRunnerStreaming) IterationCount

func (b *BetaToolRunnerStreaming) IterationCount() int

IterationCount returns the number of API calls made so far. This is incremented each time a turn makes an API call.

func (*BetaToolRunnerStreaming) LastMessage

func (b *BetaToolRunnerStreaming) LastMessage() *BetaMessage

LastMessage returns the most recent assistant message, or nil if no messages have been received yet.

func (*BetaToolRunnerStreaming) Messages

func (b *BetaToolRunnerStreaming) Messages() []BetaMessageParam

Messages returns a copy of the current conversation history. The returned slice can be safely modified without affecting the runner's state.

func (*BetaToolRunnerStreaming) NextStreaming

NextStreaming advances the conversation by one turn with streaming. It executes any pending tool calls from the previous message, then makes a streaming API call.

Returns an iterator that yields streaming events as they arrive. The iterator should be fully consumed to ensure the message is properly accumulated for subsequent turns.

If an error occurs, it will be yielded as the second value in the iterator pair. Check IsCompleted() after consuming the iterator to determine if the conversation has finished.

type BetaToolSearchToolBm25_20251119Param

type BetaToolSearchToolBm25_20251119Param struct {
	// Any of "tool_search_tool_bm25_20251119", "tool_search_tool_bm25".
	Type BetaToolSearchToolBm25_20251119Type `json:"type,omitzero,required"`
	// If true, tool will not be included in initial system prompt. Only loaded when
	// returned via tool_reference from tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// When true, guarantees schema validation on tool names and inputs
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// Create a cache control breakpoint at this content block.
	CacheControl  BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	InputExamples []map[string]any               `json:"input_examples,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
	// "tool_search_tool_bm25".
	Name constant.ToolSearchToolBm25 `json:"name,required"`
	// contains filtered or unexported fields
}

The properties Name, Type are required.

func (BetaToolSearchToolBm25_20251119Param) MarshalJSON

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

func (*BetaToolSearchToolBm25_20251119Param) UnmarshalJSON

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

type BetaToolSearchToolBm25_20251119Type

type BetaToolSearchToolBm25_20251119Type string
const (
	BetaToolSearchToolBm25_20251119TypeToolSearchToolBm25_20251119 BetaToolSearchToolBm25_20251119Type = "tool_search_tool_bm25_20251119"
	BetaToolSearchToolBm25_20251119TypeToolSearchToolBm25          BetaToolSearchToolBm25_20251119Type = "tool_search_tool_bm25"
)

type BetaToolSearchToolRegex20251119Param

type BetaToolSearchToolRegex20251119Param struct {
	// Any of "tool_search_tool_regex_20251119", "tool_search_tool_regex".
	Type BetaToolSearchToolRegex20251119Type `json:"type,omitzero,required"`
	// If true, tool will not be included in initial system prompt. Only loaded when
	// returned via tool_reference from tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// When true, guarantees schema validation on tool names and inputs
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// Create a cache control breakpoint at this content block.
	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
	// "tool_search_tool_regex".
	Name constant.ToolSearchToolRegex `json:"name,required"`
	// contains filtered or unexported fields
}

The properties Name, Type are required.

func (BetaToolSearchToolRegex20251119Param) MarshalJSON

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

func (*BetaToolSearchToolRegex20251119Param) UnmarshalJSON

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

type BetaToolSearchToolRegex20251119Type

type BetaToolSearchToolRegex20251119Type string
const (
	BetaToolSearchToolRegex20251119TypeToolSearchToolRegex20251119 BetaToolSearchToolRegex20251119Type = "tool_search_tool_regex_20251119"
	BetaToolSearchToolRegex20251119TypeToolSearchToolRegex         BetaToolSearchToolRegex20251119Type = "tool_search_tool_regex"
)

type BetaToolSearchToolResultBlock

type BetaToolSearchToolResultBlock struct {
	Content   BetaToolSearchToolResultBlockContentUnion `json:"content,required"`
	ToolUseID string                                    `json:"tool_use_id,required"`
	Type      constant.ToolSearchToolResult             `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Content     respjson.Field
		ToolUseID   respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaToolSearchToolResultBlock) RawJSON

Returns the unmodified JSON received from the API

func (BetaToolSearchToolResultBlock) ToParam

func (*BetaToolSearchToolResultBlock) UnmarshalJSON

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

type BetaToolSearchToolResultBlockContentUnion

type BetaToolSearchToolResultBlockContentUnion struct {
	// This field is from variant [BetaToolSearchToolResultError].
	ErrorCode BetaToolSearchToolResultErrorErrorCode `json:"error_code"`
	// This field is from variant [BetaToolSearchToolResultError].
	ErrorMessage string `json:"error_message"`
	Type         string `json:"type"`
	// This field is from variant [BetaToolSearchToolSearchResultBlock].
	ToolReferences []BetaToolReferenceBlock `json:"tool_references"`
	JSON           struct {
		ErrorCode      respjson.Field
		ErrorMessage   respjson.Field
		Type           respjson.Field
		ToolReferences respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

BetaToolSearchToolResultBlockContentUnion contains all possible properties and values from BetaToolSearchToolResultError, BetaToolSearchToolSearchResultBlock.

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

func (BetaToolSearchToolResultBlockContentUnion) AsResponseToolSearchToolResultError

func (u BetaToolSearchToolResultBlockContentUnion) AsResponseToolSearchToolResultError() (v BetaToolSearchToolResultError)

func (BetaToolSearchToolResultBlockContentUnion) AsResponseToolSearchToolSearchResultBlock

func (u BetaToolSearchToolResultBlockContentUnion) AsResponseToolSearchToolSearchResultBlock() (v BetaToolSearchToolSearchResultBlock)

func (BetaToolSearchToolResultBlockContentUnion) RawJSON

Returns the unmodified JSON received from the API

func (*BetaToolSearchToolResultBlockContentUnion) UnmarshalJSON

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

type BetaToolSearchToolResultBlockParam

type BetaToolSearchToolResultBlockParam struct {
	Content   BetaToolSearchToolResultBlockParamContentUnion `json:"content,omitzero,required"`
	ToolUseID string                                         `json:"tool_use_id,required"`
	// Create a cache control breakpoint at this content block.
	CacheControl BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	// This field can be elided, and will marshal its zero value as
	// "tool_search_tool_result".
	Type constant.ToolSearchToolResult `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Content, ToolUseID, Type are required.

func (BetaToolSearchToolResultBlockParam) MarshalJSON

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

func (*BetaToolSearchToolResultBlockParam) UnmarshalJSON

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

type BetaToolSearchToolResultBlockParamContentUnion

type BetaToolSearchToolResultBlockParamContentUnion struct {
	OfRequestToolSearchToolResultError       *BetaToolSearchToolResultErrorParam       `json:",omitzero,inline"`
	OfRequestToolSearchToolSearchResultBlock *BetaToolSearchToolSearchResultBlockParam `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 (BetaToolSearchToolResultBlockParamContentUnion) GetErrorCode

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

func (BetaToolSearchToolResultBlockParamContentUnion) GetToolReferences

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

func (BetaToolSearchToolResultBlockParamContentUnion) GetType

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

func (BetaToolSearchToolResultBlockParamContentUnion) MarshalJSON

func (*BetaToolSearchToolResultBlockParamContentUnion) UnmarshalJSON

type BetaToolSearchToolResultError

type BetaToolSearchToolResultError struct {
	// Any of "invalid_tool_input", "unavailable", "too_many_requests",
	// "execution_time_exceeded".
	ErrorCode    BetaToolSearchToolResultErrorErrorCode `json:"error_code,required"`
	ErrorMessage string                                 `json:"error_message,required"`
	Type         constant.ToolSearchToolResultError     `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ErrorCode    respjson.Field
		ErrorMessage respjson.Field
		Type         respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaToolSearchToolResultError) RawJSON

Returns the unmodified JSON received from the API

func (*BetaToolSearchToolResultError) UnmarshalJSON

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

type BetaToolSearchToolResultErrorErrorCode

type BetaToolSearchToolResultErrorErrorCode string
const (
	BetaToolSearchToolResultErrorErrorCodeInvalidToolInput      BetaToolSearchToolResultErrorErrorCode = "invalid_tool_input"
	BetaToolSearchToolResultErrorErrorCodeUnavailable           BetaToolSearchToolResultErrorErrorCode = "unavailable"
	BetaToolSearchToolResultErrorErrorCodeTooManyRequests       BetaToolSearchToolResultErrorErrorCode = "too_many_requests"
	BetaToolSearchToolResultErrorErrorCodeExecutionTimeExceeded BetaToolSearchToolResultErrorErrorCode = "execution_time_exceeded"
)

type BetaToolSearchToolResultErrorParam

type BetaToolSearchToolResultErrorParam struct {
	// Any of "invalid_tool_input", "unavailable", "too_many_requests",
	// "execution_time_exceeded".
	ErrorCode BetaToolSearchToolResultErrorParamErrorCode `json:"error_code,omitzero,required"`
	// This field can be elided, and will marshal its zero value as
	// "tool_search_tool_result_error".
	Type constant.ToolSearchToolResultError `json:"type,required"`
	// contains filtered or unexported fields
}

The properties ErrorCode, Type are required.

func (BetaToolSearchToolResultErrorParam) MarshalJSON

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

func (*BetaToolSearchToolResultErrorParam) UnmarshalJSON

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

type BetaToolSearchToolResultErrorParamErrorCode

type BetaToolSearchToolResultErrorParamErrorCode string
const (
	BetaToolSearchToolResultErrorParamErrorCodeInvalidToolInput      BetaToolSearchToolResultErrorParamErrorCode = "invalid_tool_input"
	BetaToolSearchToolResultErrorParamErrorCodeUnavailable           BetaToolSearchToolResultErrorParamErrorCode = "unavailable"
	BetaToolSearchToolResultErrorParamErrorCodeTooManyRequests       BetaToolSearchToolResultErrorParamErrorCode = "too_many_requests"
	BetaToolSearchToolResultErrorParamErrorCodeExecutionTimeExceeded BetaToolSearchToolResultErrorParamErrorCode = "execution_time_exceeded"
)

type BetaToolSearchToolSearchResultBlock

type BetaToolSearchToolSearchResultBlock struct {
	ToolReferences []BetaToolReferenceBlock            `json:"tool_references,required"`
	Type           constant.ToolSearchToolSearchResult `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ToolReferences respjson.Field
		Type           respjson.Field
		ExtraFields    map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaToolSearchToolSearchResultBlock) RawJSON

Returns the unmodified JSON received from the API

func (*BetaToolSearchToolSearchResultBlock) UnmarshalJSON

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

type BetaToolSearchToolSearchResultBlockParam

type BetaToolSearchToolSearchResultBlockParam struct {
	ToolReferences []BetaToolReferenceBlockParam `json:"tool_references,omitzero,required"`
	// This field can be elided, and will marshal its zero value as
	// "tool_search_tool_search_result".
	Type constant.ToolSearchToolSearchResult `json:"type,required"`
	// contains filtered or unexported fields
}

The properties ToolReferences, Type are required.

func (BetaToolSearchToolSearchResultBlockParam) MarshalJSON

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

func (*BetaToolSearchToolSearchResultBlockParam) UnmarshalJSON

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

type BetaToolTextEditor20241022Param

type BetaToolTextEditor20241022Param struct {
	// If true, tool will not be included in initial system prompt. Only loaded when
	// returned via tool_reference from tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// When true, guarantees schema validation on tool names and inputs
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// Create a cache control breakpoint at this content block.
	CacheControl  BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	InputExamples []map[string]any               `json:"input_examples,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) MarshalJSON

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

func (*BetaToolTextEditor20241022Param) UnmarshalJSON

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

type BetaToolTextEditor20250124Param

type BetaToolTextEditor20250124Param struct {
	// If true, tool will not be included in initial system prompt. Only loaded when
	// returned via tool_reference from tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// When true, guarantees schema validation on tool names and inputs
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// Create a cache control breakpoint at this content block.
	CacheControl  BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	InputExamples []map[string]any               `json:"input_examples,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) MarshalJSON

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

func (*BetaToolTextEditor20250124Param) UnmarshalJSON

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

type BetaToolTextEditor20250429Param

type BetaToolTextEditor20250429Param struct {
	// If true, tool will not be included in initial system prompt. Only loaded when
	// returned via tool_reference from tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// When true, guarantees schema validation on tool names and inputs
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// Create a cache control breakpoint at this content block.
	CacheControl  BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	InputExamples []map[string]any               `json:"input_examples,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_based_edit_tool".
	Name constant.StrReplaceBasedEditTool `json:"name,required"`
	// This field can be elided, and will marshal its zero value as
	// "text_editor_20250429".
	Type constant.TextEditor20250429 `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Name, Type are required.

func (BetaToolTextEditor20250429Param) MarshalJSON

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

func (*BetaToolTextEditor20250429Param) UnmarshalJSON

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

type BetaToolTextEditor20250728Param

type BetaToolTextEditor20250728Param struct {
	// Maximum number of characters to display when viewing a file. If not specified,
	// defaults to displaying the full file.
	MaxCharacters param.Opt[int64] `json:"max_characters,omitzero"`
	// If true, tool will not be included in initial system prompt. Only loaded when
	// returned via tool_reference from tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// When true, guarantees schema validation on tool names and inputs
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// Create a cache control breakpoint at this content block.
	CacheControl  BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	InputExamples []map[string]any               `json:"input_examples,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_based_edit_tool".
	Name constant.StrReplaceBasedEditTool `json:"name,required"`
	// This field can be elided, and will marshal its zero value as
	// "text_editor_20250728".
	Type constant.TextEditor20250728 `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Name, Type are required.

func (BetaToolTextEditor20250728Param) MarshalJSON

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

func (*BetaToolTextEditor20250728Param) UnmarshalJSON

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

type BetaToolType

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

type BetaToolUnionParam

type BetaToolUnionParam struct {
	OfTool                        *BetaToolParam                        `json:",omitzero,inline"`
	OfBashTool20241022            *BetaToolBash20241022Param            `json:",omitzero,inline"`
	OfBashTool20250124            *BetaToolBash20250124Param            `json:",omitzero,inline"`
	OfCodeExecutionTool20250522   *BetaCodeExecutionTool20250522Param   `json:",omitzero,inline"`
	OfCodeExecutionTool20250825   *BetaCodeExecutionTool20250825Param   `json:",omitzero,inline"`
	OfCodeExecutionTool20260120   *BetaCodeExecutionTool20260120Param   `json:",omitzero,inline"`
	OfComputerUseTool20241022     *BetaToolComputerUse20241022Param     `json:",omitzero,inline"`
	OfMemoryTool20250818          *BetaMemoryTool20250818Param          `json:",omitzero,inline"`
	OfComputerUseTool20250124     *BetaToolComputerUse20250124Param     `json:",omitzero,inline"`
	OfTextEditor20241022          *BetaToolTextEditor20241022Param      `json:",omitzero,inline"`
	OfComputerUseTool20251124     *BetaToolComputerUse20251124Param     `json:",omitzero,inline"`
	OfTextEditor20250124          *BetaToolTextEditor20250124Param      `json:",omitzero,inline"`
	OfTextEditor20250429          *BetaToolTextEditor20250429Param      `json:",omitzero,inline"`
	OfTextEditor20250728          *BetaToolTextEditor20250728Param      `json:",omitzero,inline"`
	OfWebSearchTool20250305       *BetaWebSearchTool20250305Param       `json:",omitzero,inline"`
	OfWebFetchTool20250910        *BetaWebFetchTool20250910Param        `json:",omitzero,inline"`
	OfWebSearchTool20260209       *BetaWebSearchTool20260209Param       `json:",omitzero,inline"`
	OfWebFetchTool20260209        *BetaWebFetchTool20260209Param        `json:",omitzero,inline"`
	OfToolSearchToolBm25_20251119 *BetaToolSearchToolBm25_20251119Param `json:",omitzero,inline"`
	OfToolSearchToolRegex20251119 *BetaToolSearchToolRegex20251119Param `json:",omitzero,inline"`
	OfMCPToolset                  *BetaMCPToolsetParam                  `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 BetaToolUnionParamOfComputerUseTool20251124

func BetaToolUnionParamOfComputerUseTool20251124(displayHeightPx int64, displayWidthPx int64) BetaToolUnionParam

func BetaToolUnionParamOfMCPToolset

func BetaToolUnionParamOfMCPToolset(mcpServerName string) BetaToolUnionParam

func BetaToolUnionParamOfTool

func BetaToolUnionParamOfTool(inputSchema BetaToolInputSchemaParam, name string) BetaToolUnionParam

func BetaToolUnionParamOfToolSearchToolBm25_20251119

func BetaToolUnionParamOfToolSearchToolBm25_20251119(type_ BetaToolSearchToolBm25_20251119Type) BetaToolUnionParam

func BetaToolUnionParamOfToolSearchToolRegex20251119

func BetaToolUnionParamOfToolSearchToolRegex20251119(type_ BetaToolSearchToolRegex20251119Type) BetaToolUnionParam

func (BetaToolUnionParam) GetAllowedCallers

func (u BetaToolUnionParam) GetAllowedCallers() []string

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

func (BetaToolUnionParam) GetAllowedDomains

func (u BetaToolUnionParam) GetAllowedDomains() []string

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

func (BetaToolUnionParam) GetBlockedDomains

func (u BetaToolUnionParam) GetBlockedDomains() []string

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

func (BetaToolUnionParam) GetCacheControl

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

func (BetaToolUnionParam) GetCitations

func (u BetaToolUnionParam) GetCitations() *BetaCitationsConfigParam

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

func (BetaToolUnionParam) GetConfigs

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

func (BetaToolUnionParam) GetDefaultConfig

func (u BetaToolUnionParam) GetDefaultConfig() *BetaMCPToolDefaultConfigParam

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

func (BetaToolUnionParam) GetDeferLoading

func (u BetaToolUnionParam) GetDeferLoading() *bool

Returns a pointer to the underlying variant's 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) GetEagerInputStreaming

func (u BetaToolUnionParam) GetEagerInputStreaming() *bool

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

func (BetaToolUnionParam) GetEnableZoom

func (u BetaToolUnionParam) GetEnableZoom() *bool

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

func (BetaToolUnionParam) GetInputExamples

func (u BetaToolUnionParam) GetInputExamples() []map[string]any

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

func (BetaToolUnionParam) GetInputSchema

func (u BetaToolUnionParam) GetInputSchema() *BetaToolInputSchemaParam

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

func (BetaToolUnionParam) GetMCPServerName

func (u BetaToolUnionParam) GetMCPServerName() *string

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

func (BetaToolUnionParam) GetMaxCharacters

func (u BetaToolUnionParam) GetMaxCharacters() *int64

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

func (BetaToolUnionParam) GetMaxContentTokens

func (u BetaToolUnionParam) GetMaxContentTokens() *int64

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

func (BetaToolUnionParam) GetMaxUses

func (u BetaToolUnionParam) GetMaxUses() *int64

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) GetStrict

func (u BetaToolUnionParam) GetStrict() *bool

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) GetUserLocation

func (u BetaToolUnionParam) GetUserLocation() *BetaUserLocationParam

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

func (BetaToolUnionParam) MarshalJSON

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

func (*BetaToolUnionParam) UnmarshalJSON

func (u *BetaToolUnionParam) UnmarshalJSON(data []byte) error

type BetaToolUseBlock

type BetaToolUseBlock struct {
	ID    string           `json:"id,required"`
	Input any              `json:"input,required"`
	Name  string           `json:"name,required"`
	Type  constant.ToolUse `json:"type,required"`
	// Tool invocation directly from the model.
	Caller BetaToolUseBlockCallerUnion `json:"caller"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Input       respjson.Field
		Name        respjson.Field
		Type        respjson.Field
		Caller      respjson.Field
		ExtraFields map[string]respjson.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 BetaToolUseBlockCallerUnion

type BetaToolUseBlockCallerUnion struct {
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	Type   string `json:"type"`
	ToolID string `json:"tool_id"`
	JSON   struct {
		Type   respjson.Field
		ToolID respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

BetaToolUseBlockCallerUnion contains all possible properties and values from BetaDirectCaller, BetaServerToolCaller, BetaServerToolCaller20260120.

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

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

func (BetaToolUseBlockCallerUnion) AsAny

func (u BetaToolUseBlockCallerUnion) AsAny() anyBetaToolUseBlockCaller

Use the following switch statement to find the correct variant

switch variant := BetaToolUseBlockCallerUnion.AsAny().(type) {
case anthropic.BetaDirectCaller:
case anthropic.BetaServerToolCaller:
case anthropic.BetaServerToolCaller20260120:
default:
  fmt.Errorf("no variant present")
}

func (BetaToolUseBlockCallerUnion) AsCodeExecution20250825

func (u BetaToolUseBlockCallerUnion) AsCodeExecution20250825() (v BetaServerToolCaller)

func (BetaToolUseBlockCallerUnion) AsCodeExecution20260120

func (u BetaToolUseBlockCallerUnion) AsCodeExecution20260120() (v BetaServerToolCaller20260120)

func (BetaToolUseBlockCallerUnion) AsDirect

func (BetaToolUseBlockCallerUnion) RawJSON

func (u BetaToolUseBlockCallerUnion) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaToolUseBlockCallerUnion) UnmarshalJSON

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

type BetaToolUseBlockParam

type BetaToolUseBlockParam struct {
	ID    string `json:"id,required"`
	Input any    `json:"input,omitzero,required"`
	Name  string `json:"name,required"`
	// Create a cache control breakpoint at this content block.
	CacheControl BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	// Tool invocation directly from the model.
	Caller BetaToolUseBlockParamCallerUnion `json:"caller,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) MarshalJSON

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

func (*BetaToolUseBlockParam) UnmarshalJSON

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

type BetaToolUseBlockParamCallerUnion

type BetaToolUseBlockParamCallerUnion struct {
	OfDirect                *BetaDirectCallerParam             `json:",omitzero,inline"`
	OfCodeExecution20250825 *BetaServerToolCallerParam         `json:",omitzero,inline"`
	OfCodeExecution20260120 *BetaServerToolCaller20260120Param `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 (BetaToolUseBlockParamCallerUnion) GetToolID

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

func (BetaToolUseBlockParamCallerUnion) GetType

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

func (BetaToolUseBlockParamCallerUnion) MarshalJSON

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

func (*BetaToolUseBlockParamCallerUnion) UnmarshalJSON

func (u *BetaToolUseBlockParamCallerUnion) UnmarshalJSON(data []byte) error

type BetaToolUsesKeepParam

type BetaToolUsesKeepParam struct {
	Value int64 `json:"value,required"`
	// This field can be elided, and will marshal its zero value as "tool_uses".
	Type constant.ToolUses `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Type, Value are required.

func (BetaToolUsesKeepParam) MarshalJSON

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

func (*BetaToolUsesKeepParam) UnmarshalJSON

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

type BetaToolUsesTriggerParam

type BetaToolUsesTriggerParam struct {
	Value int64 `json:"value,required"`
	// This field can be elided, and will marshal its zero value as "tool_uses".
	Type constant.ToolUses `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Type, Value are required.

func (BetaToolUsesTriggerParam) MarshalJSON

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

func (*BetaToolUsesTriggerParam) UnmarshalJSON

func (r *BetaToolUsesTriggerParam) UnmarshalJSON(data []byte) 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) MarshalJSON

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

func (*BetaURLImageSourceParam) UnmarshalJSON

func (r *BetaURLImageSourceParam) UnmarshalJSON(data []byte) 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) MarshalJSON

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

func (*BetaURLPDFSourceParam) UnmarshalJSON

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

type BetaUsage

type BetaUsage struct {
	// Breakdown of cached tokens by TTL
	CacheCreation BetaCacheCreation `json:"cache_creation,required"`
	// 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 geographic region where inference was performed for this request.
	InferenceGeo string `json:"inference_geo,required"`
	// The number of input tokens which were used.
	InputTokens int64 `json:"input_tokens,required"`
	// Per-iteration token usage breakdown.
	//
	// Each entry represents one sampling iteration, with its own input/output token
	// counts and cache statistics. This allows you to:
	//
	// - Determine which iterations exceeded long context thresholds (>=200k tokens)
	// - Calculate the true context window size from the last iteration
	// - Understand token accumulation across server-side tool use loops
	Iterations BetaIterationsUsage `json:"iterations,required"`
	// The number of output tokens which were used.
	OutputTokens int64 `json:"output_tokens,required"`
	// The number of server tool requests.
	ServerToolUse BetaServerToolUsage `json:"server_tool_use,required"`
	// If the request used the priority, standard, or batch tier.
	//
	// Any of "standard", "priority", "batch".
	ServiceTier BetaUsageServiceTier `json:"service_tier,required"`
	// The inference speed mode used for this request.
	//
	// Any of "standard", "fast".
	Speed BetaUsageSpeed `json:"speed,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CacheCreation            respjson.Field
		CacheCreationInputTokens respjson.Field
		CacheReadInputTokens     respjson.Field
		InferenceGeo             respjson.Field
		InputTokens              respjson.Field
		Iterations               respjson.Field
		OutputTokens             respjson.Field
		ServerToolUse            respjson.Field
		ServiceTier              respjson.Field
		Speed                    respjson.Field
		ExtraFields              map[string]respjson.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 BetaUsageServiceTier

type BetaUsageServiceTier string

If the request used the priority, standard, or batch tier.

const (
	BetaUsageServiceTierStandard BetaUsageServiceTier = "standard"
	BetaUsageServiceTierPriority BetaUsageServiceTier = "priority"
	BetaUsageServiceTierBatch    BetaUsageServiceTier = "batch"
)

type BetaUsageSpeed

type BetaUsageSpeed string

The inference speed mode used for this request.

const (
	BetaUsageSpeedStandard BetaUsageSpeed = "standard"
	BetaUsageSpeedFast     BetaUsageSpeed = "fast"
)

type BetaUserLocationParam

type BetaUserLocationParam struct {
	// The city of the user.
	City param.Opt[string] `json:"city,omitzero"`
	// The two letter
	// [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the
	// user.
	Country param.Opt[string] `json:"country,omitzero"`
	// The region of the user.
	Region param.Opt[string] `json:"region,omitzero"`
	// The [IANA timezone](https://nodatime.org/TimeZones) of the user.
	Timezone param.Opt[string] `json:"timezone,omitzero"`
	// This field can be elided, and will marshal its zero value as "approximate".
	Type constant.Approximate `json:"type,required"`
	// contains filtered or unexported fields
}

The property Type is required.

func (BetaUserLocationParam) MarshalJSON

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

func (*BetaUserLocationParam) UnmarshalJSON

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

type BetaWebFetchBlock

type BetaWebFetchBlock struct {
	Content BetaDocumentBlock `json:"content,required"`
	// ISO 8601 timestamp when the content was retrieved
	RetrievedAt string                  `json:"retrieved_at,required"`
	Type        constant.WebFetchResult `json:"type,required"`
	// Fetched content URL
	URL string `json:"url,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Content     respjson.Field
		RetrievedAt respjson.Field
		Type        respjson.Field
		URL         respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaWebFetchBlock) RawJSON

func (r BetaWebFetchBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (*BetaWebFetchBlock) UnmarshalJSON

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

type BetaWebFetchBlockParam

type BetaWebFetchBlockParam struct {
	Content BetaRequestDocumentBlockParam `json:"content,omitzero,required"`
	// Fetched content URL
	URL string `json:"url,required"`
	// ISO 8601 timestamp when the content was retrieved
	RetrievedAt param.Opt[string] `json:"retrieved_at,omitzero"`
	// This field can be elided, and will marshal its zero value as "web_fetch_result".
	Type constant.WebFetchResult `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Content, Type, URL are required.

func (BetaWebFetchBlockParam) MarshalJSON

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

func (*BetaWebFetchBlockParam) UnmarshalJSON

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

type BetaWebFetchTool20250910Param

type BetaWebFetchTool20250910Param struct {
	// Maximum number of tokens used by including web page text content in the context.
	// The limit is approximate and does not apply to binary content such as PDFs.
	MaxContentTokens param.Opt[int64] `json:"max_content_tokens,omitzero"`
	// Maximum number of times the tool can be used in the API request.
	MaxUses param.Opt[int64] `json:"max_uses,omitzero"`
	// If true, tool will not be included in initial system prompt. Only loaded when
	// returned via tool_reference from tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// When true, guarantees schema validation on tool names and inputs
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// List of domains to allow fetching from
	AllowedDomains []string `json:"allowed_domains,omitzero"`
	// List of domains to block fetching from
	BlockedDomains []string `json:"blocked_domains,omitzero"`
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// Create a cache control breakpoint at this content block.
	CacheControl BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	// Citations configuration for fetched documents. Citations are disabled by
	// default.
	Citations BetaCitationsConfigParam `json:"citations,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 "web_fetch".
	Name constant.WebFetch `json:"name,required"`
	// This field can be elided, and will marshal its zero value as
	// "web_fetch_20250910".
	Type constant.WebFetch20250910 `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Name, Type are required.

func (BetaWebFetchTool20250910Param) MarshalJSON

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

func (*BetaWebFetchTool20250910Param) UnmarshalJSON

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

type BetaWebFetchTool20260209Param

type BetaWebFetchTool20260209Param struct {
	// Maximum number of tokens used by including web page text content in the context.
	// The limit is approximate and does not apply to binary content such as PDFs.
	MaxContentTokens param.Opt[int64] `json:"max_content_tokens,omitzero"`
	// Maximum number of times the tool can be used in the API request.
	MaxUses param.Opt[int64] `json:"max_uses,omitzero"`
	// If true, tool will not be included in initial system prompt. Only loaded when
	// returned via tool_reference from tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// When true, guarantees schema validation on tool names and inputs
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// List of domains to allow fetching from
	AllowedDomains []string `json:"allowed_domains,omitzero"`
	// List of domains to block fetching from
	BlockedDomains []string `json:"blocked_domains,omitzero"`
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// Create a cache control breakpoint at this content block.
	CacheControl BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	// Citations configuration for fetched documents. Citations are disabled by
	// default.
	Citations BetaCitationsConfigParam `json:"citations,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 "web_fetch".
	Name constant.WebFetch `json:"name,required"`
	// This field can be elided, and will marshal its zero value as
	// "web_fetch_20260209".
	Type constant.WebFetch20260209 `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Name, Type are required.

func (BetaWebFetchTool20260209Param) MarshalJSON

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

func (*BetaWebFetchTool20260209Param) UnmarshalJSON

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

type BetaWebFetchToolResultBlock

type BetaWebFetchToolResultBlock struct {
	Content   BetaWebFetchToolResultBlockContentUnion `json:"content,required"`
	ToolUseID string                                  `json:"tool_use_id,required"`
	Type      constant.WebFetchToolResult             `json:"type,required"`
	// Tool invocation directly from the model.
	Caller BetaWebFetchToolResultBlockCallerUnion `json:"caller"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Content     respjson.Field
		ToolUseID   respjson.Field
		Type        respjson.Field
		Caller      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaWebFetchToolResultBlock) RawJSON

func (r BetaWebFetchToolResultBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (BetaWebFetchToolResultBlock) ToParam

func (*BetaWebFetchToolResultBlock) UnmarshalJSON

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

type BetaWebFetchToolResultBlockCallerUnion

type BetaWebFetchToolResultBlockCallerUnion struct {
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	Type   string `json:"type"`
	ToolID string `json:"tool_id"`
	JSON   struct {
		Type   respjson.Field
		ToolID respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

BetaWebFetchToolResultBlockCallerUnion contains all possible properties and values from BetaDirectCaller, BetaServerToolCaller, BetaServerToolCaller20260120.

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

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

func (BetaWebFetchToolResultBlockCallerUnion) AsAny

func (u BetaWebFetchToolResultBlockCallerUnion) AsAny() anyBetaWebFetchToolResultBlockCaller

Use the following switch statement to find the correct variant

switch variant := BetaWebFetchToolResultBlockCallerUnion.AsAny().(type) {
case anthropic.BetaDirectCaller:
case anthropic.BetaServerToolCaller:
case anthropic.BetaServerToolCaller20260120:
default:
  fmt.Errorf("no variant present")
}

func (BetaWebFetchToolResultBlockCallerUnion) AsCodeExecution20250825

func (u BetaWebFetchToolResultBlockCallerUnion) AsCodeExecution20250825() (v BetaServerToolCaller)

func (BetaWebFetchToolResultBlockCallerUnion) AsCodeExecution20260120

func (BetaWebFetchToolResultBlockCallerUnion) AsDirect

func (BetaWebFetchToolResultBlockCallerUnion) RawJSON

Returns the unmodified JSON received from the API

func (*BetaWebFetchToolResultBlockCallerUnion) UnmarshalJSON

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

type BetaWebFetchToolResultBlockContentUnion

type BetaWebFetchToolResultBlockContentUnion struct {
	// This field is from variant [BetaWebFetchToolResultErrorBlock].
	ErrorCode BetaWebFetchToolResultErrorCode `json:"error_code"`
	Type      string                          `json:"type"`
	// This field is from variant [BetaWebFetchBlock].
	Content BetaDocumentBlock `json:"content"`
	// This field is from variant [BetaWebFetchBlock].
	RetrievedAt string `json:"retrieved_at"`
	// This field is from variant [BetaWebFetchBlock].
	URL  string `json:"url"`
	JSON struct {
		ErrorCode   respjson.Field
		Type        respjson.Field
		Content     respjson.Field
		RetrievedAt respjson.Field
		URL         respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

BetaWebFetchToolResultBlockContentUnion contains all possible properties and values from BetaWebFetchToolResultErrorBlock, BetaWebFetchBlock.

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

func (BetaWebFetchToolResultBlockContentUnion) AsResponseWebFetchResultBlock

func (u BetaWebFetchToolResultBlockContentUnion) AsResponseWebFetchResultBlock() (v BetaWebFetchBlock)

func (BetaWebFetchToolResultBlockContentUnion) AsResponseWebFetchToolResultError

func (u BetaWebFetchToolResultBlockContentUnion) AsResponseWebFetchToolResultError() (v BetaWebFetchToolResultErrorBlock)

func (BetaWebFetchToolResultBlockContentUnion) RawJSON

Returns the unmodified JSON received from the API

func (*BetaWebFetchToolResultBlockContentUnion) UnmarshalJSON

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

type BetaWebFetchToolResultBlockParam

type BetaWebFetchToolResultBlockParam struct {
	Content   BetaWebFetchToolResultBlockParamContentUnion `json:"content,omitzero,required"`
	ToolUseID string                                       `json:"tool_use_id,required"`
	// Create a cache control breakpoint at this content block.
	CacheControl BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	// Tool invocation directly from the model.
	Caller BetaWebFetchToolResultBlockParamCallerUnion `json:"caller,omitzero"`
	// This field can be elided, and will marshal its zero value as
	// "web_fetch_tool_result".
	Type constant.WebFetchToolResult `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Content, ToolUseID, Type are required.

func (BetaWebFetchToolResultBlockParam) MarshalJSON

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

func (*BetaWebFetchToolResultBlockParam) UnmarshalJSON

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

type BetaWebFetchToolResultBlockParamCallerUnion

type BetaWebFetchToolResultBlockParamCallerUnion struct {
	OfDirect                *BetaDirectCallerParam             `json:",omitzero,inline"`
	OfCodeExecution20250825 *BetaServerToolCallerParam         `json:",omitzero,inline"`
	OfCodeExecution20260120 *BetaServerToolCaller20260120Param `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 (BetaWebFetchToolResultBlockParamCallerUnion) GetToolID

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

func (BetaWebFetchToolResultBlockParamCallerUnion) GetType

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

func (BetaWebFetchToolResultBlockParamCallerUnion) MarshalJSON

func (*BetaWebFetchToolResultBlockParamCallerUnion) UnmarshalJSON

func (u *BetaWebFetchToolResultBlockParamCallerUnion) UnmarshalJSON(data []byte) error

type BetaWebFetchToolResultBlockParamContentUnion

type BetaWebFetchToolResultBlockParamContentUnion struct {
	OfRequestWebFetchToolResultError *BetaWebFetchToolResultErrorBlockParam `json:",omitzero,inline"`
	OfRequestWebFetchResultBlock     *BetaWebFetchBlockParam                `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 (BetaWebFetchToolResultBlockParamContentUnion) GetContent

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

func (BetaWebFetchToolResultBlockParamContentUnion) GetErrorCode

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

func (BetaWebFetchToolResultBlockParamContentUnion) GetRetrievedAt

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

func (BetaWebFetchToolResultBlockParamContentUnion) GetType

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

func (BetaWebFetchToolResultBlockParamContentUnion) GetURL

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

func (BetaWebFetchToolResultBlockParamContentUnion) MarshalJSON

func (*BetaWebFetchToolResultBlockParamContentUnion) UnmarshalJSON

func (u *BetaWebFetchToolResultBlockParamContentUnion) UnmarshalJSON(data []byte) error

type BetaWebFetchToolResultErrorBlock

type BetaWebFetchToolResultErrorBlock struct {
	// Any of "invalid_tool_input", "url_too_long", "url_not_allowed",
	// "url_not_accessible", "unsupported_content_type", "too_many_requests",
	// "max_uses_exceeded", "unavailable".
	ErrorCode BetaWebFetchToolResultErrorCode  `json:"error_code,required"`
	Type      constant.WebFetchToolResultError `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ErrorCode   respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaWebFetchToolResultErrorBlock) RawJSON

Returns the unmodified JSON received from the API

func (*BetaWebFetchToolResultErrorBlock) UnmarshalJSON

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

type BetaWebFetchToolResultErrorBlockParam

type BetaWebFetchToolResultErrorBlockParam struct {
	// Any of "invalid_tool_input", "url_too_long", "url_not_allowed",
	// "url_not_accessible", "unsupported_content_type", "too_many_requests",
	// "max_uses_exceeded", "unavailable".
	ErrorCode BetaWebFetchToolResultErrorCode `json:"error_code,omitzero,required"`
	// This field can be elided, and will marshal its zero value as
	// "web_fetch_tool_result_error".
	Type constant.WebFetchToolResultError `json:"type,required"`
	// contains filtered or unexported fields
}

The properties ErrorCode, Type are required.

func (BetaWebFetchToolResultErrorBlockParam) MarshalJSON

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

func (*BetaWebFetchToolResultErrorBlockParam) UnmarshalJSON

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

type BetaWebFetchToolResultErrorCode

type BetaWebFetchToolResultErrorCode string
const (
	BetaWebFetchToolResultErrorCodeInvalidToolInput       BetaWebFetchToolResultErrorCode = "invalid_tool_input"
	BetaWebFetchToolResultErrorCodeURLTooLong             BetaWebFetchToolResultErrorCode = "url_too_long"
	BetaWebFetchToolResultErrorCodeURLNotAllowed          BetaWebFetchToolResultErrorCode = "url_not_allowed"
	BetaWebFetchToolResultErrorCodeURLNotAccessible       BetaWebFetchToolResultErrorCode = "url_not_accessible"
	BetaWebFetchToolResultErrorCodeUnsupportedContentType BetaWebFetchToolResultErrorCode = "unsupported_content_type"
	BetaWebFetchToolResultErrorCodeTooManyRequests        BetaWebFetchToolResultErrorCode = "too_many_requests"
	BetaWebFetchToolResultErrorCodeMaxUsesExceeded        BetaWebFetchToolResultErrorCode = "max_uses_exceeded"
	BetaWebFetchToolResultErrorCodeUnavailable            BetaWebFetchToolResultErrorCode = "unavailable"
)

type BetaWebSearchResultBlock

type BetaWebSearchResultBlock struct {
	EncryptedContent string                   `json:"encrypted_content,required"`
	PageAge          string                   `json:"page_age,required"`
	Title            string                   `json:"title,required"`
	Type             constant.WebSearchResult `json:"type,required"`
	URL              string                   `json:"url,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		EncryptedContent respjson.Field
		PageAge          respjson.Field
		Title            respjson.Field
		Type             respjson.Field
		URL              respjson.Field
		ExtraFields      map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaWebSearchResultBlock) RawJSON

func (r BetaWebSearchResultBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (BetaWebSearchResultBlock) ToParam

func (*BetaWebSearchResultBlock) UnmarshalJSON

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

type BetaWebSearchResultBlockParam

type BetaWebSearchResultBlockParam struct {
	EncryptedContent string            `json:"encrypted_content,required"`
	Title            string            `json:"title,required"`
	URL              string            `json:"url,required"`
	PageAge          param.Opt[string] `json:"page_age,omitzero"`
	// This field can be elided, and will marshal its zero value as
	// "web_search_result".
	Type constant.WebSearchResult `json:"type,required"`
	// contains filtered or unexported fields
}

The properties EncryptedContent, Title, Type, URL are required.

func (BetaWebSearchResultBlockParam) MarshalJSON

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

func (*BetaWebSearchResultBlockParam) UnmarshalJSON

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

type BetaWebSearchTool20250305Param

type BetaWebSearchTool20250305Param struct {
	// Maximum number of times the tool can be used in the API request.
	MaxUses param.Opt[int64] `json:"max_uses,omitzero"`
	// If true, tool will not be included in initial system prompt. Only loaded when
	// returned via tool_reference from tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// When true, guarantees schema validation on tool names and inputs
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// If provided, only these domains will be included in results. Cannot be used
	// alongside `blocked_domains`.
	AllowedDomains []string `json:"allowed_domains,omitzero"`
	// If provided, these domains will never appear in results. Cannot be used
	// alongside `allowed_domains`.
	BlockedDomains []string `json:"blocked_domains,omitzero"`
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// Create a cache control breakpoint at this content block.
	CacheControl BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	// Parameters for the user's location. Used to provide more relevant search
	// results.
	UserLocation BetaUserLocationParam `json:"user_location,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 "web_search".
	Name constant.WebSearch `json:"name,required"`
	// This field can be elided, and will marshal its zero value as
	// "web_search_20250305".
	Type constant.WebSearch20250305 `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Name, Type are required.

func (BetaWebSearchTool20250305Param) MarshalJSON

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

func (*BetaWebSearchTool20250305Param) UnmarshalJSON

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

type BetaWebSearchTool20260209Param

type BetaWebSearchTool20260209Param struct {
	// Maximum number of times the tool can be used in the API request.
	MaxUses param.Opt[int64] `json:"max_uses,omitzero"`
	// If true, tool will not be included in initial system prompt. Only loaded when
	// returned via tool_reference from tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// When true, guarantees schema validation on tool names and inputs
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// If provided, only these domains will be included in results. Cannot be used
	// alongside `blocked_domains`.
	AllowedDomains []string `json:"allowed_domains,omitzero"`
	// If provided, these domains will never appear in results. Cannot be used
	// alongside `allowed_domains`.
	BlockedDomains []string `json:"blocked_domains,omitzero"`
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// Create a cache control breakpoint at this content block.
	CacheControl BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	// Parameters for the user's location. Used to provide more relevant search
	// results.
	UserLocation BetaUserLocationParam `json:"user_location,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 "web_search".
	Name constant.WebSearch `json:"name,required"`
	// This field can be elided, and will marshal its zero value as
	// "web_search_20260209".
	Type constant.WebSearch20260209 `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Name, Type are required.

func (BetaWebSearchTool20260209Param) MarshalJSON

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

func (*BetaWebSearchTool20260209Param) UnmarshalJSON

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

type BetaWebSearchToolRequestErrorParam

type BetaWebSearchToolRequestErrorParam struct {
	// Any of "invalid_tool_input", "unavailable", "max_uses_exceeded",
	// "too_many_requests", "query_too_long", "request_too_large".
	ErrorCode BetaWebSearchToolResultErrorCode `json:"error_code,omitzero,required"`
	// This field can be elided, and will marshal its zero value as
	// "web_search_tool_result_error".
	Type constant.WebSearchToolResultError `json:"type,required"`
	// contains filtered or unexported fields
}

The properties ErrorCode, Type are required.

func (BetaWebSearchToolRequestErrorParam) MarshalJSON

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

func (*BetaWebSearchToolRequestErrorParam) UnmarshalJSON

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

type BetaWebSearchToolResultBlock

type BetaWebSearchToolResultBlock struct {
	Content   BetaWebSearchToolResultBlockContentUnion `json:"content,required"`
	ToolUseID string                                   `json:"tool_use_id,required"`
	Type      constant.WebSearchToolResult             `json:"type,required"`
	// Tool invocation directly from the model.
	Caller BetaWebSearchToolResultBlockCallerUnion `json:"caller"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Content     respjson.Field
		ToolUseID   respjson.Field
		Type        respjson.Field
		Caller      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaWebSearchToolResultBlock) RawJSON

Returns the unmodified JSON received from the API

func (BetaWebSearchToolResultBlock) ToParam

func (*BetaWebSearchToolResultBlock) UnmarshalJSON

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

type BetaWebSearchToolResultBlockCallerUnion

type BetaWebSearchToolResultBlockCallerUnion struct {
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	Type   string `json:"type"`
	ToolID string `json:"tool_id"`
	JSON   struct {
		Type   respjson.Field
		ToolID respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

BetaWebSearchToolResultBlockCallerUnion contains all possible properties and values from BetaDirectCaller, BetaServerToolCaller, BetaServerToolCaller20260120.

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

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

func (BetaWebSearchToolResultBlockCallerUnion) AsAny

func (u BetaWebSearchToolResultBlockCallerUnion) AsAny() anyBetaWebSearchToolResultBlockCaller

Use the following switch statement to find the correct variant

switch variant := BetaWebSearchToolResultBlockCallerUnion.AsAny().(type) {
case anthropic.BetaDirectCaller:
case anthropic.BetaServerToolCaller:
case anthropic.BetaServerToolCaller20260120:
default:
  fmt.Errorf("no variant present")
}

func (BetaWebSearchToolResultBlockCallerUnion) AsCodeExecution20250825

func (u BetaWebSearchToolResultBlockCallerUnion) AsCodeExecution20250825() (v BetaServerToolCaller)

func (BetaWebSearchToolResultBlockCallerUnion) AsCodeExecution20260120

func (BetaWebSearchToolResultBlockCallerUnion) AsDirect

func (BetaWebSearchToolResultBlockCallerUnion) RawJSON

Returns the unmodified JSON received from the API

func (*BetaWebSearchToolResultBlockCallerUnion) UnmarshalJSON

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

type BetaWebSearchToolResultBlockContentUnion

type BetaWebSearchToolResultBlockContentUnion struct {
	// This field will be present if the value is a [[]BetaWebSearchResultBlock]
	// instead of an object.
	OfBetaWebSearchResultBlockArray []BetaWebSearchResultBlock `json:",inline"`
	// This field is from variant [BetaWebSearchToolResultError].
	ErrorCode BetaWebSearchToolResultErrorCode `json:"error_code"`
	// This field is from variant [BetaWebSearchToolResultError].
	Type constant.WebSearchToolResultError `json:"type"`
	JSON struct {
		OfBetaWebSearchResultBlockArray respjson.Field
		ErrorCode                       respjson.Field
		Type                            respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

BetaWebSearchToolResultBlockContentUnion contains all possible properties and values from BetaWebSearchToolResultError, [[]BetaWebSearchResultBlock].

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

If the underlying value is not a json object, one of the following properties will be valid: OfBetaWebSearchResultBlockArray]

func (BetaWebSearchToolResultBlockContentUnion) AsBetaWebSearchResultBlockArray

func (u BetaWebSearchToolResultBlockContentUnion) AsBetaWebSearchResultBlockArray() (v []BetaWebSearchResultBlock)

func (BetaWebSearchToolResultBlockContentUnion) AsResponseWebSearchToolResultError

func (u BetaWebSearchToolResultBlockContentUnion) AsResponseWebSearchToolResultError() (v BetaWebSearchToolResultError)

func (BetaWebSearchToolResultBlockContentUnion) RawJSON

Returns the unmodified JSON received from the API

func (*BetaWebSearchToolResultBlockContentUnion) UnmarshalJSON

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

type BetaWebSearchToolResultBlockParam

type BetaWebSearchToolResultBlockParam struct {
	Content   BetaWebSearchToolResultBlockParamContentUnion `json:"content,omitzero,required"`
	ToolUseID string                                        `json:"tool_use_id,required"`
	// Create a cache control breakpoint at this content block.
	CacheControl BetaCacheControlEphemeralParam `json:"cache_control,omitzero"`
	// Tool invocation directly from the model.
	Caller BetaWebSearchToolResultBlockParamCallerUnion `json:"caller,omitzero"`
	// This field can be elided, and will marshal its zero value as
	// "web_search_tool_result".
	Type constant.WebSearchToolResult `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Content, ToolUseID, Type are required.

func (BetaWebSearchToolResultBlockParam) MarshalJSON

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

func (*BetaWebSearchToolResultBlockParam) UnmarshalJSON

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

type BetaWebSearchToolResultBlockParamCallerUnion

type BetaWebSearchToolResultBlockParamCallerUnion struct {
	OfDirect                *BetaDirectCallerParam             `json:",omitzero,inline"`
	OfCodeExecution20250825 *BetaServerToolCallerParam         `json:",omitzero,inline"`
	OfCodeExecution20260120 *BetaServerToolCaller20260120Param `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 (BetaWebSearchToolResultBlockParamCallerUnion) GetToolID

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

func (BetaWebSearchToolResultBlockParamCallerUnion) GetType

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

func (BetaWebSearchToolResultBlockParamCallerUnion) MarshalJSON

func (*BetaWebSearchToolResultBlockParamCallerUnion) UnmarshalJSON

func (u *BetaWebSearchToolResultBlockParamCallerUnion) UnmarshalJSON(data []byte) error

type BetaWebSearchToolResultBlockParamContentUnion

type BetaWebSearchToolResultBlockParamContentUnion struct {
	OfResultBlock []BetaWebSearchResultBlockParam     `json:",omitzero,inline"`
	OfError       *BetaWebSearchToolRequestErrorParam `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 (BetaWebSearchToolResultBlockParamContentUnion) MarshalJSON

func (*BetaWebSearchToolResultBlockParamContentUnion) UnmarshalJSON

func (u *BetaWebSearchToolResultBlockParamContentUnion) UnmarshalJSON(data []byte) error

type BetaWebSearchToolResultError

type BetaWebSearchToolResultError struct {
	// Any of "invalid_tool_input", "unavailable", "max_uses_exceeded",
	// "too_many_requests", "query_too_long", "request_too_large".
	ErrorCode BetaWebSearchToolResultErrorCode  `json:"error_code,required"`
	Type      constant.WebSearchToolResultError `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ErrorCode   respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BetaWebSearchToolResultError) RawJSON

Returns the unmodified JSON received from the API

func (*BetaWebSearchToolResultError) UnmarshalJSON

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

type BetaWebSearchToolResultErrorCode

type BetaWebSearchToolResultErrorCode string
const (
	BetaWebSearchToolResultErrorCodeInvalidToolInput BetaWebSearchToolResultErrorCode = "invalid_tool_input"
	BetaWebSearchToolResultErrorCodeUnavailable      BetaWebSearchToolResultErrorCode = "unavailable"
	BetaWebSearchToolResultErrorCodeMaxUsesExceeded  BetaWebSearchToolResultErrorCode = "max_uses_exceeded"
	BetaWebSearchToolResultErrorCodeTooManyRequests  BetaWebSearchToolResultErrorCode = "too_many_requests"
	BetaWebSearchToolResultErrorCodeQueryTooLong     BetaWebSearchToolResultErrorCode = "query_too_long"
	BetaWebSearchToolResultErrorCodeRequestTooLarge  BetaWebSearchToolResultErrorCode = "request_too_large"
)

type BillingError

type BillingError = shared.BillingError

This is an alias to an internal type.

type CacheControlEphemeralParam

type CacheControlEphemeralParam struct {
	// The time-to-live for the cache control breakpoint.
	//
	// This may be one the following values:
	//
	// - `5m`: 5 minutes
	// - `1h`: 1 hour
	//
	// Defaults to `5m`.
	//
	// Any of "5m", "1h".
	TTL  CacheControlEphemeralTTL `json:"ttl,omitzero"`
	Type constant.Ephemeral       `json:"type,required"`
	// contains filtered or unexported fields
}

This struct has a constant value, construct it with NewCacheControlEphemeralParam.

func NewCacheControlEphemeralParam

func NewCacheControlEphemeralParam() CacheControlEphemeralParam

func (CacheControlEphemeralParam) MarshalJSON

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

func (*CacheControlEphemeralParam) UnmarshalJSON

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

type CacheControlEphemeralTTL

type CacheControlEphemeralTTL string

The time-to-live for the cache control breakpoint.

This may be one the following values:

- `5m`: 5 minutes - `1h`: 1 hour

Defaults to `5m`.

const (
	CacheControlEphemeralTTLTTL5m CacheControlEphemeralTTL = "5m"
	CacheControlEphemeralTTLTTL1h CacheControlEphemeralTTL = "1h"
)

type CacheCreation

type CacheCreation struct {
	// The number of input tokens used to create the 1 hour cache entry.
	Ephemeral1hInputTokens int64 `json:"ephemeral_1h_input_tokens,required"`
	// The number of input tokens used to create the 5 minute cache entry.
	Ephemeral5mInputTokens int64 `json:"ephemeral_5m_input_tokens,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Ephemeral1hInputTokens respjson.Field
		Ephemeral5mInputTokens respjson.Field
		ExtraFields            map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (CacheCreation) RawJSON

func (r CacheCreation) RawJSON() string

Returns the unmodified JSON received from the API

func (*CacheCreation) UnmarshalJSON

func (r *CacheCreation) UnmarshalJSON(data []byte) 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"`
	FileID         string                `json:"file_id,required"`
	StartCharIndex int64                 `json:"start_char_index,required"`
	Type           constant.CharLocation `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CitedText      respjson.Field
		DocumentIndex  respjson.Field
		DocumentTitle  respjson.Field
		EndCharIndex   respjson.Field
		FileID         respjson.Field
		StartCharIndex respjson.Field
		Type           respjson.Field
		ExtraFields    map[string]respjson.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) MarshalJSON

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

func (*CitationCharLocationParam) UnmarshalJSON

func (r *CitationCharLocationParam) UnmarshalJSON(data []byte) 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"`
	FileID          string                        `json:"file_id,required"`
	StartBlockIndex int64                         `json:"start_block_index,required"`
	Type            constant.ContentBlockLocation `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CitedText       respjson.Field
		DocumentIndex   respjson.Field
		DocumentTitle   respjson.Field
		EndBlockIndex   respjson.Field
		FileID          respjson.Field
		StartBlockIndex respjson.Field
		Type            respjson.Field
		ExtraFields     map[string]respjson.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) MarshalJSON

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

func (*CitationContentBlockLocationParam) UnmarshalJSON

func (r *CitationContentBlockLocationParam) UnmarshalJSON(data []byte) 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"`
	FileID          string                `json:"file_id,required"`
	StartPageNumber int64                 `json:"start_page_number,required"`
	Type            constant.PageLocation `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CitedText       respjson.Field
		DocumentIndex   respjson.Field
		DocumentTitle   respjson.Field
		EndPageNumber   respjson.Field
		FileID          respjson.Field
		StartPageNumber respjson.Field
		Type            respjson.Field
		ExtraFields     map[string]respjson.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) MarshalJSON

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

func (*CitationPageLocationParam) UnmarshalJSON

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

type CitationSearchResultLocationParam

type CitationSearchResultLocationParam struct {
	Title             param.Opt[string] `json:"title,omitzero,required"`
	CitedText         string            `json:"cited_text,required"`
	EndBlockIndex     int64             `json:"end_block_index,required"`
	SearchResultIndex int64             `json:"search_result_index,required"`
	Source            string            `json:"source,required"`
	StartBlockIndex   int64             `json:"start_block_index,required"`
	// This field can be elided, and will marshal its zero value as
	// "search_result_location".
	Type constant.SearchResultLocation `json:"type,required"`
	// contains filtered or unexported fields
}

The properties CitedText, EndBlockIndex, SearchResultIndex, Source, StartBlockIndex, Title, Type are required.

func (CitationSearchResultLocationParam) MarshalJSON

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

func (*CitationSearchResultLocationParam) UnmarshalJSON

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

type CitationWebSearchResultLocationParam

type CitationWebSearchResultLocationParam struct {
	Title          param.Opt[string] `json:"title,omitzero,required"`
	CitedText      string            `json:"cited_text,required"`
	EncryptedIndex string            `json:"encrypted_index,required"`
	URL            string            `json:"url,required"`
	// This field can be elided, and will marshal its zero value as
	// "web_search_result_location".
	Type constant.WebSearchResultLocation `json:"type,required"`
	// contains filtered or unexported fields
}

The properties CitedText, EncryptedIndex, Title, Type, URL are required.

func (CitationWebSearchResultLocationParam) MarshalJSON

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

func (*CitationWebSearchResultLocationParam) UnmarshalJSON

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

type CitationsConfig

type CitationsConfig struct {
	Enabled bool `json:"enabled,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Enabled     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (CitationsConfig) RawJSON

func (r CitationsConfig) RawJSON() string

Returns the unmodified JSON received from the API

func (*CitationsConfig) UnmarshalJSON

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

type CitationsConfigParam

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

func (CitationsConfigParam) MarshalJSON

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

func (*CitationsConfigParam) UnmarshalJSON

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

type CitationsDelta

type CitationsDelta struct {
	Citation CitationsDeltaCitationUnion `json:"citation,required"`
	Type     constant.CitationsDelta     `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Citation    respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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"`
	FileID       string `json:"file_id"`
	// This field is from variant [CitationCharLocation].
	StartCharIndex int64 `json:"start_char_index"`
	// Any of "char_location", "page_location", "content_block_location",
	// "web_search_result_location", "search_result_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"`
	EndBlockIndex   int64 `json:"end_block_index"`
	StartBlockIndex int64 `json:"start_block_index"`
	// This field is from variant [CitationsWebSearchResultLocation].
	EncryptedIndex string `json:"encrypted_index"`
	Title          string `json:"title"`
	// This field is from variant [CitationsWebSearchResultLocation].
	URL string `json:"url"`
	// This field is from variant [CitationsSearchResultLocation].
	SearchResultIndex int64 `json:"search_result_index"`
	// This field is from variant [CitationsSearchResultLocation].
	Source string `json:"source"`
	JSON   struct {
		CitedText         respjson.Field
		DocumentIndex     respjson.Field
		DocumentTitle     respjson.Field
		EndCharIndex      respjson.Field
		FileID            respjson.Field
		StartCharIndex    respjson.Field
		Type              respjson.Field
		EndPageNumber     respjson.Field
		StartPageNumber   respjson.Field
		EndBlockIndex     respjson.Field
		StartBlockIndex   respjson.Field
		EncryptedIndex    respjson.Field
		Title             respjson.Field
		URL               respjson.Field
		SearchResultIndex respjson.Field
		Source            respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

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

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() anyCitationsDeltaCitation

Use the following switch statement to find the correct variant

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

func (CitationsDeltaCitationUnion) AsCharLocation

func (u CitationsDeltaCitationUnion) AsCharLocation() (v CitationCharLocation)

func (CitationsDeltaCitationUnion) AsContentBlockLocation

func (u CitationsDeltaCitationUnion) AsContentBlockLocation() (v CitationContentBlockLocation)

func (CitationsDeltaCitationUnion) AsPageLocation

func (u CitationsDeltaCitationUnion) AsPageLocation() (v CitationPageLocation)

func (CitationsDeltaCitationUnion) AsSearchResultLocation

func (u CitationsDeltaCitationUnion) AsSearchResultLocation() (v CitationsSearchResultLocation)

func (CitationsDeltaCitationUnion) AsWebSearchResultLocation

func (u CitationsDeltaCitationUnion) AsWebSearchResultLocation() (v CitationsWebSearchResultLocation)

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 CitationsSearchResultLocation

type CitationsSearchResultLocation struct {
	CitedText         string                        `json:"cited_text,required"`
	EndBlockIndex     int64                         `json:"end_block_index,required"`
	SearchResultIndex int64                         `json:"search_result_index,required"`
	Source            string                        `json:"source,required"`
	StartBlockIndex   int64                         `json:"start_block_index,required"`
	Title             string                        `json:"title,required"`
	Type              constant.SearchResultLocation `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CitedText         respjson.Field
		EndBlockIndex     respjson.Field
		SearchResultIndex respjson.Field
		Source            respjson.Field
		StartBlockIndex   respjson.Field
		Title             respjson.Field
		Type              respjson.Field
		ExtraFields       map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (CitationsSearchResultLocation) RawJSON

Returns the unmodified JSON received from the API

func (*CitationsSearchResultLocation) UnmarshalJSON

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

type CitationsWebSearchResultLocation

type CitationsWebSearchResultLocation struct {
	CitedText      string                           `json:"cited_text,required"`
	EncryptedIndex string                           `json:"encrypted_index,required"`
	Title          string                           `json:"title,required"`
	Type           constant.WebSearchResultLocation `json:"type,required"`
	URL            string                           `json:"url,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CitedText      respjson.Field
		EncryptedIndex respjson.Field
		Title          respjson.Field
		Type           respjson.Field
		URL            respjson.Field
		ExtraFields    map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (CitationsWebSearchResultLocation) RawJSON

Returns the unmodified JSON received from the API

func (*CitationsWebSearchResultLocation) UnmarshalJSON

func (r *CitationsWebSearchResultLocation) 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, ANTHROPIC_BASE_URL). 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 any, res any, 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 any, res any, 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 any, res any, 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 any, res any, 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 any, res any, 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 any, res any, 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 CodeExecutionOutputBlock

type CodeExecutionOutputBlock struct {
	FileID string                       `json:"file_id,required"`
	Type   constant.CodeExecutionOutput `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		FileID      respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (CodeExecutionOutputBlock) RawJSON

func (r CodeExecutionOutputBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (CodeExecutionOutputBlock) ToParam

func (*CodeExecutionOutputBlock) UnmarshalJSON

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

type CodeExecutionOutputBlockParam

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

The properties FileID, Type are required.

func (CodeExecutionOutputBlockParam) MarshalJSON

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

func (*CodeExecutionOutputBlockParam) UnmarshalJSON

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

type CodeExecutionResultBlock

type CodeExecutionResultBlock struct {
	Content    []CodeExecutionOutputBlock   `json:"content,required"`
	ReturnCode int64                        `json:"return_code,required"`
	Stderr     string                       `json:"stderr,required"`
	Stdout     string                       `json:"stdout,required"`
	Type       constant.CodeExecutionResult `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Content     respjson.Field
		ReturnCode  respjson.Field
		Stderr      respjson.Field
		Stdout      respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (CodeExecutionResultBlock) RawJSON

func (r CodeExecutionResultBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (*CodeExecutionResultBlock) UnmarshalJSON

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

type CodeExecutionResultBlockParam

type CodeExecutionResultBlockParam struct {
	Content    []CodeExecutionOutputBlockParam `json:"content,omitzero,required"`
	ReturnCode int64                           `json:"return_code,required"`
	Stderr     string                          `json:"stderr,required"`
	Stdout     string                          `json:"stdout,required"`
	// This field can be elided, and will marshal its zero value as
	// "code_execution_result".
	Type constant.CodeExecutionResult `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Content, ReturnCode, Stderr, Stdout, Type are required.

func (CodeExecutionResultBlockParam) MarshalJSON

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

func (*CodeExecutionResultBlockParam) UnmarshalJSON

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

type CodeExecutionTool20250522Param

type CodeExecutionTool20250522Param struct {
	// If true, tool will not be included in initial system prompt. Only loaded when
	// returned via tool_reference from tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// When true, guarantees schema validation on tool names and inputs
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// Create a cache control breakpoint at this content block.
	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 "code_execution".
	Name constant.CodeExecution `json:"name,required"`
	// This field can be elided, and will marshal its zero value as
	// "code_execution_20250522".
	Type constant.CodeExecution20250522 `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Name, Type are required.

func (CodeExecutionTool20250522Param) MarshalJSON

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

func (*CodeExecutionTool20250522Param) UnmarshalJSON

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

type CodeExecutionTool20250825Param

type CodeExecutionTool20250825Param struct {
	// If true, tool will not be included in initial system prompt. Only loaded when
	// returned via tool_reference from tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// When true, guarantees schema validation on tool names and inputs
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// Create a cache control breakpoint at this content block.
	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 "code_execution".
	Name constant.CodeExecution `json:"name,required"`
	// This field can be elided, and will marshal its zero value as
	// "code_execution_20250825".
	Type constant.CodeExecution20250825 `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Name, Type are required.

func (CodeExecutionTool20250825Param) MarshalJSON

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

func (*CodeExecutionTool20250825Param) UnmarshalJSON

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

type CodeExecutionTool20260120Param

type CodeExecutionTool20260120Param struct {
	// If true, tool will not be included in initial system prompt. Only loaded when
	// returned via tool_reference from tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// When true, guarantees schema validation on tool names and inputs
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// Create a cache control breakpoint at this content block.
	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 "code_execution".
	Name constant.CodeExecution `json:"name,required"`
	// This field can be elided, and will marshal its zero value as
	// "code_execution_20260120".
	Type constant.CodeExecution20260120 `json:"type,required"`
	// contains filtered or unexported fields
}

Code execution tool with REPL state persistence (daemon mode + gVisor checkpoint).

The properties Name, Type are required.

func (CodeExecutionTool20260120Param) MarshalJSON

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

func (*CodeExecutionTool20260120Param) UnmarshalJSON

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

type CodeExecutionToolResultBlock

type CodeExecutionToolResultBlock struct {
	// Code execution result with encrypted stdout for PFC + web_search results.
	Content   CodeExecutionToolResultBlockContentUnion `json:"content,required"`
	ToolUseID string                                   `json:"tool_use_id,required"`
	Type      constant.CodeExecutionToolResult         `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Content     respjson.Field
		ToolUseID   respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (CodeExecutionToolResultBlock) RawJSON

Returns the unmodified JSON received from the API

func (CodeExecutionToolResultBlock) ToParam

func (*CodeExecutionToolResultBlock) UnmarshalJSON

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

type CodeExecutionToolResultBlockContentUnion

type CodeExecutionToolResultBlockContentUnion struct {
	// This field is from variant [CodeExecutionToolResultError].
	ErrorCode  CodeExecutionToolResultErrorCode `json:"error_code"`
	Type       string                           `json:"type"`
	Content    []CodeExecutionOutputBlock       `json:"content"`
	ReturnCode int64                            `json:"return_code"`
	Stderr     string                           `json:"stderr"`
	// This field is from variant [CodeExecutionResultBlock].
	Stdout string `json:"stdout"`
	// This field is from variant [EncryptedCodeExecutionResultBlock].
	EncryptedStdout string `json:"encrypted_stdout"`
	JSON            struct {
		ErrorCode       respjson.Field
		Type            respjson.Field
		Content         respjson.Field
		ReturnCode      respjson.Field
		Stderr          respjson.Field
		Stdout          respjson.Field
		EncryptedStdout respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

CodeExecutionToolResultBlockContentUnion contains all possible properties and values from CodeExecutionToolResultError, CodeExecutionResultBlock, EncryptedCodeExecutionResultBlock.

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

func (CodeExecutionToolResultBlockContentUnion) AsResponseCodeExecutionResultBlock

func (u CodeExecutionToolResultBlockContentUnion) AsResponseCodeExecutionResultBlock() (v CodeExecutionResultBlock)

func (CodeExecutionToolResultBlockContentUnion) AsResponseCodeExecutionToolResultError

func (u CodeExecutionToolResultBlockContentUnion) AsResponseCodeExecutionToolResultError() (v CodeExecutionToolResultError)

func (CodeExecutionToolResultBlockContentUnion) AsResponseEncryptedCodeExecutionResultBlock

func (u CodeExecutionToolResultBlockContentUnion) AsResponseEncryptedCodeExecutionResultBlock() (v EncryptedCodeExecutionResultBlock)

func (CodeExecutionToolResultBlockContentUnion) RawJSON

Returns the unmodified JSON received from the API

func (*CodeExecutionToolResultBlockContentUnion) UnmarshalJSON

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

type CodeExecutionToolResultBlockParam

type CodeExecutionToolResultBlockParam struct {
	// Code execution result with encrypted stdout for PFC + web_search results.
	Content   CodeExecutionToolResultBlockParamContentUnion `json:"content,omitzero,required"`
	ToolUseID string                                        `json:"tool_use_id,required"`
	// Create a cache control breakpoint at this content block.
	CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"`
	// This field can be elided, and will marshal its zero value as
	// "code_execution_tool_result".
	Type constant.CodeExecutionToolResult `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Content, ToolUseID, Type are required.

func (CodeExecutionToolResultBlockParam) MarshalJSON

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

func (*CodeExecutionToolResultBlockParam) UnmarshalJSON

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

type CodeExecutionToolResultBlockParamContentUnion

type CodeExecutionToolResultBlockParamContentUnion struct {
	OfRequestCodeExecutionToolResultError      *CodeExecutionToolResultErrorParam      `json:",omitzero,inline"`
	OfRequestCodeExecutionResultBlock          *CodeExecutionResultBlockParam          `json:",omitzero,inline"`
	OfRequestEncryptedCodeExecutionResultBlock *EncryptedCodeExecutionResultBlockParam `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 CodeExecutionToolResultBlockParamContentOfRequestCodeExecutionToolResultError

func CodeExecutionToolResultBlockParamContentOfRequestCodeExecutionToolResultError(errorCode CodeExecutionToolResultErrorCode) CodeExecutionToolResultBlockParamContentUnion

func (CodeExecutionToolResultBlockParamContentUnion) GetContent

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

func (CodeExecutionToolResultBlockParamContentUnion) GetEncryptedStdout

func (u CodeExecutionToolResultBlockParamContentUnion) GetEncryptedStdout() *string

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

func (CodeExecutionToolResultBlockParamContentUnion) GetErrorCode

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

func (CodeExecutionToolResultBlockParamContentUnion) GetReturnCode

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

func (CodeExecutionToolResultBlockParamContentUnion) GetStderr

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

func (CodeExecutionToolResultBlockParamContentUnion) GetStdout

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

func (CodeExecutionToolResultBlockParamContentUnion) GetType

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

func (CodeExecutionToolResultBlockParamContentUnion) MarshalJSON

func (*CodeExecutionToolResultBlockParamContentUnion) UnmarshalJSON

func (u *CodeExecutionToolResultBlockParamContentUnion) UnmarshalJSON(data []byte) error

type CodeExecutionToolResultError

type CodeExecutionToolResultError struct {
	// Any of "invalid_tool_input", "unavailable", "too_many_requests",
	// "execution_time_exceeded".
	ErrorCode CodeExecutionToolResultErrorCode      `json:"error_code,required"`
	Type      constant.CodeExecutionToolResultError `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ErrorCode   respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (CodeExecutionToolResultError) RawJSON

Returns the unmodified JSON received from the API

func (*CodeExecutionToolResultError) UnmarshalJSON

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

type CodeExecutionToolResultErrorCode

type CodeExecutionToolResultErrorCode string
const (
	CodeExecutionToolResultErrorCodeInvalidToolInput      CodeExecutionToolResultErrorCode = "invalid_tool_input"
	CodeExecutionToolResultErrorCodeUnavailable           CodeExecutionToolResultErrorCode = "unavailable"
	CodeExecutionToolResultErrorCodeTooManyRequests       CodeExecutionToolResultErrorCode = "too_many_requests"
	CodeExecutionToolResultErrorCodeExecutionTimeExceeded CodeExecutionToolResultErrorCode = "execution_time_exceeded"
)

type CodeExecutionToolResultErrorParam

type CodeExecutionToolResultErrorParam struct {
	// Any of "invalid_tool_input", "unavailable", "too_many_requests",
	// "execution_time_exceeded".
	ErrorCode CodeExecutionToolResultErrorCode `json:"error_code,omitzero,required"`
	// This field can be elided, and will marshal its zero value as
	// "code_execution_tool_result_error".
	Type constant.CodeExecutionToolResultError `json:"type,required"`
	// contains filtered or unexported fields
}

The properties ErrorCode, Type are required.

func (CodeExecutionToolResultErrorParam) MarshalJSON

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

func (*CodeExecutionToolResultErrorParam) UnmarshalJSON

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

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"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Completion  respjson.Field
		Model       respjson.Field
		StopReason  respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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.claude.com/en/api/prompt-validation) and
	// our guide to [prompt design](https://docs.claude.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"`
	// 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 (CompletionNewParams) MarshalJSON

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

func (*CompletionNewParams) UnmarshalJSON

func (r *CompletionNewParams) UnmarshalJSON(data []byte) 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

func (r *CompletionService) New(ctx context.Context, params CompletionNewParams, opts ...option.RequestOption) (res *Completion, err error)

[Legacy] Create a Text Completion.

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

Future models and features will not be compatible with Text Completions. See our [migration guide](https://docs.claude.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, params 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.claude.com/en/api/messages) going forward.

Future models and features will not be compatible with Text Completions. See our [migration guide](https://docs.claude.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 Container

type Container struct {
	// Identifier for the container used in this request
	ID string `json:"id,required"`
	// The time at which the container will expire.
	ExpiresAt time.Time `json:"expires_at,required" format:"date-time"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		ExpiresAt   respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Information about the container used in the request (for the code execution tool)

func (Container) RawJSON

func (r Container) RawJSON() string

Returns the unmodified JSON received from the API

func (*Container) UnmarshalJSON

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

type ContainerUploadBlock

type ContainerUploadBlock struct {
	FileID string                   `json:"file_id,required"`
	Type   constant.ContainerUpload `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		FileID      respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Response model for a file uploaded to the container.

func (ContainerUploadBlock) RawJSON

func (r ContainerUploadBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (ContainerUploadBlock) ToParam

func (*ContainerUploadBlock) UnmarshalJSON

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

type ContainerUploadBlockParam

type ContainerUploadBlockParam struct {
	FileID string `json:"file_id,required"`
	// Create a cache control breakpoint at this content block.
	CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"`
	// This field can be elided, and will marshal its zero value as "container_upload".
	Type constant.ContainerUpload `json:"type,required"`
	// contains filtered or unexported fields
}

A content block that represents a file to be uploaded to the container Files uploaded via this block will be available in the container's input directory.

The properties FileID, Type are required.

func (ContainerUploadBlockParam) MarshalJSON

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

func (*ContainerUploadBlockParam) UnmarshalJSON

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

type ContentBlockDeltaEvent

type ContentBlockDeltaEvent struct {
	Delta RawContentBlockDeltaUnion  `json:"delta,required"`
	Index int64                      `json:"index,required"`
	Type  constant.ContentBlockDelta `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Delta       respjson.Field
		Index       respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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 ContentBlockParamUnion

type ContentBlockParamUnion struct {
	OfText                              *TextBlockParam                              `json:",omitzero,inline"`
	OfImage                             *ImageBlockParam                             `json:",omitzero,inline"`
	OfDocument                          *DocumentBlockParam                          `json:",omitzero,inline"`
	OfSearchResult                      *SearchResultBlockParam                      `json:",omitzero,inline"`
	OfThinking                          *ThinkingBlockParam                          `json:",omitzero,inline"`
	OfRedactedThinking                  *RedactedThinkingBlockParam                  `json:",omitzero,inline"`
	OfToolUse                           *ToolUseBlockParam                           `json:",omitzero,inline"`
	OfToolResult                        *ToolResultBlockParam                        `json:",omitzero,inline"`
	OfServerToolUse                     *ServerToolUseBlockParam                     `json:",omitzero,inline"`
	OfWebSearchToolResult               *WebSearchToolResultBlockParam               `json:",omitzero,inline"`
	OfWebFetchToolResult                *WebFetchToolResultBlockParam                `json:",omitzero,inline"`
	OfCodeExecutionToolResult           *CodeExecutionToolResultBlockParam           `json:",omitzero,inline"`
	OfBashCodeExecutionToolResult       *BashCodeExecutionToolResultBlockParam       `json:",omitzero,inline"`
	OfTextEditorCodeExecutionToolResult *TextEditorCodeExecutionToolResultBlockParam `json:",omitzero,inline"`
	OfToolSearchToolResult              *ToolSearchToolResultBlockParam              `json:",omitzero,inline"`
	OfContainerUpload                   *ContainerUploadBlockParam                   `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 NewContainerUploadBlock

func NewContainerUploadBlock(fileID string) ContentBlockParamUnion

func NewImageBlockBase64

func NewImageBlockBase64(mediaType string, encodedData string) ContentBlockParamUnion

func NewRedactedThinkingBlock

func NewRedactedThinkingBlock(data string) ContentBlockParamUnion

func NewSearchResultBlock

func NewSearchResultBlock(content []TextBlockParam, source string, title string) ContentBlockParamUnion

func NewServerToolUseBlock

func NewServerToolUseBlock(id string, input any, name ServerToolUseBlockParamName) ContentBlockParamUnion

func NewTextBlock

func NewTextBlock(text string) ContentBlockParamUnion

func NewThinkingBlock

func NewThinkingBlock(signature string, thinking string) ContentBlockParamUnion

func NewToolResultBlock

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

func NewToolUseBlock

func NewToolUseBlock(id string, input any, name string) ContentBlockParamUnion

func NewWebFetchToolResultBlock

func NewWebFetchToolResultBlock[
	T WebFetchToolResultErrorBlockParam | WebFetchBlockParam,
](content T, toolUseID string) ContentBlockParamUnion

func NewWebSearchToolResultBlock

func NewWebSearchToolResultBlock[
	T []WebSearchResultBlockParam | WebSearchToolRequestErrorParam,
](content T, toolUseID string) ContentBlockParamUnion

func (ContentBlockParamUnion) GetCacheControl

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

func (ContentBlockParamUnion) GetCaller

func (u ContentBlockParamUnion) GetCaller() (res contentBlockParamUnionCaller)

Returns a subunion which exports methods to access subproperties

Or use AsAny() to get the underlying value

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

func (u ContentBlockParamUnion) GetContent() (res contentBlockParamUnionContent)

Returns a subunion which exports methods to access subproperties

Or use AsAny() to get the underlying value

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) GetFileID

func (u ContentBlockParamUnion) GetFileID() *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() *any

Returns a pointer to the underlying variant's Input 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) MarshalJSON

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

func (*ContentBlockParamUnion) UnmarshalJSON

func (u *ContentBlockParamUnion) UnmarshalJSON(data []byte) error

type ContentBlockSourceContentItemUnionParam

type ContentBlockSourceContentItemUnionParam struct {
	OfText  *TextBlockParam  `json:",omitzero,inline"`
	OfImage *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 ContentBlockSourceContentItemParamOfText

func ContentBlockSourceContentItemParamOfText(text string) ContentBlockSourceContentItemUnionParam

func (ContentBlockSourceContentItemUnionParam) GetCacheControl

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

func (ContentBlockSourceContentItemUnionParam) GetCitations

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

func (ContentBlockSourceContentItemUnionParam) GetSource

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

func (ContentBlockSourceContentItemUnionParam) GetText

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

func (ContentBlockSourceContentItemUnionParam) GetType

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

func (ContentBlockSourceContentItemUnionParam) MarshalJSON

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

func (*ContentBlockSourceContentItemUnionParam) UnmarshalJSON

func (u *ContentBlockSourceContentItemUnionParam) UnmarshalJSON(data []byte) error

type ContentBlockSourceContentUnionParam

type ContentBlockSourceContentUnionParam struct {
	OfString                    param.Opt[string]                         `json:",omitzero,inline"`
	OfContentBlockSourceContent []ContentBlockSourceContentItemUnionParam `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) MarshalJSON

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

func (*ContentBlockSourceContentUnionParam) UnmarshalJSON

func (u *ContentBlockSourceContentUnionParam) UnmarshalJSON(data []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) MarshalJSON

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

func (*ContentBlockSourceParam) UnmarshalJSON

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

type ContentBlockStartEvent

type ContentBlockStartEvent struct {
	// Response model for a file uploaded to the container.
	ContentBlock ContentBlockStartEventContentBlockUnion `json:"content_block,required"`
	Index        int64                                   `json:"index,required"`
	Type         constant.ContentBlockStart              `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ContentBlock respjson.Field
		Index        respjson.Field
		Type         respjson.Field
		ExtraFields  map[string]respjson.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", "thinking", "redacted_thinking", "tool_use", "server_tool_use",
	// "web_search_tool_result", "web_fetch_tool_result", "code_execution_tool_result",
	// "bash_code_execution_tool_result", "text_editor_code_execution_tool_result",
	// "tool_search_tool_result", "container_upload".
	Type string `json:"type"`
	// 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"`
	ID   string `json:"id"`
	// This field is a union of [ToolUseBlockCallerUnion],
	// [ServerToolUseBlockCallerUnion], [WebSearchToolResultBlockCallerUnion],
	// [WebFetchToolResultBlockCallerUnion]
	Caller ContentBlockStartEventContentBlockUnionCaller `json:"caller"`
	Input  any                                           `json:"input"`
	Name   string                                        `json:"name"`
	// This field is a union of [WebSearchToolResultBlockContentUnion],
	// [WebFetchToolResultBlockContentUnion],
	// [CodeExecutionToolResultBlockContentUnion],
	// [BashCodeExecutionToolResultBlockContentUnion],
	// [TextEditorCodeExecutionToolResultBlockContentUnion],
	// [ToolSearchToolResultBlockContentUnion]
	Content   ContentBlockStartEventContentBlockUnionContent `json:"content"`
	ToolUseID string                                         `json:"tool_use_id"`
	// This field is from variant [ContainerUploadBlock].
	FileID string `json:"file_id"`
	JSON   struct {
		Citations respjson.Field
		Text      respjson.Field
		Type      respjson.Field
		Signature respjson.Field
		Thinking  respjson.Field
		Data      respjson.Field
		ID        respjson.Field
		Caller    respjson.Field
		Input     respjson.Field
		Name      respjson.Field
		Content   respjson.Field
		ToolUseID respjson.Field
		FileID    respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

ContentBlockStartEventContentBlockUnion contains all possible properties and values from TextBlock, ThinkingBlock, RedactedThinkingBlock, ToolUseBlock, ServerToolUseBlock, WebSearchToolResultBlock, WebFetchToolResultBlock, CodeExecutionToolResultBlock, BashCodeExecutionToolResultBlock, TextEditorCodeExecutionToolResultBlock, ToolSearchToolResultBlock, ContainerUploadBlock.

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

func (u ContentBlockStartEventContentBlockUnion) AsAny() anyContentBlockStartEventContentBlock

Use the following switch statement to find the correct variant

switch variant := ContentBlockStartEventContentBlockUnion.AsAny().(type) {
case anthropic.TextBlock:
case anthropic.ThinkingBlock:
case anthropic.RedactedThinkingBlock:
case anthropic.ToolUseBlock:
case anthropic.ServerToolUseBlock:
case anthropic.WebSearchToolResultBlock:
case anthropic.WebFetchToolResultBlock:
case anthropic.CodeExecutionToolResultBlock:
case anthropic.BashCodeExecutionToolResultBlock:
case anthropic.TextEditorCodeExecutionToolResultBlock:
case anthropic.ToolSearchToolResultBlock:
case anthropic.ContainerUploadBlock:
default:
  fmt.Errorf("no variant present")
}

func (ContentBlockStartEventContentBlockUnion) AsBashCodeExecutionToolResult

func (u ContentBlockStartEventContentBlockUnion) AsBashCodeExecutionToolResult() (v BashCodeExecutionToolResultBlock)

func (ContentBlockStartEventContentBlockUnion) AsCodeExecutionToolResult

func (ContentBlockStartEventContentBlockUnion) AsContainerUpload

func (ContentBlockStartEventContentBlockUnion) AsRedactedThinking

func (ContentBlockStartEventContentBlockUnion) AsServerToolUse

func (ContentBlockStartEventContentBlockUnion) AsText

func (ContentBlockStartEventContentBlockUnion) AsTextEditorCodeExecutionToolResult

func (u ContentBlockStartEventContentBlockUnion) AsTextEditorCodeExecutionToolResult() (v TextEditorCodeExecutionToolResultBlock)

func (ContentBlockStartEventContentBlockUnion) AsThinking

func (ContentBlockStartEventContentBlockUnion) AsToolSearchToolResult

func (ContentBlockStartEventContentBlockUnion) AsToolUse

func (ContentBlockStartEventContentBlockUnion) AsWebFetchToolResult

func (ContentBlockStartEventContentBlockUnion) AsWebSearchToolResult

func (ContentBlockStartEventContentBlockUnion) RawJSON

Returns the unmodified JSON received from the API

func (*ContentBlockStartEventContentBlockUnion) UnmarshalJSON

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

type ContentBlockStartEventContentBlockUnionCaller

type ContentBlockStartEventContentBlockUnionCaller struct {
	Type   string `json:"type"`
	ToolID string `json:"tool_id"`
	JSON   struct {
		Type   respjson.Field
		ToolID respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

ContentBlockStartEventContentBlockUnionCaller is an implicit subunion of ContentBlockStartEventContentBlockUnion. ContentBlockStartEventContentBlockUnionCaller provides convenient access to the sub-properties of the union.

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

func (*ContentBlockStartEventContentBlockUnionCaller) UnmarshalJSON

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

type ContentBlockStartEventContentBlockUnionContent

type ContentBlockStartEventContentBlockUnionContent struct {
	// This field will be present if the value is a [[]WebSearchResultBlock] instead of
	// an object.
	OfWebSearchResultBlockArray []WebSearchResultBlock `json:",inline"`
	ErrorCode                   string                 `json:"error_code"`
	Type                        string                 `json:"type"`
	// This field is a union of [DocumentBlock], [[]CodeExecutionOutputBlock],
	// [[]CodeExecutionOutputBlock], [[]BashCodeExecutionOutputBlock], [string]
	Content ContentBlockStartEventContentBlockUnionContentContent `json:"content"`
	// This field is from variant [WebFetchToolResultBlockContentUnion].
	RetrievedAt string `json:"retrieved_at"`
	// This field is from variant [WebFetchToolResultBlockContentUnion].
	URL        string `json:"url"`
	ReturnCode int64  `json:"return_code"`
	Stderr     string `json:"stderr"`
	Stdout     string `json:"stdout"`
	// This field is from variant [CodeExecutionToolResultBlockContentUnion].
	EncryptedStdout string `json:"encrypted_stdout"`
	ErrorMessage    string `json:"error_message"`
	// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].
	FileType TextEditorCodeExecutionViewResultBlockFileType `json:"file_type"`
	// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].
	NumLines int64 `json:"num_lines"`
	// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].
	StartLine int64 `json:"start_line"`
	// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].
	TotalLines int64 `json:"total_lines"`
	// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].
	IsFileUpdate bool `json:"is_file_update"`
	// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].
	Lines []string `json:"lines"`
	// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].
	NewLines int64 `json:"new_lines"`
	// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].
	NewStart int64 `json:"new_start"`
	// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].
	OldLines int64 `json:"old_lines"`
	// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].
	OldStart int64 `json:"old_start"`
	// This field is from variant [ToolSearchToolResultBlockContentUnion].
	ToolReferences []ToolReferenceBlock `json:"tool_references"`
	JSON           struct {
		OfWebSearchResultBlockArray respjson.Field
		ErrorCode                   respjson.Field
		Type                        respjson.Field
		Content                     respjson.Field
		RetrievedAt                 respjson.Field
		URL                         respjson.Field
		ReturnCode                  respjson.Field
		Stderr                      respjson.Field
		Stdout                      respjson.Field
		EncryptedStdout             respjson.Field
		ErrorMessage                respjson.Field
		FileType                    respjson.Field
		NumLines                    respjson.Field
		StartLine                   respjson.Field
		TotalLines                  respjson.Field
		IsFileUpdate                respjson.Field
		Lines                       respjson.Field
		NewLines                    respjson.Field
		NewStart                    respjson.Field
		OldLines                    respjson.Field
		OldStart                    respjson.Field
		ToolReferences              respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

ContentBlockStartEventContentBlockUnionContent is an implicit subunion of ContentBlockStartEventContentBlockUnion. ContentBlockStartEventContentBlockUnionContent provides convenient access to the sub-properties of the union.

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

If the underlying value is not a json object, one of the following properties will be valid: OfWebSearchResultBlockArray]

func (*ContentBlockStartEventContentBlockUnionContent) UnmarshalJSON

type ContentBlockStartEventContentBlockUnionContentContent

type ContentBlockStartEventContentBlockUnionContentContent struct {
	// This field will be present if the value is a [[]CodeExecutionOutputBlock]
	// instead of an object.
	OfContent []CodeExecutionOutputBlock `json:",inline"`
	// This field will be present if the value is a [string] instead of an object.
	OfString string `json:",inline"`
	// This field is from variant [DocumentBlock].
	Citations CitationsConfig `json:"citations"`
	// This field is from variant [DocumentBlock].
	Source DocumentBlockSourceUnion `json:"source"`
	// This field is from variant [DocumentBlock].
	Title string `json:"title"`
	// This field is from variant [DocumentBlock].
	Type constant.Document `json:"type"`
	JSON struct {
		OfContent respjson.Field
		OfString  respjson.Field
		Citations respjson.Field
		Source    respjson.Field
		Title     respjson.Field
		Type      respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

ContentBlockStartEventContentBlockUnionContentContent is an implicit subunion of ContentBlockStartEventContentBlockUnion. ContentBlockStartEventContentBlockUnionContentContent provides convenient access to the sub-properties of the union.

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

If the underlying value is not a json object, one of the following properties will be valid: OfContent OfString]

func (*ContentBlockStartEventContentBlockUnionContentContent) UnmarshalJSON

type ContentBlockStopEvent

type ContentBlockStopEvent struct {
	Index int64                     `json:"index,required"`
	Type  constant.ContentBlockStop `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Index       respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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", "thinking", "redacted_thinking", "tool_use", "server_tool_use",
	// "web_search_tool_result", "web_fetch_tool_result", "code_execution_tool_result",
	// "bash_code_execution_tool_result", "text_editor_code_execution_tool_result",
	// "tool_search_tool_result", "container_upload".
	Type string `json:"type"`
	// 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"`
	ID   string `json:"id"`
	// necessary custom code modification
	Input json.RawMessage `json:"input"`
	Name  string          `json:"name"`
	// This field is from variant [WebSearchToolResultBlock].
	Content WebSearchToolResultBlockContentUnion `json:"content"`
	// This field is from variant [WebSearchToolResultBlock].
	ToolUseID string `json:"tool_use_id"`
	JSON      struct {
		Citations respjson.Field
		Text      respjson.Field
		Type      respjson.Field
		Signature respjson.Field
		Thinking  respjson.Field
		Data      respjson.Field
		ID        respjson.Field
		Caller    respjson.Field
		Input     respjson.Field
		Name      respjson.Field
		Content   respjson.Field
		ToolUseID respjson.Field
		FileID    respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

ContentBlockUnion contains all possible properties and values from TextBlock, ThinkingBlock, RedactedThinkingBlock, ToolUseBlock, ServerToolUseBlock, WebSearchToolResultBlock, WebFetchToolResultBlock, CodeExecutionToolResultBlock, BashCodeExecutionToolResultBlock, TextEditorCodeExecutionToolResultBlock, ToolSearchToolResultBlock, ContainerUploadBlock.

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() anyContentBlock

Use the following switch statement to find the correct variant

switch variant := ContentBlockUnion.AsAny().(type) {
case anthropic.TextBlock:
case anthropic.ThinkingBlock:
case anthropic.RedactedThinkingBlock:
case anthropic.ToolUseBlock:
case anthropic.ServerToolUseBlock:
case anthropic.WebSearchToolResultBlock:
case anthropic.WebFetchToolResultBlock:
case anthropic.CodeExecutionToolResultBlock:
case anthropic.BashCodeExecutionToolResultBlock:
case anthropic.TextEditorCodeExecutionToolResultBlock:
case anthropic.ToolSearchToolResultBlock:
case anthropic.ContainerUploadBlock:
default:
  fmt.Errorf("no variant present")
}

func (ContentBlockUnion) AsBashCodeExecutionToolResult

func (u ContentBlockUnion) AsBashCodeExecutionToolResult() (v BashCodeExecutionToolResultBlock)

func (ContentBlockUnion) AsCodeExecutionToolResult

func (u ContentBlockUnion) AsCodeExecutionToolResult() (v CodeExecutionToolResultBlock)

func (ContentBlockUnion) AsContainerUpload

func (u ContentBlockUnion) AsContainerUpload() (v ContainerUploadBlock)

func (ContentBlockUnion) AsRedactedThinking

func (u ContentBlockUnion) AsRedactedThinking() (v RedactedThinkingBlock)

func (ContentBlockUnion) AsServerToolUse

func (u ContentBlockUnion) AsServerToolUse() (v ServerToolUseBlock)

func (ContentBlockUnion) AsText

func (u ContentBlockUnion) AsText() (v TextBlock)

func (ContentBlockUnion) AsTextEditorCodeExecutionToolResult

func (u ContentBlockUnion) AsTextEditorCodeExecutionToolResult() (v TextEditorCodeExecutionToolResultBlock)

func (ContentBlockUnion) AsThinking

func (u ContentBlockUnion) AsThinking() (v ThinkingBlock)

func (ContentBlockUnion) AsToolSearchToolResult

func (u ContentBlockUnion) AsToolSearchToolResult() (v ToolSearchToolResultBlock)

func (ContentBlockUnion) AsToolUse

func (u ContentBlockUnion) AsToolUse() (v ToolUseBlock)

func (ContentBlockUnion) AsWebFetchToolResult

func (u ContentBlockUnion) AsWebFetchToolResult() (v WebFetchToolResultBlock)

func (ContentBlockUnion) AsWebSearchToolResult

func (u ContentBlockUnion) AsWebSearchToolResult() (v WebSearchToolResultBlock)

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 ContentBlockUnionCaller

type ContentBlockUnionCaller struct {
	Type   string `json:"type"`
	ToolID string `json:"tool_id"`
	JSON   struct {
		Type   respjson.Field
		ToolID respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

ContentBlockUnionCaller is an implicit subunion of ContentBlockUnion. ContentBlockUnionCaller provides convenient access to the sub-properties of the union.

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

func (*ContentBlockUnionCaller) UnmarshalJSON

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

type ContentBlockUnionContent

type ContentBlockUnionContent struct {
	// This field will be present if the value is a [[]WebSearchResultBlock] instead of
	// an object.
	OfWebSearchResultBlockArray []WebSearchResultBlock `json:",inline"`
	ErrorCode                   string                 `json:"error_code"`
	Type                        string                 `json:"type"`
	// This field is a union of [DocumentBlock], [[]CodeExecutionOutputBlock],
	// [[]CodeExecutionOutputBlock], [[]BashCodeExecutionOutputBlock], [string]
	Content ContentBlockUnionContentContent `json:"content"`
	// This field is from variant [WebFetchToolResultBlockContentUnion].
	RetrievedAt string `json:"retrieved_at"`
	// This field is from variant [WebFetchToolResultBlockContentUnion].
	URL        string `json:"url"`
	ReturnCode int64  `json:"return_code"`
	Stderr     string `json:"stderr"`
	Stdout     string `json:"stdout"`
	// This field is from variant [CodeExecutionToolResultBlockContentUnion].
	EncryptedStdout string `json:"encrypted_stdout"`
	ErrorMessage    string `json:"error_message"`
	// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].
	FileType TextEditorCodeExecutionViewResultBlockFileType `json:"file_type"`
	// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].
	NumLines int64 `json:"num_lines"`
	// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].
	StartLine int64 `json:"start_line"`
	// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].
	TotalLines int64 `json:"total_lines"`
	// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].
	IsFileUpdate bool `json:"is_file_update"`
	// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].
	Lines []string `json:"lines"`
	// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].
	NewLines int64 `json:"new_lines"`
	// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].
	NewStart int64 `json:"new_start"`
	// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].
	OldLines int64 `json:"old_lines"`
	// This field is from variant [TextEditorCodeExecutionToolResultBlockContentUnion].
	OldStart int64 `json:"old_start"`
	// This field is from variant [ToolSearchToolResultBlockContentUnion].
	ToolReferences []ToolReferenceBlock `json:"tool_references"`
	JSON           struct {
		OfWebSearchResultBlockArray respjson.Field
		ErrorCode                   respjson.Field
		Type                        respjson.Field
		Content                     respjson.Field
		RetrievedAt                 respjson.Field
		URL                         respjson.Field
		ReturnCode                  respjson.Field
		Stderr                      respjson.Field
		Stdout                      respjson.Field
		EncryptedStdout             respjson.Field
		ErrorMessage                respjson.Field
		FileType                    respjson.Field
		NumLines                    respjson.Field
		StartLine                   respjson.Field
		TotalLines                  respjson.Field
		IsFileUpdate                respjson.Field
		Lines                       respjson.Field
		NewLines                    respjson.Field
		NewStart                    respjson.Field
		OldLines                    respjson.Field
		OldStart                    respjson.Field
		ToolReferences              respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

ContentBlockUnionContent is an implicit subunion of ContentBlockUnion. ContentBlockUnionContent provides convenient access to the sub-properties of the union.

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

If the underlying value is not a json object, one of the following properties will be valid: OfWebSearchResultBlockArray]

func (*ContentBlockUnionContent) UnmarshalJSON

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

type ContentBlockUnionContentContent

type ContentBlockUnionContentContent struct {
	// This field will be present if the value is a [[]CodeExecutionOutputBlock]
	// instead of an object.
	OfContent []CodeExecutionOutputBlock `json:",inline"`
	// This field will be present if the value is a [string] instead of an object.
	OfString string `json:",inline"`
	// This field is from variant [DocumentBlock].
	Citations CitationsConfig `json:"citations"`
	// This field is from variant [DocumentBlock].
	Source DocumentBlockSourceUnion `json:"source"`
	// This field is from variant [DocumentBlock].
	Title string `json:"title"`
	// This field is from variant [DocumentBlock].
	Type constant.Document `json:"type"`
	JSON struct {
		OfContent respjson.Field
		OfString  respjson.Field
		Citations respjson.Field
		Source    respjson.Field
		Title     respjson.Field
		Type      respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

ContentBlockUnionContentContent is an implicit subunion of ContentBlockUnion. ContentBlockUnionContentContent provides convenient access to the sub-properties of the union.

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

If the underlying value is not a json object, one of the following properties will be valid: OfContent OfString]

func (*ContentBlockUnionContentContent) UnmarshalJSON

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

type DeletedFile

type DeletedFile struct {
	// ID of the deleted file.
	ID string `json:"id,required"`
	// Deleted object type.
	//
	// For file deletion, this is always `"file_deleted"`.
	//
	// Any of "file_deleted".
	Type DeletedFileType `json:"type"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (DeletedFile) RawJSON

func (r DeletedFile) RawJSON() string

Returns the unmodified JSON received from the API

func (*DeletedFile) UnmarshalJSON

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

type DeletedFileType

type DeletedFileType string

Deleted object type.

For file deletion, this is always `"file_deleted"`.

const (
	DeletedFileTypeFileDeleted DeletedFileType = "file_deleted"
)

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"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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 DirectCaller

type DirectCaller struct {
	Type constant.Direct `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Tool invocation directly from the model.

func (DirectCaller) RawJSON

func (r DirectCaller) RawJSON() string

Returns the unmodified JSON received from the API

func (DirectCaller) ToParam

func (r DirectCaller) ToParam() DirectCallerParam

ToParam converts this DirectCaller to a DirectCallerParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with DirectCallerParam.Overrides()

func (*DirectCaller) UnmarshalJSON

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

type DirectCallerParam

type DirectCallerParam struct {
	Type constant.Direct `json:"type,required"`
	// contains filtered or unexported fields
}

Tool invocation directly from the model.

This struct has a constant value, construct it with NewDirectCallerParam.

func NewDirectCallerParam

func NewDirectCallerParam() DirectCallerParam

func (DirectCallerParam) MarshalJSON

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

func (*DirectCallerParam) UnmarshalJSON

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

type DocumentBlock

type DocumentBlock struct {
	// Citation configuration for the document
	Citations CitationsConfig          `json:"citations,required"`
	Source    DocumentBlockSourceUnion `json:"source,required"`
	// The title of the document
	Title string            `json:"title,required"`
	Type  constant.Document `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Citations   respjson.Field
		Source      respjson.Field
		Title       respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (DocumentBlock) RawJSON

func (r DocumentBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (*DocumentBlock) UnmarshalJSON

func (r *DocumentBlock) 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"`
	// Create a cache control breakpoint at this content block.
	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) MarshalJSON

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

func (*DocumentBlockParam) UnmarshalJSON

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

type DocumentBlockParamSourceUnion

type DocumentBlockParamSourceUnion struct {
	OfBase64  *Base64PDFSourceParam    `json:",omitzero,inline"`
	OfText    *PlainTextSourceParam    `json:",omitzero,inline"`
	OfContent *ContentBlockSourceParam `json:",omitzero,inline"`
	OfURL     *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) MarshalJSON

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

func (*DocumentBlockParamSourceUnion) UnmarshalJSON

func (u *DocumentBlockParamSourceUnion) UnmarshalJSON(data []byte) error

type DocumentBlockSourceUnion

type DocumentBlockSourceUnion struct {
	Data      string `json:"data"`
	MediaType string `json:"media_type"`
	// Any of "base64", "text".
	Type string `json:"type"`
	JSON struct {
		Data      respjson.Field
		MediaType respjson.Field
		Type      respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

DocumentBlockSourceUnion contains all possible properties and values from Base64PDFSource, PlainTextSource.

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

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

func (DocumentBlockSourceUnion) AsAny

func (u DocumentBlockSourceUnion) AsAny() anyDocumentBlockSource

Use the following switch statement to find the correct variant

switch variant := DocumentBlockSourceUnion.AsAny().(type) {
case anthropic.Base64PDFSource:
case anthropic.PlainTextSource:
default:
  fmt.Errorf("no variant present")
}

func (DocumentBlockSourceUnion) AsBase64

func (u DocumentBlockSourceUnion) AsBase64() (v Base64PDFSource)

func (DocumentBlockSourceUnion) AsText

func (DocumentBlockSourceUnion) RawJSON

func (u DocumentBlockSourceUnion) RawJSON() string

Returns the unmodified JSON received from the API

func (*DocumentBlockSourceUnion) UnmarshalJSON

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

type EncryptedCodeExecutionResultBlock

type EncryptedCodeExecutionResultBlock struct {
	Content         []CodeExecutionOutputBlock            `json:"content,required"`
	EncryptedStdout string                                `json:"encrypted_stdout,required"`
	ReturnCode      int64                                 `json:"return_code,required"`
	Stderr          string                                `json:"stderr,required"`
	Type            constant.EncryptedCodeExecutionResult `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Content         respjson.Field
		EncryptedStdout respjson.Field
		ReturnCode      respjson.Field
		Stderr          respjson.Field
		Type            respjson.Field
		ExtraFields     map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Code execution result with encrypted stdout for PFC + web_search results.

func (EncryptedCodeExecutionResultBlock) RawJSON

Returns the unmodified JSON received from the API

func (*EncryptedCodeExecutionResultBlock) UnmarshalJSON

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

type EncryptedCodeExecutionResultBlockParam

type EncryptedCodeExecutionResultBlockParam struct {
	Content         []CodeExecutionOutputBlockParam `json:"content,omitzero,required"`
	EncryptedStdout string                          `json:"encrypted_stdout,required"`
	ReturnCode      int64                           `json:"return_code,required"`
	Stderr          string                          `json:"stderr,required"`
	// This field can be elided, and will marshal its zero value as
	// "encrypted_code_execution_result".
	Type constant.EncryptedCodeExecutionResult `json:"type,required"`
	// contains filtered or unexported fields
}

Code execution result with encrypted stdout for PFC + web_search results.

The properties Content, EncryptedStdout, ReturnCode, Stderr, Type are required.

func (EncryptedCodeExecutionResultBlockParam) MarshalJSON

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

func (*EncryptedCodeExecutionResultBlockParam) UnmarshalJSON

func (r *EncryptedCodeExecutionResultBlockParam) UnmarshalJSON(data []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 FileMetadata

type FileMetadata struct {
	// Unique object identifier.
	//
	// The format and length of IDs may change over time.
	ID string `json:"id,required"`
	// RFC 3339 datetime string representing when the file was created.
	CreatedAt time.Time `json:"created_at,required" format:"date-time"`
	// Original filename of the uploaded file.
	Filename string `json:"filename,required"`
	// MIME type of the file.
	MimeType string `json:"mime_type,required"`
	// Size of the file in bytes.
	SizeBytes int64 `json:"size_bytes,required"`
	// Object type.
	//
	// For files, this is always `"file"`.
	Type constant.File `json:"type,required"`
	// Whether the file can be downloaded.
	Downloadable bool `json:"downloadable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID           respjson.Field
		CreatedAt    respjson.Field
		Filename     respjson.Field
		MimeType     respjson.Field
		SizeBytes    respjson.Field
		Type         respjson.Field
		Downloadable respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (FileMetadata) RawJSON

func (r FileMetadata) RawJSON() string

Returns the unmodified JSON received from the API

func (*FileMetadata) UnmarshalJSON

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

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"`
	// Create a cache control breakpoint at this content block.
	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) MarshalJSON

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

func (*ImageBlockParam) UnmarshalJSON

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

type ImageBlockParamSourceUnion

type ImageBlockParamSourceUnion struct {
	OfBase64 *Base64ImageSourceParam `json:",omitzero,inline"`
	OfURL    *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) MarshalJSON

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

func (*ImageBlockParamSourceUnion) UnmarshalJSON

func (u *ImageBlockParamSourceUnion) UnmarshalJSON(data []byte) error

type InputJSONDelta

type InputJSONDelta struct {
	PartialJSON string                  `json:"partial_json,required"`
	Type        constant.InputJSONDelta `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		PartialJSON respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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 InvalidRequestError

type InvalidRequestError = shared.InvalidRequestError

This is an alias to an internal type.

type JSONOutputFormatParam

type JSONOutputFormatParam struct {
	// The JSON schema of the format
	Schema map[string]any `json:"schema,omitzero,required"`
	// This field can be elided, and will marshal its zero value as "json_schema".
	Type constant.JSONSchema `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Schema, Type are required.

func (JSONOutputFormatParam) MarshalJSON

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

func (*JSONOutputFormatParam) UnmarshalJSON

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

type MemoryTool20250818Param

type MemoryTool20250818Param struct {
	// If true, tool will not be included in initial system prompt. Only loaded when
	// returned via tool_reference from tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// When true, guarantees schema validation on tool names and inputs
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// Create a cache control breakpoint at this content block.
	CacheControl  CacheControlEphemeralParam `json:"cache_control,omitzero"`
	InputExamples []map[string]any           `json:"input_examples,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 "memory".
	Name constant.Memory `json:"name,required"`
	// This field can be elided, and will marshal its zero value as "memory_20250818".
	Type constant.Memory20250818 `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Name, Type are required.

func (MemoryTool20250818Param) MarshalJSON

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

func (*MemoryTool20250818Param) UnmarshalJSON

func (r *MemoryTool20250818Param) 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"`
	// Information about the container used in the request (for the code execution
	// tool)
	Container Container `json:"container,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
	//   - `"pause_turn"`: we paused a long-running turn. You may provide the response
	//     back as-is in a subsequent request to let the model continue.
	//   - `"refusal"`: when streaming classifiers intervene to handle potential policy
	//     violations
	//
	// 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", "pause_turn",
	// "refusal".
	StopReason StopReason `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"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID           respjson.Field
		Container    respjson.Field
		Content      respjson.Field
		Model        respjson.Field
		Role         respjson.Field
		StopReason   respjson.Field
		StopSequence respjson.Field
		Type         respjson.Field
		Usage        respjson.Field
		ExtraFields  map[string]respjson.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"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID                respjson.Field
		ArchivedAt        respjson.Field
		CancelInitiatedAt respjson.Field
		CreatedAt         respjson.Field
		EndedAt           respjson.Field
		ExpiresAt         respjson.Field
		ProcessingStatus  respjson.Field
		RequestCounts     respjson.Field
		ResultsURL        respjson.Field
		Type              respjson.Field
		ExtraFields       map[string]respjson.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"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.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"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Error       respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.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"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CustomID    respjson.Field
		Result      respjson.Field
		ExtraFields map[string]respjson.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) URLQuery

func (r MessageBatchListParams) URLQuery() (v url.Values, err error)

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) MarshalJSON

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

func (*MessageBatchNewParams) UnmarshalJSON

func (r *MessageBatchNewParams) UnmarshalJSON(data []byte) 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](https://docs.claude.com/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) MarshalJSON

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

func (*MessageBatchNewParamsRequest) UnmarshalJSON

func (r *MessageBatchNewParamsRequest) UnmarshalJSON(data []byte) 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.claude.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" }] }
	// “`
	//
	// See [input examples](https://docs.claude.com/en/api/messages-examples).
	//
	// Note that if you want to include a
	// [system prompt](https://docs.claude.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.
	//
	// There is a limit of 100,000 messages in a single request.
	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"`
	// Container identifier for reuse across requests.
	Container param.Opt[string] `json:"container,omitzero"`
	// Specifies the geographic region for inference processing. If not specified, the
	// workspace's `default_inference_geo` is used.
	InferenceGeo param.Opt[string] `json:"inference_geo,omitzero"`
	// Whether to incrementally stream the response using server-sent events.
	//
	// See [streaming](https://docs.claude.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"`
	// Top-level cache control automatically applies a cache_control marker to the last
	// cacheable block in the request.
	CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"`
	// An object describing metadata about the request.
	Metadata MetadataParam `json:"metadata,omitzero"`
	// Configuration options for the model's output, such as the output format.
	OutputConfig OutputConfigParam `json:"output_config,omitzero"`
	// Determines whether to use priority capacity (if available) or standard capacity
	// for this request.
	//
	// Anthropic offers different levels of service for your API requests. See
	// [service-tiers](https://docs.claude.com/en/api/service-tiers) for details.
	//
	// Any of "auto", "standard_only".
	ServiceTier string `json:"service_tier,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.claude.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.claude.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.
	//
	// There are two types of tools: **client tools** and **server tools**. The
	// behavior described below applies to client tools. For
	// [server tools](https://docs.claude.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
	// see their individual documentation as each has its own behavior (e.g., the
	// [web search tool](https://docs.claude.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
	//
	// 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.claude.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](https://docs.claude.com/en/api/messages) for full documentation on available parameters.

The properties MaxTokens, Messages, Model are required.

func (MessageBatchNewParamsRequestParams) MarshalJSON

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

func (*MessageBatchNewParamsRequestParams) UnmarshalJSON

func (r *MessageBatchNewParamsRequestParams) UnmarshalJSON(data []byte) 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"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Canceled    respjson.Field
		Errored     respjson.Field
		Expired     respjson.Field
		Processing  respjson.Field
		Succeeded   respjson.Field
		ExtraFields map[string]respjson.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 respjson.Field
		Type    respjson.Field
		Error   respjson.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() anyMessageBatchResult

Use the following switch statement to find the correct variant

switch variant := MessageBatchResultUnion.AsAny().(type) {
case anthropic.MessageBatchSucceededResult:
case anthropic.MessageBatchErroredResult:
case anthropic.MessageBatchCanceledResult:
case anthropic.MessageBatchExpiredResult:
default:
  fmt.Errorf("no variant present")
}

func (MessageBatchResultUnion) AsCanceled

func (MessageBatchResultUnion) AsErrored

func (MessageBatchResultUnion) AsExpired

func (MessageBatchResultUnion) AsSucceeded

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](https://docs.claude.com/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](https://docs.claude.com/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](https://docs.claude.com/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](https://docs.claude.com/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](https://docs.claude.com/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](https://docs.claude.com/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](https://docs.claude.com/en/docs/build-with-claude/batch-processing)

type MessageBatchSucceededResult

type MessageBatchSucceededResult struct {
	Message Message            `json:"message,required"`
	Type    constant.Succeeded `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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" }] }
	// “`
	//
	// See [input examples](https://docs.claude.com/en/api/messages-examples).
	//
	// Note that if you want to include a
	// [system prompt](https://docs.claude.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.
	//
	// There is a limit of 100,000 messages in a single request.
	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"`
	// Top-level cache control automatically applies a cache_control marker to the last
	// cacheable block in the request.
	CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"`
	// Configuration options for the model's output, such as the output format.
	OutputConfig OutputConfigParam `json:"output_config,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.claude.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.claude.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.
	//
	// There are two types of tools: **client tools** and **server tools**. The
	// behavior described below applies to client tools. For
	// [server tools](https://docs.claude.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
	// see their individual documentation as each has its own behavior (e.g., the
	// [web search tool](https://docs.claude.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
	//
	// 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.claude.com/en/docs/tool-use) for more details.
	Tools []MessageCountTokensToolUnionParam `json:"tools,omitzero"`
	// contains filtered or unexported fields
}

func (MessageCountTokensParams) MarshalJSON

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

func (*MessageCountTokensParams) UnmarshalJSON

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

type MessageCountTokensParamsSystemUnion

type MessageCountTokensParamsSystemUnion struct {
	OfString         param.Opt[string] `json:",omitzero,inline"`
	OfTextBlockArray []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) MarshalJSON

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

func (*MessageCountTokensParamsSystemUnion) UnmarshalJSON

func (u *MessageCountTokensParamsSystemUnion) UnmarshalJSON(data []byte) error

type MessageCountTokensToolUnionParam

type MessageCountTokensToolUnionParam struct {
	OfTool                        *ToolParam                        `json:",omitzero,inline"`
	OfBashTool20250124            *ToolBash20250124Param            `json:",omitzero,inline"`
	OfCodeExecutionTool20250522   *CodeExecutionTool20250522Param   `json:",omitzero,inline"`
	OfCodeExecutionTool20250825   *CodeExecutionTool20250825Param   `json:",omitzero,inline"`
	OfCodeExecutionTool20260120   *CodeExecutionTool20260120Param   `json:",omitzero,inline"`
	OfMemoryTool20250818          *MemoryTool20250818Param          `json:",omitzero,inline"`
	OfTextEditor20250124          *ToolTextEditor20250124Param      `json:",omitzero,inline"`
	OfTextEditor20250429          *ToolTextEditor20250429Param      `json:",omitzero,inline"`
	OfTextEditor20250728          *ToolTextEditor20250728Param      `json:",omitzero,inline"`
	OfWebSearchTool20250305       *WebSearchTool20250305Param       `json:",omitzero,inline"`
	OfWebFetchTool20250910        *WebFetchTool20250910Param        `json:",omitzero,inline"`
	OfWebSearchTool20260209       *WebSearchTool20260209Param       `json:",omitzero,inline"`
	OfWebFetchTool20260209        *WebFetchTool20260209Param        `json:",omitzero,inline"`
	OfToolSearchToolBm25_20251119 *ToolSearchToolBm25_20251119Param `json:",omitzero,inline"`
	OfToolSearchToolRegex20251119 *ToolSearchToolRegex20251119Param `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) GetAllowedCallers

func (u MessageCountTokensToolUnionParam) GetAllowedCallers() []string

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

func (MessageCountTokensToolUnionParam) GetAllowedDomains

func (u MessageCountTokensToolUnionParam) GetAllowedDomains() []string

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

func (MessageCountTokensToolUnionParam) GetBlockedDomains

func (u MessageCountTokensToolUnionParam) GetBlockedDomains() []string

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

func (MessageCountTokensToolUnionParam) GetCacheControl

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

func (MessageCountTokensToolUnionParam) GetCitations

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

func (MessageCountTokensToolUnionParam) GetDeferLoading

func (u MessageCountTokensToolUnionParam) GetDeferLoading() *bool

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

func (MessageCountTokensToolUnionParam) GetDescription

func (u MessageCountTokensToolUnionParam) GetDescription() *string

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

func (MessageCountTokensToolUnionParam) GetEagerInputStreaming

func (u MessageCountTokensToolUnionParam) GetEagerInputStreaming() *bool

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

func (MessageCountTokensToolUnionParam) GetInputExamples

func (u MessageCountTokensToolUnionParam) GetInputExamples() []map[string]any

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

func (MessageCountTokensToolUnionParam) GetInputSchema

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

func (MessageCountTokensToolUnionParam) GetMaxCharacters

func (u MessageCountTokensToolUnionParam) GetMaxCharacters() *int64

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

func (MessageCountTokensToolUnionParam) GetMaxContentTokens

func (u MessageCountTokensToolUnionParam) GetMaxContentTokens() *int64

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

func (MessageCountTokensToolUnionParam) GetMaxUses

func (u MessageCountTokensToolUnionParam) GetMaxUses() *int64

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) GetStrict

func (u MessageCountTokensToolUnionParam) GetStrict() *bool

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) GetUserLocation

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

func (MessageCountTokensToolUnionParam) MarshalJSON

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

func (*MessageCountTokensToolUnionParam) UnmarshalJSON

func (u *MessageCountTokensToolUnionParam) UnmarshalJSON(data []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"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Delta       respjson.Field
		Type        respjson.Field
		Usage       respjson.Field
		ExtraFields map[string]respjson.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 {
	// Information about the container used in the request (for the code execution
	// tool)
	Container Container `json:"container,required"`
	// Any of "end_turn", "max_tokens", "stop_sequence", "tool_use", "pause_turn",
	// "refusal".
	StopReason   StopReason `json:"stop_reason,required"`
	StopSequence string     `json:"stop_sequence,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Container    respjson.Field
		StopReason   respjson.Field
		StopSequence respjson.Field
		ExtraFields  map[string]respjson.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 input tokens used to create the cache entry.
	CacheCreationInputTokens int64 `json:"cache_creation_input_tokens,required"`
	// The cumulative number of input tokens read from the cache.
	CacheReadInputTokens int64 `json:"cache_read_input_tokens,required"`
	// The cumulative number of input tokens which were used.
	InputTokens int64 `json:"input_tokens,required"`
	// The cumulative number of output tokens which were used.
	OutputTokens int64 `json:"output_tokens,required"`
	// The number of server tool requests.
	ServerToolUse ServerToolUsage `json:"server_tool_use,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CacheCreationInputTokens respjson.Field
		CacheReadInputTokens     respjson.Field
		InputTokens              respjson.Field
		OutputTokens             respjson.Field
		ServerToolUse            respjson.Field
		ExtraFields              map[string]respjson.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.claude.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" }] }
	// “`
	//
	// See [input examples](https://docs.claude.com/en/api/messages-examples).
	//
	// Note that if you want to include a
	// [system prompt](https://docs.claude.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.
	//
	// There is a limit of 100,000 messages in a single request.
	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"`
	// Container identifier for reuse across requests.
	Container param.Opt[string] `json:"container,omitzero"`
	// Specifies the geographic region for inference processing. If not specified, the
	// workspace's `default_inference_geo` is used.
	InferenceGeo param.Opt[string] `json:"inference_geo,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"`
	// Top-level cache control automatically applies a cache_control marker to the last
	// cacheable block in the request.
	CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"`
	// An object describing metadata about the request.
	Metadata MetadataParam `json:"metadata,omitzero"`
	// Configuration options for the model's output, such as the output format.
	OutputConfig OutputConfigParam `json:"output_config,omitzero"`
	// Determines whether to use priority capacity (if available) or standard capacity
	// for this request.
	//
	// Anthropic offers different levels of service for your API requests. See
	// [service-tiers](https://docs.claude.com/en/api/service-tiers) for details.
	//
	// Any of "auto", "standard_only".
	ServiceTier MessageNewParamsServiceTier `json:"service_tier,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.claude.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.claude.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.
	//
	// There are two types of tools: **client tools** and **server tools**. The
	// behavior described below applies to client tools. For
	// [server tools](https://docs.claude.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
	// see their individual documentation as each has its own behavior (e.g., the
	// [web search tool](https://docs.claude.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
	//
	// 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.claude.com/en/docs/tool-use) for more details.
	Tools []ToolUnionParam `json:"tools,omitzero"`
	// contains filtered or unexported fields
}

func (MessageNewParams) MarshalJSON

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

func (*MessageNewParams) UnmarshalJSON

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

type MessageNewParamsServiceTier

type MessageNewParamsServiceTier string

Determines whether to use priority capacity (if available) or standard capacity for this request.

Anthropic offers different levels of service for your API requests. See [service-tiers](https://docs.claude.com/en/api/service-tiers) for details.

const (
	MessageNewParamsServiceTierAuto         MessageNewParamsServiceTier = "auto"
	MessageNewParamsServiceTierStandardOnly MessageNewParamsServiceTier = "standard_only"
)

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) MarshalJSON

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

func (*MessageParam) UnmarshalJSON

func (r *MessageParam) UnmarshalJSON(data []byte) 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](https://docs.claude.com/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](https://docs.claude.com/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](https://docs.claude.com/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"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type        respjson.Field
		ExtraFields map[string]respjson.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], [RawContentBlockDeltaUnion]
	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      respjson.Field
		Type         respjson.Field
		Delta        respjson.Field
		Usage        respjson.Field
		ContentBlock respjson.Field
		Index        respjson.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() anyMessageStreamEvent

Use the following switch statement to find the correct variant

switch variant := MessageStreamEventUnion.AsAny().(type) {
case anthropic.MessageStartEvent:
case anthropic.MessageDeltaEvent:
case anthropic.MessageStopEvent:
case anthropic.ContentBlockStartEvent:
case anthropic.ContentBlockDeltaEvent:
case anthropic.ContentBlockStopEvent:
default:
  fmt.Errorf("no variant present")
}

func (MessageStreamEventUnion) AsContentBlockDelta

func (u MessageStreamEventUnion) AsContentBlockDelta() (v ContentBlockDeltaEvent)

func (MessageStreamEventUnion) AsContentBlockStart

func (u MessageStreamEventUnion) AsContentBlockStart() (v ContentBlockStartEvent)

func (MessageStreamEventUnion) AsContentBlockStop

func (u MessageStreamEventUnion) AsContentBlockStop() (v ContentBlockStopEvent)

func (MessageStreamEventUnion) AsMessageDelta

func (u MessageStreamEventUnion) AsMessageDelta() (v MessageDeltaEvent)

func (MessageStreamEventUnion) AsMessageStart

func (u MessageStreamEventUnion) AsMessageStart() (v MessageStartEvent)

func (MessageStreamEventUnion) AsMessageStop

func (u MessageStreamEventUnion) AsMessageStop() (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].
	Container Container `json:"container"`
	// This field is from variant [MessageDeltaEventDelta].
	StopReason StopReason `json:"stop_reason"`
	// This field is from variant [MessageDeltaEventDelta].
	StopSequence string `json:"stop_sequence"`
	// This field is from variant [RawContentBlockDeltaUnion].
	Text string `json:"text"`
	Type string `json:"type"`
	// This field is from variant [RawContentBlockDeltaUnion].
	PartialJSON string `json:"partial_json"`
	// This field is from variant [RawContentBlockDeltaUnion].
	Citation CitationsDeltaCitationUnion `json:"citation"`
	// This field is from variant [RawContentBlockDeltaUnion].
	Thinking string `json:"thinking"`
	// This field is from variant [RawContentBlockDeltaUnion].
	Signature string `json:"signature"`
	JSON      struct {
		Container    respjson.Field
		StopReason   respjson.Field
		StopSequence respjson.Field
		Text         respjson.Field
		Type         respjson.Field
		PartialJSON  respjson.Field
		Citation     respjson.Field
		Thinking     respjson.Field
		Signature    respjson.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"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		InputTokens respjson.Field
		ExtraFields map[string]respjson.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) MarshalJSON

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

func (*MetadataParam) UnmarshalJSON

func (r *MetadataParam) UnmarshalJSON(data []byte) 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 (
	ModelClaudeOpus4_6          Model = "claude-opus-4-6"
	ModelClaudeSonnet4_6        Model = "claude-sonnet-4-6"
	ModelClaudeOpus4_5_20251101 Model = "claude-opus-4-5-20251101"
	ModelClaudeOpus4_5          Model = "claude-opus-4-5"
	// Deprecated: Will reach end-of-life on February 19th, 2026. Please migrate to a
	// newer model. Visit
	// https://docs.anthropic.com/en/docs/resources/model-deprecations for more
	// information.
	ModelClaude3_7SonnetLatest Model = "claude-3-7-sonnet-latest"
	// Deprecated: Will reach end-of-life on February 19th, 2026. Please migrate to a
	// newer model. Visit
	// https://docs.anthropic.com/en/docs/resources/model-deprecations for more
	// information.
	ModelClaude3_7Sonnet20250219 Model = "claude-3-7-sonnet-20250219"
	// Deprecated: Will reach end-of-life on February 19th, 2026. Please migrate to a
	// newer model. Visit
	// https://docs.anthropic.com/en/docs/resources/model-deprecations for more
	// information.
	ModelClaude3_5HaikuLatest Model = "claude-3-5-haiku-latest"
	// Deprecated: Will reach end-of-life on February 19th, 2026. Please migrate to a
	// newer model. Visit
	// https://docs.anthropic.com/en/docs/resources/model-deprecations for more
	// information.
	ModelClaude3_5Haiku20241022   Model = "claude-3-5-haiku-20241022"
	ModelClaudeHaiku4_5           Model = "claude-haiku-4-5"
	ModelClaudeHaiku4_5_20251001  Model = "claude-haiku-4-5-20251001"
	ModelClaudeSonnet4_20250514   Model = "claude-sonnet-4-20250514"
	ModelClaudeSonnet4_0          Model = "claude-sonnet-4-0"
	ModelClaude4Sonnet20250514    Model = "claude-4-sonnet-20250514"
	ModelClaudeSonnet4_5          Model = "claude-sonnet-4-5"
	ModelClaudeSonnet4_5_20250929 Model = "claude-sonnet-4-5-20250929"
	ModelClaudeOpus4_0            Model = "claude-opus-4-0"
	ModelClaudeOpus4_20250514     Model = "claude-opus-4-20250514"
	ModelClaude4Opus20250514      Model = "claude-4-opus-20250514"
	ModelClaudeOpus4_1_20250805   Model = "claude-opus-4-1-20250805"
	// Deprecated: Will reach end-of-life on January 5th, 2026. Please migrate to a
	// newer model. Visit
	// https://docs.anthropic.com/en/docs/resources/model-deprecations for more
	// information.
	ModelClaude3OpusLatest Model = "claude-3-opus-latest"
	// Deprecated: Will reach end-of-life on January 5th, 2026. Please migrate to a
	// newer model. Visit
	// https://docs.anthropic.com/en/docs/resources/model-deprecations for more
	// information.
	ModelClaude_3_Opus_20240229  Model = "claude-3-opus-20240229"
	ModelClaude_3_Haiku_20240307 Model = "claude-3-haiku-20240307"
)

type ModelGetParams

type ModelGetParams 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
}

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"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		CreatedAt   respjson.Field
		DisplayName respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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:"-"`
	// 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 (ModelListParams) URLQuery

func (r ModelListParams) URLQuery() (v url.Values, err error)

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, query ModelGetParams, 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, params 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 NotFoundError

type NotFoundError = shared.NotFoundError

This is an alias to an internal type.

type OutputConfigEffort

type OutputConfigEffort string

All possible effort levels.

const (
	OutputConfigEffortLow    OutputConfigEffort = "low"
	OutputConfigEffortMedium OutputConfigEffort = "medium"
	OutputConfigEffortHigh   OutputConfigEffort = "high"
	OutputConfigEffortMax    OutputConfigEffort = "max"
)

type OutputConfigParam

type OutputConfigParam struct {
	// All possible effort levels.
	//
	// Any of "low", "medium", "high", "max".
	Effort OutputConfigEffort `json:"effort,omitzero"`
	// A schema to specify Claude's output format in responses. See
	// [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)
	Format JSONOutputFormatParam `json:"format,omitzero"`
	// contains filtered or unexported fields
}

func (OutputConfigParam) MarshalJSON

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

func (*OutputConfigParam) UnmarshalJSON

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

type OverloadedError

type OverloadedError = shared.OverloadedError

This is an alias to an internal type.

type PermissionError

type PermissionError = shared.PermissionError

This is an alias to an internal type.

type PlainTextSource

type PlainTextSource struct {
	Data      string             `json:"data,required"`
	MediaType constant.TextPlain `json:"media_type,required"`
	Type      constant.Text      `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		MediaType   respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (PlainTextSource) RawJSON

func (r PlainTextSource) RawJSON() string

Returns the unmodified JSON received from the API

func (PlainTextSource) ToParam

ToParam converts this PlainTextSource to a PlainTextSourceParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with PlainTextSourceParam.Overrides()

func (*PlainTextSource) UnmarshalJSON

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

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) MarshalJSON

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

func (*PlainTextSourceParam) UnmarshalJSON

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

type RateLimitError

type RateLimitError = shared.RateLimitError

This is an alias to an internal type.

type RawContentBlockDeltaUnion

type RawContentBlockDeltaUnion 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        respjson.Field
		Type        respjson.Field
		PartialJSON respjson.Field
		Citation    respjson.Field
		Thinking    respjson.Field
		Signature   respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

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

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

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

func (RawContentBlockDeltaUnion) AsAny

func (u RawContentBlockDeltaUnion) AsAny() anyRawContentBlockDelta

Use the following switch statement to find the correct variant

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

func (RawContentBlockDeltaUnion) AsCitationsDelta

func (u RawContentBlockDeltaUnion) AsCitationsDelta() (v CitationsDelta)

func (RawContentBlockDeltaUnion) AsInputJSONDelta

func (u RawContentBlockDeltaUnion) AsInputJSONDelta() (v InputJSONDelta)

func (RawContentBlockDeltaUnion) AsSignatureDelta

func (u RawContentBlockDeltaUnion) AsSignatureDelta() (v SignatureDelta)

func (RawContentBlockDeltaUnion) AsTextDelta

func (u RawContentBlockDeltaUnion) AsTextDelta() (v TextDelta)

func (RawContentBlockDeltaUnion) AsThinkingDelta

func (u RawContentBlockDeltaUnion) AsThinkingDelta() (v ThinkingDelta)

func (RawContentBlockDeltaUnion) RawJSON

func (u RawContentBlockDeltaUnion) RawJSON() string

Returns the unmodified JSON received from the API

func (*RawContentBlockDeltaUnion) UnmarshalJSON

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

type RedactedThinkingBlock

type RedactedThinkingBlock struct {
	Data string                    `json:"data,required"`
	Type constant.RedactedThinking `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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) MarshalJSON

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

func (*RedactedThinkingBlockParam) UnmarshalJSON

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

type SearchResultBlockParam

type SearchResultBlockParam struct {
	Content []TextBlockParam `json:"content,omitzero,required"`
	Source  string           `json:"source,required"`
	Title   string           `json:"title,required"`
	// Create a cache control breakpoint at this content block.
	CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"`
	Citations    CitationsConfigParam       `json:"citations,omitzero"`
	// This field can be elided, and will marshal its zero value as "search_result".
	Type constant.SearchResult `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Content, Source, Title, Type are required.

func (SearchResultBlockParam) MarshalJSON

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

func (*SearchResultBlockParam) UnmarshalJSON

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

type ServerToolCaller

type ServerToolCaller struct {
	ToolID string                         `json:"tool_id,required"`
	Type   constant.CodeExecution20250825 `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ToolID      respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Tool invocation generated by a server-side tool.

func (ServerToolCaller) RawJSON

func (r ServerToolCaller) RawJSON() string

Returns the unmodified JSON received from the API

func (ServerToolCaller) ToParam

ToParam converts this ServerToolCaller to a ServerToolCallerParam.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with ServerToolCallerParam.Overrides()

func (*ServerToolCaller) UnmarshalJSON

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

type ServerToolCaller20260120

type ServerToolCaller20260120 struct {
	ToolID string                         `json:"tool_id,required"`
	Type   constant.CodeExecution20260120 `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ToolID      respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ServerToolCaller20260120) RawJSON

func (r ServerToolCaller20260120) RawJSON() string

Returns the unmodified JSON received from the API

func (ServerToolCaller20260120) ToParam

ToParam converts this ServerToolCaller20260120 to a ServerToolCaller20260120Param.

Warning: the fields of the param type will not be present. ToParam should only be used at the last possible moment before sending a request. Test for this with ServerToolCaller20260120Param.Overrides()

func (*ServerToolCaller20260120) UnmarshalJSON

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

type ServerToolCaller20260120Param

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

The properties ToolID, Type are required.

func (ServerToolCaller20260120Param) MarshalJSON

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

func (*ServerToolCaller20260120Param) UnmarshalJSON

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

type ServerToolCallerParam

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

Tool invocation generated by a server-side tool.

The properties ToolID, Type are required.

func (ServerToolCallerParam) MarshalJSON

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

func (*ServerToolCallerParam) UnmarshalJSON

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

type ServerToolUsage

type ServerToolUsage struct {
	// The number of web fetch tool requests.
	WebFetchRequests int64 `json:"web_fetch_requests,required"`
	// The number of web search tool requests.
	WebSearchRequests int64 `json:"web_search_requests,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		WebFetchRequests  respjson.Field
		WebSearchRequests respjson.Field
		ExtraFields       map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ServerToolUsage) RawJSON

func (r ServerToolUsage) RawJSON() string

Returns the unmodified JSON received from the API

func (*ServerToolUsage) UnmarshalJSON

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

type ServerToolUseBlock

type ServerToolUseBlock struct {
	ID string `json:"id,required"`
	// Tool invocation directly from the model.
	Caller ServerToolUseBlockCallerUnion `json:"caller,required"`
	Input  any                           `json:"input,required"`
	// Any of "web_search", "web_fetch", "code_execution", "bash_code_execution",
	// "text_editor_code_execution", "tool_search_tool_regex", "tool_search_tool_bm25".
	Name ServerToolUseBlockName `json:"name,required"`
	Type constant.ServerToolUse `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Caller      respjson.Field
		Input       respjson.Field
		Name        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ServerToolUseBlock) RawJSON

func (r ServerToolUseBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (ServerToolUseBlock) ToParam

func (*ServerToolUseBlock) UnmarshalJSON

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

type ServerToolUseBlockCallerUnion

type ServerToolUseBlockCallerUnion struct {
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	Type   string `json:"type"`
	ToolID string `json:"tool_id"`
	JSON   struct {
		Type   respjson.Field
		ToolID respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

ServerToolUseBlockCallerUnion contains all possible properties and values from DirectCaller, ServerToolCaller, ServerToolCaller20260120.

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

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

func (ServerToolUseBlockCallerUnion) AsAny

func (u ServerToolUseBlockCallerUnion) AsAny() anyServerToolUseBlockCaller

Use the following switch statement to find the correct variant

switch variant := ServerToolUseBlockCallerUnion.AsAny().(type) {
case anthropic.DirectCaller:
case anthropic.ServerToolCaller:
case anthropic.ServerToolCaller20260120:
default:
  fmt.Errorf("no variant present")
}

func (ServerToolUseBlockCallerUnion) AsCodeExecution20250825

func (u ServerToolUseBlockCallerUnion) AsCodeExecution20250825() (v ServerToolCaller)

func (ServerToolUseBlockCallerUnion) AsCodeExecution20260120

func (u ServerToolUseBlockCallerUnion) AsCodeExecution20260120() (v ServerToolCaller20260120)

func (ServerToolUseBlockCallerUnion) AsDirect

func (ServerToolUseBlockCallerUnion) RawJSON

Returns the unmodified JSON received from the API

func (*ServerToolUseBlockCallerUnion) UnmarshalJSON

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

type ServerToolUseBlockName

type ServerToolUseBlockName string
const (
	ServerToolUseBlockNameWebSearch               ServerToolUseBlockName = "web_search"
	ServerToolUseBlockNameWebFetch                ServerToolUseBlockName = "web_fetch"
	ServerToolUseBlockNameCodeExecution           ServerToolUseBlockName = "code_execution"
	ServerToolUseBlockNameBashCodeExecution       ServerToolUseBlockName = "bash_code_execution"
	ServerToolUseBlockNameTextEditorCodeExecution ServerToolUseBlockName = "text_editor_code_execution"
	ServerToolUseBlockNameToolSearchToolRegex     ServerToolUseBlockName = "tool_search_tool_regex"
	ServerToolUseBlockNameToolSearchToolBm25      ServerToolUseBlockName = "tool_search_tool_bm25"
)

type ServerToolUseBlockParam

type ServerToolUseBlockParam struct {
	ID    string `json:"id,required"`
	Input any    `json:"input,omitzero,required"`
	// Create a cache control breakpoint at this content block.
	CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"`
	// Tool invocation directly from the model.
	Caller ServerToolUseBlockParamCallerUnion `json:"caller,omitzero"`
	// Any of "web_search", "web_fetch", "code_execution", "bash_code_execution",
	// "text_editor_code_execution", "tool_search_tool_regex", "tool_search_tool_bm25".
	Name ServerToolUseBlockParamName `json:"name,required"`
	// This field can be elided, and will marshal its zero value as "server_tool_use".
	Type constant.ServerToolUse `json:"type,required"`
	// contains filtered or unexported fields
}

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

func (ServerToolUseBlockParam) MarshalJSON

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

func (*ServerToolUseBlockParam) UnmarshalJSON

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

type ServerToolUseBlockParamCallerUnion

type ServerToolUseBlockParamCallerUnion struct {
	OfDirect                *DirectCallerParam             `json:",omitzero,inline"`
	OfCodeExecution20250825 *ServerToolCallerParam         `json:",omitzero,inline"`
	OfCodeExecution20260120 *ServerToolCaller20260120Param `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 (ServerToolUseBlockParamCallerUnion) GetToolID

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

func (ServerToolUseBlockParamCallerUnion) GetType

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

func (ServerToolUseBlockParamCallerUnion) MarshalJSON

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

func (*ServerToolUseBlockParamCallerUnion) UnmarshalJSON

func (u *ServerToolUseBlockParamCallerUnion) UnmarshalJSON(data []byte) error

type ServerToolUseBlockParamName

type ServerToolUseBlockParamName string
const (
	ServerToolUseBlockParamNameWebSearch               ServerToolUseBlockParamName = "web_search"
	ServerToolUseBlockParamNameWebFetch                ServerToolUseBlockParamName = "web_fetch"
	ServerToolUseBlockParamNameCodeExecution           ServerToolUseBlockParamName = "code_execution"
	ServerToolUseBlockParamNameBashCodeExecution       ServerToolUseBlockParamName = "bash_code_execution"
	ServerToolUseBlockParamNameTextEditorCodeExecution ServerToolUseBlockParamName = "text_editor_code_execution"
	ServerToolUseBlockParamNameToolSearchToolRegex     ServerToolUseBlockParamName = "tool_search_tool_regex"
	ServerToolUseBlockParamNameToolSearchToolBm25      ServerToolUseBlockParamName = "tool_search_tool_bm25"
)

type SignatureDelta

type SignatureDelta struct {
	Signature string                  `json:"signature,required"`
	Type      constant.SignatureDelta `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Signature   respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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 StopReason

type StopReason string
const (
	StopReasonEndTurn      StopReason = "end_turn"
	StopReasonMaxTokens    StopReason = "max_tokens"
	StopReasonStopSequence StopReason = "stop_sequence"
	StopReasonToolUse      StopReason = "tool_use"
	StopReasonPauseTurn    StopReason = "pause_turn"
	StopReasonRefusal      StopReason = "refusal"
)

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"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Citations   respjson.Field
		Text        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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"`
	// Create a cache control breakpoint at this content block.
	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) MarshalJSON

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

func (*TextBlockParam) UnmarshalJSON

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

type TextCitationParamUnion

type TextCitationParamUnion struct {
	OfCharLocation            *CitationCharLocationParam            `json:",omitzero,inline"`
	OfPageLocation            *CitationPageLocationParam            `json:",omitzero,inline"`
	OfContentBlockLocation    *CitationContentBlockLocationParam    `json:",omitzero,inline"`
	OfWebSearchResultLocation *CitationWebSearchResultLocationParam `json:",omitzero,inline"`
	OfSearchResultLocation    *CitationSearchResultLocationParam    `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) GetEncryptedIndex

func (u TextCitationParamUnion) GetEncryptedIndex() *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) GetSearchResultIndex

func (u TextCitationParamUnion) GetSearchResultIndex() *int64

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

func (TextCitationParamUnion) GetSource

func (u TextCitationParamUnion) GetSource() *string

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) GetTitle

func (u TextCitationParamUnion) GetTitle() *string

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) GetURL

func (u TextCitationParamUnion) GetURL() *string

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

func (TextCitationParamUnion) MarshalJSON

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

func (*TextCitationParamUnion) UnmarshalJSON

func (u *TextCitationParamUnion) UnmarshalJSON(data []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"`
	FileID       string `json:"file_id"`
	// This field is from variant [CitationCharLocation].
	StartCharIndex int64 `json:"start_char_index"`
	// Any of "char_location", "page_location", "content_block_location",
	// "web_search_result_location", "search_result_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"`
	EndBlockIndex   int64 `json:"end_block_index"`
	StartBlockIndex int64 `json:"start_block_index"`
	// This field is from variant [CitationsWebSearchResultLocation].
	EncryptedIndex string `json:"encrypted_index"`
	Title          string `json:"title"`
	// This field is from variant [CitationsWebSearchResultLocation].
	URL string `json:"url"`
	// This field is from variant [CitationsSearchResultLocation].
	SearchResultIndex int64 `json:"search_result_index"`
	// This field is from variant [CitationsSearchResultLocation].
	Source string `json:"source"`
	JSON   struct {
		CitedText         respjson.Field
		DocumentIndex     respjson.Field
		DocumentTitle     respjson.Field
		EndCharIndex      respjson.Field
		FileID            respjson.Field
		StartCharIndex    respjson.Field
		Type              respjson.Field
		EndPageNumber     respjson.Field
		StartPageNumber   respjson.Field
		EndBlockIndex     respjson.Field
		StartBlockIndex   respjson.Field
		EncryptedIndex    respjson.Field
		Title             respjson.Field
		URL               respjson.Field
		SearchResultIndex respjson.Field
		Source            respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

TextCitationUnion contains all possible properties and values from CitationCharLocation, CitationPageLocation, CitationContentBlockLocation, CitationsWebSearchResultLocation, CitationsSearchResultLocation.

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() anyTextCitation

Use the following switch statement to find the correct variant

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

func (TextCitationUnion) AsCharLocation

func (u TextCitationUnion) AsCharLocation() (v CitationCharLocation)

func (TextCitationUnion) AsContentBlockLocation

func (u TextCitationUnion) AsContentBlockLocation() (v CitationContentBlockLocation)

func (TextCitationUnion) AsPageLocation

func (u TextCitationUnion) AsPageLocation() (v CitationPageLocation)

func (TextCitationUnion) AsSearchResultLocation

func (u TextCitationUnion) AsSearchResultLocation() (v CitationsSearchResultLocation)

func (TextCitationUnion) AsWebSearchResultLocation

func (u TextCitationUnion) AsWebSearchResultLocation() (v CitationsWebSearchResultLocation)

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"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Text        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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 TextEditorCodeExecutionCreateResultBlock

type TextEditorCodeExecutionCreateResultBlock struct {
	IsFileUpdate bool                                         `json:"is_file_update,required"`
	Type         constant.TextEditorCodeExecutionCreateResult `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		IsFileUpdate respjson.Field
		Type         respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TextEditorCodeExecutionCreateResultBlock) RawJSON

Returns the unmodified JSON received from the API

func (*TextEditorCodeExecutionCreateResultBlock) UnmarshalJSON

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

type TextEditorCodeExecutionCreateResultBlockParam

type TextEditorCodeExecutionCreateResultBlockParam struct {
	IsFileUpdate bool `json:"is_file_update,required"`
	// This field can be elided, and will marshal its zero value as
	// "text_editor_code_execution_create_result".
	Type constant.TextEditorCodeExecutionCreateResult `json:"type,required"`
	// contains filtered or unexported fields
}

The properties IsFileUpdate, Type are required.

func (TextEditorCodeExecutionCreateResultBlockParam) MarshalJSON

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

func (*TextEditorCodeExecutionCreateResultBlockParam) UnmarshalJSON

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

type TextEditorCodeExecutionStrReplaceResultBlock

type TextEditorCodeExecutionStrReplaceResultBlock struct {
	Lines    []string                                         `json:"lines,required"`
	NewLines int64                                            `json:"new_lines,required"`
	NewStart int64                                            `json:"new_start,required"`
	OldLines int64                                            `json:"old_lines,required"`
	OldStart int64                                            `json:"old_start,required"`
	Type     constant.TextEditorCodeExecutionStrReplaceResult `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Lines       respjson.Field
		NewLines    respjson.Field
		NewStart    respjson.Field
		OldLines    respjson.Field
		OldStart    respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TextEditorCodeExecutionStrReplaceResultBlock) RawJSON

Returns the unmodified JSON received from the API

func (*TextEditorCodeExecutionStrReplaceResultBlock) UnmarshalJSON

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

type TextEditorCodeExecutionStrReplaceResultBlockParam

type TextEditorCodeExecutionStrReplaceResultBlockParam struct {
	NewLines param.Opt[int64] `json:"new_lines,omitzero"`
	NewStart param.Opt[int64] `json:"new_start,omitzero"`
	OldLines param.Opt[int64] `json:"old_lines,omitzero"`
	OldStart param.Opt[int64] `json:"old_start,omitzero"`
	Lines    []string         `json:"lines,omitzero"`
	// This field can be elided, and will marshal its zero value as
	// "text_editor_code_execution_str_replace_result".
	Type constant.TextEditorCodeExecutionStrReplaceResult `json:"type,required"`
	// contains filtered or unexported fields
}

The property Type is required.

func (TextEditorCodeExecutionStrReplaceResultBlockParam) MarshalJSON

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

func (*TextEditorCodeExecutionStrReplaceResultBlockParam) UnmarshalJSON

type TextEditorCodeExecutionToolResultBlock

type TextEditorCodeExecutionToolResultBlock struct {
	Content   TextEditorCodeExecutionToolResultBlockContentUnion `json:"content,required"`
	ToolUseID string                                             `json:"tool_use_id,required"`
	Type      constant.TextEditorCodeExecutionToolResult         `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Content     respjson.Field
		ToolUseID   respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TextEditorCodeExecutionToolResultBlock) RawJSON

Returns the unmodified JSON received from the API

func (TextEditorCodeExecutionToolResultBlock) ToParam

func (*TextEditorCodeExecutionToolResultBlock) UnmarshalJSON

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

type TextEditorCodeExecutionToolResultBlockContentUnion

type TextEditorCodeExecutionToolResultBlockContentUnion struct {
	// This field is from variant [TextEditorCodeExecutionToolResultError].
	ErrorCode TextEditorCodeExecutionToolResultErrorCode `json:"error_code"`
	// This field is from variant [TextEditorCodeExecutionToolResultError].
	ErrorMessage string `json:"error_message"`
	Type         string `json:"type"`
	// This field is from variant [TextEditorCodeExecutionViewResultBlock].
	Content string `json:"content"`
	// This field is from variant [TextEditorCodeExecutionViewResultBlock].
	FileType TextEditorCodeExecutionViewResultBlockFileType `json:"file_type"`
	// This field is from variant [TextEditorCodeExecutionViewResultBlock].
	NumLines int64 `json:"num_lines"`
	// This field is from variant [TextEditorCodeExecutionViewResultBlock].
	StartLine int64 `json:"start_line"`
	// This field is from variant [TextEditorCodeExecutionViewResultBlock].
	TotalLines int64 `json:"total_lines"`
	// This field is from variant [TextEditorCodeExecutionCreateResultBlock].
	IsFileUpdate bool `json:"is_file_update"`
	// This field is from variant [TextEditorCodeExecutionStrReplaceResultBlock].
	Lines []string `json:"lines"`
	// This field is from variant [TextEditorCodeExecutionStrReplaceResultBlock].
	NewLines int64 `json:"new_lines"`
	// This field is from variant [TextEditorCodeExecutionStrReplaceResultBlock].
	NewStart int64 `json:"new_start"`
	// This field is from variant [TextEditorCodeExecutionStrReplaceResultBlock].
	OldLines int64 `json:"old_lines"`
	// This field is from variant [TextEditorCodeExecutionStrReplaceResultBlock].
	OldStart int64 `json:"old_start"`
	JSON     struct {
		ErrorCode    respjson.Field
		ErrorMessage respjson.Field
		Type         respjson.Field
		Content      respjson.Field
		FileType     respjson.Field
		NumLines     respjson.Field
		StartLine    respjson.Field
		TotalLines   respjson.Field
		IsFileUpdate respjson.Field
		Lines        respjson.Field
		NewLines     respjson.Field
		NewStart     respjson.Field
		OldLines     respjson.Field
		OldStart     respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

TextEditorCodeExecutionToolResultBlockContentUnion contains all possible properties and values from TextEditorCodeExecutionToolResultError, TextEditorCodeExecutionViewResultBlock, TextEditorCodeExecutionCreateResultBlock, TextEditorCodeExecutionStrReplaceResultBlock.

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

func (TextEditorCodeExecutionToolResultBlockContentUnion) AsResponseTextEditorCodeExecutionCreateResultBlock

func (u TextEditorCodeExecutionToolResultBlockContentUnion) AsResponseTextEditorCodeExecutionCreateResultBlock() (v TextEditorCodeExecutionCreateResultBlock)

func (TextEditorCodeExecutionToolResultBlockContentUnion) AsResponseTextEditorCodeExecutionStrReplaceResultBlock

func (u TextEditorCodeExecutionToolResultBlockContentUnion) AsResponseTextEditorCodeExecutionStrReplaceResultBlock() (v TextEditorCodeExecutionStrReplaceResultBlock)

func (TextEditorCodeExecutionToolResultBlockContentUnion) AsResponseTextEditorCodeExecutionToolResultError

func (u TextEditorCodeExecutionToolResultBlockContentUnion) AsResponseTextEditorCodeExecutionToolResultError() (v TextEditorCodeExecutionToolResultError)

func (TextEditorCodeExecutionToolResultBlockContentUnion) AsResponseTextEditorCodeExecutionViewResultBlock

func (u TextEditorCodeExecutionToolResultBlockContentUnion) AsResponseTextEditorCodeExecutionViewResultBlock() (v TextEditorCodeExecutionViewResultBlock)

func (TextEditorCodeExecutionToolResultBlockContentUnion) RawJSON

Returns the unmodified JSON received from the API

func (*TextEditorCodeExecutionToolResultBlockContentUnion) UnmarshalJSON

type TextEditorCodeExecutionToolResultBlockParam

type TextEditorCodeExecutionToolResultBlockParam struct {
	Content   TextEditorCodeExecutionToolResultBlockParamContentUnion `json:"content,omitzero,required"`
	ToolUseID string                                                  `json:"tool_use_id,required"`
	// Create a cache control breakpoint at this content block.
	CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"`
	// This field can be elided, and will marshal its zero value as
	// "text_editor_code_execution_tool_result".
	Type constant.TextEditorCodeExecutionToolResult `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Content, ToolUseID, Type are required.

func (TextEditorCodeExecutionToolResultBlockParam) MarshalJSON

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

func (*TextEditorCodeExecutionToolResultBlockParam) UnmarshalJSON

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

type TextEditorCodeExecutionToolResultBlockParamContentUnion

type TextEditorCodeExecutionToolResultBlockParamContentUnion struct {
	OfRequestTextEditorCodeExecutionToolResultError       *TextEditorCodeExecutionToolResultErrorParam       `json:",omitzero,inline"`
	OfRequestTextEditorCodeExecutionViewResultBlock       *TextEditorCodeExecutionViewResultBlockParam       `json:",omitzero,inline"`
	OfRequestTextEditorCodeExecutionCreateResultBlock     *TextEditorCodeExecutionCreateResultBlockParam     `json:",omitzero,inline"`
	OfRequestTextEditorCodeExecutionStrReplaceResultBlock *TextEditorCodeExecutionStrReplaceResultBlockParam `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 (TextEditorCodeExecutionToolResultBlockParamContentUnion) GetContent

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

func (TextEditorCodeExecutionToolResultBlockParamContentUnion) GetErrorCode

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

func (TextEditorCodeExecutionToolResultBlockParamContentUnion) GetErrorMessage

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

func (TextEditorCodeExecutionToolResultBlockParamContentUnion) GetFileType

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

func (TextEditorCodeExecutionToolResultBlockParamContentUnion) GetIsFileUpdate

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

func (TextEditorCodeExecutionToolResultBlockParamContentUnion) GetLines

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

func (TextEditorCodeExecutionToolResultBlockParamContentUnion) GetNewLines

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

func (TextEditorCodeExecutionToolResultBlockParamContentUnion) GetNewStart

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

func (TextEditorCodeExecutionToolResultBlockParamContentUnion) GetNumLines

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

func (TextEditorCodeExecutionToolResultBlockParamContentUnion) GetOldLines

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

func (TextEditorCodeExecutionToolResultBlockParamContentUnion) GetOldStart

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

func (TextEditorCodeExecutionToolResultBlockParamContentUnion) GetStartLine

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

func (TextEditorCodeExecutionToolResultBlockParamContentUnion) GetTotalLines

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

func (TextEditorCodeExecutionToolResultBlockParamContentUnion) GetType

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

func (TextEditorCodeExecutionToolResultBlockParamContentUnion) MarshalJSON

func (*TextEditorCodeExecutionToolResultBlockParamContentUnion) UnmarshalJSON

type TextEditorCodeExecutionToolResultError

type TextEditorCodeExecutionToolResultError struct {
	// Any of "invalid_tool_input", "unavailable", "too_many_requests",
	// "execution_time_exceeded", "file_not_found".
	ErrorCode    TextEditorCodeExecutionToolResultErrorCode      `json:"error_code,required"`
	ErrorMessage string                                          `json:"error_message,required"`
	Type         constant.TextEditorCodeExecutionToolResultError `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ErrorCode    respjson.Field
		ErrorMessage respjson.Field
		Type         respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TextEditorCodeExecutionToolResultError) RawJSON

Returns the unmodified JSON received from the API

func (*TextEditorCodeExecutionToolResultError) UnmarshalJSON

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

type TextEditorCodeExecutionToolResultErrorCode

type TextEditorCodeExecutionToolResultErrorCode string
const (
	TextEditorCodeExecutionToolResultErrorCodeInvalidToolInput      TextEditorCodeExecutionToolResultErrorCode = "invalid_tool_input"
	TextEditorCodeExecutionToolResultErrorCodeUnavailable           TextEditorCodeExecutionToolResultErrorCode = "unavailable"
	TextEditorCodeExecutionToolResultErrorCodeTooManyRequests       TextEditorCodeExecutionToolResultErrorCode = "too_many_requests"
	TextEditorCodeExecutionToolResultErrorCodeExecutionTimeExceeded TextEditorCodeExecutionToolResultErrorCode = "execution_time_exceeded"
	TextEditorCodeExecutionToolResultErrorCodeFileNotFound          TextEditorCodeExecutionToolResultErrorCode = "file_not_found"
)

type TextEditorCodeExecutionToolResultErrorParam

type TextEditorCodeExecutionToolResultErrorParam struct {
	// Any of "invalid_tool_input", "unavailable", "too_many_requests",
	// "execution_time_exceeded", "file_not_found".
	ErrorCode    TextEditorCodeExecutionToolResultErrorCode `json:"error_code,omitzero,required"`
	ErrorMessage param.Opt[string]                          `json:"error_message,omitzero"`
	// This field can be elided, and will marshal its zero value as
	// "text_editor_code_execution_tool_result_error".
	Type constant.TextEditorCodeExecutionToolResultError `json:"type,required"`
	// contains filtered or unexported fields
}

The properties ErrorCode, Type are required.

func (TextEditorCodeExecutionToolResultErrorParam) MarshalJSON

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

func (*TextEditorCodeExecutionToolResultErrorParam) UnmarshalJSON

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

type TextEditorCodeExecutionViewResultBlock

type TextEditorCodeExecutionViewResultBlock struct {
	Content string `json:"content,required"`
	// Any of "text", "image", "pdf".
	FileType   TextEditorCodeExecutionViewResultBlockFileType `json:"file_type,required"`
	NumLines   int64                                          `json:"num_lines,required"`
	StartLine  int64                                          `json:"start_line,required"`
	TotalLines int64                                          `json:"total_lines,required"`
	Type       constant.TextEditorCodeExecutionViewResult     `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Content     respjson.Field
		FileType    respjson.Field
		NumLines    respjson.Field
		StartLine   respjson.Field
		TotalLines  respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TextEditorCodeExecutionViewResultBlock) RawJSON

Returns the unmodified JSON received from the API

func (*TextEditorCodeExecutionViewResultBlock) UnmarshalJSON

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

type TextEditorCodeExecutionViewResultBlockFileType

type TextEditorCodeExecutionViewResultBlockFileType string
const (
	TextEditorCodeExecutionViewResultBlockFileTypeText  TextEditorCodeExecutionViewResultBlockFileType = "text"
	TextEditorCodeExecutionViewResultBlockFileTypeImage TextEditorCodeExecutionViewResultBlockFileType = "image"
	TextEditorCodeExecutionViewResultBlockFileTypePDF   TextEditorCodeExecutionViewResultBlockFileType = "pdf"
)

type TextEditorCodeExecutionViewResultBlockParam

type TextEditorCodeExecutionViewResultBlockParam struct {
	Content string `json:"content,required"`
	// Any of "text", "image", "pdf".
	FileType   TextEditorCodeExecutionViewResultBlockParamFileType `json:"file_type,omitzero,required"`
	NumLines   param.Opt[int64]                                    `json:"num_lines,omitzero"`
	StartLine  param.Opt[int64]                                    `json:"start_line,omitzero"`
	TotalLines param.Opt[int64]                                    `json:"total_lines,omitzero"`
	// This field can be elided, and will marshal its zero value as
	// "text_editor_code_execution_view_result".
	Type constant.TextEditorCodeExecutionViewResult `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Content, FileType, Type are required.

func (TextEditorCodeExecutionViewResultBlockParam) MarshalJSON

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

func (*TextEditorCodeExecutionViewResultBlockParam) UnmarshalJSON

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

type TextEditorCodeExecutionViewResultBlockParamFileType

type TextEditorCodeExecutionViewResultBlockParamFileType string
const (
	TextEditorCodeExecutionViewResultBlockParamFileTypeText  TextEditorCodeExecutionViewResultBlockParamFileType = "text"
	TextEditorCodeExecutionViewResultBlockParamFileTypeImage TextEditorCodeExecutionViewResultBlockParamFileType = "image"
	TextEditorCodeExecutionViewResultBlockParamFileTypePDF   TextEditorCodeExecutionViewResultBlockParamFileType = "pdf"
)

type ThinkingBlock

type ThinkingBlock struct {
	Signature string            `json:"signature,required"`
	Thinking  string            `json:"thinking,required"`
	Type      constant.Thinking `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Signature   respjson.Field
		Thinking    respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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) MarshalJSON

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

func (*ThinkingBlockParam) UnmarshalJSON

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

type ThinkingConfigAdaptiveParam

type ThinkingConfigAdaptiveParam struct {
	Type constant.Adaptive `json:"type,required"`
	// contains filtered or unexported fields
}

This struct has a constant value, construct it with NewThinkingConfigAdaptiveParam.

func NewThinkingConfigAdaptiveParam

func NewThinkingConfigAdaptiveParam() ThinkingConfigAdaptiveParam

func (ThinkingConfigAdaptiveParam) MarshalJSON

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

func (*ThinkingConfigAdaptiveParam) UnmarshalJSON

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

type ThinkingConfigDisabledParam

type ThinkingConfigDisabledParam struct {
	Type constant.Disabled `json:"type,required"`
	// contains filtered or unexported fields
}

This struct has a constant value, construct it with NewThinkingConfigDisabledParam.

func NewThinkingConfigDisabledParam

func NewThinkingConfigDisabledParam() ThinkingConfigDisabledParam

func (ThinkingConfigDisabledParam) MarshalJSON

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

func (*ThinkingConfigDisabledParam) UnmarshalJSON

func (r *ThinkingConfigDisabledParam) UnmarshalJSON(data []byte) 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.claude.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) MarshalJSON

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

func (*ThinkingConfigEnabledParam) UnmarshalJSON

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

type ThinkingConfigParamUnion

type ThinkingConfigParamUnion struct {
	OfEnabled  *ThinkingConfigEnabledParam  `json:",omitzero,inline"`
	OfDisabled *ThinkingConfigDisabledParam `json:",omitzero,inline"`
	OfAdaptive *ThinkingConfigAdaptiveParam `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 ThinkingConfigParamOfEnabled

func ThinkingConfigParamOfEnabled(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) MarshalJSON

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

func (*ThinkingConfigParamUnion) UnmarshalJSON

func (u *ThinkingConfigParamUnion) UnmarshalJSON(data []byte) error

type ThinkingDelta

type ThinkingDelta struct {
	Thinking string                 `json:"thinking,required"`
	Type     constant.ThinkingDelta `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Thinking    respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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 {
	// If true, tool will not be included in initial system prompt. Only loaded when
	// returned via tool_reference from tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// When true, guarantees schema validation on tool names and inputs
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// Create a cache control breakpoint at this content block.
	CacheControl  CacheControlEphemeralParam `json:"cache_control,omitzero"`
	InputExamples []map[string]any           `json:"input_examples,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) MarshalJSON

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

func (*ToolBash20250124Param) UnmarshalJSON

func (r *ToolBash20250124Param) UnmarshalJSON(data []byte) 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) MarshalJSON

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

func (*ToolChoiceAnyParam) UnmarshalJSON

func (r *ToolChoiceAnyParam) UnmarshalJSON(data []byte) 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) MarshalJSON

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

func (*ToolChoiceAutoParam) UnmarshalJSON

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

type ToolChoiceNoneParam

type ToolChoiceNoneParam struct {
	Type constant.None `json:"type,required"`
	// contains filtered or unexported fields
}

The model will not be allowed to use tools.

This struct has a constant value, construct it with NewToolChoiceNoneParam.

func NewToolChoiceNoneParam

func NewToolChoiceNoneParam() ToolChoiceNoneParam

func (ToolChoiceNoneParam) MarshalJSON

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

func (*ToolChoiceNoneParam) UnmarshalJSON

func (r *ToolChoiceNoneParam) UnmarshalJSON(data []byte) 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) MarshalJSON

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

func (*ToolChoiceToolParam) UnmarshalJSON

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

type ToolChoiceUnionParam

type ToolChoiceUnionParam struct {
	OfAuto *ToolChoiceAutoParam `json:",omitzero,inline"`
	OfAny  *ToolChoiceAnyParam  `json:",omitzero,inline"`
	OfTool *ToolChoiceToolParam `json:",omitzero,inline"`
	OfNone *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 ToolChoiceParamOfTool

func ToolChoiceParamOfTool(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) MarshalJSON

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

func (*ToolChoiceUnionParam) UnmarshalJSON

func (u *ToolChoiceUnionParam) UnmarshalJSON(data []byte) error

type ToolInputSchemaParam

type ToolInputSchemaParam struct {
	Properties any      `json:"properties,omitzero"`
	Required   []string `json:"required,omitzero"`
	// This field can be elided, and will marshal its zero value as "object".
	Type        constant.Object `json:"type,required"`
	ExtraFields map[string]any  `json:"-"`
	// 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) MarshalJSON

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

func (*ToolInputSchemaParam) UnmarshalJSON

func (r *ToolInputSchemaParam) UnmarshalJSON(data []byte) 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"`
	// Enable eager input streaming for this tool. When true, tool input parameters
	// will be streamed incrementally as they are generated, and types will be inferred
	// on-the-fly rather than buffering the full JSON output. When false, streaming is
	// disabled for this tool even if the fine-grained-tool-streaming beta is active.
	// When null (default), uses the default behavior based on beta headers.
	EagerInputStreaming param.Opt[bool] `json:"eager_input_streaming,omitzero"`
	// If true, tool will not be included in initial system prompt. Only loaded when
	// returned via tool_reference from tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// 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"`
	// When true, guarantees schema validation on tool names and inputs
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// Any of "custom".
	Type ToolType `json:"type,omitzero"`
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// Create a cache control breakpoint at this content block.
	CacheControl  CacheControlEphemeralParam `json:"cache_control,omitzero"`
	InputExamples []map[string]any           `json:"input_examples,omitzero"`
	// contains filtered or unexported fields
}

The properties InputSchema, Name are required.

func (ToolParam) MarshalJSON

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

func (*ToolParam) UnmarshalJSON

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

type ToolReferenceBlock

type ToolReferenceBlock struct {
	ToolName string                 `json:"tool_name,required"`
	Type     constant.ToolReference `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ToolName    respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ToolReferenceBlock) RawJSON

func (r ToolReferenceBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (ToolReferenceBlock) ToParam

func (*ToolReferenceBlock) UnmarshalJSON

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

type ToolReferenceBlockParam

type ToolReferenceBlockParam struct {
	ToolName string `json:"tool_name,required"`
	// Create a cache control breakpoint at this content block.
	CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"`
	// This field can be elided, and will marshal its zero value as "tool_reference".
	Type constant.ToolReference `json:"type,required"`
	// contains filtered or unexported fields
}

Tool reference block that can be included in tool_result content.

The properties ToolName, Type are required.

func (ToolReferenceBlockParam) MarshalJSON

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

func (*ToolReferenceBlockParam) UnmarshalJSON

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

type ToolResultBlockParam

type ToolResultBlockParam struct {
	ToolUseID string          `json:"tool_use_id,required"`
	IsError   param.Opt[bool] `json:"is_error,omitzero"`
	// Create a cache control breakpoint at this content block.
	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) MarshalJSON

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

func (*ToolResultBlockParam) UnmarshalJSON

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

type ToolResultBlockParamContentUnion

type ToolResultBlockParamContentUnion struct {
	OfText          *TextBlockParam          `json:",omitzero,inline"`
	OfImage         *ImageBlockParam         `json:",omitzero,inline"`
	OfSearchResult  *SearchResultBlockParam  `json:",omitzero,inline"`
	OfDocument      *DocumentBlockParam      `json:",omitzero,inline"`
	OfToolReference *ToolReferenceBlockParam `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

func (u ToolResultBlockParamContentUnion) GetCitations() (res toolResultBlockParamContentUnionCitations)

Returns a subunion which exports methods to access subproperties

Or use AsAny() to get the underlying value

func (ToolResultBlockParamContentUnion) GetContent

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

func (ToolResultBlockParamContentUnion) GetContext

func (u ToolResultBlockParamContentUnion) GetContext() *string

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

func (ToolResultBlockParamContentUnion) GetSource

func (u ToolResultBlockParamContentUnion) GetSource() (res toolResultBlockParamContentUnionSource)

Returns a subunion which exports methods to access subproperties

Or use AsAny() to get the underlying value

func (ToolResultBlockParamContentUnion) GetText

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

func (ToolResultBlockParamContentUnion) GetTitle

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

func (ToolResultBlockParamContentUnion) GetToolName

func (u ToolResultBlockParamContentUnion) GetToolName() *string

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) MarshalJSON

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

func (*ToolResultBlockParamContentUnion) UnmarshalJSON

func (u *ToolResultBlockParamContentUnion) UnmarshalJSON(data []byte) error

type ToolSearchToolBm25_20251119Param

type ToolSearchToolBm25_20251119Param struct {
	// Any of "tool_search_tool_bm25_20251119", "tool_search_tool_bm25".
	Type ToolSearchToolBm25_20251119Type `json:"type,omitzero,required"`
	// If true, tool will not be included in initial system prompt. Only loaded when
	// returned via tool_reference from tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// When true, guarantees schema validation on tool names and inputs
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// Create a cache control breakpoint at this content block.
	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
	// "tool_search_tool_bm25".
	Name constant.ToolSearchToolBm25 `json:"name,required"`
	// contains filtered or unexported fields
}

The properties Name, Type are required.

func (ToolSearchToolBm25_20251119Param) MarshalJSON

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

func (*ToolSearchToolBm25_20251119Param) UnmarshalJSON

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

type ToolSearchToolBm25_20251119Type

type ToolSearchToolBm25_20251119Type string
const (
	ToolSearchToolBm25_20251119TypeToolSearchToolBm25_20251119 ToolSearchToolBm25_20251119Type = "tool_search_tool_bm25_20251119"
	ToolSearchToolBm25_20251119TypeToolSearchToolBm25          ToolSearchToolBm25_20251119Type = "tool_search_tool_bm25"
)

type ToolSearchToolRegex20251119Param

type ToolSearchToolRegex20251119Param struct {
	// Any of "tool_search_tool_regex_20251119", "tool_search_tool_regex".
	Type ToolSearchToolRegex20251119Type `json:"type,omitzero,required"`
	// If true, tool will not be included in initial system prompt. Only loaded when
	// returned via tool_reference from tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// When true, guarantees schema validation on tool names and inputs
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// Create a cache control breakpoint at this content block.
	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
	// "tool_search_tool_regex".
	Name constant.ToolSearchToolRegex `json:"name,required"`
	// contains filtered or unexported fields
}

The properties Name, Type are required.

func (ToolSearchToolRegex20251119Param) MarshalJSON

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

func (*ToolSearchToolRegex20251119Param) UnmarshalJSON

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

type ToolSearchToolRegex20251119Type

type ToolSearchToolRegex20251119Type string
const (
	ToolSearchToolRegex20251119TypeToolSearchToolRegex20251119 ToolSearchToolRegex20251119Type = "tool_search_tool_regex_20251119"
	ToolSearchToolRegex20251119TypeToolSearchToolRegex         ToolSearchToolRegex20251119Type = "tool_search_tool_regex"
)

type ToolSearchToolResultBlock

type ToolSearchToolResultBlock struct {
	Content   ToolSearchToolResultBlockContentUnion `json:"content,required"`
	ToolUseID string                                `json:"tool_use_id,required"`
	Type      constant.ToolSearchToolResult         `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Content     respjson.Field
		ToolUseID   respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ToolSearchToolResultBlock) RawJSON

func (r ToolSearchToolResultBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (ToolSearchToolResultBlock) ToParam

func (*ToolSearchToolResultBlock) UnmarshalJSON

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

type ToolSearchToolResultBlockContentUnion

type ToolSearchToolResultBlockContentUnion struct {
	// This field is from variant [ToolSearchToolResultError].
	ErrorCode ToolSearchToolResultErrorCode `json:"error_code"`
	// This field is from variant [ToolSearchToolResultError].
	ErrorMessage string `json:"error_message"`
	Type         string `json:"type"`
	// This field is from variant [ToolSearchToolSearchResultBlock].
	ToolReferences []ToolReferenceBlock `json:"tool_references"`
	JSON           struct {
		ErrorCode      respjson.Field
		ErrorMessage   respjson.Field
		Type           respjson.Field
		ToolReferences respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

ToolSearchToolResultBlockContentUnion contains all possible properties and values from ToolSearchToolResultError, ToolSearchToolSearchResultBlock.

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

func (ToolSearchToolResultBlockContentUnion) AsResponseToolSearchToolResultError

func (u ToolSearchToolResultBlockContentUnion) AsResponseToolSearchToolResultError() (v ToolSearchToolResultError)

func (ToolSearchToolResultBlockContentUnion) AsResponseToolSearchToolSearchResultBlock

func (u ToolSearchToolResultBlockContentUnion) AsResponseToolSearchToolSearchResultBlock() (v ToolSearchToolSearchResultBlock)

func (ToolSearchToolResultBlockContentUnion) RawJSON

Returns the unmodified JSON received from the API

func (*ToolSearchToolResultBlockContentUnion) UnmarshalJSON

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

type ToolSearchToolResultBlockParam

type ToolSearchToolResultBlockParam struct {
	Content   ToolSearchToolResultBlockParamContentUnion `json:"content,omitzero,required"`
	ToolUseID string                                     `json:"tool_use_id,required"`
	// Create a cache control breakpoint at this content block.
	CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"`
	// This field can be elided, and will marshal its zero value as
	// "tool_search_tool_result".
	Type constant.ToolSearchToolResult `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Content, ToolUseID, Type are required.

func (ToolSearchToolResultBlockParam) MarshalJSON

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

func (*ToolSearchToolResultBlockParam) UnmarshalJSON

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

type ToolSearchToolResultBlockParamContentUnion

type ToolSearchToolResultBlockParamContentUnion struct {
	OfRequestToolSearchToolResultError       *ToolSearchToolResultErrorParam       `json:",omitzero,inline"`
	OfRequestToolSearchToolSearchResultBlock *ToolSearchToolSearchResultBlockParam `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 (ToolSearchToolResultBlockParamContentUnion) GetErrorCode

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

func (ToolSearchToolResultBlockParamContentUnion) GetToolReferences

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

func (ToolSearchToolResultBlockParamContentUnion) GetType

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

func (ToolSearchToolResultBlockParamContentUnion) MarshalJSON

func (*ToolSearchToolResultBlockParamContentUnion) UnmarshalJSON

func (u *ToolSearchToolResultBlockParamContentUnion) UnmarshalJSON(data []byte) error

type ToolSearchToolResultError

type ToolSearchToolResultError struct {
	// Any of "invalid_tool_input", "unavailable", "too_many_requests",
	// "execution_time_exceeded".
	ErrorCode    ToolSearchToolResultErrorCode      `json:"error_code,required"`
	ErrorMessage string                             `json:"error_message,required"`
	Type         constant.ToolSearchToolResultError `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ErrorCode    respjson.Field
		ErrorMessage respjson.Field
		Type         respjson.Field
		ExtraFields  map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ToolSearchToolResultError) RawJSON

func (r ToolSearchToolResultError) RawJSON() string

Returns the unmodified JSON received from the API

func (*ToolSearchToolResultError) UnmarshalJSON

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

type ToolSearchToolResultErrorCode

type ToolSearchToolResultErrorCode string
const (
	ToolSearchToolResultErrorCodeInvalidToolInput      ToolSearchToolResultErrorCode = "invalid_tool_input"
	ToolSearchToolResultErrorCodeUnavailable           ToolSearchToolResultErrorCode = "unavailable"
	ToolSearchToolResultErrorCodeTooManyRequests       ToolSearchToolResultErrorCode = "too_many_requests"
	ToolSearchToolResultErrorCodeExecutionTimeExceeded ToolSearchToolResultErrorCode = "execution_time_exceeded"
)

type ToolSearchToolResultErrorParam

type ToolSearchToolResultErrorParam struct {
	// Any of "invalid_tool_input", "unavailable", "too_many_requests",
	// "execution_time_exceeded".
	ErrorCode ToolSearchToolResultErrorCode `json:"error_code,omitzero,required"`
	// This field can be elided, and will marshal its zero value as
	// "tool_search_tool_result_error".
	Type constant.ToolSearchToolResultError `json:"type,required"`
	// contains filtered or unexported fields
}

The properties ErrorCode, Type are required.

func (ToolSearchToolResultErrorParam) MarshalJSON

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

func (*ToolSearchToolResultErrorParam) UnmarshalJSON

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

type ToolSearchToolSearchResultBlock

type ToolSearchToolSearchResultBlock struct {
	ToolReferences []ToolReferenceBlock                `json:"tool_references,required"`
	Type           constant.ToolSearchToolSearchResult `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ToolReferences respjson.Field
		Type           respjson.Field
		ExtraFields    map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ToolSearchToolSearchResultBlock) RawJSON

Returns the unmodified JSON received from the API

func (*ToolSearchToolSearchResultBlock) UnmarshalJSON

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

type ToolSearchToolSearchResultBlockParam

type ToolSearchToolSearchResultBlockParam struct {
	ToolReferences []ToolReferenceBlockParam `json:"tool_references,omitzero,required"`
	// This field can be elided, and will marshal its zero value as
	// "tool_search_tool_search_result".
	Type constant.ToolSearchToolSearchResult `json:"type,required"`
	// contains filtered or unexported fields
}

The properties ToolReferences, Type are required.

func (ToolSearchToolSearchResultBlockParam) MarshalJSON

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

func (*ToolSearchToolSearchResultBlockParam) UnmarshalJSON

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

type ToolTextEditor20250124Param

type ToolTextEditor20250124Param struct {
	// If true, tool will not be included in initial system prompt. Only loaded when
	// returned via tool_reference from tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// When true, guarantees schema validation on tool names and inputs
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// Create a cache control breakpoint at this content block.
	CacheControl  CacheControlEphemeralParam `json:"cache_control,omitzero"`
	InputExamples []map[string]any           `json:"input_examples,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) MarshalJSON

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

func (*ToolTextEditor20250124Param) UnmarshalJSON

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

type ToolTextEditor20250429Param

type ToolTextEditor20250429Param struct {
	// If true, tool will not be included in initial system prompt. Only loaded when
	// returned via tool_reference from tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// When true, guarantees schema validation on tool names and inputs
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// Create a cache control breakpoint at this content block.
	CacheControl  CacheControlEphemeralParam `json:"cache_control,omitzero"`
	InputExamples []map[string]any           `json:"input_examples,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_based_edit_tool".
	Name constant.StrReplaceBasedEditTool `json:"name,required"`
	// This field can be elided, and will marshal its zero value as
	// "text_editor_20250429".
	Type constant.TextEditor20250429 `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Name, Type are required.

func (ToolTextEditor20250429Param) MarshalJSON

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

func (*ToolTextEditor20250429Param) UnmarshalJSON

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

type ToolTextEditor20250728Param

type ToolTextEditor20250728Param struct {
	// Maximum number of characters to display when viewing a file. If not specified,
	// defaults to displaying the full file.
	MaxCharacters param.Opt[int64] `json:"max_characters,omitzero"`
	// If true, tool will not be included in initial system prompt. Only loaded when
	// returned via tool_reference from tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// When true, guarantees schema validation on tool names and inputs
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// Create a cache control breakpoint at this content block.
	CacheControl  CacheControlEphemeralParam `json:"cache_control,omitzero"`
	InputExamples []map[string]any           `json:"input_examples,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_based_edit_tool".
	Name constant.StrReplaceBasedEditTool `json:"name,required"`
	// This field can be elided, and will marshal its zero value as
	// "text_editor_20250728".
	Type constant.TextEditor20250728 `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Name, Type are required.

func (ToolTextEditor20250728Param) MarshalJSON

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

func (*ToolTextEditor20250728Param) UnmarshalJSON

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

type ToolType

type ToolType string
const (
	ToolTypeCustom ToolType = "custom"
)

type ToolUnionParam

type ToolUnionParam struct {
	OfTool                        *ToolParam                        `json:",omitzero,inline"`
	OfBashTool20250124            *ToolBash20250124Param            `json:",omitzero,inline"`
	OfCodeExecutionTool20250522   *CodeExecutionTool20250522Param   `json:",omitzero,inline"`
	OfCodeExecutionTool20250825   *CodeExecutionTool20250825Param   `json:",omitzero,inline"`
	OfCodeExecutionTool20260120   *CodeExecutionTool20260120Param   `json:",omitzero,inline"`
	OfMemoryTool20250818          *MemoryTool20250818Param          `json:",omitzero,inline"`
	OfTextEditor20250124          *ToolTextEditor20250124Param      `json:",omitzero,inline"`
	OfTextEditor20250429          *ToolTextEditor20250429Param      `json:",omitzero,inline"`
	OfTextEditor20250728          *ToolTextEditor20250728Param      `json:",omitzero,inline"`
	OfWebSearchTool20250305       *WebSearchTool20250305Param       `json:",omitzero,inline"`
	OfWebFetchTool20250910        *WebFetchTool20250910Param        `json:",omitzero,inline"`
	OfWebSearchTool20260209       *WebSearchTool20260209Param       `json:",omitzero,inline"`
	OfWebFetchTool20260209        *WebFetchTool20260209Param        `json:",omitzero,inline"`
	OfToolSearchToolBm25_20251119 *ToolSearchToolBm25_20251119Param `json:",omitzero,inline"`
	OfToolSearchToolRegex20251119 *ToolSearchToolRegex20251119Param `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 ToolUnionParamOfToolSearchToolBm25_20251119

func ToolUnionParamOfToolSearchToolBm25_20251119(type_ ToolSearchToolBm25_20251119Type) ToolUnionParam

func ToolUnionParamOfToolSearchToolRegex20251119

func ToolUnionParamOfToolSearchToolRegex20251119(type_ ToolSearchToolRegex20251119Type) ToolUnionParam

func (ToolUnionParam) GetAllowedCallers

func (u ToolUnionParam) GetAllowedCallers() []string

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

func (ToolUnionParam) GetAllowedDomains

func (u ToolUnionParam) GetAllowedDomains() []string

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

func (ToolUnionParam) GetBlockedDomains

func (u ToolUnionParam) GetBlockedDomains() []string

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

func (ToolUnionParam) GetCacheControl

func (u ToolUnionParam) GetCacheControl() *CacheControlEphemeralParam

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

func (ToolUnionParam) GetCitations

func (u ToolUnionParam) GetCitations() *CitationsConfigParam

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

func (ToolUnionParam) GetDeferLoading

func (u ToolUnionParam) GetDeferLoading() *bool

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

func (ToolUnionParam) GetDescription

func (u ToolUnionParam) GetDescription() *string

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

func (ToolUnionParam) GetEagerInputStreaming

func (u ToolUnionParam) GetEagerInputStreaming() *bool

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

func (ToolUnionParam) GetInputExamples

func (u ToolUnionParam) GetInputExamples() []map[string]any

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

func (ToolUnionParam) GetInputSchema

func (u ToolUnionParam) GetInputSchema() *ToolInputSchemaParam

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

func (ToolUnionParam) GetMaxCharacters

func (u ToolUnionParam) GetMaxCharacters() *int64

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

func (ToolUnionParam) GetMaxContentTokens

func (u ToolUnionParam) GetMaxContentTokens() *int64

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

func (ToolUnionParam) GetMaxUses

func (u ToolUnionParam) GetMaxUses() *int64

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) GetStrict

func (u ToolUnionParam) GetStrict() *bool

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) GetUserLocation

func (u ToolUnionParam) GetUserLocation() *UserLocationParam

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

func (ToolUnionParam) MarshalJSON

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

func (*ToolUnionParam) UnmarshalJSON

func (u *ToolUnionParam) UnmarshalJSON(data []byte) error

type ToolUseBlock

type ToolUseBlock struct {
	ID string `json:"id,required"`
	// necessary custom code modification
	Input json.RawMessage  `json:"input,required"`
	Name  string           `json:"name,required"`
	Type  constant.ToolUse `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Caller      respjson.Field
		Input       respjson.Field
		Name        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.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 ToolUseBlockCallerUnion

type ToolUseBlockCallerUnion struct {
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	Type   string `json:"type"`
	ToolID string `json:"tool_id"`
	JSON   struct {
		Type   respjson.Field
		ToolID respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

ToolUseBlockCallerUnion contains all possible properties and values from DirectCaller, ServerToolCaller, ServerToolCaller20260120.

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

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

func (ToolUseBlockCallerUnion) AsAny

func (u ToolUseBlockCallerUnion) AsAny() anyToolUseBlockCaller

Use the following switch statement to find the correct variant

switch variant := ToolUseBlockCallerUnion.AsAny().(type) {
case anthropic.DirectCaller:
case anthropic.ServerToolCaller:
case anthropic.ServerToolCaller20260120:
default:
  fmt.Errorf("no variant present")
}

func (ToolUseBlockCallerUnion) AsCodeExecution20250825

func (u ToolUseBlockCallerUnion) AsCodeExecution20250825() (v ServerToolCaller)

func (ToolUseBlockCallerUnion) AsCodeExecution20260120

func (u ToolUseBlockCallerUnion) AsCodeExecution20260120() (v ServerToolCaller20260120)

func (ToolUseBlockCallerUnion) AsDirect

func (u ToolUseBlockCallerUnion) AsDirect() (v DirectCaller)

func (ToolUseBlockCallerUnion) RawJSON

func (u ToolUseBlockCallerUnion) RawJSON() string

Returns the unmodified JSON received from the API

func (*ToolUseBlockCallerUnion) UnmarshalJSON

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

type ToolUseBlockParam

type ToolUseBlockParam struct {
	ID    string `json:"id,required"`
	Input any    `json:"input,omitzero,required"`
	Name  string `json:"name,required"`
	// Create a cache control breakpoint at this content block.
	CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"`
	// Tool invocation directly from the model.
	Caller ToolUseBlockParamCallerUnion `json:"caller,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) MarshalJSON

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

func (*ToolUseBlockParam) UnmarshalJSON

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

type ToolUseBlockParamCallerUnion

type ToolUseBlockParamCallerUnion struct {
	OfDirect                *DirectCallerParam             `json:",omitzero,inline"`
	OfCodeExecution20250825 *ServerToolCallerParam         `json:",omitzero,inline"`
	OfCodeExecution20260120 *ServerToolCaller20260120Param `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 (ToolUseBlockParamCallerUnion) GetToolID

func (u ToolUseBlockParamCallerUnion) GetToolID() *string

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

func (ToolUseBlockParamCallerUnion) GetType

func (u ToolUseBlockParamCallerUnion) GetType() *string

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

func (ToolUseBlockParamCallerUnion) MarshalJSON

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

func (*ToolUseBlockParamCallerUnion) UnmarshalJSON

func (u *ToolUseBlockParamCallerUnion) UnmarshalJSON(data []byte) 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) MarshalJSON

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

func (*URLImageSourceParam) UnmarshalJSON

func (r *URLImageSourceParam) UnmarshalJSON(data []byte) 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) MarshalJSON

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

func (*URLPDFSourceParam) UnmarshalJSON

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

type Usage

type Usage struct {
	// Breakdown of cached tokens by TTL
	CacheCreation CacheCreation `json:"cache_creation,required"`
	// 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 geographic region where inference was performed for this request.
	InferenceGeo string `json:"inference_geo,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"`
	// The number of server tool requests.
	ServerToolUse ServerToolUsage `json:"server_tool_use,required"`
	// If the request used the priority, standard, or batch tier.
	//
	// Any of "standard", "priority", "batch".
	ServiceTier UsageServiceTier `json:"service_tier,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CacheCreation            respjson.Field
		CacheCreationInputTokens respjson.Field
		CacheReadInputTokens     respjson.Field
		InferenceGeo             respjson.Field
		InputTokens              respjson.Field
		OutputTokens             respjson.Field
		ServerToolUse            respjson.Field
		ServiceTier              respjson.Field
		ExtraFields              map[string]respjson.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

type UsageServiceTier

type UsageServiceTier string

If the request used the priority, standard, or batch tier.

const (
	UsageServiceTierStandard UsageServiceTier = "standard"
	UsageServiceTierPriority UsageServiceTier = "priority"
	UsageServiceTierBatch    UsageServiceTier = "batch"
)

type UserLocationParam

type UserLocationParam struct {
	// The city of the user.
	City param.Opt[string] `json:"city,omitzero"`
	// The two letter
	// [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the
	// user.
	Country param.Opt[string] `json:"country,omitzero"`
	// The region of the user.
	Region param.Opt[string] `json:"region,omitzero"`
	// The [IANA timezone](https://nodatime.org/TimeZones) of the user.
	Timezone param.Opt[string] `json:"timezone,omitzero"`
	// This field can be elided, and will marshal its zero value as "approximate".
	Type constant.Approximate `json:"type,required"`
	// contains filtered or unexported fields
}

The property Type is required.

func (UserLocationParam) MarshalJSON

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

func (*UserLocationParam) UnmarshalJSON

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

type WebFetchBlock

type WebFetchBlock struct {
	Content DocumentBlock `json:"content,required"`
	// ISO 8601 timestamp when the content was retrieved
	RetrievedAt string                  `json:"retrieved_at,required"`
	Type        constant.WebFetchResult `json:"type,required"`
	// Fetched content URL
	URL string `json:"url,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Content     respjson.Field
		RetrievedAt respjson.Field
		Type        respjson.Field
		URL         respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (WebFetchBlock) RawJSON

func (r WebFetchBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (*WebFetchBlock) UnmarshalJSON

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

type WebFetchBlockParam

type WebFetchBlockParam struct {
	Content DocumentBlockParam `json:"content,omitzero,required"`
	// Fetched content URL
	URL string `json:"url,required"`
	// ISO 8601 timestamp when the content was retrieved
	RetrievedAt param.Opt[string] `json:"retrieved_at,omitzero"`
	// This field can be elided, and will marshal its zero value as "web_fetch_result".
	Type constant.WebFetchResult `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Content, Type, URL are required.

func (WebFetchBlockParam) MarshalJSON

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

func (*WebFetchBlockParam) UnmarshalJSON

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

type WebFetchTool20250910Param

type WebFetchTool20250910Param struct {
	// Maximum number of tokens used by including web page text content in the context.
	// The limit is approximate and does not apply to binary content such as PDFs.
	MaxContentTokens param.Opt[int64] `json:"max_content_tokens,omitzero"`
	// Maximum number of times the tool can be used in the API request.
	MaxUses param.Opt[int64] `json:"max_uses,omitzero"`
	// If true, tool will not be included in initial system prompt. Only loaded when
	// returned via tool_reference from tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// When true, guarantees schema validation on tool names and inputs
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// List of domains to allow fetching from
	AllowedDomains []string `json:"allowed_domains,omitzero"`
	// List of domains to block fetching from
	BlockedDomains []string `json:"blocked_domains,omitzero"`
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// Create a cache control breakpoint at this content block.
	CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"`
	// Citations configuration for fetched documents. Citations are disabled by
	// default.
	Citations CitationsConfigParam `json:"citations,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 "web_fetch".
	Name constant.WebFetch `json:"name,required"`
	// This field can be elided, and will marshal its zero value as
	// "web_fetch_20250910".
	Type constant.WebFetch20250910 `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Name, Type are required.

func (WebFetchTool20250910Param) MarshalJSON

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

func (*WebFetchTool20250910Param) UnmarshalJSON

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

type WebFetchTool20260209Param

type WebFetchTool20260209Param struct {
	// Maximum number of tokens used by including web page text content in the context.
	// The limit is approximate and does not apply to binary content such as PDFs.
	MaxContentTokens param.Opt[int64] `json:"max_content_tokens,omitzero"`
	// Maximum number of times the tool can be used in the API request.
	MaxUses param.Opt[int64] `json:"max_uses,omitzero"`
	// If true, tool will not be included in initial system prompt. Only loaded when
	// returned via tool_reference from tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// When true, guarantees schema validation on tool names and inputs
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// List of domains to allow fetching from
	AllowedDomains []string `json:"allowed_domains,omitzero"`
	// List of domains to block fetching from
	BlockedDomains []string `json:"blocked_domains,omitzero"`
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// Create a cache control breakpoint at this content block.
	CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"`
	// Citations configuration for fetched documents. Citations are disabled by
	// default.
	Citations CitationsConfigParam `json:"citations,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 "web_fetch".
	Name constant.WebFetch `json:"name,required"`
	// This field can be elided, and will marshal its zero value as
	// "web_fetch_20260209".
	Type constant.WebFetch20260209 `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Name, Type are required.

func (WebFetchTool20260209Param) MarshalJSON

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

func (*WebFetchTool20260209Param) UnmarshalJSON

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

type WebFetchToolResultBlock

type WebFetchToolResultBlock struct {
	// Tool invocation directly from the model.
	Caller    WebFetchToolResultBlockCallerUnion  `json:"caller,required"`
	Content   WebFetchToolResultBlockContentUnion `json:"content,required"`
	ToolUseID string                              `json:"tool_use_id,required"`
	Type      constant.WebFetchToolResult         `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Caller      respjson.Field
		Content     respjson.Field
		ToolUseID   respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (WebFetchToolResultBlock) RawJSON

func (r WebFetchToolResultBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (WebFetchToolResultBlock) ToParam

func (*WebFetchToolResultBlock) UnmarshalJSON

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

type WebFetchToolResultBlockCallerUnion

type WebFetchToolResultBlockCallerUnion struct {
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	Type   string `json:"type"`
	ToolID string `json:"tool_id"`
	JSON   struct {
		Type   respjson.Field
		ToolID respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

WebFetchToolResultBlockCallerUnion contains all possible properties and values from DirectCaller, ServerToolCaller, ServerToolCaller20260120.

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

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

func (WebFetchToolResultBlockCallerUnion) AsAny

func (u WebFetchToolResultBlockCallerUnion) AsAny() anyWebFetchToolResultBlockCaller

Use the following switch statement to find the correct variant

switch variant := WebFetchToolResultBlockCallerUnion.AsAny().(type) {
case anthropic.DirectCaller:
case anthropic.ServerToolCaller:
case anthropic.ServerToolCaller20260120:
default:
  fmt.Errorf("no variant present")
}

func (WebFetchToolResultBlockCallerUnion) AsCodeExecution20250825

func (u WebFetchToolResultBlockCallerUnion) AsCodeExecution20250825() (v ServerToolCaller)

func (WebFetchToolResultBlockCallerUnion) AsCodeExecution20260120

func (u WebFetchToolResultBlockCallerUnion) AsCodeExecution20260120() (v ServerToolCaller20260120)

func (WebFetchToolResultBlockCallerUnion) AsDirect

func (WebFetchToolResultBlockCallerUnion) RawJSON

Returns the unmodified JSON received from the API

func (*WebFetchToolResultBlockCallerUnion) UnmarshalJSON

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

type WebFetchToolResultBlockContentUnion

type WebFetchToolResultBlockContentUnion struct {
	// This field is from variant [WebFetchToolResultErrorBlock].
	ErrorCode WebFetchToolResultErrorCode `json:"error_code"`
	Type      string                      `json:"type"`
	// This field is from variant [WebFetchBlock].
	Content DocumentBlock `json:"content"`
	// This field is from variant [WebFetchBlock].
	RetrievedAt string `json:"retrieved_at"`
	// This field is from variant [WebFetchBlock].
	URL  string `json:"url"`
	JSON struct {
		ErrorCode   respjson.Field
		Type        respjson.Field
		Content     respjson.Field
		RetrievedAt respjson.Field
		URL         respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

WebFetchToolResultBlockContentUnion contains all possible properties and values from WebFetchToolResultErrorBlock, WebFetchBlock.

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

func (WebFetchToolResultBlockContentUnion) AsResponseWebFetchResultBlock

func (u WebFetchToolResultBlockContentUnion) AsResponseWebFetchResultBlock() (v WebFetchBlock)

func (WebFetchToolResultBlockContentUnion) AsResponseWebFetchToolResultError

func (u WebFetchToolResultBlockContentUnion) AsResponseWebFetchToolResultError() (v WebFetchToolResultErrorBlock)

func (WebFetchToolResultBlockContentUnion) RawJSON

Returns the unmodified JSON received from the API

func (*WebFetchToolResultBlockContentUnion) UnmarshalJSON

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

type WebFetchToolResultBlockParam

type WebFetchToolResultBlockParam struct {
	Content   WebFetchToolResultBlockParamContentUnion `json:"content,omitzero,required"`
	ToolUseID string                                   `json:"tool_use_id,required"`
	// Create a cache control breakpoint at this content block.
	CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"`
	// Tool invocation directly from the model.
	Caller WebFetchToolResultBlockParamCallerUnion `json:"caller,omitzero"`
	// This field can be elided, and will marshal its zero value as
	// "web_fetch_tool_result".
	Type constant.WebFetchToolResult `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Content, ToolUseID, Type are required.

func (WebFetchToolResultBlockParam) MarshalJSON

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

func (*WebFetchToolResultBlockParam) UnmarshalJSON

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

type WebFetchToolResultBlockParamCallerUnion

type WebFetchToolResultBlockParamCallerUnion struct {
	OfDirect                *DirectCallerParam             `json:",omitzero,inline"`
	OfCodeExecution20250825 *ServerToolCallerParam         `json:",omitzero,inline"`
	OfCodeExecution20260120 *ServerToolCaller20260120Param `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 (WebFetchToolResultBlockParamCallerUnion) GetToolID

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

func (WebFetchToolResultBlockParamCallerUnion) GetType

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

func (WebFetchToolResultBlockParamCallerUnion) MarshalJSON

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

func (*WebFetchToolResultBlockParamCallerUnion) UnmarshalJSON

func (u *WebFetchToolResultBlockParamCallerUnion) UnmarshalJSON(data []byte) error

type WebFetchToolResultBlockParamContentUnion

type WebFetchToolResultBlockParamContentUnion struct {
	OfRequestWebFetchToolResultError *WebFetchToolResultErrorBlockParam `json:",omitzero,inline"`
	OfRequestWebFetchResultBlock     *WebFetchBlockParam                `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 (WebFetchToolResultBlockParamContentUnion) GetContent

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

func (WebFetchToolResultBlockParamContentUnion) GetErrorCode

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

func (WebFetchToolResultBlockParamContentUnion) GetRetrievedAt

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

func (WebFetchToolResultBlockParamContentUnion) GetType

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

func (WebFetchToolResultBlockParamContentUnion) GetURL

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

func (WebFetchToolResultBlockParamContentUnion) MarshalJSON

func (*WebFetchToolResultBlockParamContentUnion) UnmarshalJSON

func (u *WebFetchToolResultBlockParamContentUnion) UnmarshalJSON(data []byte) error

type WebFetchToolResultErrorBlock

type WebFetchToolResultErrorBlock struct {
	// Any of "invalid_tool_input", "url_too_long", "url_not_allowed",
	// "url_not_accessible", "unsupported_content_type", "too_many_requests",
	// "max_uses_exceeded", "unavailable".
	ErrorCode WebFetchToolResultErrorCode      `json:"error_code,required"`
	Type      constant.WebFetchToolResultError `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ErrorCode   respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (WebFetchToolResultErrorBlock) RawJSON

Returns the unmodified JSON received from the API

func (*WebFetchToolResultErrorBlock) UnmarshalJSON

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

type WebFetchToolResultErrorBlockParam

type WebFetchToolResultErrorBlockParam struct {
	// Any of "invalid_tool_input", "url_too_long", "url_not_allowed",
	// "url_not_accessible", "unsupported_content_type", "too_many_requests",
	// "max_uses_exceeded", "unavailable".
	ErrorCode WebFetchToolResultErrorCode `json:"error_code,omitzero,required"`
	// This field can be elided, and will marshal its zero value as
	// "web_fetch_tool_result_error".
	Type constant.WebFetchToolResultError `json:"type,required"`
	// contains filtered or unexported fields
}

The properties ErrorCode, Type are required.

func (WebFetchToolResultErrorBlockParam) MarshalJSON

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

func (*WebFetchToolResultErrorBlockParam) UnmarshalJSON

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

type WebFetchToolResultErrorCode

type WebFetchToolResultErrorCode string
const (
	WebFetchToolResultErrorCodeInvalidToolInput       WebFetchToolResultErrorCode = "invalid_tool_input"
	WebFetchToolResultErrorCodeURLTooLong             WebFetchToolResultErrorCode = "url_too_long"
	WebFetchToolResultErrorCodeURLNotAllowed          WebFetchToolResultErrorCode = "url_not_allowed"
	WebFetchToolResultErrorCodeURLNotAccessible       WebFetchToolResultErrorCode = "url_not_accessible"
	WebFetchToolResultErrorCodeUnsupportedContentType WebFetchToolResultErrorCode = "unsupported_content_type"
	WebFetchToolResultErrorCodeTooManyRequests        WebFetchToolResultErrorCode = "too_many_requests"
	WebFetchToolResultErrorCodeMaxUsesExceeded        WebFetchToolResultErrorCode = "max_uses_exceeded"
	WebFetchToolResultErrorCodeUnavailable            WebFetchToolResultErrorCode = "unavailable"
)

type WebSearchResultBlock

type WebSearchResultBlock struct {
	EncryptedContent string                   `json:"encrypted_content,required"`
	PageAge          string                   `json:"page_age,required"`
	Title            string                   `json:"title,required"`
	Type             constant.WebSearchResult `json:"type,required"`
	URL              string                   `json:"url,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		EncryptedContent respjson.Field
		PageAge          respjson.Field
		Title            respjson.Field
		Type             respjson.Field
		URL              respjson.Field
		ExtraFields      map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (WebSearchResultBlock) RawJSON

func (r WebSearchResultBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (WebSearchResultBlock) ToParam

func (*WebSearchResultBlock) UnmarshalJSON

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

type WebSearchResultBlockParam

type WebSearchResultBlockParam struct {
	EncryptedContent string            `json:"encrypted_content,required"`
	Title            string            `json:"title,required"`
	URL              string            `json:"url,required"`
	PageAge          param.Opt[string] `json:"page_age,omitzero"`
	// This field can be elided, and will marshal its zero value as
	// "web_search_result".
	Type constant.WebSearchResult `json:"type,required"`
	// contains filtered or unexported fields
}

The properties EncryptedContent, Title, Type, URL are required.

func (WebSearchResultBlockParam) MarshalJSON

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

func (*WebSearchResultBlockParam) UnmarshalJSON

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

type WebSearchTool20250305Param

type WebSearchTool20250305Param struct {
	// Maximum number of times the tool can be used in the API request.
	MaxUses param.Opt[int64] `json:"max_uses,omitzero"`
	// If true, tool will not be included in initial system prompt. Only loaded when
	// returned via tool_reference from tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// When true, guarantees schema validation on tool names and inputs
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// If provided, only these domains will be included in results. Cannot be used
	// alongside `blocked_domains`.
	AllowedDomains []string `json:"allowed_domains,omitzero"`
	// If provided, these domains will never appear in results. Cannot be used
	// alongside `allowed_domains`.
	BlockedDomains []string `json:"blocked_domains,omitzero"`
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// Create a cache control breakpoint at this content block.
	CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"`
	// Parameters for the user's location. Used to provide more relevant search
	// results.
	UserLocation UserLocationParam `json:"user_location,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 "web_search".
	Name constant.WebSearch `json:"name,required"`
	// This field can be elided, and will marshal its zero value as
	// "web_search_20250305".
	Type constant.WebSearch20250305 `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Name, Type are required.

func (WebSearchTool20250305Param) MarshalJSON

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

func (*WebSearchTool20250305Param) UnmarshalJSON

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

type WebSearchTool20250305UserLocationParam

type WebSearchTool20250305UserLocationParam = UserLocationParam

type WebSearchTool20260209Param

type WebSearchTool20260209Param struct {
	// Maximum number of times the tool can be used in the API request.
	MaxUses param.Opt[int64] `json:"max_uses,omitzero"`
	// If true, tool will not be included in initial system prompt. Only loaded when
	// returned via tool_reference from tool search.
	DeferLoading param.Opt[bool] `json:"defer_loading,omitzero"`
	// When true, guarantees schema validation on tool names and inputs
	Strict param.Opt[bool] `json:"strict,omitzero"`
	// If provided, only these domains will be included in results. Cannot be used
	// alongside `blocked_domains`.
	AllowedDomains []string `json:"allowed_domains,omitzero"`
	// If provided, these domains will never appear in results. Cannot be used
	// alongside `allowed_domains`.
	BlockedDomains []string `json:"blocked_domains,omitzero"`
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	AllowedCallers []string `json:"allowed_callers,omitzero"`
	// Create a cache control breakpoint at this content block.
	CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"`
	// Parameters for the user's location. Used to provide more relevant search
	// results.
	UserLocation UserLocationParam `json:"user_location,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 "web_search".
	Name constant.WebSearch `json:"name,required"`
	// This field can be elided, and will marshal its zero value as
	// "web_search_20260209".
	Type constant.WebSearch20260209 `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Name, Type are required.

func (WebSearchTool20260209Param) MarshalJSON

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

func (*WebSearchTool20260209Param) UnmarshalJSON

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

type WebSearchTool20260209UserLocationParam

type WebSearchTool20260209UserLocationParam = UserLocationParam

type WebSearchToolRequestErrorErrorCode

type WebSearchToolRequestErrorErrorCode = WebSearchToolResultErrorCode

type WebSearchToolRequestErrorParam

type WebSearchToolRequestErrorParam struct {
	// Any of "invalid_tool_input", "unavailable", "max_uses_exceeded",
	// "too_many_requests", "query_too_long", "request_too_large".
	ErrorCode WebSearchToolResultErrorCode `json:"error_code,omitzero,required"`
	// This field can be elided, and will marshal its zero value as
	// "web_search_tool_result_error".
	Type constant.WebSearchToolResultError `json:"type,required"`
	// contains filtered or unexported fields
}

The properties ErrorCode, Type are required.

func (WebSearchToolRequestErrorParam) MarshalJSON

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

func (*WebSearchToolRequestErrorParam) UnmarshalJSON

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

type WebSearchToolResultBlock

type WebSearchToolResultBlock struct {
	// Tool invocation directly from the model.
	Caller    WebSearchToolResultBlockCallerUnion  `json:"caller,required"`
	Content   WebSearchToolResultBlockContentUnion `json:"content,required"`
	ToolUseID string                               `json:"tool_use_id,required"`
	Type      constant.WebSearchToolResult         `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Caller      respjson.Field
		Content     respjson.Field
		ToolUseID   respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (WebSearchToolResultBlock) RawJSON

func (r WebSearchToolResultBlock) RawJSON() string

Returns the unmodified JSON received from the API

func (WebSearchToolResultBlock) ToParam

func (*WebSearchToolResultBlock) UnmarshalJSON

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

type WebSearchToolResultBlockCallerUnion

type WebSearchToolResultBlockCallerUnion struct {
	// Any of "direct", "code_execution_20250825", "code_execution_20260120".
	Type   string `json:"type"`
	ToolID string `json:"tool_id"`
	JSON   struct {
		Type   respjson.Field
		ToolID respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

WebSearchToolResultBlockCallerUnion contains all possible properties and values from DirectCaller, ServerToolCaller, ServerToolCaller20260120.

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

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

func (WebSearchToolResultBlockCallerUnion) AsAny

func (u WebSearchToolResultBlockCallerUnion) AsAny() anyWebSearchToolResultBlockCaller

Use the following switch statement to find the correct variant

switch variant := WebSearchToolResultBlockCallerUnion.AsAny().(type) {
case anthropic.DirectCaller:
case anthropic.ServerToolCaller:
case anthropic.ServerToolCaller20260120:
default:
  fmt.Errorf("no variant present")
}

func (WebSearchToolResultBlockCallerUnion) AsCodeExecution20250825

func (u WebSearchToolResultBlockCallerUnion) AsCodeExecution20250825() (v ServerToolCaller)

func (WebSearchToolResultBlockCallerUnion) AsCodeExecution20260120

func (u WebSearchToolResultBlockCallerUnion) AsCodeExecution20260120() (v ServerToolCaller20260120)

func (WebSearchToolResultBlockCallerUnion) AsDirect

func (WebSearchToolResultBlockCallerUnion) RawJSON

Returns the unmodified JSON received from the API

func (*WebSearchToolResultBlockCallerUnion) UnmarshalJSON

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

type WebSearchToolResultBlockContentUnion

type WebSearchToolResultBlockContentUnion struct {
	// This field will be present if the value is a [[]WebSearchResultBlock] instead of
	// an object.
	OfWebSearchResultBlockArray []WebSearchResultBlock `json:",inline"`
	// This field is from variant [WebSearchToolResultError].
	ErrorCode WebSearchToolResultErrorCode `json:"error_code"`
	// This field is from variant [WebSearchToolResultError].
	Type constant.WebSearchToolResultError `json:"type"`
	JSON struct {
		OfWebSearchResultBlockArray respjson.Field
		ErrorCode                   respjson.Field
		Type                        respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

WebSearchToolResultBlockContentUnion contains all possible properties and values from WebSearchToolResultError, [[]WebSearchResultBlock].

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

If the underlying value is not a json object, one of the following properties will be valid: OfWebSearchResultBlockArray]

func (WebSearchToolResultBlockContentUnion) AsResponseWebSearchToolResultError

func (u WebSearchToolResultBlockContentUnion) AsResponseWebSearchToolResultError() (v WebSearchToolResultError)

func (WebSearchToolResultBlockContentUnion) AsWebSearchResultBlockArray

func (u WebSearchToolResultBlockContentUnion) AsWebSearchResultBlockArray() (v []WebSearchResultBlock)

func (WebSearchToolResultBlockContentUnion) RawJSON

Returns the unmodified JSON received from the API

func (WebSearchToolResultBlockContentUnion) ToParam

func (*WebSearchToolResultBlockContentUnion) UnmarshalJSON

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

type WebSearchToolResultBlockParam

type WebSearchToolResultBlockParam struct {
	Content   WebSearchToolResultBlockParamContentUnion `json:"content,omitzero,required"`
	ToolUseID string                                    `json:"tool_use_id,required"`
	// Create a cache control breakpoint at this content block.
	CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"`
	// Tool invocation directly from the model.
	Caller WebSearchToolResultBlockParamCallerUnion `json:"caller,omitzero"`
	// This field can be elided, and will marshal its zero value as
	// "web_search_tool_result".
	Type constant.WebSearchToolResult `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Content, ToolUseID, Type are required.

func (WebSearchToolResultBlockParam) MarshalJSON

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

func (*WebSearchToolResultBlockParam) UnmarshalJSON

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

type WebSearchToolResultBlockParamCallerUnion

type WebSearchToolResultBlockParamCallerUnion struct {
	OfDirect                *DirectCallerParam             `json:",omitzero,inline"`
	OfCodeExecution20250825 *ServerToolCallerParam         `json:",omitzero,inline"`
	OfCodeExecution20260120 *ServerToolCaller20260120Param `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 (WebSearchToolResultBlockParamCallerUnion) GetToolID

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

func (WebSearchToolResultBlockParamCallerUnion) GetType

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

func (WebSearchToolResultBlockParamCallerUnion) MarshalJSON

func (*WebSearchToolResultBlockParamCallerUnion) UnmarshalJSON

func (u *WebSearchToolResultBlockParamCallerUnion) UnmarshalJSON(data []byte) error

type WebSearchToolResultBlockParamContentUnion

type WebSearchToolResultBlockParamContentUnion struct {
	OfWebSearchToolResultBlockItem    []WebSearchResultBlockParam     `json:",omitzero,inline"`
	OfRequestWebSearchToolResultError *WebSearchToolRequestErrorParam `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 (WebSearchToolResultBlockParamContentUnion) MarshalJSON

func (*WebSearchToolResultBlockParamContentUnion) UnmarshalJSON

func (u *WebSearchToolResultBlockParamContentUnion) UnmarshalJSON(data []byte) error

type WebSearchToolResultError

type WebSearchToolResultError struct {
	// Any of "invalid_tool_input", "unavailable", "max_uses_exceeded",
	// "too_many_requests", "query_too_long", "request_too_large".
	ErrorCode WebSearchToolResultErrorCode      `json:"error_code,required"`
	Type      constant.WebSearchToolResultError `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ErrorCode   respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (WebSearchToolResultError) RawJSON

func (r WebSearchToolResultError) RawJSON() string

Returns the unmodified JSON received from the API

func (*WebSearchToolResultError) UnmarshalJSON

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

type WebSearchToolResultErrorCode

type WebSearchToolResultErrorCode string
const (
	WebSearchToolResultErrorCodeInvalidToolInput WebSearchToolResultErrorCode = "invalid_tool_input"
	WebSearchToolResultErrorCodeUnavailable      WebSearchToolResultErrorCode = "unavailable"
	WebSearchToolResultErrorCodeMaxUsesExceeded  WebSearchToolResultErrorCode = "max_uses_exceeded"
	WebSearchToolResultErrorCodeTooManyRequests  WebSearchToolResultErrorCode = "too_many_requests"
	WebSearchToolResultErrorCodeQueryTooLong     WebSearchToolResultErrorCode = "query_too_long"
	WebSearchToolResultErrorCodeRequestTooLarge  WebSearchToolResultErrorCode = "request_too_large"
)

type WebSearchToolResultErrorErrorCode

type WebSearchToolResultErrorErrorCode = WebSearchToolResultErrorCode

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.22, 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.22, 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