Documentation
¶
Index ¶
- func Bool(b bool) param.Opt[bool]
- func BoolPtr(v bool) *bool
- func CalculateNonStreamingTimeout(maxTokens int, model Model, opts []option.RequestOption) (time.Duration, error)
- func DefaultClientOptions() []option.RequestOption
- func File(rdr io.Reader, filename string, contentType string) file
- func Float(f float64) param.Opt[float64]
- func FloatPtr(v float64) *float64
- func Int(i int64) param.Opt[int64]
- func IntPtr(v int64) *int64
- func Opt[T comparable](v T) param.Opt[T]
- func Ptr[T any](v T) *T
- func String(s string) param.Opt[string]
- func StringPtr(v string) *string
- func Time(t time.Time) param.Opt[time.Time]
- func TimePtr(v time.Time) *time.Time
- type APIErrorObject
- type AnthropicBeta
- type AuthenticationError
- type Base64ImageSourceMediaType
- type Base64ImageSourceParam
- type Base64PDFSourceParam
- type BetaAPIError
- type BetaAuthenticationError
- type BetaBase64ImageSourceMediaType
- type BetaBase64ImageSourceParam
- type BetaBase64PDFBlockParam
- type BetaBase64PDFBlockSourceUnionParam
- func (u BetaBase64PDFBlockSourceUnionParam) GetContent() *BetaContentBlockSourceContentUnionParam
- func (u BetaBase64PDFBlockSourceUnionParam) GetData() *string
- func (u BetaBase64PDFBlockSourceUnionParam) GetFileID() *string
- func (u BetaBase64PDFBlockSourceUnionParam) GetMediaType() *string
- func (u BetaBase64PDFBlockSourceUnionParam) GetType() *string
- func (u BetaBase64PDFBlockSourceUnionParam) GetURL() *string
- func (u BetaBase64PDFBlockSourceUnionParam) MarshalJSON() ([]byte, error)
- func (u *BetaBase64PDFBlockSourceUnionParam) UnmarshalJSON(data []byte) error
- type BetaBase64PDFSourceParam
- type BetaBillingError
- type BetaCacheControlEphemeralParam
- type BetaCacheControlEphemeralTTL
- type BetaCacheCreation
- type BetaCitationCharLocation
- type BetaCitationCharLocationParam
- type BetaCitationContentBlockLocation
- type BetaCitationContentBlockLocationParam
- type BetaCitationPageLocation
- type BetaCitationPageLocationParam
- type BetaCitationWebSearchResultLocationParam
- type BetaCitationsConfigParam
- type BetaCitationsDelta
- type BetaCitationsDeltaCitationUnion
- func (u BetaCitationsDeltaCitationUnion) AsAny() anyBetaCitationsDeltaCitation
- func (u BetaCitationsDeltaCitationUnion) AsCharLocation() (v BetaCitationCharLocation)
- func (u BetaCitationsDeltaCitationUnion) AsContentBlockLocation() (v BetaCitationContentBlockLocation)
- func (u BetaCitationsDeltaCitationUnion) AsPageLocation() (v BetaCitationPageLocation)
- func (u BetaCitationsDeltaCitationUnion) AsWebSearchResultLocation() (v BetaCitationsWebSearchResultLocation)
- func (u BetaCitationsDeltaCitationUnion) RawJSON() string
- func (r *BetaCitationsDeltaCitationUnion) UnmarshalJSON(data []byte) error
- type BetaCitationsWebSearchResultLocation
- type BetaCodeExecutionOutputBlock
- type BetaCodeExecutionOutputBlockParam
- type BetaCodeExecutionResultBlock
- type BetaCodeExecutionResultBlockParam
- type BetaCodeExecutionTool20250522Param
- type BetaCodeExecutionToolResultBlock
- type BetaCodeExecutionToolResultBlockContentUnion
- func (u BetaCodeExecutionToolResultBlockContentUnion) AsResponseCodeExecutionResultBlock() (v BetaCodeExecutionResultBlock)
- func (u BetaCodeExecutionToolResultBlockContentUnion) AsResponseCodeExecutionToolResultError() (v BetaCodeExecutionToolResultError)
- func (u BetaCodeExecutionToolResultBlockContentUnion) RawJSON() string
- func (r *BetaCodeExecutionToolResultBlockContentUnion) UnmarshalJSON(data []byte) error
- type BetaCodeExecutionToolResultBlockParam
- type BetaCodeExecutionToolResultBlockParamContentUnion
- func (u BetaCodeExecutionToolResultBlockParamContentUnion) GetContent() []BetaCodeExecutionOutputBlockParam
- func (u BetaCodeExecutionToolResultBlockParamContentUnion) GetErrorCode() *string
- func (u BetaCodeExecutionToolResultBlockParamContentUnion) GetReturnCode() *int64
- func (u BetaCodeExecutionToolResultBlockParamContentUnion) GetStderr() *string
- func (u BetaCodeExecutionToolResultBlockParamContentUnion) GetStdout() *string
- func (u BetaCodeExecutionToolResultBlockParamContentUnion) GetType() *string
- func (u BetaCodeExecutionToolResultBlockParamContentUnion) MarshalJSON() ([]byte, error)
- func (u *BetaCodeExecutionToolResultBlockParamContentUnion) UnmarshalJSON(data []byte) error
- type BetaCodeExecutionToolResultError
- type BetaCodeExecutionToolResultErrorCode
- type BetaCodeExecutionToolResultErrorParam
- type BetaContainer
- type BetaContainerUploadBlock
- type BetaContainerUploadBlockParam
- type BetaContentBlockParamUnion
- func NewBetaCodeExecutionToolResultBlock[T BetaCodeExecutionToolResultErrorParam | BetaCodeExecutionResultBlockParam](content T, toolUseID string) BetaContentBlockParamUnion
- func NewBetaContainerUploadBlock(fileID string) BetaContentBlockParamUnion
- func NewBetaDocumentBlock[...](source T) BetaContentBlockParamUnion
- func NewBetaImageBlock[...](source T) BetaContentBlockParamUnion
- func NewBetaMCPToolResultBlock(toolUseID string) BetaContentBlockParamUnion
- func NewBetaRedactedThinkingBlock(data string) BetaContentBlockParamUnion
- func NewBetaServerToolUseBlock(id string, input any, name BetaServerToolUseBlockParamName) BetaContentBlockParamUnion
- func NewBetaTextBlock(text string) BetaContentBlockParamUnion
- func NewBetaThinkingBlock(signature string, thinking string) BetaContentBlockParamUnion
- func NewBetaToolResultBlock(toolUseID string, content string, isError bool) BetaContentBlockParamUnion
- func NewBetaToolUseBlock(id string, input any, name string) BetaContentBlockParamUnion
- func NewBetaWebSearchToolResultBlock[T []BetaWebSearchResultBlockParam | BetaWebSearchToolRequestErrorParam](content T, toolUseID string) BetaContentBlockParamUnion
- func (u BetaContentBlockParamUnion) GetCacheControl() *BetaCacheControlEphemeralParam
- func (u BetaContentBlockParamUnion) GetCitations() (res betaContentBlockParamUnionCitations)
- func (u BetaContentBlockParamUnion) GetContent() (res betaContentBlockParamUnionContent)
- func (u BetaContentBlockParamUnion) GetContext() *string
- func (u BetaContentBlockParamUnion) GetData() *string
- func (u BetaContentBlockParamUnion) GetFileID() *string
- func (u BetaContentBlockParamUnion) GetID() *string
- func (u BetaContentBlockParamUnion) GetInput() *any
- func (u BetaContentBlockParamUnion) GetIsError() *bool
- func (u BetaContentBlockParamUnion) GetName() *string
- func (u BetaContentBlockParamUnion) GetServerName() *string
- func (u BetaContentBlockParamUnion) GetSignature() *string
- func (u BetaContentBlockParamUnion) GetSource() (res betaContentBlockParamUnionSource)
- func (u BetaContentBlockParamUnion) GetText() *string
- func (u BetaContentBlockParamUnion) GetThinking() *string
- func (u BetaContentBlockParamUnion) GetTitle() *string
- func (u BetaContentBlockParamUnion) GetToolUseID() *string
- func (u BetaContentBlockParamUnion) GetType() *string
- func (u BetaContentBlockParamUnion) MarshalJSON() ([]byte, error)
- func (u *BetaContentBlockParamUnion) UnmarshalJSON(data []byte) error
- type BetaContentBlockSourceContentUnionParam
- type BetaContentBlockSourceParam
- type BetaContentBlockUnion
- func (u BetaContentBlockUnion) AsAny() anyBetaContentBlock
- func (u BetaContentBlockUnion) AsCodeExecutionToolResult() (v BetaCodeExecutionToolResultBlock)
- func (u BetaContentBlockUnion) AsContainerUpload() (v BetaContainerUploadBlock)
- func (u BetaContentBlockUnion) AsMCPToolResult() (v BetaMCPToolResultBlock)
- func (u BetaContentBlockUnion) AsMCPToolUse() (v BetaMCPToolUseBlock)
- func (u BetaContentBlockUnion) AsRedactedThinking() (v BetaRedactedThinkingBlock)
- func (u BetaContentBlockUnion) AsServerToolUse() (v BetaServerToolUseBlock)
- func (u BetaContentBlockUnion) AsText() (v BetaTextBlock)
- func (u BetaContentBlockUnion) AsThinking() (v BetaThinkingBlock)
- func (u BetaContentBlockUnion) AsToolUse() (v BetaToolUseBlock)
- func (u BetaContentBlockUnion) AsWebSearchToolResult() (v BetaWebSearchToolResultBlock)
- func (u BetaContentBlockUnion) RawJSON() string
- func (r BetaContentBlockUnion) ToParam() BetaContentBlockParamUnion
- func (r *BetaContentBlockUnion) UnmarshalJSON(data []byte) error
- type BetaContentBlockUnionContent
- type BetaDeletedMessageBatch
- type BetaErrorResponse
- type BetaErrorUnion
- func (u BetaErrorUnion) AsAPIError() (v BetaAPIError)
- func (u BetaErrorUnion) AsAny() anyBetaError
- func (u BetaErrorUnion) AsAuthenticationError() (v BetaAuthenticationError)
- func (u BetaErrorUnion) AsBillingError() (v BetaBillingError)
- func (u BetaErrorUnion) AsInvalidRequestError() (v BetaInvalidRequestError)
- func (u BetaErrorUnion) AsNotFoundError() (v BetaNotFoundError)
- func (u BetaErrorUnion) AsOverloadedError() (v BetaOverloadedError)
- func (u BetaErrorUnion) AsPermissionError() (v BetaPermissionError)
- func (u BetaErrorUnion) AsRateLimitError() (v BetaRateLimitError)
- func (u BetaErrorUnion) AsTimeoutError() (v BetaGatewayTimeoutError)
- func (u BetaErrorUnion) RawJSON() string
- func (r *BetaErrorUnion) UnmarshalJSON(data []byte) error
- type BetaFileDeleteParams
- type BetaFileDocumentSourceParam
- type BetaFileDownloadParams
- type BetaFileGetMetadataParams
- type BetaFileImageSourceParam
- type BetaFileListParams
- type BetaFileService
- func (r *BetaFileService) Delete(ctx context.Context, fileID string, body BetaFileDeleteParams, ...) (res *DeletedFile, err error)
- func (r *BetaFileService) Download(ctx context.Context, fileID string, query BetaFileDownloadParams, ...) (res *http.Response, err error)
- func (r *BetaFileService) GetMetadata(ctx context.Context, fileID string, query BetaFileGetMetadataParams, ...) (res *FileMetadata, err error)
- func (r *BetaFileService) List(ctx context.Context, params BetaFileListParams, opts ...option.RequestOption) (res *pagination.Page[FileMetadata], err error)
- func (r *BetaFileService) ListAutoPaging(ctx context.Context, params BetaFileListParams, opts ...option.RequestOption) *pagination.PageAutoPager[FileMetadata]
- func (r *BetaFileService) Upload(ctx context.Context, params BetaFileUploadParams, opts ...option.RequestOption) (res *FileMetadata, err error)
- type BetaFileUploadParams
- type BetaGatewayTimeoutError
- type BetaImageBlockParam
- type BetaImageBlockParamSourceUnion
- func (u BetaImageBlockParamSourceUnion) GetData() *string
- func (u BetaImageBlockParamSourceUnion) GetFileID() *string
- func (u BetaImageBlockParamSourceUnion) GetMediaType() *string
- func (u BetaImageBlockParamSourceUnion) GetType() *string
- func (u BetaImageBlockParamSourceUnion) GetURL() *string
- func (u BetaImageBlockParamSourceUnion) MarshalJSON() ([]byte, error)
- func (u *BetaImageBlockParamSourceUnion) UnmarshalJSON(data []byte) error
- type BetaInputJSONDelta
- type BetaInvalidRequestError
- type BetaMCPToolResultBlock
- type BetaMCPToolResultBlockContentUnion
- func (u BetaMCPToolResultBlockContentUnion) AsBetaMCPToolResultBlockContent() (v []BetaTextBlock)
- func (u BetaMCPToolResultBlockContentUnion) AsString() (v string)
- func (u BetaMCPToolResultBlockContentUnion) RawJSON() string
- func (r *BetaMCPToolResultBlockContentUnion) UnmarshalJSON(data []byte) error
- type BetaMCPToolUseBlock
- type BetaMCPToolUseBlockParam
- type BetaMessage
- type BetaMessageBatch
- type BetaMessageBatchCancelParams
- type BetaMessageBatchCanceledResult
- type BetaMessageBatchDeleteParams
- type BetaMessageBatchErroredResult
- type BetaMessageBatchExpiredResult
- type BetaMessageBatchGetParams
- type BetaMessageBatchIndividualResponse
- type BetaMessageBatchListParams
- type BetaMessageBatchNewParams
- type BetaMessageBatchNewParamsRequest
- type BetaMessageBatchNewParamsRequestParams
- type BetaMessageBatchProcessingStatus
- type BetaMessageBatchRequestCounts
- type BetaMessageBatchResultUnion
- func (u BetaMessageBatchResultUnion) AsAny() anyBetaMessageBatchResult
- func (u BetaMessageBatchResultUnion) AsCanceled() (v BetaMessageBatchCanceledResult)
- func (u BetaMessageBatchResultUnion) AsErrored() (v BetaMessageBatchErroredResult)
- func (u BetaMessageBatchResultUnion) AsExpired() (v BetaMessageBatchExpiredResult)
- func (u BetaMessageBatchResultUnion) AsSucceeded() (v BetaMessageBatchSucceededResult)
- func (u BetaMessageBatchResultUnion) RawJSON() string
- func (r *BetaMessageBatchResultUnion) UnmarshalJSON(data []byte) error
- type BetaMessageBatchResultsParams
- type BetaMessageBatchService
- func (r *BetaMessageBatchService) Cancel(ctx context.Context, messageBatchID string, body BetaMessageBatchCancelParams, ...) (res *BetaMessageBatch, err error)
- func (r *BetaMessageBatchService) Delete(ctx context.Context, messageBatchID string, body BetaMessageBatchDeleteParams, ...) (res *BetaDeletedMessageBatch, err error)
- func (r *BetaMessageBatchService) Get(ctx context.Context, messageBatchID string, query BetaMessageBatchGetParams, ...) (res *BetaMessageBatch, err error)
- func (r *BetaMessageBatchService) List(ctx context.Context, params BetaMessageBatchListParams, ...) (res *pagination.Page[BetaMessageBatch], err error)
- func (r *BetaMessageBatchService) ListAutoPaging(ctx context.Context, params BetaMessageBatchListParams, ...) *pagination.PageAutoPager[BetaMessageBatch]
- func (r *BetaMessageBatchService) New(ctx context.Context, params BetaMessageBatchNewParams, ...) (res *BetaMessageBatch, err error)
- func (r *BetaMessageBatchService) ResultsStreaming(ctx context.Context, messageBatchID string, ...) (stream *jsonl.Stream[BetaMessageBatchIndividualResponse])
- type BetaMessageBatchSucceededResult
- type BetaMessageCountTokensParams
- type BetaMessageCountTokensParamsSystemUnion
- type BetaMessageCountTokensParamsToolUnion
- func (u BetaMessageCountTokensParamsToolUnion) GetAllowedDomains() []string
- func (u BetaMessageCountTokensParamsToolUnion) GetBlockedDomains() []string
- func (u BetaMessageCountTokensParamsToolUnion) GetCacheControl() *BetaCacheControlEphemeralParam
- func (u BetaMessageCountTokensParamsToolUnion) GetDescription() *string
- func (u BetaMessageCountTokensParamsToolUnion) GetDisplayHeightPx() *int64
- func (u BetaMessageCountTokensParamsToolUnion) GetDisplayNumber() *int64
- func (u BetaMessageCountTokensParamsToolUnion) GetDisplayWidthPx() *int64
- func (u BetaMessageCountTokensParamsToolUnion) GetInputSchema() *BetaToolInputSchemaParam
- func (u BetaMessageCountTokensParamsToolUnion) GetMaxUses() *int64
- func (u BetaMessageCountTokensParamsToolUnion) GetName() *string
- func (u BetaMessageCountTokensParamsToolUnion) GetType() *string
- func (u BetaMessageCountTokensParamsToolUnion) GetUserLocation() *BetaWebSearchTool20250305UserLocationParam
- func (u BetaMessageCountTokensParamsToolUnion) MarshalJSON() ([]byte, error)
- func (u *BetaMessageCountTokensParamsToolUnion) UnmarshalJSON(data []byte) error
- type BetaMessageDeltaUsage
- type BetaMessageNewParams
- type BetaMessageNewParamsServiceTier
- type BetaMessageParam
- type BetaMessageParamRole
- type BetaMessageService
- func (r *BetaMessageService) CountTokens(ctx context.Context, params BetaMessageCountTokensParams, ...) (res *BetaMessageTokensCount, err error)
- func (r *BetaMessageService) New(ctx context.Context, params BetaMessageNewParams, opts ...option.RequestOption) (res *BetaMessage, err error)
- func (r *BetaMessageService) NewStreaming(ctx context.Context, params BetaMessageNewParams, opts ...option.RequestOption) (stream *ssestream.Stream[BetaRawMessageStreamEventUnion])
- type BetaMessageStopReason
- type BetaMessageTokensCount
- type BetaMetadataParam
- type BetaModelGetParams
- type BetaModelInfo
- type BetaModelListParams
- type BetaModelService
- func (r *BetaModelService) Get(ctx context.Context, modelID string, query BetaModelGetParams, ...) (res *BetaModelInfo, err error)
- func (r *BetaModelService) List(ctx context.Context, params BetaModelListParams, opts ...option.RequestOption) (res *pagination.Page[BetaModelInfo], err error)
- func (r *BetaModelService) ListAutoPaging(ctx context.Context, params BetaModelListParams, opts ...option.RequestOption) *pagination.PageAutoPager[BetaModelInfo]
- type BetaNotFoundError
- type BetaOverloadedError
- type BetaPermissionError
- type BetaPlainTextSourceParam
- type BetaRateLimitError
- type BetaRawContentBlockDeltaEvent
- type BetaRawContentBlockDeltaUnion
- func (u BetaRawContentBlockDeltaUnion) AsAny() anyBetaRawContentBlockDelta
- func (u BetaRawContentBlockDeltaUnion) AsCitationsDelta() (v BetaCitationsDelta)
- func (u BetaRawContentBlockDeltaUnion) AsInputJSONDelta() (v BetaInputJSONDelta)
- func (u BetaRawContentBlockDeltaUnion) AsSignatureDelta() (v BetaSignatureDelta)
- func (u BetaRawContentBlockDeltaUnion) AsTextDelta() (v BetaTextDelta)
- func (u BetaRawContentBlockDeltaUnion) AsThinkingDelta() (v BetaThinkingDelta)
- func (u BetaRawContentBlockDeltaUnion) RawJSON() string
- func (r *BetaRawContentBlockDeltaUnion) UnmarshalJSON(data []byte) error
- type BetaRawContentBlockStartEvent
- type BetaRawContentBlockStartEventContentBlockUnion
- func (u BetaRawContentBlockStartEventContentBlockUnion) AsAny() anyBetaRawContentBlockStartEventContentBlock
- func (u BetaRawContentBlockStartEventContentBlockUnion) AsCodeExecutionToolResult() (v BetaCodeExecutionToolResultBlock)
- func (u BetaRawContentBlockStartEventContentBlockUnion) AsContainerUpload() (v BetaContainerUploadBlock)
- func (u BetaRawContentBlockStartEventContentBlockUnion) AsMCPToolResult() (v BetaMCPToolResultBlock)
- func (u BetaRawContentBlockStartEventContentBlockUnion) AsMCPToolUse() (v BetaMCPToolUseBlock)
- func (u BetaRawContentBlockStartEventContentBlockUnion) AsRedactedThinking() (v BetaRedactedThinkingBlock)
- func (u BetaRawContentBlockStartEventContentBlockUnion) AsServerToolUse() (v BetaServerToolUseBlock)
- func (u BetaRawContentBlockStartEventContentBlockUnion) AsText() (v BetaTextBlock)
- func (u BetaRawContentBlockStartEventContentBlockUnion) AsThinking() (v BetaThinkingBlock)
- func (u BetaRawContentBlockStartEventContentBlockUnion) AsToolUse() (v BetaToolUseBlock)
- func (u BetaRawContentBlockStartEventContentBlockUnion) AsWebSearchToolResult() (v BetaWebSearchToolResultBlock)
- func (u BetaRawContentBlockStartEventContentBlockUnion) RawJSON() string
- func (r *BetaRawContentBlockStartEventContentBlockUnion) UnmarshalJSON(data []byte) error
- type BetaRawContentBlockStartEventContentBlockUnionContent
- type BetaRawContentBlockStopEvent
- type BetaRawMessageDeltaEvent
- type BetaRawMessageDeltaEventDelta
- type BetaRawMessageStartEvent
- type BetaRawMessageStopEvent
- type BetaRawMessageStreamEventUnion
- func (u BetaRawMessageStreamEventUnion) AsAny() anyBetaRawMessageStreamEvent
- func (u BetaRawMessageStreamEventUnion) AsContentBlockDelta() (v BetaRawContentBlockDeltaEvent)
- func (u BetaRawMessageStreamEventUnion) AsContentBlockStart() (v BetaRawContentBlockStartEvent)
- func (u BetaRawMessageStreamEventUnion) AsContentBlockStop() (v BetaRawContentBlockStopEvent)
- func (u BetaRawMessageStreamEventUnion) AsMessageDelta() (v BetaRawMessageDeltaEvent)
- func (u BetaRawMessageStreamEventUnion) AsMessageStart() (v BetaRawMessageStartEvent)
- func (u BetaRawMessageStreamEventUnion) AsMessageStop() (v BetaRawMessageStopEvent)
- func (u BetaRawMessageStreamEventUnion) RawJSON() string
- func (r *BetaRawMessageStreamEventUnion) UnmarshalJSON(data []byte) error
- type BetaRawMessageStreamEventUnionDelta
- type BetaRedactedThinkingBlock
- type BetaRedactedThinkingBlockParam
- type BetaRequestMCPServerToolConfigurationParam
- type BetaRequestMCPServerURLDefinitionParam
- type BetaRequestMCPToolResultBlockParam
- type BetaRequestMCPToolResultBlockParamContentUnion
- type BetaServerToolUsage
- type BetaServerToolUseBlock
- type BetaServerToolUseBlockName
- type BetaServerToolUseBlockParam
- type BetaServerToolUseBlockParamName
- type BetaService
- type BetaSignatureDelta
- type BetaStopReason
- type BetaTextBlock
- type BetaTextBlockParam
- type BetaTextCitationParamUnion
- func (u BetaTextCitationParamUnion) GetCitedText() *string
- func (u BetaTextCitationParamUnion) GetDocumentIndex() *int64
- func (u BetaTextCitationParamUnion) GetDocumentTitle() *string
- func (u BetaTextCitationParamUnion) GetEncryptedIndex() *string
- func (u BetaTextCitationParamUnion) GetEndBlockIndex() *int64
- func (u BetaTextCitationParamUnion) GetEndCharIndex() *int64
- func (u BetaTextCitationParamUnion) GetEndPageNumber() *int64
- func (u BetaTextCitationParamUnion) GetStartBlockIndex() *int64
- func (u BetaTextCitationParamUnion) GetStartCharIndex() *int64
- func (u BetaTextCitationParamUnion) GetStartPageNumber() *int64
- func (u BetaTextCitationParamUnion) GetTitle() *string
- func (u BetaTextCitationParamUnion) GetType() *string
- func (u BetaTextCitationParamUnion) GetURL() *string
- func (u BetaTextCitationParamUnion) MarshalJSON() ([]byte, error)
- func (u *BetaTextCitationParamUnion) UnmarshalJSON(data []byte) error
- type BetaTextCitationUnion
- func (u BetaTextCitationUnion) AsAny() anyBetaTextCitation
- func (u BetaTextCitationUnion) AsCharLocation() (v BetaCitationCharLocation)
- func (u BetaTextCitationUnion) AsContentBlockLocation() (v BetaCitationContentBlockLocation)
- func (u BetaTextCitationUnion) AsPageLocation() (v BetaCitationPageLocation)
- func (u BetaTextCitationUnion) AsWebSearchResultLocation() (v BetaCitationsWebSearchResultLocation)
- func (u BetaTextCitationUnion) RawJSON() string
- func (r *BetaTextCitationUnion) UnmarshalJSON(data []byte) error
- type BetaTextDelta
- type BetaThinkingBlock
- type BetaThinkingBlockParam
- type BetaThinkingConfigDisabledParam
- type BetaThinkingConfigEnabledParam
- type BetaThinkingConfigParamUnion
- type BetaThinkingDelta
- type BetaToolBash20241022Param
- type BetaToolBash20250124Param
- type BetaToolChoiceAnyParam
- type BetaToolChoiceAutoParam
- type BetaToolChoiceNoneParam
- type BetaToolChoiceToolParam
- type BetaToolChoiceUnionParam
- func (u BetaToolChoiceUnionParam) GetDisableParallelToolUse() *bool
- func (u BetaToolChoiceUnionParam) GetName() *string
- func (u BetaToolChoiceUnionParam) GetType() *string
- func (u BetaToolChoiceUnionParam) MarshalJSON() ([]byte, error)
- func (u *BetaToolChoiceUnionParam) UnmarshalJSON(data []byte) error
- type BetaToolComputerUse20241022Param
- type BetaToolComputerUse20250124Param
- type BetaToolInputSchemaParam
- type BetaToolParam
- type BetaToolResultBlockParam
- type BetaToolResultBlockParamContentUnion
- func (u BetaToolResultBlockParamContentUnion) GetCacheControl() *BetaCacheControlEphemeralParam
- func (u BetaToolResultBlockParamContentUnion) GetCitations() []BetaTextCitationParamUnion
- func (u BetaToolResultBlockParamContentUnion) GetSource() *BetaImageBlockParamSourceUnion
- func (u BetaToolResultBlockParamContentUnion) GetText() *string
- func (u BetaToolResultBlockParamContentUnion) GetType() *string
- func (u BetaToolResultBlockParamContentUnion) MarshalJSON() ([]byte, error)
- func (u *BetaToolResultBlockParamContentUnion) UnmarshalJSON(data []byte) error
- type BetaToolTextEditor20241022Param
- type BetaToolTextEditor20250124Param
- type BetaToolTextEditor20250429Param
- type BetaToolType
- type BetaToolUnionParam
- func BetaToolUnionParamOfComputerUseTool20241022(displayHeightPx int64, displayWidthPx int64) BetaToolUnionParam
- func BetaToolUnionParamOfComputerUseTool20250124(displayHeightPx int64, displayWidthPx int64) BetaToolUnionParam
- func BetaToolUnionParamOfTool(inputSchema BetaToolInputSchemaParam, name string) BetaToolUnionParam
- func (u BetaToolUnionParam) GetAllowedDomains() []string
- func (u BetaToolUnionParam) GetBlockedDomains() []string
- func (u BetaToolUnionParam) GetCacheControl() *BetaCacheControlEphemeralParam
- func (u BetaToolUnionParam) GetDescription() *string
- func (u BetaToolUnionParam) GetDisplayHeightPx() *int64
- func (u BetaToolUnionParam) GetDisplayNumber() *int64
- func (u BetaToolUnionParam) GetDisplayWidthPx() *int64
- func (u BetaToolUnionParam) GetInputSchema() *BetaToolInputSchemaParam
- func (u BetaToolUnionParam) GetMaxUses() *int64
- func (u BetaToolUnionParam) GetName() *string
- func (u BetaToolUnionParam) GetType() *string
- func (u BetaToolUnionParam) GetUserLocation() *BetaWebSearchTool20250305UserLocationParam
- func (u BetaToolUnionParam) MarshalJSON() ([]byte, error)
- func (u *BetaToolUnionParam) UnmarshalJSON(data []byte) error
- type BetaToolUseBlock
- type BetaToolUseBlockParam
- type BetaURLImageSourceParam
- type BetaURLPDFSourceParam
- type BetaUsage
- type BetaUsageServiceTier
- type BetaWebSearchResultBlock
- type BetaWebSearchResultBlockParam
- type BetaWebSearchTool20250305Param
- type BetaWebSearchTool20250305UserLocationParam
- type BetaWebSearchToolRequestErrorParam
- type BetaWebSearchToolResultBlock
- type BetaWebSearchToolResultBlockContentUnion
- func (u BetaWebSearchToolResultBlockContentUnion) AsBetaWebSearchResultBlockArray() (v []BetaWebSearchResultBlock)
- func (u BetaWebSearchToolResultBlockContentUnion) AsResponseWebSearchToolResultError() (v BetaWebSearchToolResultError)
- func (u BetaWebSearchToolResultBlockContentUnion) RawJSON() string
- func (r *BetaWebSearchToolResultBlockContentUnion) UnmarshalJSON(data []byte) error
- type BetaWebSearchToolResultBlockParam
- type BetaWebSearchToolResultBlockParamContentUnion
- type BetaWebSearchToolResultError
- type BetaWebSearchToolResultErrorCode
- type BillingError
- type CacheControlEphemeralParam
- type CitationCharLocation
- type CitationCharLocationParam
- type CitationContentBlockLocation
- type CitationContentBlockLocationParam
- type CitationPageLocation
- type CitationPageLocationParam
- type CitationWebSearchResultLocationParam
- type CitationsConfigParam
- type CitationsDelta
- type CitationsDeltaCitationUnion
- func (u CitationsDeltaCitationUnion) AsAny() anyCitationsDeltaCitation
- func (u CitationsDeltaCitationUnion) AsCharLocation() (v CitationCharLocation)
- func (u CitationsDeltaCitationUnion) AsContentBlockLocation() (v CitationContentBlockLocation)
- func (u CitationsDeltaCitationUnion) AsPageLocation() (v CitationPageLocation)
- func (u CitationsDeltaCitationUnion) AsWebSearchResultLocation() (v CitationsWebSearchResultLocation)
- func (u CitationsDeltaCitationUnion) RawJSON() string
- func (r *CitationsDeltaCitationUnion) UnmarshalJSON(data []byte) error
- type CitationsWebSearchResultLocation
- type Client
- func (r *Client) Delete(ctx context.Context, path string, params any, res any, ...) error
- func (r *Client) Execute(ctx context.Context, method string, path string, params any, res any, ...) error
- func (r *Client) Get(ctx context.Context, path string, params any, res any, ...) error
- func (r *Client) Patch(ctx context.Context, path string, params any, res any, ...) error
- func (r *Client) Post(ctx context.Context, path string, params any, res any, ...) error
- func (r *Client) Put(ctx context.Context, path string, params any, res any, ...) error
- type Completion
- type CompletionNewParams
- type CompletionService
- type ContentBlockDeltaEvent
- type ContentBlockParamUnion
- func NewDocumentBlock[...](source T) ContentBlockParamUnion
- func NewImageBlock[T Base64ImageSourceParam | URLImageSourceParam](source T) ContentBlockParamUnion
- func NewImageBlockBase64(mediaType string, encodedData string) ContentBlockParamUnion
- func NewRedactedThinkingBlock(data string) ContentBlockParamUnion
- func NewServerToolUseBlock(id string, input any) ContentBlockParamUnion
- func NewTextBlock(text string) ContentBlockParamUnion
- func NewThinkingBlock(signature string, thinking string) ContentBlockParamUnion
- func NewToolResultBlock(toolUseID string, content string, isError bool) ContentBlockParamUnion
- func NewToolUseBlock(id string, input any, name string) ContentBlockParamUnion
- func NewWebSearchToolResultBlock[T []WebSearchResultBlockParam | WebSearchToolRequestErrorParam](content T, toolUseID string) ContentBlockParamUnion
- func (u ContentBlockParamUnion) GetCacheControl() *CacheControlEphemeralParam
- func (u ContentBlockParamUnion) GetCitations() (res contentBlockParamUnionCitations)
- func (u ContentBlockParamUnion) GetContent() (res contentBlockParamUnionContent)
- func (u ContentBlockParamUnion) GetContext() *string
- func (u ContentBlockParamUnion) GetData() *string
- func (u ContentBlockParamUnion) GetID() *string
- func (u ContentBlockParamUnion) GetInput() *any
- func (u ContentBlockParamUnion) GetIsError() *bool
- func (u ContentBlockParamUnion) GetName() *string
- func (u ContentBlockParamUnion) GetSignature() *string
- func (u ContentBlockParamUnion) GetSource() (res contentBlockParamUnionSource)
- func (u ContentBlockParamUnion) GetText() *string
- func (u ContentBlockParamUnion) GetThinking() *string
- func (u ContentBlockParamUnion) GetTitle() *string
- func (u ContentBlockParamUnion) GetToolUseID() *string
- func (u ContentBlockParamUnion) GetType() *string
- func (u ContentBlockParamUnion) MarshalJSON() ([]byte, error)
- func (u *ContentBlockParamUnion) UnmarshalJSON(data []byte) error
- type ContentBlockSourceContentUnionParam
- type ContentBlockSourceParam
- type ContentBlockStartEvent
- type ContentBlockStartEventContentBlockUnion
- func (u ContentBlockStartEventContentBlockUnion) AsAny() anyContentBlockStartEventContentBlock
- func (u ContentBlockStartEventContentBlockUnion) AsRedactedThinking() (v RedactedThinkingBlock)
- func (u ContentBlockStartEventContentBlockUnion) AsServerToolUse() (v ServerToolUseBlock)
- func (u ContentBlockStartEventContentBlockUnion) AsText() (v TextBlock)
- func (u ContentBlockStartEventContentBlockUnion) AsThinking() (v ThinkingBlock)
- func (u ContentBlockStartEventContentBlockUnion) AsToolUse() (v ToolUseBlock)
- func (u ContentBlockStartEventContentBlockUnion) AsWebSearchToolResult() (v WebSearchToolResultBlock)
- func (u ContentBlockStartEventContentBlockUnion) RawJSON() string
- func (r *ContentBlockStartEventContentBlockUnion) UnmarshalJSON(data []byte) error
- type ContentBlockStopEvent
- type ContentBlockUnion
- func (u ContentBlockUnion) AsAny() anyContentBlock
- func (u ContentBlockUnion) AsRedactedThinking() (v RedactedThinkingBlock)
- func (u ContentBlockUnion) AsServerToolUse() (v ServerToolUseBlock)
- func (u ContentBlockUnion) AsText() (v TextBlock)
- func (u ContentBlockUnion) AsThinking() (v ThinkingBlock)
- func (u ContentBlockUnion) AsToolUse() (v ToolUseBlock)
- func (u ContentBlockUnion) AsWebSearchToolResult() (v WebSearchToolResultBlock)
- func (u ContentBlockUnion) RawJSON() string
- func (r ContentBlockUnion) ToParam() ContentBlockParamUnion
- func (r *ContentBlockUnion) UnmarshalJSON(data []byte) error
- type DeletedFile
- type DeletedFileType
- type DeletedMessageBatch
- type DocumentBlockParam
- type DocumentBlockParamSourceUnion
- func (u DocumentBlockParamSourceUnion) GetContent() *ContentBlockSourceContentUnionParam
- func (u DocumentBlockParamSourceUnion) GetData() *string
- func (u DocumentBlockParamSourceUnion) GetMediaType() *string
- func (u DocumentBlockParamSourceUnion) GetType() *string
- func (u DocumentBlockParamSourceUnion) GetURL() *string
- func (u DocumentBlockParamSourceUnion) MarshalJSON() ([]byte, error)
- func (u *DocumentBlockParamSourceUnion) UnmarshalJSON(data []byte) error
- type Error
- type ErrorObjectUnion
- type ErrorResponse
- type FileMetadata
- type GatewayTimeoutError
- type ImageBlockParam
- type ImageBlockParamSourceUnion
- func (u ImageBlockParamSourceUnion) GetData() *string
- func (u ImageBlockParamSourceUnion) GetMediaType() *string
- func (u ImageBlockParamSourceUnion) GetType() *string
- func (u ImageBlockParamSourceUnion) GetURL() *string
- func (u ImageBlockParamSourceUnion) MarshalJSON() ([]byte, error)
- func (u *ImageBlockParamSourceUnion) UnmarshalJSON(data []byte) error
- type InputJSONDelta
- type InvalidRequestError
- type Message
- type MessageBatch
- type MessageBatchCanceledResult
- type MessageBatchErroredResult
- type MessageBatchExpiredResult
- type MessageBatchIndividualResponse
- type MessageBatchListParams
- type MessageBatchNewParams
- type MessageBatchNewParamsRequest
- type MessageBatchNewParamsRequestParams
- type MessageBatchProcessingStatus
- type MessageBatchRequestCounts
- type MessageBatchResultUnion
- func (u MessageBatchResultUnion) AsAny() anyMessageBatchResult
- func (u MessageBatchResultUnion) AsCanceled() (v MessageBatchCanceledResult)
- func (u MessageBatchResultUnion) AsErrored() (v MessageBatchErroredResult)
- func (u MessageBatchResultUnion) AsExpired() (v MessageBatchExpiredResult)
- func (u MessageBatchResultUnion) AsSucceeded() (v MessageBatchSucceededResult)
- func (u MessageBatchResultUnion) RawJSON() string
- func (r *MessageBatchResultUnion) UnmarshalJSON(data []byte) error
- type MessageBatchService
- func (r *MessageBatchService) Cancel(ctx context.Context, messageBatchID string, opts ...option.RequestOption) (res *MessageBatch, err error)
- func (r *MessageBatchService) Delete(ctx context.Context, messageBatchID string, opts ...option.RequestOption) (res *DeletedMessageBatch, err error)
- func (r *MessageBatchService) Get(ctx context.Context, messageBatchID string, opts ...option.RequestOption) (res *MessageBatch, err error)
- func (r *MessageBatchService) List(ctx context.Context, query MessageBatchListParams, ...) (res *pagination.Page[MessageBatch], err error)
- func (r *MessageBatchService) ListAutoPaging(ctx context.Context, query MessageBatchListParams, ...) *pagination.PageAutoPager[MessageBatch]
- func (r *MessageBatchService) New(ctx context.Context, body MessageBatchNewParams, opts ...option.RequestOption) (res *MessageBatch, err error)
- func (r *MessageBatchService) ResultsStreaming(ctx context.Context, messageBatchID string, opts ...option.RequestOption) (stream *jsonl.Stream[MessageBatchIndividualResponse])
- type MessageBatchSucceededResult
- type MessageCountTokensParams
- type MessageCountTokensParamsSystemUnion
- type MessageCountTokensToolUnionParam
- func (u MessageCountTokensToolUnionParam) GetAllowedDomains() []string
- func (u MessageCountTokensToolUnionParam) GetBlockedDomains() []string
- func (u MessageCountTokensToolUnionParam) GetCacheControl() *CacheControlEphemeralParam
- func (u MessageCountTokensToolUnionParam) GetDescription() *string
- func (u MessageCountTokensToolUnionParam) GetInputSchema() *ToolInputSchemaParam
- func (u MessageCountTokensToolUnionParam) GetMaxUses() *int64
- func (u MessageCountTokensToolUnionParam) GetName() *string
- func (u MessageCountTokensToolUnionParam) GetType() *string
- func (u MessageCountTokensToolUnionParam) GetUserLocation() *WebSearchTool20250305UserLocationParam
- func (u MessageCountTokensToolUnionParam) MarshalJSON() ([]byte, error)
- func (u *MessageCountTokensToolUnionParam) UnmarshalJSON(data []byte) error
- type MessageDeltaEvent
- type MessageDeltaEventDelta
- type MessageDeltaUsage
- type MessageNewParams
- type MessageNewParamsServiceTier
- type MessageParam
- type MessageParamRole
- type MessageService
- func (r *MessageService) CountTokens(ctx context.Context, body MessageCountTokensParams, ...) (res *MessageTokensCount, err error)
- func (r *MessageService) New(ctx context.Context, body MessageNewParams, opts ...option.RequestOption) (res *Message, err error)
- func (r *MessageService) NewStreaming(ctx context.Context, body MessageNewParams, opts ...option.RequestOption) (stream *ssestream.Stream[MessageStreamEventUnion])
- type MessageStartEvent
- type MessageStopEvent
- type MessageStopReason
- type MessageStreamEventUnion
- func (u MessageStreamEventUnion) AsAny() anyMessageStreamEvent
- func (u MessageStreamEventUnion) AsContentBlockDelta() (v ContentBlockDeltaEvent)
- func (u MessageStreamEventUnion) AsContentBlockStart() (v ContentBlockStartEvent)
- func (u MessageStreamEventUnion) AsContentBlockStop() (v ContentBlockStopEvent)
- func (u MessageStreamEventUnion) AsMessageDelta() (v MessageDeltaEvent)
- func (u MessageStreamEventUnion) AsMessageStart() (v MessageStartEvent)
- func (u MessageStreamEventUnion) AsMessageStop() (v MessageStopEvent)
- func (u MessageStreamEventUnion) RawJSON() string
- func (r *MessageStreamEventUnion) UnmarshalJSON(data []byte) error
- type MessageStreamEventUnionDelta
- type MessageTokensCount
- type MetadataParam
- type Model
- type ModelGetParams
- type ModelInfo
- type ModelListParams
- type ModelService
- func (r *ModelService) Get(ctx context.Context, modelID string, query ModelGetParams, ...) (res *ModelInfo, err error)
- func (r *ModelService) List(ctx context.Context, params ModelListParams, opts ...option.RequestOption) (res *pagination.Page[ModelInfo], err error)
- func (r *ModelService) ListAutoPaging(ctx context.Context, params ModelListParams, opts ...option.RequestOption) *pagination.PageAutoPager[ModelInfo]
- type NotFoundError
- type OverloadedError
- type PermissionError
- type PlainTextSourceParam
- type RateLimitError
- type RawContentBlockDeltaUnion
- func (u RawContentBlockDeltaUnion) AsAny() anyRawContentBlockDelta
- func (u RawContentBlockDeltaUnion) AsCitationsDelta() (v CitationsDelta)
- func (u RawContentBlockDeltaUnion) AsInputJSONDelta() (v InputJSONDelta)
- func (u RawContentBlockDeltaUnion) AsSignatureDelta() (v SignatureDelta)
- func (u RawContentBlockDeltaUnion) AsTextDelta() (v TextDelta)
- func (u RawContentBlockDeltaUnion) AsThinkingDelta() (v ThinkingDelta)
- func (u RawContentBlockDeltaUnion) RawJSON() string
- func (r *RawContentBlockDeltaUnion) UnmarshalJSON(data []byte) error
- type RedactedThinkingBlock
- type RedactedThinkingBlockParam
- type ServerToolUsage
- type ServerToolUseBlock
- type ServerToolUseBlockParam
- type SignatureDelta
- type StopReason
- type TextBlock
- type TextBlockParam
- type TextCitationParamUnion
- func (u TextCitationParamUnion) GetCitedText() *string
- func (u TextCitationParamUnion) GetDocumentIndex() *int64
- func (u TextCitationParamUnion) GetDocumentTitle() *string
- func (u TextCitationParamUnion) GetEncryptedIndex() *string
- func (u TextCitationParamUnion) GetEndBlockIndex() *int64
- func (u TextCitationParamUnion) GetEndCharIndex() *int64
- func (u TextCitationParamUnion) GetEndPageNumber() *int64
- func (u TextCitationParamUnion) GetStartBlockIndex() *int64
- func (u TextCitationParamUnion) GetStartCharIndex() *int64
- func (u TextCitationParamUnion) GetStartPageNumber() *int64
- func (u TextCitationParamUnion) GetTitle() *string
- func (u TextCitationParamUnion) GetType() *string
- func (u TextCitationParamUnion) GetURL() *string
- func (u TextCitationParamUnion) MarshalJSON() ([]byte, error)
- func (u *TextCitationParamUnion) UnmarshalJSON(data []byte) error
- type TextCitationUnion
- func (u TextCitationUnion) AsAny() anyTextCitation
- func (u TextCitationUnion) AsCharLocation() (v CitationCharLocation)
- func (u TextCitationUnion) AsContentBlockLocation() (v CitationContentBlockLocation)
- func (u TextCitationUnion) AsPageLocation() (v CitationPageLocation)
- func (u TextCitationUnion) AsWebSearchResultLocation() (v CitationsWebSearchResultLocation)
- func (u TextCitationUnion) RawJSON() string
- func (r *TextCitationUnion) UnmarshalJSON(data []byte) error
- type TextDelta
- type ThinkingBlock
- type ThinkingBlockParam
- type ThinkingConfigDisabledParam
- type ThinkingConfigEnabledParam
- type ThinkingConfigParamUnion
- type ThinkingDelta
- type ToolBash20250124Param
- type ToolChoiceAnyParam
- type ToolChoiceAutoParam
- type ToolChoiceNoneParam
- type ToolChoiceToolParam
- type ToolChoiceUnionParam
- type ToolInputSchemaParam
- type ToolParam
- type ToolResultBlockParam
- type ToolResultBlockParamContentUnion
- func (u ToolResultBlockParamContentUnion) GetCacheControl() *CacheControlEphemeralParam
- func (u ToolResultBlockParamContentUnion) GetCitations() []TextCitationParamUnion
- func (u ToolResultBlockParamContentUnion) GetSource() *ImageBlockParamSourceUnion
- func (u ToolResultBlockParamContentUnion) GetText() *string
- func (u ToolResultBlockParamContentUnion) GetType() *string
- func (u ToolResultBlockParamContentUnion) MarshalJSON() ([]byte, error)
- func (u *ToolResultBlockParamContentUnion) UnmarshalJSON(data []byte) error
- type ToolTextEditor20250124Param
- type ToolTextEditor20250429Param
- type ToolType
- type ToolUnionParam
- func (u ToolUnionParam) GetAllowedDomains() []string
- func (u ToolUnionParam) GetBlockedDomains() []string
- func (u ToolUnionParam) GetCacheControl() *CacheControlEphemeralParam
- func (u ToolUnionParam) GetDescription() *string
- func (u ToolUnionParam) GetInputSchema() *ToolInputSchemaParam
- func (u ToolUnionParam) GetMaxUses() *int64
- func (u ToolUnionParam) GetName() *string
- func (u ToolUnionParam) GetType() *string
- func (u ToolUnionParam) GetUserLocation() *WebSearchTool20250305UserLocationParam
- func (u ToolUnionParam) MarshalJSON() ([]byte, error)
- func (u *ToolUnionParam) UnmarshalJSON(data []byte) error
- type ToolUseBlock
- type ToolUseBlockParam
- type URLImageSourceParam
- type URLPDFSourceParam
- type Usage
- type UsageServiceTier
- type WebSearchResultBlock
- type WebSearchResultBlockParam
- type WebSearchTool20250305Param
- type WebSearchTool20250305UserLocationParam
- type WebSearchToolRequestErrorErrorCode
- type WebSearchToolRequestErrorParam
- type WebSearchToolResultBlock
- type WebSearchToolResultBlockContentUnion
- func (u WebSearchToolResultBlockContentUnion) AsResponseWebSearchToolResultError() (v WebSearchToolResultError)
- func (u WebSearchToolResultBlockContentUnion) AsWebSearchResultBlockArray() (v []WebSearchResultBlock)
- func (u WebSearchToolResultBlockContentUnion) RawJSON() string
- func (r *WebSearchToolResultBlockContentUnion) UnmarshalJSON(data []byte) error
- type WebSearchToolResultBlockParam
- type WebSearchToolResultBlockParamContentUnion
- type WebSearchToolResultError
- type WebSearchToolResultErrorErrorCode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculateNonStreamingTimeout ¶ added in v1.2.0
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 Opt ¶
func Opt[T comparable](v T) param.Opt[T]
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" 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" )
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 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 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 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 ¶
func (u BetaBase64PDFBlockSourceUnionParam) GetContent() *BetaContentBlockSourceContentUnionParam
Returns a pointer to the underlying variant's property, if present.
func (BetaBase64PDFBlockSourceUnionParam) GetData ¶
func (u BetaBase64PDFBlockSourceUnionParam) GetData() *string
Returns a pointer to the underlying variant's property, if present.
func (BetaBase64PDFBlockSourceUnionParam) GetFileID ¶ added in v1.2.0
func (u BetaBase64PDFBlockSourceUnionParam) GetFileID() *string
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 ¶
func (u BetaBase64PDFBlockSourceUnionParam) GetType() *string
Returns a pointer to the underlying variant's property, if present.
func (BetaBase64PDFBlockSourceUnionParam) GetURL ¶
func (u BetaBase64PDFBlockSourceUnionParam) GetURL() *string
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 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 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 ¶ added in v1.2.0
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 ¶ added in v1.2.0
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 ¶ added in v1.2.0
func (r BetaCacheCreation) RawJSON() string
Returns the unmodified JSON received from the API
func (*BetaCacheCreation) UnmarshalJSON ¶ added in v1.2.0
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"`
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
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 BetaCitationContentBlockLocation ¶
type BetaCitationContentBlockLocation struct {
CitedText string `json:"cited_text,required"`
DocumentIndex int64 `json:"document_index,required"`
DocumentTitle string `json:"document_title,required"`
EndBlockIndex int64 `json:"end_block_index,required"`
StartBlockIndex int64 `json:"start_block_index,required"`
Type constant.ContentBlockLocation `json:"type,required"`
// 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
StartBlockIndex respjson.Field
Type respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (BetaCitationContentBlockLocation) RawJSON ¶
func (r BetaCitationContentBlockLocation) RawJSON() string
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"`
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
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 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"`
// 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".
Type string `json:"type"`
// This field is from variant [BetaCitationPageLocation].
EndPageNumber int64 `json:"end_page_number"`
// This field is from variant [BetaCitationPageLocation].
StartPageNumber int64 `json:"start_page_number"`
// This field is from variant [BetaCitationContentBlockLocation].
EndBlockIndex int64 `json:"end_block_index"`
// This field is from variant [BetaCitationContentBlockLocation].
StartBlockIndex int64 `json:"start_block_index"`
// This field is from variant [BetaCitationsWebSearchResultLocation].
EncryptedIndex string `json:"encrypted_index"`
// This field is from variant [BetaCitationsWebSearchResultLocation].
Title string `json:"title"`
// This field is from variant [BetaCitationsWebSearchResultLocation].
URL string `json:"url"`
JSON struct {
CitedText respjson.Field
DocumentIndex respjson.Field
DocumentTitle respjson.Field
EndCharIndex 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
// contains filtered or unexported fields
} `json:"-"`
}
BetaCitationsDeltaCitationUnion contains all possible properties and values from BetaCitationCharLocation, BetaCitationPageLocation, BetaCitationContentBlockLocation, BetaCitationsWebSearchResultLocation.
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:
default:
fmt.Errorf("no variant present")
}
func (BetaCitationsDeltaCitationUnion) AsCharLocation ¶
func (u BetaCitationsDeltaCitationUnion) AsCharLocation() (v BetaCitationCharLocation)
func (BetaCitationsDeltaCitationUnion) AsContentBlockLocation ¶
func (u BetaCitationsDeltaCitationUnion) AsContentBlockLocation() (v BetaCitationContentBlockLocation)
func (BetaCitationsDeltaCitationUnion) AsPageLocation ¶
func (u BetaCitationsDeltaCitationUnion) AsPageLocation() (v BetaCitationPageLocation)
func (BetaCitationsDeltaCitationUnion) AsWebSearchResultLocation ¶
func (u BetaCitationsDeltaCitationUnion) AsWebSearchResultLocation() (v BetaCitationsWebSearchResultLocation)
func (BetaCitationsDeltaCitationUnion) RawJSON ¶
func (u BetaCitationsDeltaCitationUnion) RawJSON() string
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 ¶
func (r BetaCitationsWebSearchResultLocation) RawJSON() string
Returns the unmodified JSON received from the API
func (*BetaCitationsWebSearchResultLocation) UnmarshalJSON ¶
func (r *BetaCitationsWebSearchResultLocation) UnmarshalJSON(data []byte) error
type BetaCodeExecutionOutputBlock ¶ added in v1.2.0
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 ¶ added in v1.2.0
func (r BetaCodeExecutionOutputBlock) RawJSON() string
Returns the unmodified JSON received from the API
func (*BetaCodeExecutionOutputBlock) UnmarshalJSON ¶ added in v1.2.0
func (r *BetaCodeExecutionOutputBlock) UnmarshalJSON(data []byte) error
type BetaCodeExecutionOutputBlockParam ¶ added in v1.2.0
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 ¶ added in v1.2.0
func (r BetaCodeExecutionOutputBlockParam) MarshalJSON() (data []byte, err error)
func (*BetaCodeExecutionOutputBlockParam) UnmarshalJSON ¶ added in v1.2.0
func (r *BetaCodeExecutionOutputBlockParam) UnmarshalJSON(data []byte) error
type BetaCodeExecutionResultBlock ¶ added in v1.2.0
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 ¶ added in v1.2.0
func (r BetaCodeExecutionResultBlock) RawJSON() string
Returns the unmodified JSON received from the API
func (*BetaCodeExecutionResultBlock) UnmarshalJSON ¶ added in v1.2.0
func (r *BetaCodeExecutionResultBlock) UnmarshalJSON(data []byte) error
type BetaCodeExecutionResultBlockParam ¶ added in v1.2.0
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 ¶ added in v1.2.0
func (r BetaCodeExecutionResultBlockParam) MarshalJSON() (data []byte, err error)
func (*BetaCodeExecutionResultBlockParam) UnmarshalJSON ¶ added in v1.2.0
func (r *BetaCodeExecutionResultBlockParam) UnmarshalJSON(data []byte) error
type BetaCodeExecutionTool20250522Param ¶ added in v1.2.0
type BetaCodeExecutionTool20250522Param struct {
// 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 ¶ added in v1.2.0
func (r BetaCodeExecutionTool20250522Param) MarshalJSON() (data []byte, err error)
func (*BetaCodeExecutionTool20250522Param) UnmarshalJSON ¶ added in v1.2.0
func (r *BetaCodeExecutionTool20250522Param) UnmarshalJSON(data []byte) error
type BetaCodeExecutionToolResultBlock ¶ added in v1.2.0
type BetaCodeExecutionToolResultBlock struct {
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 ¶ added in v1.2.0
func (r BetaCodeExecutionToolResultBlock) RawJSON() string
Returns the unmodified JSON received from the API
func (*BetaCodeExecutionToolResultBlock) UnmarshalJSON ¶ added in v1.2.0
func (r *BetaCodeExecutionToolResultBlock) UnmarshalJSON(data []byte) error
type BetaCodeExecutionToolResultBlockContentUnion ¶ added in v1.2.0
type BetaCodeExecutionToolResultBlockContentUnion struct {
// This field is from variant [BetaCodeExecutionToolResultError].
ErrorCode BetaCodeExecutionToolResultErrorCode `json:"error_code"`
Type string `json:"type"`
// This field is from variant [BetaCodeExecutionResultBlock].
Content []BetaCodeExecutionOutputBlock `json:"content"`
// This field is from variant [BetaCodeExecutionResultBlock].
ReturnCode int64 `json:"return_code"`
// This field is from variant [BetaCodeExecutionResultBlock].
Stderr string `json:"stderr"`
// This field is from variant [BetaCodeExecutionResultBlock].
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:"-"`
}
BetaCodeExecutionToolResultBlockContentUnion contains all possible properties and values from BetaCodeExecutionToolResultError, BetaCodeExecutionResultBlock.
Use the methods beginning with 'As' to cast the union to one of its variants.
func (BetaCodeExecutionToolResultBlockContentUnion) AsResponseCodeExecutionResultBlock ¶ added in v1.2.0
func (u BetaCodeExecutionToolResultBlockContentUnion) AsResponseCodeExecutionResultBlock() (v BetaCodeExecutionResultBlock)
func (BetaCodeExecutionToolResultBlockContentUnion) AsResponseCodeExecutionToolResultError ¶ added in v1.2.0
func (u BetaCodeExecutionToolResultBlockContentUnion) AsResponseCodeExecutionToolResultError() (v BetaCodeExecutionToolResultError)
func (BetaCodeExecutionToolResultBlockContentUnion) RawJSON ¶ added in v1.2.0
func (u BetaCodeExecutionToolResultBlockContentUnion) RawJSON() string
Returns the unmodified JSON received from the API
func (*BetaCodeExecutionToolResultBlockContentUnion) UnmarshalJSON ¶ added in v1.2.0
func (r *BetaCodeExecutionToolResultBlockContentUnion) UnmarshalJSON(data []byte) error
type BetaCodeExecutionToolResultBlockParam ¶ added in v1.2.0
type BetaCodeExecutionToolResultBlockParam struct {
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 ¶ added in v1.2.0
func (r BetaCodeExecutionToolResultBlockParam) MarshalJSON() (data []byte, err error)
func (*BetaCodeExecutionToolResultBlockParam) UnmarshalJSON ¶ added in v1.2.0
func (r *BetaCodeExecutionToolResultBlockParam) UnmarshalJSON(data []byte) error
type BetaCodeExecutionToolResultBlockParamContentUnion ¶ added in v1.2.0
type BetaCodeExecutionToolResultBlockParamContentUnion struct {
OfError *BetaCodeExecutionToolResultErrorParam `json:",omitzero,inline"`
OfResultBlock *BetaCodeExecutionResultBlockParam `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 BetaNewCodeExecutionToolRequestError ¶ added in v1.2.0
func BetaNewCodeExecutionToolRequestError(errorCode BetaCodeExecutionToolResultErrorCode) BetaCodeExecutionToolResultBlockParamContentUnion
func (BetaCodeExecutionToolResultBlockParamContentUnion) GetContent ¶ added in v1.2.0
func (u BetaCodeExecutionToolResultBlockParamContentUnion) GetContent() []BetaCodeExecutionOutputBlockParam
Returns a pointer to the underlying variant's property, if present.
func (BetaCodeExecutionToolResultBlockParamContentUnion) GetErrorCode ¶ added in v1.2.0
func (u BetaCodeExecutionToolResultBlockParamContentUnion) GetErrorCode() *string
Returns a pointer to the underlying variant's property, if present.
func (BetaCodeExecutionToolResultBlockParamContentUnion) GetReturnCode ¶ added in v1.2.0
func (u BetaCodeExecutionToolResultBlockParamContentUnion) GetReturnCode() *int64
Returns a pointer to the underlying variant's property, if present.
func (BetaCodeExecutionToolResultBlockParamContentUnion) GetStderr ¶ added in v1.2.0
func (u BetaCodeExecutionToolResultBlockParamContentUnion) GetStderr() *string
Returns a pointer to the underlying variant's property, if present.
func (BetaCodeExecutionToolResultBlockParamContentUnion) GetStdout ¶ added in v1.2.0
func (u BetaCodeExecutionToolResultBlockParamContentUnion) GetStdout() *string
Returns a pointer to the underlying variant's property, if present.
func (BetaCodeExecutionToolResultBlockParamContentUnion) GetType ¶ added in v1.2.0
func (u BetaCodeExecutionToolResultBlockParamContentUnion) GetType() *string
Returns a pointer to the underlying variant's property, if present.
func (BetaCodeExecutionToolResultBlockParamContentUnion) MarshalJSON ¶ added in v1.2.0
func (u BetaCodeExecutionToolResultBlockParamContentUnion) MarshalJSON() ([]byte, error)
func (*BetaCodeExecutionToolResultBlockParamContentUnion) UnmarshalJSON ¶ added in v1.2.0
func (u *BetaCodeExecutionToolResultBlockParamContentUnion) UnmarshalJSON(data []byte) error
type BetaCodeExecutionToolResultError ¶ added in v1.2.0
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 ¶ added in v1.2.0
func (r BetaCodeExecutionToolResultError) RawJSON() string
Returns the unmodified JSON received from the API
func (*BetaCodeExecutionToolResultError) UnmarshalJSON ¶ added in v1.2.0
func (r *BetaCodeExecutionToolResultError) UnmarshalJSON(data []byte) error
type BetaCodeExecutionToolResultErrorCode ¶ added in v1.2.0
type BetaCodeExecutionToolResultErrorCode string
const ( BetaCodeExecutionToolResultErrorCodeInvalidToolInput BetaCodeExecutionToolResultErrorCode = "invalid_tool_input" BetaCodeExecutionToolResultErrorCodeTooManyRequests BetaCodeExecutionToolResultErrorCode = "too_many_requests" BetaCodeExecutionToolResultErrorCodeExecutionTimeExceeded BetaCodeExecutionToolResultErrorCode = "execution_time_exceeded" )
type BetaCodeExecutionToolResultErrorParam ¶ added in v1.2.0
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 ¶ added in v1.2.0
func (r BetaCodeExecutionToolResultErrorParam) MarshalJSON() (data []byte, err error)
func (*BetaCodeExecutionToolResultErrorParam) UnmarshalJSON ¶ added in v1.2.0
func (r *BetaCodeExecutionToolResultErrorParam) UnmarshalJSON(data []byte) error
type BetaContainer ¶ added in v1.2.0
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"`
// 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 (BetaContainer) RawJSON ¶ added in v1.2.0
func (r BetaContainer) RawJSON() string
Returns the unmodified JSON received from the API
func (*BetaContainer) UnmarshalJSON ¶ added in v1.2.0
func (r *BetaContainer) UnmarshalJSON(data []byte) error
type BetaContainerUploadBlock ¶ added in v1.2.0
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 ¶ added in v1.2.0
func (r BetaContainerUploadBlock) RawJSON() string
Returns the unmodified JSON received from the API
func (*BetaContainerUploadBlock) UnmarshalJSON ¶ added in v1.2.0
func (r *BetaContainerUploadBlock) UnmarshalJSON(data []byte) error
type BetaContainerUploadBlockParam ¶ added in v1.2.0
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 ¶ added in v1.2.0
func (r BetaContainerUploadBlockParam) MarshalJSON() (data []byte, err error)
func (*BetaContainerUploadBlockParam) UnmarshalJSON ¶ added in v1.2.0
func (r *BetaContainerUploadBlockParam) UnmarshalJSON(data []byte) error
type BetaContentBlockParamUnion ¶
type BetaContentBlockParamUnion struct {
OfServerToolUse *BetaServerToolUseBlockParam `json:",omitzero,inline"`
OfWebSearchToolResult *BetaWebSearchToolResultBlockParam `json:",omitzero,inline"`
OfCodeExecutionToolResult *BetaCodeExecutionToolResultBlockParam `json:",omitzero,inline"`
OfMCPToolUse *BetaMCPToolUseBlockParam `json:",omitzero,inline"`
OfMCPToolResult *BetaRequestMCPToolResultBlockParam `json:",omitzero,inline"`
OfText *BetaTextBlockParam `json:",omitzero,inline"`
OfImage *BetaImageBlockParam `json:",omitzero,inline"`
OfToolUse *BetaToolUseBlockParam `json:",omitzero,inline"`
OfToolResult *BetaToolResultBlockParam `json:",omitzero,inline"`
OfDocument *BetaBase64PDFBlockParam `json:",omitzero,inline"`
OfThinking *BetaThinkingBlockParam `json:",omitzero,inline"`
OfRedactedThinking *BetaRedactedThinkingBlockParam `json:",omitzero,inline"`
OfContainerUpload *BetaContainerUploadBlockParam `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 NewBetaCodeExecutionToolResultBlock ¶ added in v1.2.0
func NewBetaCodeExecutionToolResultBlock[ T BetaCodeExecutionToolResultErrorParam | BetaCodeExecutionResultBlockParam, ](content T, toolUseID string) BetaContentBlockParamUnion
func NewBetaContainerUploadBlock ¶ added in v1.2.0
func NewBetaContainerUploadBlock(fileID string) BetaContentBlockParamUnion
func NewBetaDocumentBlock ¶
func NewBetaDocumentBlock[ T BetaBase64PDFSourceParam | BetaPlainTextSourceParam | BetaContentBlockSourceParam | BetaURLPDFSourceParam | BetaFileDocumentSourceParam, ](source T) BetaContentBlockParamUnion
func NewBetaImageBlock ¶
func NewBetaImageBlock[ T BetaBase64ImageSourceParam | BetaURLImageSourceParam | BetaFileImageSourceParam, ](source T) BetaContentBlockParamUnion
func NewBetaMCPToolResultBlock ¶ added in v1.2.0
func NewBetaMCPToolResultBlock(toolUseID string) BetaContentBlockParamUnion
func NewBetaRedactedThinkingBlock ¶
func NewBetaRedactedThinkingBlock(data string) BetaContentBlockParamUnion
func NewBetaServerToolUseBlock ¶
func NewBetaServerToolUseBlock(id string, input any, name BetaServerToolUseBlockParamName) 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 NewBetaWebSearchToolResultBlock ¶
func NewBetaWebSearchToolResultBlock[ T []BetaWebSearchResultBlockParam | BetaWebSearchToolRequestErrorParam, ](content T, toolUseID string) BetaContentBlockParamUnion
func (BetaContentBlockParamUnion) GetCacheControl ¶
func (u BetaContentBlockParamUnion) GetCacheControl() *BetaCacheControlEphemeralParam
Returns a pointer to the underlying variant's CacheControl property, if present.
func (BetaContentBlockParamUnion) GetCitations ¶
func (u BetaContentBlockParamUnion) GetCitations() (res betaContentBlockParamUnionCitations)
Returns a subunion which exports methods to access subproperties
Or use AsAny() to get the underlying value
func (BetaContentBlockParamUnion) GetContent ¶
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 ¶ added in v1.2.0
func (u BetaContentBlockParamUnion) GetFileID() *string
Returns a pointer to the underlying variant's property, if present.
func (BetaContentBlockParamUnion) GetID ¶
func (u BetaContentBlockParamUnion) GetID() *string
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 ¶ added in v1.2.0
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", "tool_use", "server_tool_use", "web_search_tool_result",
// "code_execution_tool_result", "mcp_tool_use", "mcp_tool_result",
// "container_upload", "thinking", "redacted_thinking".
Type string `json:"type"`
ID string `json:"id"`
Input json.RawMessage `json:"input"`
Name string `json:"name"`
// This field is a union of [BetaWebSearchToolResultBlockContentUnion],
// [BetaCodeExecutionToolResultBlockContentUnion],
// [BetaMCPToolResultBlockContentUnion]
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"`
// This field is from variant [BetaThinkingBlock].
Signature string `json:"signature"`
// This field is from variant [BetaThinkingBlock].
Thinking string `json:"thinking"`
// This field is from variant [BetaRedactedThinkingBlock].
Data string `json:"data"`
JSON struct {
Citations respjson.Field
Text respjson.Field
Type respjson.Field
ID respjson.Field
Input respjson.Field
Name respjson.Field
Content respjson.Field
ToolUseID respjson.Field
ServerName respjson.Field
IsError respjson.Field
FileID respjson.Field
Signature respjson.Field
Thinking respjson.Field
Data respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
BetaContentBlockUnion contains all possible properties and values from BetaTextBlock, BetaToolUseBlock, BetaServerToolUseBlock, BetaWebSearchToolResultBlock, BetaCodeExecutionToolResultBlock, BetaMCPToolUseBlock, BetaMCPToolResultBlock, BetaContainerUploadBlock, BetaThinkingBlock, BetaRedactedThinkingBlock.
Use the BetaContentBlockUnion.AsAny method to switch on the variant.
Use the methods beginning with 'As' to cast the union to one of its variants.
func (BetaContentBlockUnion) AsAny ¶
func (u BetaContentBlockUnion) AsAny() anyBetaContentBlock
Use the following switch statement to find the correct variant
switch variant := BetaContentBlockUnion.AsAny().(type) {
case anthropic.BetaTextBlock:
case anthropic.BetaToolUseBlock:
case anthropic.BetaServerToolUseBlock:
case anthropic.BetaWebSearchToolResultBlock:
case anthropic.BetaCodeExecutionToolResultBlock:
case anthropic.BetaMCPToolUseBlock:
case anthropic.BetaMCPToolResultBlock:
case anthropic.BetaContainerUploadBlock:
case anthropic.BetaThinkingBlock:
case anthropic.BetaRedactedThinkingBlock:
default:
fmt.Errorf("no variant present")
}
func (BetaContentBlockUnion) AsCodeExecutionToolResult ¶ added in v1.2.0
func (u BetaContentBlockUnion) AsCodeExecutionToolResult() (v BetaCodeExecutionToolResultBlock)
func (BetaContentBlockUnion) AsContainerUpload ¶ added in v1.2.0
func (u BetaContentBlockUnion) AsContainerUpload() (v BetaContainerUploadBlock)
func (BetaContentBlockUnion) AsMCPToolResult ¶ added in v1.2.0
func (u BetaContentBlockUnion) AsMCPToolResult() (v BetaMCPToolResultBlock)
func (BetaContentBlockUnion) AsMCPToolUse ¶ added in v1.2.0
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) AsThinking ¶
func (u BetaContentBlockUnion) AsThinking() (v BetaThinkingBlock)
func (BetaContentBlockUnion) AsToolUse ¶
func (u BetaContentBlockUnion) AsToolUse() (v BetaToolUseBlock)
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 (r BetaContentBlockUnion) ToParam() BetaContentBlockParamUnion
func (*BetaContentBlockUnion) UnmarshalJSON ¶
func (r *BetaContentBlockUnion) UnmarshalJSON(data []byte) error
type BetaContentBlockUnionContent ¶ added in v1.2.0
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 from variant [BetaCodeExecutionToolResultBlockContentUnion].
Content []BetaCodeExecutionOutputBlock `json:"content"`
// This field is from variant [BetaCodeExecutionToolResultBlockContentUnion].
ReturnCode int64 `json:"return_code"`
// This field is from variant [BetaCodeExecutionToolResultBlockContentUnion].
Stderr string `json:"stderr"`
// This field is from variant [BetaCodeExecutionToolResultBlockContentUnion].
Stdout string `json:"stdout"`
JSON struct {
OfBetaWebSearchResultBlockArray respjson.Field
OfString respjson.Field
OfBetaMCPToolResultBlockContent respjson.Field
ErrorCode respjson.Field
Type respjson.Field
Content respjson.Field
ReturnCode respjson.Field
Stderr respjson.Field
Stdout 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 ¶ added in v1.2.0
func (r *BetaContentBlockUnionContent) 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 BetaErrorResponse ¶
type BetaErrorResponse struct {
Error BetaErrorUnion `json:"error,required"`
Type constant.Error `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 (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 ¶ added in v1.2.0
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 ¶ added in v1.2.0
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 ¶ added in v1.2.0
func (r BetaFileDocumentSourceParam) MarshalJSON() (data []byte, err error)
func (*BetaFileDocumentSourceParam) UnmarshalJSON ¶ added in v1.2.0
func (r *BetaFileDocumentSourceParam) UnmarshalJSON(data []byte) error
type BetaFileDownloadParams ¶ added in v1.2.0
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 ¶ added in v1.2.0
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 ¶ added in v1.2.0
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 ¶ added in v1.2.0
func (r BetaFileImageSourceParam) MarshalJSON() (data []byte, err error)
func (*BetaFileImageSourceParam) UnmarshalJSON ¶ added in v1.2.0
func (r *BetaFileImageSourceParam) UnmarshalJSON(data []byte) error
type BetaFileListParams ¶ added in v1.2.0
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 ¶ added in v1.2.0
func (r BetaFileListParams) URLQuery() (v url.Values, err error)
URLQuery serializes BetaFileListParams's query parameters as `url.Values`.
type BetaFileService ¶ added in v1.2.0
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 ¶ added in v1.2.0
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 ¶ added in v1.2.0
func (r *BetaFileService) Delete(ctx context.Context, fileID string, body BetaFileDeleteParams, opts ...option.RequestOption) (res *DeletedFile, err error)
Delete File
func (*BetaFileService) Download ¶ added in v1.2.0
func (r *BetaFileService) Download(ctx context.Context, fileID string, query BetaFileDownloadParams, opts ...option.RequestOption) (res *http.Response, err error)
Download File
func (*BetaFileService) GetMetadata ¶ added in v1.2.0
func (r *BetaFileService) GetMetadata(ctx context.Context, fileID string, query BetaFileGetMetadataParams, opts ...option.RequestOption) (res *FileMetadata, err error)
Get File Metadata
func (*BetaFileService) List ¶ added in v1.2.0
func (r *BetaFileService) List(ctx context.Context, params BetaFileListParams, opts ...option.RequestOption) (res *pagination.Page[FileMetadata], err error)
List Files
func (*BetaFileService) ListAutoPaging ¶ added in v1.2.0
func (r *BetaFileService) ListAutoPaging(ctx context.Context, params BetaFileListParams, opts ...option.RequestOption) *pagination.PageAutoPager[FileMetadata]
List Files
func (*BetaFileService) Upload ¶ added in v1.2.0
func (r *BetaFileService) Upload(ctx context.Context, params BetaFileUploadParams, opts ...option.RequestOption) (res *FileMetadata, err error)
Upload File
type BetaFileUploadParams ¶ added in v1.2.0
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 ¶ added in v1.2.0
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 ¶
func (u BetaImageBlockParamSourceUnion) GetData() *string
Returns a pointer to the underlying variant's property, if present.
func (BetaImageBlockParamSourceUnion) GetFileID ¶ added in v1.2.0
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 ¶
func (u BetaImageBlockParamSourceUnion) GetType() *string
Returns a pointer to the underlying variant's property, if present.
func (BetaImageBlockParamSourceUnion) GetURL ¶
func (u BetaImageBlockParamSourceUnion) GetURL() *string
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 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 BetaMCPToolResultBlock ¶ added in v1.2.0
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 ¶ added in v1.2.0
func (r BetaMCPToolResultBlock) RawJSON() string
Returns the unmodified JSON received from the API
func (*BetaMCPToolResultBlock) UnmarshalJSON ¶ added in v1.2.0
func (r *BetaMCPToolResultBlock) UnmarshalJSON(data []byte) error
type BetaMCPToolResultBlockContentUnion ¶ added in v1.2.0
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 ¶ added in v1.2.0
func (u BetaMCPToolResultBlockContentUnion) AsBetaMCPToolResultBlockContent() (v []BetaTextBlock)
func (BetaMCPToolResultBlockContentUnion) AsString ¶ added in v1.2.0
func (u BetaMCPToolResultBlockContentUnion) AsString() (v string)
func (BetaMCPToolResultBlockContentUnion) RawJSON ¶ added in v1.2.0
func (u BetaMCPToolResultBlockContentUnion) RawJSON() string
Returns the unmodified JSON received from the API
func (*BetaMCPToolResultBlockContentUnion) UnmarshalJSON ¶ added in v1.2.0
func (r *BetaMCPToolResultBlockContentUnion) UnmarshalJSON(data []byte) error
type BetaMCPToolUseBlock ¶ added in v1.2.0
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 ¶ added in v1.2.0
func (r BetaMCPToolUseBlock) RawJSON() string
Returns the unmodified JSON received from the API
func (*BetaMCPToolUseBlock) UnmarshalJSON ¶ added in v1.2.0
func (r *BetaMCPToolUseBlock) UnmarshalJSON(data []byte) error
type BetaMCPToolUseBlockParam ¶ added in v1.2.0
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 ¶ added in v1.2.0
func (r BetaMCPToolUseBlockParam) MarshalJSON() (data []byte, err error)
func (*BetaMCPToolUseBlockParam) UnmarshalJSON ¶ added in v1.2.0
func (r *BetaMCPToolUseBlockParam) 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"`
// The model that will complete your prompt.\n\nSee
// [models](https://docs.anthropic.com/en/docs/models-overview) for additional
// details and options.
Model Model `json:"model,required"`
// Conversational role of the generated message.
//
// This will always be `"assistant"`.
Role constant.Assistant `json:"role,required"`
// The reason that we stopped.
//
// This may be one the following values:
//
// - `"end_turn"`: the model reached a natural stopping point
// - `"max_tokens"`: we exceeded the requested `max_tokens` or the model's maximum
// - `"stop_sequence"`: one of your provided custom `stop_sequences` was generated
// - `"tool_use"`: the model invoked one or more tools
//
// In non-streaming mode this value is always non-null. In streaming mode, it is
// null in the `message_start` event and non-null otherwise.
//
// Any of "end_turn", "max_tokens", "stop_sequence", "tool_use", "pause_turn",
// "refusal".
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
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 ¶ added in v1.2.1
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 ¶
func (r BetaMessageBatchCanceledResult) RawJSON() string
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 ¶
func (r BetaMessageBatchErroredResult) RawJSON() string
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 ¶
func (r BetaMessageBatchExpiredResult) RawJSON() string
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 ¶
func (r BetaMessageBatchIndividualResponse) RawJSON() string
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](/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.anthropic.com/en/docs/models-overview) for details.
MaxTokens int64 `json:"max_tokens,required"`
// Input messages.
//
// Our models are trained to operate on alternating `user` and `assistant`
// conversational turns. When creating a new `Message`, you specify the prior
// conversational turns with the `messages` parameter, and the model then generates
// the next `Message` in the conversation. Consecutive `user` or `assistant` turns
// in your request will be combined into a single turn.
//
// Each input message must be an object with a `role` and `content`. You can
// specify a single `user`-role message, or you can include multiple `user` and
// `assistant` messages.
//
// If the final message uses the `assistant` role, the response content will
// continue immediately from the content in that message. This can be used to
// constrain part of the model's response.
//
// Example with a single `user` message:
//
// “`json
// [{ "role": "user", "content": "Hello, Claude" }]
// “`
//
// Example with multiple conversational turns:
//
// “`json
// [
//
// { "role": "user", "content": "Hello there." },
// { "role": "assistant", "content": "Hi, I'm Claude. How can I help you?" },
// { "role": "user", "content": "Can you explain LLMs in plain English?" }
//
// ]
// “`
//
// Example with a partially-filled response from Claude:
//
// “`json
// [
//
// {
// "role": "user",
// "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"
// },
// { "role": "assistant", "content": "The best answer is (" }
//
// ]
// “`
//
// Each input message `content` may be either a single `string` or an array of
// content blocks, where each block has a specific `type`. Using a `string` for
// `content` is shorthand for an array of one content block of type `"text"`. The
// following input messages are equivalent:
//
// “`json
// { "role": "user", "content": "Hello, Claude" }
// “`
//
// “`json
// { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
// “`
//
// Starting with Claude 3 models, you can also send image content blocks:
//
// “`json
//
// {
// "role": "user",
// "content": [
// {
// "type": "image",
// "source": {
// "type": "base64",
// "media_type": "image/jpeg",
// "data": "/9j/4AAQSkZJRg..."
// }
// },
// { "type": "text", "text": "What is in this image?" }
// ]
// }
//
// “`
//
// We currently support the `base64` source type for images, and the `image/jpeg`,
// `image/png`, `image/gif`, and `image/webp` media types.
//
// See [examples](https://docs.anthropic.com/en/api/messages-examples#vision) for
// more input examples.
//
// Note that if you want to include a
// [system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
// the top-level `system` parameter — there is no `"system"` role for input
// messages in the Messages API.
//
// There is a limit of 100000 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"`
// Container identifier for reuse across requests.
Container param.Opt[string] `json:"container,omitzero"`
// Whether to incrementally stream the response using server-sent events.
//
// See [streaming](https://docs.anthropic.com/en/api/messages-streaming) for
// details.
Stream param.Opt[bool] `json:"stream,omitzero"`
// Amount of randomness injected into the response.
//
// Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0`
// for analytical / multiple choice, and closer to `1.0` for creative and
// generative tasks.
//
// Note that even with `temperature` of `0.0`, the results will not be fully
// deterministic.
Temperature param.Opt[float64] `json:"temperature,omitzero"`
// Only sample from the top K options for each subsequent token.
//
// Used to remove "long tail" low probability responses.
// [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).
//
// Recommended for advanced use cases only. You usually only need to use
// `temperature`.
TopK param.Opt[int64] `json:"top_k,omitzero"`
// Use nucleus sampling.
//
// In nucleus sampling, we compute the cumulative distribution over all the options
// for each subsequent token in decreasing probability order and cut it off once it
// reaches a particular probability specified by `top_p`. You should either alter
// `temperature` or `top_p`, but not both.
//
// Recommended for advanced use cases only. You usually only need to use
// `temperature`.
TopP param.Opt[float64] `json:"top_p,omitzero"`
// 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"`
// 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.anthropic.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.anthropic.com/en/docs/system-prompts).
System []BetaTextBlockParam `json:"system,omitzero"`
// Configuration for enabling Claude's extended thinking.
//
// When enabled, responses include `thinking` content blocks showing Claude's
// thinking process before the final answer. Requires a minimum budget of 1,024
// tokens and counts towards your `max_tokens` limit.
//
// See
// [extended thinking](https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking)
// for details.
Thinking BetaThinkingConfigParamUnion `json:"thinking,omitzero"`
// How the model should use the provided tools. The model can use a specific tool,
// any available tool, decide by itself, or not use tools at all.
ToolChoice BetaToolChoiceUnionParam `json:"tool_choice,omitzero"`
// Definitions of tools that the model may use.
//
// If you include `tools` in your API request, the model may return `tool_use`
// content blocks that represent the model's use of those tools. You can then run
// those tools using the tool input generated by the model and then optionally
// return results back to the model using `tool_result` content blocks.
//
// Each tool definition includes:
//
// - `name`: Name of the tool.
// - `description`: Optional, but strongly-recommended description of the tool.
// - `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the
// tool `input` shape that the model will produce in `tool_use` output content
// blocks.
//
// For example, if you defined `tools` as:
//
// “`json
// [
//
// {
// "name": "get_stock_price",
// "description": "Get the current stock price for a given ticker symbol.",
// "input_schema": {
// "type": "object",
// "properties": {
// "ticker": {
// "type": "string",
// "description": "The stock ticker symbol, e.g. AAPL for Apple Inc."
// }
// },
// "required": ["ticker"]
// }
// }
//
// ]
// “`
//
// And then asked the model "What's the S&P 500 at today?", the model might produce
// `tool_use` content blocks in the response like this:
//
// “`json
// [
//
// {
// "type": "tool_use",
// "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
// "name": "get_stock_price",
// "input": { "ticker": "^GSPC" }
// }
//
// ]
// “`
//
// You might then run your `get_stock_price` tool with `{"ticker": "^GSPC"}` as an
// input, and return the following back to the model in a subsequent `user`
// message:
//
// “`json
// [
//
// {
// "type": "tool_result",
// "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
// "content": "259.75 USD"
// }
//
// ]
// “`
//
// Tools can be used for workflows that include running client-side tools and
// functions, or more generally whenever you want the model to produce a particular
// JSON structure of output.
//
// See our [guide](https://docs.anthropic.com/en/docs/tool-use) for more details.
Tools []BetaToolUnionParam `json:"tools,omitzero"`
// contains filtered or unexported fields
}
Messages API creation parameters for the individual request.
See the [Messages API reference](/en/api/messages) for full documentation on available parameters.
The properties MaxTokens, Messages, Model are required.
func (BetaMessageBatchNewParamsRequestParams) MarshalJSON ¶
func (r BetaMessageBatchNewParamsRequestParams) MarshalJSON() (data []byte, err error)
func (*BetaMessageBatchNewParamsRequestParams) UnmarshalJSON ¶
func (r *BetaMessageBatchNewParamsRequestParams) UnmarshalJSON(data []byte) error
type BetaMessageBatchProcessingStatus ¶
type BetaMessageBatchProcessingStatus string
Processing status of the Message Batch.
const ( BetaMessageBatchProcessingStatusInProgress BetaMessageBatchProcessingStatus = "in_progress" BetaMessageBatchProcessingStatusCanceling BetaMessageBatchProcessingStatus = "canceling" BetaMessageBatchProcessingStatusEnded BetaMessageBatchProcessingStatus = "ended" )
type BetaMessageBatchRequestCounts ¶
type BetaMessageBatchRequestCounts struct {
// Number of requests in the Message Batch that have been canceled.
//
// This is zero until processing of the entire Message Batch has ended.
Canceled int64 `json:"canceled,required"`
// Number of requests in the Message Batch that encountered an error.
//
// This is zero until processing of the entire Message Batch has ended.
Errored int64 `json:"errored,required"`
// Number of requests in the Message Batch that have expired.
//
// This is zero until processing of the entire Message Batch has ended.
Expired int64 `json:"expired,required"`
// Number of requests in the Message Batch that are processing.
Processing int64 `json:"processing,required"`
// Number of requests in the Message Batch that have completed successfully.
//
// This is zero until processing of the entire Message Batch has ended.
Succeeded int64 `json:"succeeded,required"`
// 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 ¶
func (r BetaMessageBatchRequestCounts) RawJSON() string
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 (u BetaMessageBatchResultUnion) AsCanceled() (v BetaMessageBatchCanceledResult)
func (BetaMessageBatchResultUnion) AsErrored ¶
func (u BetaMessageBatchResultUnion) AsErrored() (v BetaMessageBatchErroredResult)
func (BetaMessageBatchResultUnion) AsExpired ¶
func (u BetaMessageBatchResultUnion) AsExpired() (v BetaMessageBatchExpiredResult)
func (BetaMessageBatchResultUnion) AsSucceeded ¶
func (u BetaMessageBatchResultUnion) AsSucceeded() (v BetaMessageBatchSucceededResult)
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](/en/docs/build-with-claude/batch-processing)
func (*BetaMessageBatchService) Delete ¶
func (r *BetaMessageBatchService) Delete(ctx context.Context, messageBatchID string, body BetaMessageBatchDeleteParams, opts ...option.RequestOption) (res *BetaDeletedMessageBatch, err error)
Delete a Message Batch.
Message Batches can only be deleted once they've finished processing. If you'd like to delete an in-progress batch, you must first cancel it.
Learn more about the Message Batches API in our [user guide](/en/docs/build-with-claude/batch-processing)
func (*BetaMessageBatchService) Get ¶
func (r *BetaMessageBatchService) Get(ctx context.Context, messageBatchID string, query BetaMessageBatchGetParams, opts ...option.RequestOption) (res *BetaMessageBatch, err error)
This endpoint is idempotent and can be used to poll for Message Batch completion. To access the results of a Message Batch, make a request to the `results_url` field in the response.
Learn more about the Message Batches API in our [user guide](/en/docs/build-with-claude/batch-processing)
func (*BetaMessageBatchService) List ¶
func (r *BetaMessageBatchService) List(ctx context.Context, params BetaMessageBatchListParams, opts ...option.RequestOption) (res *pagination.Page[BetaMessageBatch], err error)
List all Message Batches within a Workspace. Most recently created batches are returned first.
Learn more about the Message Batches API in our [user guide](/en/docs/build-with-claude/batch-processing)
func (*BetaMessageBatchService) ListAutoPaging ¶
func (r *BetaMessageBatchService) ListAutoPaging(ctx context.Context, params BetaMessageBatchListParams, opts ...option.RequestOption) *pagination.PageAutoPager[BetaMessageBatch]
List all Message Batches within a Workspace. Most recently created batches are returned first.
Learn more about the Message Batches API in our [user guide](/en/docs/build-with-claude/batch-processing)
func (*BetaMessageBatchService) New ¶
func (r *BetaMessageBatchService) New(ctx context.Context, params BetaMessageBatchNewParams, opts ...option.RequestOption) (res *BetaMessageBatch, err error)
Send a batch of Message creation requests.
The Message Batches API can be used to process multiple Messages API requests at once. Once a Message Batch is created, it begins processing immediately. Batches can take up to 24 hours to complete.
Learn more about the Message Batches API in our [user guide](/en/docs/build-with-claude/batch-processing)
func (*BetaMessageBatchService) ResultsStreaming ¶
func (r *BetaMessageBatchService) ResultsStreaming(ctx context.Context, messageBatchID string, query BetaMessageBatchResultsParams, opts ...option.RequestOption) (stream *jsonl.Stream[BetaMessageBatchIndividualResponse])
Streams the results of a Message Batch as a `.jsonl` file.
Each line in the file is a JSON object containing the result of a single request in the Message Batch. Results are not guaranteed to be in the same order as requests. Use the `custom_id` field to match results to requests.
Learn more about the Message Batches API in our [user guide](/en/docs/build-with-claude/batch-processing)
type BetaMessageBatchSucceededResult ¶
type BetaMessageBatchSucceededResult struct {
Message BetaMessage `json:"message,required"`
Type constant.Succeeded `json:"type,required"`
// 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 ¶
func (r BetaMessageBatchSucceededResult) RawJSON() string
Returns the unmodified JSON received from the API
func (*BetaMessageBatchSucceededResult) UnmarshalJSON ¶
func (r *BetaMessageBatchSucceededResult) UnmarshalJSON(data []byte) error
type BetaMessageCountTokensParams ¶
type BetaMessageCountTokensParams struct {
// Input messages.
//
// Our models are trained to operate on alternating `user` and `assistant`
// conversational turns. When creating a new `Message`, you specify the prior
// conversational turns with the `messages` parameter, and the model then generates
// the next `Message` in the conversation. Consecutive `user` or `assistant` turns
// in your request will be combined into a single turn.
//
// Each input message must be an object with a `role` and `content`. You can
// specify a single `user`-role message, or you can include multiple `user` and
// `assistant` messages.
//
// If the final message uses the `assistant` role, the response content will
// continue immediately from the content in that message. This can be used to
// constrain part of the model's response.
//
// Example with a single `user` message:
//
// “`json
// [{ "role": "user", "content": "Hello, Claude" }]
// “`
//
// Example with multiple conversational turns:
//
// “`json
// [
//
// { "role": "user", "content": "Hello there." },
// { "role": "assistant", "content": "Hi, I'm Claude. How can I help you?" },
// { "role": "user", "content": "Can you explain LLMs in plain English?" }
//
// ]
// “`
//
// Example with a partially-filled response from Claude:
//
// “`json
// [
//
// {
// "role": "user",
// "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"
// },
// { "role": "assistant", "content": "The best answer is (" }
//
// ]
// “`
//
// Each input message `content` may be either a single `string` or an array of
// content blocks, where each block has a specific `type`. Using a `string` for
// `content` is shorthand for an array of one content block of type `"text"`. The
// following input messages are equivalent:
//
// “`json
// { "role": "user", "content": "Hello, Claude" }
// “`
//
// “`json
// { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
// “`
//
// Starting with Claude 3 models, you can also send image content blocks:
//
// “`json
//
// {
// "role": "user",
// "content": [
// {
// "type": "image",
// "source": {
// "type": "base64",
// "media_type": "image/jpeg",
// "data": "/9j/4AAQSkZJRg..."
// }
// },
// { "type": "text", "text": "What is in this image?" }
// ]
// }
//
// “`
//
// We currently support the `base64` source type for images, and the `image/jpeg`,
// `image/png`, `image/gif`, and `image/webp` media types.
//
// See [examples](https://docs.anthropic.com/en/api/messages-examples#vision) for
// more input examples.
//
// Note that if you want to include a
// [system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
// the top-level `system` parameter — there is no `"system"` role for input
// messages in the Messages API.
//
// There is a limit of 100000 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"`
// MCP servers to be utilized in this request
MCPServers []BetaRequestMCPServerURLDefinitionParam `json:"mcp_servers,omitzero"`
// System prompt.
//
// A system prompt is a way of providing context and instructions to Claude, such
// as specifying a particular goal or role. See our
// [guide to system prompts](https://docs.anthropic.com/en/docs/system-prompts).
System BetaMessageCountTokensParamsSystemUnion `json:"system,omitzero"`
// Configuration for enabling Claude's extended thinking.
//
// When enabled, responses include `thinking` content blocks showing Claude's
// thinking process before the final answer. Requires a minimum budget of 1,024
// tokens and counts towards your `max_tokens` limit.
//
// See
// [extended thinking](https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking)
// for details.
Thinking BetaThinkingConfigParamUnion `json:"thinking,omitzero"`
// How the model should use the provided tools. The model can use a specific tool,
// any available tool, decide by itself, or not use tools at all.
ToolChoice BetaToolChoiceUnionParam `json:"tool_choice,omitzero"`
// Definitions of tools that the model may use.
//
// If you include `tools` in your API request, the model may return `tool_use`
// content blocks that represent the model's use of those tools. You can then run
// those tools using the tool input generated by the model and then optionally
// return results back to the model using `tool_result` content blocks.
//
// Each tool definition includes:
//
// - `name`: Name of the tool.
// - `description`: Optional, but strongly-recommended description of the tool.
// - `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the
// tool `input` shape that the model will produce in `tool_use` output content
// blocks.
//
// For example, if you defined `tools` as:
//
// “`json
// [
//
// {
// "name": "get_stock_price",
// "description": "Get the current stock price for a given ticker symbol.",
// "input_schema": {
// "type": "object",
// "properties": {
// "ticker": {
// "type": "string",
// "description": "The stock ticker symbol, e.g. AAPL for Apple Inc."
// }
// },
// "required": ["ticker"]
// }
// }
//
// ]
// “`
//
// And then asked the model "What's the S&P 500 at today?", the model might produce
// `tool_use` content blocks in the response like this:
//
// “`json
// [
//
// {
// "type": "tool_use",
// "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
// "name": "get_stock_price",
// "input": { "ticker": "^GSPC" }
// }
//
// ]
// “`
//
// You might then run your `get_stock_price` tool with `{"ticker": "^GSPC"}` as an
// input, and return the following back to the model in a subsequent `user`
// message:
//
// “`json
// [
//
// {
// "type": "tool_result",
// "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
// "content": "259.75 USD"
// }
//
// ]
// “`
//
// Tools can be used for workflows that include running client-side tools and
// functions, or more generally whenever you want the model to produce a particular
// JSON structure of output.
//
// See our [guide](https://docs.anthropic.com/en/docs/tool-use) for more details.
Tools []BetaMessageCountTokensParamsToolUnion `json:"tools,omitzero"`
// Optional header to specify the beta version(s) you want to use.
Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"`
// contains filtered or unexported fields
}
func (BetaMessageCountTokensParams) MarshalJSON ¶
func (r BetaMessageCountTokensParams) MarshalJSON() (data []byte, err error)
func (*BetaMessageCountTokensParams) UnmarshalJSON ¶
func (r *BetaMessageCountTokensParams) UnmarshalJSON(data []byte) error
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"`
OfComputerUseTool20241022 *BetaToolComputerUse20241022Param `json:",omitzero,inline"`
OfBashTool20241022 *BetaToolBash20241022Param `json:",omitzero,inline"`
OfTextEditor20241022 *BetaToolTextEditor20241022Param `json:",omitzero,inline"`
OfComputerUseTool20250124 *BetaToolComputerUse20250124Param `json:",omitzero,inline"`
OfBashTool20250124 *BetaToolBash20250124Param `json:",omitzero,inline"`
OfTextEditor20250124 *BetaToolTextEditor20250124Param `json:",omitzero,inline"`
OfTextEditor20250429 *BetaToolTextEditor20250429Param `json:",omitzero,inline"`
OfWebSearchTool20250305 *BetaWebSearchTool20250305Param `json:",omitzero,inline"`
OfCodeExecutionTool20250522 *BetaCodeExecutionTool20250522Param `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) GetAllowedDomains ¶
func (u BetaMessageCountTokensParamsToolUnion) GetAllowedDomains() []string
Returns a pointer to the underlying variant's property, if present.
func (BetaMessageCountTokensParamsToolUnion) GetBlockedDomains ¶
func (u BetaMessageCountTokensParamsToolUnion) GetBlockedDomains() []string
Returns a pointer to the underlying variant's property, if present.
func (BetaMessageCountTokensParamsToolUnion) GetCacheControl ¶
func (u BetaMessageCountTokensParamsToolUnion) GetCacheControl() *BetaCacheControlEphemeralParam
Returns a pointer to the underlying variant's CacheControl property, if present.
func (BetaMessageCountTokensParamsToolUnion) GetDescription ¶
func (u BetaMessageCountTokensParamsToolUnion) GetDescription() *string
Returns a pointer to the underlying variant's property, if present.
func (BetaMessageCountTokensParamsToolUnion) GetDisplayHeightPx ¶
func (u BetaMessageCountTokensParamsToolUnion) GetDisplayHeightPx() *int64
Returns a pointer to the underlying variant's property, if present.
func (BetaMessageCountTokensParamsToolUnion) GetDisplayNumber ¶
func (u BetaMessageCountTokensParamsToolUnion) GetDisplayNumber() *int64
Returns a pointer to the underlying variant's property, if present.
func (BetaMessageCountTokensParamsToolUnion) GetDisplayWidthPx ¶
func (u BetaMessageCountTokensParamsToolUnion) GetDisplayWidthPx() *int64
Returns a pointer to the underlying variant's property, if present.
func (BetaMessageCountTokensParamsToolUnion) GetInputSchema ¶
func (u BetaMessageCountTokensParamsToolUnion) GetInputSchema() *BetaToolInputSchemaParam
Returns a pointer to the underlying variant's property, if present.
func (BetaMessageCountTokensParamsToolUnion) GetMaxUses ¶
func (u BetaMessageCountTokensParamsToolUnion) GetMaxUses() *int64
Returns a pointer to the underlying variant's property, if present.
func (BetaMessageCountTokensParamsToolUnion) GetName ¶
func (u BetaMessageCountTokensParamsToolUnion) GetName() *string
Returns a pointer to the underlying variant's property, if present.
func (BetaMessageCountTokensParamsToolUnion) GetType ¶
func (u BetaMessageCountTokensParamsToolUnion) GetType() *string
Returns a pointer to the underlying variant's property, if present.
func (BetaMessageCountTokensParamsToolUnion) GetUserLocation ¶
func (u BetaMessageCountTokensParamsToolUnion) GetUserLocation() *BetaWebSearchTool20250305UserLocationParam
Returns a pointer to the underlying variant's 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"`
// 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
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 BetaMessageNewParams ¶
type BetaMessageNewParams struct {
// The maximum number of tokens to generate before stopping.
//
// Note that our models may stop _before_ reaching this maximum. This parameter
// only specifies the absolute maximum number of tokens to generate.
//
// Different models have different maximum values for this parameter. See
// [models](https://docs.anthropic.com/en/docs/models-overview) for details.
MaxTokens int64 `json:"max_tokens,required"`
// Input messages.
//
// Our models are trained to operate on alternating `user` and `assistant`
// conversational turns. When creating a new `Message`, you specify the prior
// conversational turns with the `messages` parameter, and the model then generates
// the next `Message` in the conversation. Consecutive `user` or `assistant` turns
// in your request will be combined into a single turn.
//
// Each input message must be an object with a `role` and `content`. You can
// specify a single `user`-role message, or you can include multiple `user` and
// `assistant` messages.
//
// If the final message uses the `assistant` role, the response content will
// continue immediately from the content in that message. This can be used to
// constrain part of the model's response.
//
// Example with a single `user` message:
//
// “`json
// [{ "role": "user", "content": "Hello, Claude" }]
// “`
//
// Example with multiple conversational turns:
//
// “`json
// [
//
// { "role": "user", "content": "Hello there." },
// { "role": "assistant", "content": "Hi, I'm Claude. How can I help you?" },
// { "role": "user", "content": "Can you explain LLMs in plain English?" }
//
// ]
// “`
//
// Example with a partially-filled response from Claude:
//
// “`json
// [
//
// {
// "role": "user",
// "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"
// },
// { "role": "assistant", "content": "The best answer is (" }
//
// ]
// “`
//
// Each input message `content` may be either a single `string` or an array of
// content blocks, where each block has a specific `type`. Using a `string` for
// `content` is shorthand for an array of one content block of type `"text"`. The
// following input messages are equivalent:
//
// “`json
// { "role": "user", "content": "Hello, Claude" }
// “`
//
// “`json
// { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
// “`
//
// Starting with Claude 3 models, you can also send image content blocks:
//
// “`json
//
// {
// "role": "user",
// "content": [
// {
// "type": "image",
// "source": {
// "type": "base64",
// "media_type": "image/jpeg",
// "data": "/9j/4AAQSkZJRg..."
// }
// },
// { "type": "text", "text": "What is in this image?" }
// ]
// }
//
// “`
//
// We currently support the `base64` source type for images, and the `image/jpeg`,
// `image/png`, `image/gif`, and `image/webp` media types.
//
// See [examples](https://docs.anthropic.com/en/api/messages-examples#vision) for
// more input examples.
//
// Note that if you want to include a
// [system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
// the top-level `system` parameter — there is no `"system"` role for input
// messages in the Messages API.
//
// There is a limit of 100000 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"`
// Container identifier for reuse across requests.
Container param.Opt[string] `json:"container,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"`
// 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"`
// 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.anthropic.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.anthropic.com/en/docs/system-prompts).
System []BetaTextBlockParam `json:"system,omitzero"`
// Configuration for enabling Claude's extended thinking.
//
// When enabled, responses include `thinking` content blocks showing Claude's
// thinking process before the final answer. Requires a minimum budget of 1,024
// tokens and counts towards your `max_tokens` limit.
//
// See
// [extended thinking](https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking)
// for details.
Thinking BetaThinkingConfigParamUnion `json:"thinking,omitzero"`
// How the model should use the provided tools. The model can use a specific tool,
// any available tool, decide by itself, or not use tools at all.
ToolChoice BetaToolChoiceUnionParam `json:"tool_choice,omitzero"`
// Definitions of tools that the model may use.
//
// If you include `tools` in your API request, the model may return `tool_use`
// content blocks that represent the model's use of those tools. You can then run
// those tools using the tool input generated by the model and then optionally
// return results back to the model using `tool_result` content blocks.
//
// Each tool definition includes:
//
// - `name`: Name of the tool.
// - `description`: Optional, but strongly-recommended description of the tool.
// - `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the
// tool `input` shape that the model will produce in `tool_use` output content
// blocks.
//
// For example, if you defined `tools` as:
//
// “`json
// [
//
// {
// "name": "get_stock_price",
// "description": "Get the current stock price for a given ticker symbol.",
// "input_schema": {
// "type": "object",
// "properties": {
// "ticker": {
// "type": "string",
// "description": "The stock ticker symbol, e.g. AAPL for Apple Inc."
// }
// },
// "required": ["ticker"]
// }
// }
//
// ]
// “`
//
// And then asked the model "What's the S&P 500 at today?", the model might produce
// `tool_use` content blocks in the response like this:
//
// “`json
// [
//
// {
// "type": "tool_use",
// "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
// "name": "get_stock_price",
// "input": { "ticker": "^GSPC" }
// }
//
// ]
// “`
//
// You might then run your `get_stock_price` tool with `{"ticker": "^GSPC"}` as an
// input, and return the following back to the model in a subsequent `user`
// message:
//
// “`json
// [
//
// {
// "type": "tool_result",
// "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
// "content": "259.75 USD"
// }
//
// ]
// “`
//
// Tools can be used for workflows that include running client-side tools and
// functions, or more generally whenever you want the model to produce a particular
// JSON structure of output.
//
// See our [guide](https://docs.anthropic.com/en/docs/tool-use) for more details.
Tools []BetaToolUnionParam `json:"tools,omitzero"`
// Optional header to specify the beta version(s) you want to use.
Betas []AnthropicBeta `header:"anthropic-beta,omitzero" json:"-"`
// contains filtered or unexported fields
}
func (BetaMessageNewParams) MarshalJSON ¶
func (r BetaMessageNewParams) MarshalJSON() (data []byte, err error)
func (*BetaMessageNewParams) UnmarshalJSON ¶
func (r *BetaMessageNewParams) UnmarshalJSON(data []byte) error
type BetaMessageNewParamsServiceTier ¶ added in v1.2.0
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.anthropic.com/en/api/service-tiers) for details.
const ( BetaMessageNewParamsServiceTierAuto BetaMessageNewParamsServiceTier = "auto" BetaMessageNewParamsServiceTierStandardOnly BetaMessageNewParamsServiceTier = "standard_only" )
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 ¶ added in v1.2.0
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 ¶
func (r *BetaMessageService) CountTokens(ctx context.Context, params BetaMessageCountTokensParams, opts ...option.RequestOption) (res *BetaMessageTokensCount, err error)
Count the number of tokens in a Message.
The Token Count API can be used to count the number of tokens in a Message, including tools, images, and documents, without creating it.
Learn more about token counting in our [user guide](/en/docs/build-with-claude/token-counting)
func (*BetaMessageService) New ¶
func (r *BetaMessageService) New(ctx context.Context, params BetaMessageNewParams, opts ...option.RequestOption) (res *BetaMessage, err error)
Send a structured list of input messages with text and/or image content, and the model will generate the next message in the conversation.
The Messages API can be used for either single queries or stateless multi-turn conversations.
Learn more about the Messages API in our [user guide](/en/docs/initial-setup)
Note: If you choose to set a timeout for this request, we recommend 10 minutes.
func (*BetaMessageService) NewStreaming ¶
func (r *BetaMessageService) NewStreaming(ctx context.Context, params BetaMessageNewParams, opts ...option.RequestOption) (stream *ssestream.Stream[BetaRawMessageStreamEventUnion])
Send a structured list of input messages with text and/or image content, and the model will generate the next message in the conversation.
The Messages API can be used for either single queries or stateless multi-turn conversations.
Learn more about the Messages API in our [user guide](/en/docs/initial-setup)
Note: If you choose to set a timeout for this request, we recommend 10 minutes.
type BetaMessageStopReason ¶
type BetaMessageStopReason string
The reason that we stopped.
This may be one the following values:
- `"end_turn"`: the model reached a natural stopping point - `"max_tokens"`: we exceeded the requested `max_tokens` or the model's maximum - `"stop_sequence"`: one of your provided custom `stop_sequences` was generated - `"tool_use"`: the model invoked one or more tools
In non-streaming mode this value is always non-null. In streaming mode, it is null in the `message_start` event and non-null otherwise.
const ( BetaMessageStopReasonEndTurn BetaMessageStopReason = "end_turn" BetaMessageStopReasonMaxTokens BetaMessageStopReason = "max_tokens" BetaMessageStopReasonStopSequence BetaMessageStopReason = "stop_sequence" BetaMessageStopReasonToolUse BetaMessageStopReason = "tool_use" )
type BetaMessageTokensCount ¶
type BetaMessageTokensCount struct {
// The total number of tokens across the provided list of messages, system prompt,
// and tools.
InputTokens int64 `json:"input_tokens,required"`
// 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 (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 ¶
func (r *BetaModelService) List(ctx context.Context, params BetaModelListParams, opts ...option.RequestOption) (res *pagination.Page[BetaModelInfo], 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 (*BetaModelService) ListAutoPaging ¶
func (r *BetaModelService) ListAutoPaging(ctx context.Context, params BetaModelListParams, opts ...option.RequestOption) *pagination.PageAutoPager[BetaModelInfo]
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 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 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 ¶
func (r BetaRawContentBlockDeltaEvent) RawJSON() string
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".
Type string `json:"type"`
// This field is from variant [BetaInputJSONDelta].
PartialJSON string `json:"partial_json"`
// This field is from variant [BetaCitationsDelta].
Citation BetaCitationsDeltaCitationUnion `json:"citation"`
// This field is from variant [BetaThinkingDelta].
Thinking string `json:"thinking"`
// This field is from variant [BetaSignatureDelta].
Signature string `json:"signature"`
JSON struct {
Text respjson.Field
Type respjson.Field
PartialJSON respjson.Field
Citation respjson.Field
Thinking respjson.Field
Signature respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
BetaRawContentBlockDeltaUnion contains all possible properties and values from BetaTextDelta, BetaInputJSONDelta, BetaCitationsDelta, BetaThinkingDelta, BetaSignatureDelta.
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:
default:
fmt.Errorf("no variant present")
}
func (BetaRawContentBlockDeltaUnion) AsCitationsDelta ¶
func (u BetaRawContentBlockDeltaUnion) AsCitationsDelta() (v BetaCitationsDelta)
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 ¶
func (u BetaRawContentBlockDeltaUnion) RawJSON() string
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 ¶
func (r BetaRawContentBlockStartEvent) RawJSON() string
Returns the unmodified JSON received from the API
func (*BetaRawContentBlockStartEvent) UnmarshalJSON ¶
func (r *BetaRawContentBlockStartEvent) UnmarshalJSON(data []byte) error
type BetaRawContentBlockStartEventContentBlockUnion ¶
type BetaRawContentBlockStartEventContentBlockUnion struct {
// This field is from variant [BetaTextBlock].
Citations []BetaTextCitationUnion `json:"citations"`
// This field is from variant [BetaTextBlock].
Text string `json:"text"`
// Any of "text", "tool_use", "server_tool_use", "web_search_tool_result",
// "code_execution_tool_result", "mcp_tool_use", "mcp_tool_result",
// "container_upload", "thinking", "redacted_thinking".
Type string `json:"type"`
ID string `json:"id"`
Input any `json:"input"`
Name string `json:"name"`
// This field is a union of [BetaWebSearchToolResultBlockContentUnion],
// [BetaCodeExecutionToolResultBlockContentUnion],
// [BetaMCPToolResultBlockContentUnion]
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"`
// This field is from variant [BetaThinkingBlock].
Signature string `json:"signature"`
// This field is from variant [BetaThinkingBlock].
Thinking string `json:"thinking"`
// This field is from variant [BetaRedactedThinkingBlock].
Data string `json:"data"`
JSON struct {
Citations respjson.Field
Text respjson.Field
Type respjson.Field
ID respjson.Field
Input respjson.Field
Name respjson.Field
Content respjson.Field
ToolUseID respjson.Field
ServerName respjson.Field
IsError respjson.Field
FileID respjson.Field
Signature respjson.Field
Thinking respjson.Field
Data respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
BetaRawContentBlockStartEventContentBlockUnion contains all possible properties and values from BetaTextBlock, BetaToolUseBlock, BetaServerToolUseBlock, BetaWebSearchToolResultBlock, BetaCodeExecutionToolResultBlock, BetaMCPToolUseBlock, BetaMCPToolResultBlock, BetaContainerUploadBlock, BetaThinkingBlock, BetaRedactedThinkingBlock.
Use the BetaRawContentBlockStartEventContentBlockUnion.AsAny method to switch on the variant.
Use the methods beginning with 'As' to cast the union to one of its variants.
func (BetaRawContentBlockStartEventContentBlockUnion) AsAny ¶
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.BetaToolUseBlock:
case anthropic.BetaServerToolUseBlock:
case anthropic.BetaWebSearchToolResultBlock:
case anthropic.BetaCodeExecutionToolResultBlock:
case anthropic.BetaMCPToolUseBlock:
case anthropic.BetaMCPToolResultBlock:
case anthropic.BetaContainerUploadBlock:
case anthropic.BetaThinkingBlock:
case anthropic.BetaRedactedThinkingBlock:
default:
fmt.Errorf("no variant present")
}
func (BetaRawContentBlockStartEventContentBlockUnion) AsCodeExecutionToolResult ¶ added in v1.2.0
func (u BetaRawContentBlockStartEventContentBlockUnion) AsCodeExecutionToolResult() (v BetaCodeExecutionToolResultBlock)
func (BetaRawContentBlockStartEventContentBlockUnion) AsContainerUpload ¶ added in v1.2.0
func (u BetaRawContentBlockStartEventContentBlockUnion) AsContainerUpload() (v BetaContainerUploadBlock)
func (BetaRawContentBlockStartEventContentBlockUnion) AsMCPToolResult ¶ added in v1.2.0
func (u BetaRawContentBlockStartEventContentBlockUnion) AsMCPToolResult() (v BetaMCPToolResultBlock)
func (BetaRawContentBlockStartEventContentBlockUnion) AsMCPToolUse ¶ added in v1.2.0
func (u BetaRawContentBlockStartEventContentBlockUnion) AsMCPToolUse() (v BetaMCPToolUseBlock)
func (BetaRawContentBlockStartEventContentBlockUnion) AsRedactedThinking ¶
func (u BetaRawContentBlockStartEventContentBlockUnion) AsRedactedThinking() (v BetaRedactedThinkingBlock)
func (BetaRawContentBlockStartEventContentBlockUnion) AsServerToolUse ¶
func (u BetaRawContentBlockStartEventContentBlockUnion) AsServerToolUse() (v BetaServerToolUseBlock)
func (BetaRawContentBlockStartEventContentBlockUnion) AsText ¶
func (u BetaRawContentBlockStartEventContentBlockUnion) AsText() (v BetaTextBlock)
func (BetaRawContentBlockStartEventContentBlockUnion) AsThinking ¶
func (u BetaRawContentBlockStartEventContentBlockUnion) AsThinking() (v BetaThinkingBlock)
func (BetaRawContentBlockStartEventContentBlockUnion) AsToolUse ¶
func (u BetaRawContentBlockStartEventContentBlockUnion) AsToolUse() (v BetaToolUseBlock)
func (BetaRawContentBlockStartEventContentBlockUnion) AsWebSearchToolResult ¶
func (u BetaRawContentBlockStartEventContentBlockUnion) AsWebSearchToolResult() (v BetaWebSearchToolResultBlock)
func (BetaRawContentBlockStartEventContentBlockUnion) RawJSON ¶
func (u BetaRawContentBlockStartEventContentBlockUnion) RawJSON() string
Returns the unmodified JSON received from the API
func (*BetaRawContentBlockStartEventContentBlockUnion) UnmarshalJSON ¶
func (r *BetaRawContentBlockStartEventContentBlockUnion) UnmarshalJSON(data []byte) error
type BetaRawContentBlockStartEventContentBlockUnionContent ¶ added in v1.2.0
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 from variant [BetaCodeExecutionToolResultBlockContentUnion].
Content []BetaCodeExecutionOutputBlock `json:"content"`
// This field is from variant [BetaCodeExecutionToolResultBlockContentUnion].
ReturnCode int64 `json:"return_code"`
// This field is from variant [BetaCodeExecutionToolResultBlockContentUnion].
Stderr string `json:"stderr"`
// This field is from variant [BetaCodeExecutionToolResultBlockContentUnion].
Stdout string `json:"stdout"`
JSON struct {
OfBetaWebSearchResultBlockArray respjson.Field
OfString respjson.Field
OfBetaMCPToolResultBlockContent respjson.Field
ErrorCode respjson.Field
Type respjson.Field
Content respjson.Field
ReturnCode respjson.Field
Stderr respjson.Field
Stdout 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 ¶ added in v1.2.0
func (r *BetaRawContentBlockStartEventContentBlockUnionContent) UnmarshalJSON(data []byte) error
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 ¶
func (r BetaRawContentBlockStopEvent) RawJSON() string
Returns the unmodified JSON received from the API
func (*BetaRawContentBlockStopEvent) UnmarshalJSON ¶
func (r *BetaRawContentBlockStopEvent) UnmarshalJSON(data []byte) error
type BetaRawMessageDeltaEvent ¶
type BetaRawMessageDeltaEvent struct {
Delta BetaRawMessageDeltaEventDelta `json:"delta,required"`
Type constant.MessageDelta `json:"type,required"`
// Billing and rate-limit usage.
//
// Anthropic's API bills and rate-limits by token counts, as tokens represent the
// underlying cost to our systems.
//
// Under the hood, the API transforms requests into a format suitable for the
// model. The model's output then goes through a parsing stage before becoming an
// API response. As a result, the token counts in `usage` will not match one-to-one
// with the exact visible content of an API request or response.
//
// For example, `output_tokens` will be non-zero, even for an empty string response
// from Claude.
//
// Total input tokens in a request is the summation of `input_tokens`,
// `cache_creation_input_tokens`, and `cache_read_input_tokens`.
Usage BetaMessageDeltaUsage `json:"usage,required"`
// 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 (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",
// "refusal".
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 ¶
func (r BetaRawMessageDeltaEventDelta) RawJSON() string
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 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
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 (u BetaRawMessageStreamEventUnion) AsContentBlockDelta() (v BetaRawContentBlockDeltaEvent)
func (BetaRawMessageStreamEventUnion) AsContentBlockStart ¶
func (u BetaRawMessageStreamEventUnion) AsContentBlockStart() (v BetaRawContentBlockStartEvent)
func (BetaRawMessageStreamEventUnion) AsContentBlockStop ¶
func (u BetaRawMessageStreamEventUnion) AsContentBlockStop() (v BetaRawContentBlockStopEvent)
func (BetaRawMessageStreamEventUnion) AsMessageDelta ¶
func (u BetaRawMessageStreamEventUnion) AsMessageDelta() (v BetaRawMessageDeltaEvent)
func (BetaRawMessageStreamEventUnion) AsMessageStart ¶
func (u BetaRawMessageStreamEventUnion) AsMessageStart() (v BetaRawMessageStartEvent)
func (BetaRawMessageStreamEventUnion) AsMessageStop ¶
func (u BetaRawMessageStreamEventUnion) AsMessageStop() (v BetaRawMessageStopEvent)
func (BetaRawMessageStreamEventUnion) RawJSON ¶
func (u BetaRawMessageStreamEventUnion) RawJSON() string
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"`
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:"-"`
}
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 (r BetaRedactedThinkingBlock) ToParam() BetaRedactedThinkingBlockParam
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 BetaRequestMCPServerToolConfigurationParam ¶ added in v1.2.0
type BetaRequestMCPServerToolConfigurationParam struct {
Enabled param.Opt[bool] `json:"enabled,omitzero"`
AllowedTools []string `json:"allowed_tools,omitzero"`
// contains filtered or unexported fields
}
func (BetaRequestMCPServerToolConfigurationParam) MarshalJSON ¶ added in v1.2.0
func (r BetaRequestMCPServerToolConfigurationParam) MarshalJSON() (data []byte, err error)
func (*BetaRequestMCPServerToolConfigurationParam) UnmarshalJSON ¶ added in v1.2.0
func (r *BetaRequestMCPServerToolConfigurationParam) UnmarshalJSON(data []byte) error
type BetaRequestMCPServerURLDefinitionParam ¶ added in v1.2.0
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 ¶ added in v1.2.0
func (r BetaRequestMCPServerURLDefinitionParam) MarshalJSON() (data []byte, err error)
func (*BetaRequestMCPServerURLDefinitionParam) UnmarshalJSON ¶ added in v1.2.0
func (r *BetaRequestMCPServerURLDefinitionParam) UnmarshalJSON(data []byte) error
type BetaRequestMCPToolResultBlockParam ¶ added in v1.2.0
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 ¶ added in v1.2.0
func (r BetaRequestMCPToolResultBlockParam) MarshalJSON() (data []byte, err error)
func (*BetaRequestMCPToolResultBlockParam) UnmarshalJSON ¶ added in v1.2.0
func (r *BetaRequestMCPToolResultBlockParam) UnmarshalJSON(data []byte) error
type BetaRequestMCPToolResultBlockParamContentUnion ¶ added in v1.2.0
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 ¶ added in v1.2.0
func (u BetaRequestMCPToolResultBlockParamContentUnion) MarshalJSON() ([]byte, error)
func (*BetaRequestMCPToolResultBlockParamContentUnion) UnmarshalJSON ¶ added in v1.2.0
func (u *BetaRequestMCPToolResultBlockParamContentUnion) UnmarshalJSON(data []byte) error
type BetaServerToolUsage ¶
type BetaServerToolUsage struct {
// 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 {
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", "code_execution".
Name BetaServerToolUseBlockName `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
Input respjson.Field
Name respjson.Field
Type 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) UnmarshalJSON ¶
func (r *BetaServerToolUseBlock) UnmarshalJSON(data []byte) error
type BetaServerToolUseBlockName ¶ added in v1.2.0
type BetaServerToolUseBlockName string
const ( BetaServerToolUseBlockNameWebSearch BetaServerToolUseBlockName = "web_search" BetaServerToolUseBlockNameCodeExecution BetaServerToolUseBlockName = "code_execution" )
type BetaServerToolUseBlockParam ¶
type BetaServerToolUseBlockParam struct {
ID string `json:"id,required"`
Input any `json:"input,omitzero,required"`
// Any of "web_search", "code_execution".
Name BetaServerToolUseBlockParamName `json:"name,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 "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 BetaServerToolUseBlockParamName ¶ added in v1.2.0
type BetaServerToolUseBlockParamName string
const ( BetaServerToolUseBlockParamNameWebSearch BetaServerToolUseBlockParamName = "web_search" BetaServerToolUseBlockParamNameCodeExecution BetaServerToolUseBlockParamName = "code_execution" )
type BetaService ¶
type BetaService struct {
Options []option.RequestOption
Models BetaModelService
Messages BetaMessageService
Files BetaFileService
}
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 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" BetaStopReasonRefusal BetaStopReason = "refusal" )
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"`
// 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) 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"`
// 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".
Type string `json:"type"`
// This field is from variant [BetaCitationPageLocation].
EndPageNumber int64 `json:"end_page_number"`
// This field is from variant [BetaCitationPageLocation].
StartPageNumber int64 `json:"start_page_number"`
// This field is from variant [BetaCitationContentBlockLocation].
EndBlockIndex int64 `json:"end_block_index"`
// This field is from variant [BetaCitationContentBlockLocation].
StartBlockIndex int64 `json:"start_block_index"`
// This field is from variant [BetaCitationsWebSearchResultLocation].
EncryptedIndex string `json:"encrypted_index"`
// This field is from variant [BetaCitationsWebSearchResultLocation].
Title string `json:"title"`
// This field is from variant [BetaCitationsWebSearchResultLocation].
URL string `json:"url"`
JSON struct {
CitedText respjson.Field
DocumentIndex respjson.Field
DocumentTitle respjson.Field
EndCharIndex 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
// contains filtered or unexported fields
} `json:"-"`
}
BetaTextCitationUnion contains all possible properties and values from BetaCitationCharLocation, BetaCitationPageLocation, BetaCitationContentBlockLocation, BetaCitationsWebSearchResultLocation.
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:
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) 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 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 (r BetaThinkingBlock) ToParam() BetaThinkingBlockParam
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 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.anthropic.com/en/docs/build-with-claude/extended-thinking)
// for details.
BudgetTokens int64 `json:"budget_tokens,required"`
// This field can be elided, and will marshal its zero value as "enabled".
Type constant.Enabled `json:"type,required"`
// contains filtered or unexported fields
}
The properties BudgetTokens, Type are required.
func (BetaThinkingConfigEnabledParam) 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"`
// 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 BetaToolBash20241022Param ¶
type BetaToolBash20241022Param struct {
// 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 "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 {
// 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 "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"`
// 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 "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"`
// 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 "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 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 (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"`
// Description of what this tool does.
//
// Tool descriptions should be as detailed as possible. The more information that
// the model has about what the tool is and how to use it, the better it will
// perform. You can use natural language descriptions to reinforce important
// aspects of the tool input JSON schema.
Description param.Opt[string] `json:"description,omitzero"`
// Any of "custom".
Type BetaToolType `json:"type,omitzero"`
// Create a cache control breakpoint at this content block.
CacheControl BetaCacheControlEphemeralParam `json:"cache_control,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 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 (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"`
// 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 ¶
func (u BetaToolResultBlockParamContentUnion) GetCacheControl() *BetaCacheControlEphemeralParam
Returns a pointer to the underlying variant's CacheControl property, if present.
func (BetaToolResultBlockParamContentUnion) GetCitations ¶
func (u BetaToolResultBlockParamContentUnion) GetCitations() []BetaTextCitationParamUnion
Returns a pointer to the underlying variant's property, if present.
func (BetaToolResultBlockParamContentUnion) GetSource ¶
func (u BetaToolResultBlockParamContentUnion) GetSource() *BetaImageBlockParamSourceUnion
Returns a pointer to the underlying variant's property, if present.
func (BetaToolResultBlockParamContentUnion) GetText ¶
func (u BetaToolResultBlockParamContentUnion) GetText() *string
Returns a pointer to the underlying variant's property, if present.
func (BetaToolResultBlockParamContentUnion) GetType ¶
func (u BetaToolResultBlockParamContentUnion) GetType() *string
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 BetaToolTextEditor20241022Param ¶
type BetaToolTextEditor20241022Param struct {
// 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
// "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 {
// 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
// "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 ¶ added in v1.2.0
type BetaToolTextEditor20250429Param struct {
// 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
// "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 ¶ added in v1.2.0
func (r BetaToolTextEditor20250429Param) MarshalJSON() (data []byte, err error)
func (*BetaToolTextEditor20250429Param) UnmarshalJSON ¶ added in v1.2.0
func (r *BetaToolTextEditor20250429Param) UnmarshalJSON(data []byte) error
type BetaToolUnionParam ¶
type BetaToolUnionParam struct {
OfTool *BetaToolParam `json:",omitzero,inline"`
OfComputerUseTool20241022 *BetaToolComputerUse20241022Param `json:",omitzero,inline"`
OfBashTool20241022 *BetaToolBash20241022Param `json:",omitzero,inline"`
OfTextEditor20241022 *BetaToolTextEditor20241022Param `json:",omitzero,inline"`
OfComputerUseTool20250124 *BetaToolComputerUse20250124Param `json:",omitzero,inline"`
OfBashTool20250124 *BetaToolBash20250124Param `json:",omitzero,inline"`
OfTextEditor20250124 *BetaToolTextEditor20250124Param `json:",omitzero,inline"`
OfTextEditor20250429 *BetaToolTextEditor20250429Param `json:",omitzero,inline"`
OfWebSearchTool20250305 *BetaWebSearchTool20250305Param `json:",omitzero,inline"`
OfCodeExecutionTool20250522 *BetaCodeExecutionTool20250522Param `json:",omitzero,inline"`
// contains filtered or unexported fields
}
Only one field can be non-zero.
Use param.IsOmitted to confirm if a field is set.
func BetaToolUnionParamOfComputerUseTool20241022 ¶
func BetaToolUnionParamOfComputerUseTool20241022(displayHeightPx int64, displayWidthPx int64) BetaToolUnionParam
func BetaToolUnionParamOfComputerUseTool20250124 ¶
func BetaToolUnionParamOfComputerUseTool20250124(displayHeightPx int64, displayWidthPx int64) BetaToolUnionParam
func BetaToolUnionParamOfTool ¶
func BetaToolUnionParamOfTool(inputSchema BetaToolInputSchemaParam, name string) BetaToolUnionParam
func (BetaToolUnionParam) GetAllowedDomains ¶
func (u BetaToolUnionParam) GetAllowedDomains() []string
Returns a pointer to the underlying variant's property, if present.
func (BetaToolUnionParam) GetBlockedDomains ¶
func (u BetaToolUnionParam) GetBlockedDomains() []string
Returns a pointer to the underlying variant's property, if present.
func (BetaToolUnionParam) GetCacheControl ¶
func (u BetaToolUnionParam) GetCacheControl() *BetaCacheControlEphemeralParam
Returns a pointer to the underlying variant's CacheControl property, if present.
func (BetaToolUnionParam) GetDescription ¶
func (u BetaToolUnionParam) GetDescription() *string
Returns a pointer to the underlying variant's property, if present.
func (BetaToolUnionParam) GetDisplayHeightPx ¶
func (u BetaToolUnionParam) GetDisplayHeightPx() *int64
Returns a pointer to the underlying variant's property, if present.
func (BetaToolUnionParam) GetDisplayNumber ¶
func (u BetaToolUnionParam) GetDisplayNumber() *int64
Returns a pointer to the underlying variant's property, if present.
func (BetaToolUnionParam) GetDisplayWidthPx ¶
func (u BetaToolUnionParam) GetDisplayWidthPx() *int64
Returns a pointer to the underlying variant's property, if present.
func (BetaToolUnionParam) GetInputSchema ¶
func (u BetaToolUnionParam) GetInputSchema() *BetaToolInputSchemaParam
Returns a pointer to the underlying variant's property, if present.
func (BetaToolUnionParam) 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) GetType ¶
func (u BetaToolUnionParam) GetType() *string
Returns a pointer to the underlying variant's property, if present.
func (BetaToolUnionParam) GetUserLocation ¶
func (u BetaToolUnionParam) GetUserLocation() *BetaWebSearchTool20250305UserLocationParam
Returns a pointer to the underlying variant's 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"`
// 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
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 (r BetaToolUseBlock) ToParam() BetaToolUseBlockParam
func (*BetaToolUseBlock) UnmarshalJSON ¶
func (r *BetaToolUseBlock) 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"`
// 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 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 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 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"`
// 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
ServerToolUse respjson.Field
ServiceTier respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (*BetaUsage) UnmarshalJSON ¶
type BetaUsageServiceTier ¶ added in v1.2.0
type BetaUsageServiceTier string
If the request used the priority, standard, or batch tier.
const ( BetaUsageServiceTierStandard BetaUsageServiceTier = "standard" BetaUsageServiceTierPriority BetaUsageServiceTier = "priority" BetaUsageServiceTierBatch BetaUsageServiceTier = "batch" )
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) 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 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"`
// Parameters for the user's location. Used to provide more relevant search
// results.
UserLocation BetaWebSearchTool20250305UserLocationParam `json:"user_location,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 "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 BetaWebSearchTool20250305UserLocationParam ¶
type BetaWebSearchTool20250305UserLocationParam 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
}
Parameters for the user's location. Used to provide more relevant search results.
The property Type is required.
func (BetaWebSearchTool20250305UserLocationParam) MarshalJSON ¶
func (r BetaWebSearchTool20250305UserLocationParam) MarshalJSON() (data []byte, err error)
func (*BetaWebSearchTool20250305UserLocationParam) UnmarshalJSON ¶
func (r *BetaWebSearchTool20250305UserLocationParam) UnmarshalJSON(data []byte) error
type BetaWebSearchToolRequestErrorParam ¶
type BetaWebSearchToolRequestErrorParam struct {
// Any of "invalid_tool_input", "unavailable", "max_uses_exceeded",
// "too_many_requests", "query_too_long".
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"`
// 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 (BetaWebSearchToolResultBlock) RawJSON ¶
func (r BetaWebSearchToolResultBlock) RawJSON() string
Returns the unmodified JSON received from the API
func (*BetaWebSearchToolResultBlock) UnmarshalJSON ¶
func (r *BetaWebSearchToolResultBlock) 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 ¶
func (u BetaWebSearchToolResultBlockContentUnion) RawJSON() string
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"`
// 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 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 BetaNewWebSearchToolRequestError ¶
func BetaNewWebSearchToolRequestError(errorCode BetaWebSearchToolResultErrorCode) BetaWebSearchToolResultBlockParamContentUnion
func (BetaWebSearchToolResultBlockParamContentUnion) MarshalJSON ¶
func (u BetaWebSearchToolResultBlockParamContentUnion) MarshalJSON() ([]byte, error)
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".
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 ¶
func (r BetaWebSearchToolResultError) RawJSON() string
Returns the unmodified JSON received from the API
func (*BetaWebSearchToolResultError) UnmarshalJSON ¶
func (r *BetaWebSearchToolResultError) UnmarshalJSON(data []byte) error
type BetaWebSearchToolResultErrorCode ¶ added in v1.2.0
type BetaWebSearchToolResultErrorCode string
const ( BetaWebSearchToolResultErrorCodeInvalidToolInput BetaWebSearchToolResultErrorCode = "invalid_tool_input" BetaWebSearchToolResultErrorCodeMaxUsesExceeded BetaWebSearchToolResultErrorCode = "max_uses_exceeded" BetaWebSearchToolResultErrorCodeTooManyRequests BetaWebSearchToolResultErrorCode = "too_many_requests" BetaWebSearchToolResultErrorCodeQueryTooLong BetaWebSearchToolResultErrorCode = "query_too_long" )
type CacheControlEphemeralParam ¶
type CacheControlEphemeralParam struct {
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 CitationCharLocation ¶
type CitationCharLocation struct {
CitedText string `json:"cited_text,required"`
DocumentIndex int64 `json:"document_index,required"`
DocumentTitle string `json:"document_title,required"`
EndCharIndex int64 `json:"end_char_index,required"`
StartCharIndex int64 `json:"start_char_index,required"`
Type constant.CharLocation `json:"type,required"`
// 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
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"`
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
StartBlockIndex respjson.Field
Type respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (CitationContentBlockLocation) RawJSON ¶
func (r CitationContentBlockLocation) RawJSON() string
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"`
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
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 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 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"`
// 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".
Type string `json:"type"`
// This field is from variant [CitationPageLocation].
EndPageNumber int64 `json:"end_page_number"`
// This field is from variant [CitationPageLocation].
StartPageNumber int64 `json:"start_page_number"`
// This field is from variant [CitationContentBlockLocation].
EndBlockIndex int64 `json:"end_block_index"`
// This field is from variant [CitationContentBlockLocation].
StartBlockIndex int64 `json:"start_block_index"`
// This field is from variant [CitationsWebSearchResultLocation].
EncryptedIndex string `json:"encrypted_index"`
// This field is from variant [CitationsWebSearchResultLocation].
Title string `json:"title"`
// This field is from variant [CitationsWebSearchResultLocation].
URL string `json:"url"`
JSON struct {
CitedText respjson.Field
DocumentIndex respjson.Field
DocumentTitle respjson.Field
EndCharIndex 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
// contains filtered or unexported fields
} `json:"-"`
}
CitationsDeltaCitationUnion contains all possible properties and values from CitationCharLocation, CitationPageLocation, CitationContentBlockLocation, CitationsWebSearchResultLocation.
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:
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) 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 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 ¶
func (r CitationsWebSearchResultLocation) RawJSON() string
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.
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.anthropic.com/en/api/prompt-validation) and
// our guide to
// [prompt design](https://docs.anthropic.com/en/docs/intro-to-prompting) for more
// details.
Prompt string `json:"prompt,required"`
// Amount of randomness injected into the response.
//
// Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0`
// for analytical / multiple choice, and closer to `1.0` for creative and
// generative tasks.
//
// Note that even with `temperature` of `0.0`, the results will not be fully
// deterministic.
Temperature param.Opt[float64] `json:"temperature,omitzero"`
// Only sample from the top K options for each subsequent token.
//
// Used to remove "long tail" low probability responses.
// [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).
//
// Recommended for advanced use cases only. You usually only need to use
// `temperature`.
TopK param.Opt[int64] `json:"top_k,omitzero"`
// Use nucleus sampling.
//
// In nucleus sampling, we compute the cumulative distribution over all the options
// for each subsequent token in decreasing probability order and cut it off once it
// reaches a particular probability specified by `top_p`. You should either alter
// `temperature` or `top_p`, but not both.
//
// Recommended for advanced use cases only. You usually only need to use
// `temperature`.
TopP param.Opt[float64] `json:"top_p,omitzero"`
// An object describing metadata about the request.
Metadata MetadataParam `json:"metadata,omitzero"`
// Sequences that will cause the model to stop generating.
//
// Our models stop on `"\n\nHuman:"`, and may include additional built-in stop
// sequences in the future. By providing the stop_sequences parameter, you may
// include additional strings that will cause the model to stop generating.
StopSequences []string `json:"stop_sequences,omitzero"`
// 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.anthropic.com/en/api/messages) going forward.
Future models and features will not be compatible with Text Completions. See our [migration guide](https://docs.anthropic.com/en/api/migrating-from-text-completions-to-messages) for guidance in migrating from Text Completions to Messages.
Note: If you choose to set a timeout for this request, we recommend 10 minutes.
func (*CompletionService) NewStreaming ¶
func (r *CompletionService) NewStreaming(ctx context.Context, 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.anthropic.com/en/api/messages) going forward.
Future models and features will not be compatible with Text Completions. See our [migration guide](https://docs.anthropic.com/en/api/migrating-from-text-completions-to-messages) for guidance in migrating from Text Completions to Messages.
Note: If you choose to set a timeout for this request, we recommend 10 minutes.
type ContentBlockDeltaEvent ¶
type ContentBlockDeltaEvent struct {
Delta 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 {
OfServerToolUse *ServerToolUseBlockParam `json:",omitzero,inline"`
OfWebSearchToolResult *WebSearchToolResultBlockParam `json:",omitzero,inline"`
OfText *TextBlockParam `json:",omitzero,inline"`
OfImage *ImageBlockParam `json:",omitzero,inline"`
OfToolUse *ToolUseBlockParam `json:",omitzero,inline"`
OfToolResult *ToolResultBlockParam `json:",omitzero,inline"`
OfDocument *DocumentBlockParam `json:",omitzero,inline"`
OfThinking *ThinkingBlockParam `json:",omitzero,inline"`
OfRedactedThinking *RedactedThinkingBlockParam `json:",omitzero,inline"`
// contains filtered or unexported fields
}
Only one field can be non-zero.
Use param.IsOmitted to confirm if a field is set.
func NewDocumentBlock ¶
func NewDocumentBlock[ T Base64PDFSourceParam | PlainTextSourceParam | ContentBlockSourceParam | URLPDFSourceParam, ](source T) ContentBlockParamUnion
func NewImageBlock ¶
func NewImageBlock[T Base64ImageSourceParam | URLImageSourceParam](source T) ContentBlockParamUnion
func NewImageBlockBase64 ¶
func NewImageBlockBase64(mediaType string, encodedData string) ContentBlockParamUnion
func NewRedactedThinkingBlock ¶
func NewRedactedThinkingBlock(data string) ContentBlockParamUnion
func NewServerToolUseBlock ¶
func NewServerToolUseBlock(id string, input any) 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 NewWebSearchToolResultBlock ¶
func NewWebSearchToolResultBlock[ T []WebSearchResultBlockParam | WebSearchToolRequestErrorParam, ](content T, toolUseID string) ContentBlockParamUnion
func (ContentBlockParamUnion) GetCacheControl ¶
func (u ContentBlockParamUnion) GetCacheControl() *CacheControlEphemeralParam
Returns a pointer to the underlying variant's CacheControl property, if present.
func (ContentBlockParamUnion) GetCitations ¶
func (u ContentBlockParamUnion) GetCitations() (res contentBlockParamUnionCitations)
Returns a subunion which exports methods to access subproperties
Or use AsAny() to get the underlying value
func (ContentBlockParamUnion) GetContent ¶
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) 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 ContentBlockSourceContentUnionParam ¶
type ContentBlockSourceContentUnionParam struct {
OfString param.Opt[string] `json:",omitzero,inline"`
OfContentBlockSourceContent []ContentBlockSourceContentUnionParam `json:",omitzero,inline"`
// contains filtered or unexported fields
}
Only one field can be non-zero.
Use param.IsOmitted to confirm if a field is set.
func (ContentBlockSourceContentUnionParam) 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 {
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", "tool_use", "server_tool_use", "web_search_tool_result",
// "thinking", "redacted_thinking".
Type string `json:"type"`
ID string `json:"id"`
Input any `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"`
// This field is from variant [ThinkingBlock].
Signature string `json:"signature"`
// This field is from variant [ThinkingBlock].
Thinking string `json:"thinking"`
// This field is from variant [RedactedThinkingBlock].
Data string `json:"data"`
JSON struct {
Citations respjson.Field
Text respjson.Field
Type respjson.Field
ID respjson.Field
Input respjson.Field
Name respjson.Field
Content respjson.Field
ToolUseID respjson.Field
Signature respjson.Field
Thinking respjson.Field
Data respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
ContentBlockStartEventContentBlockUnion contains all possible properties and values from TextBlock, ToolUseBlock, ServerToolUseBlock, WebSearchToolResultBlock, ThinkingBlock, RedactedThinkingBlock.
Use the ContentBlockStartEventContentBlockUnion.AsAny method to switch on the variant.
Use the methods beginning with 'As' to cast the union to one of its variants.
func (ContentBlockStartEventContentBlockUnion) AsAny ¶
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.ToolUseBlock:
case anthropic.ServerToolUseBlock:
case anthropic.WebSearchToolResultBlock:
case anthropic.ThinkingBlock:
case anthropic.RedactedThinkingBlock:
default:
fmt.Errorf("no variant present")
}
func (ContentBlockStartEventContentBlockUnion) AsRedactedThinking ¶
func (u ContentBlockStartEventContentBlockUnion) AsRedactedThinking() (v RedactedThinkingBlock)
func (ContentBlockStartEventContentBlockUnion) AsServerToolUse ¶
func (u ContentBlockStartEventContentBlockUnion) AsServerToolUse() (v ServerToolUseBlock)
func (ContentBlockStartEventContentBlockUnion) AsText ¶
func (u ContentBlockStartEventContentBlockUnion) AsText() (v TextBlock)
func (ContentBlockStartEventContentBlockUnion) AsThinking ¶
func (u ContentBlockStartEventContentBlockUnion) AsThinking() (v ThinkingBlock)
func (ContentBlockStartEventContentBlockUnion) AsToolUse ¶
func (u ContentBlockStartEventContentBlockUnion) AsToolUse() (v ToolUseBlock)
func (ContentBlockStartEventContentBlockUnion) AsWebSearchToolResult ¶
func (u ContentBlockStartEventContentBlockUnion) AsWebSearchToolResult() (v WebSearchToolResultBlock)
func (ContentBlockStartEventContentBlockUnion) RawJSON ¶
func (u ContentBlockStartEventContentBlockUnion) RawJSON() string
Returns the unmodified JSON received from the API
func (*ContentBlockStartEventContentBlockUnion) UnmarshalJSON ¶
func (r *ContentBlockStartEventContentBlockUnion) UnmarshalJSON(data []byte) error
type ContentBlockStopEvent ¶
type ContentBlockStopEvent struct {
Index int64 `json:"index,required"`
Type constant.ContentBlockStop `json:"type,required"`
// 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", "tool_use", "server_tool_use", "web_search_tool_result",
// "thinking", "redacted_thinking".
Type string `json:"type"`
ID string `json:"id"`
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"`
// This field is from variant [ThinkingBlock].
Signature string `json:"signature"`
// This field is from variant [ThinkingBlock].
Thinking string `json:"thinking"`
// This field is from variant [RedactedThinkingBlock].
Data string `json:"data"`
JSON struct {
Citations respjson.Field
Text respjson.Field
Type respjson.Field
ID respjson.Field
Input respjson.Field
Name respjson.Field
Content respjson.Field
ToolUseID respjson.Field
Signature respjson.Field
Thinking respjson.Field
Data respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
ContentBlockUnion contains all possible properties and values from TextBlock, ToolUseBlock, ServerToolUseBlock, WebSearchToolResultBlock, ThinkingBlock, RedactedThinkingBlock.
Use the ContentBlockUnion.AsAny method to switch on the variant.
Use the methods beginning with 'As' to cast the union to one of its variants.
func (ContentBlockUnion) AsAny ¶
func (u ContentBlockUnion) AsAny() anyContentBlock
Use the following switch statement to find the correct variant
switch variant := ContentBlockUnion.AsAny().(type) {
case anthropic.TextBlock:
case anthropic.ToolUseBlock:
case anthropic.ServerToolUseBlock:
case anthropic.WebSearchToolResultBlock:
case anthropic.ThinkingBlock:
case anthropic.RedactedThinkingBlock:
default:
fmt.Errorf("no variant present")
}
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) AsThinking ¶
func (u ContentBlockUnion) AsThinking() (v ThinkingBlock)
func (ContentBlockUnion) AsToolUse ¶
func (u ContentBlockUnion) AsToolUse() (v ToolUseBlock)
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 (r ContentBlockUnion) ToParam() ContentBlockParamUnion
func (*ContentBlockUnion) UnmarshalJSON ¶
func (r *ContentBlockUnion) UnmarshalJSON(data []byte) error
type DeletedFile ¶ added in v1.2.0
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 ¶ added in v1.2.0
func (r DeletedFile) RawJSON() string
Returns the unmodified JSON received from the API
func (*DeletedFile) UnmarshalJSON ¶ added in v1.2.0
func (r *DeletedFile) UnmarshalJSON(data []byte) error
type DeletedFileType ¶ added in v1.2.0
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 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 ¶
func (u DocumentBlockParamSourceUnion) GetContent() *ContentBlockSourceContentUnionParam
Returns a pointer to the underlying variant's property, if present.
func (DocumentBlockParamSourceUnion) GetData ¶
func (u DocumentBlockParamSourceUnion) GetData() *string
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 ¶
func (u DocumentBlockParamSourceUnion) GetType() *string
Returns a pointer to the underlying variant's property, if present.
func (DocumentBlockParamSourceUnion) GetURL ¶
func (u DocumentBlockParamSourceUnion) GetURL() *string
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 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 ¶ added in v1.2.0
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 ¶ added in v1.2.0
func (r FileMetadata) RawJSON() string
Returns the unmodified JSON received from the API
func (*FileMetadata) UnmarshalJSON ¶ added in v1.2.0
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 Message ¶
type Message struct {
// Unique object identifier.
//
// The format and length of IDs may change over time.
ID string `json:"id,required"`
// Content generated by the model.
//
// This is an array of content blocks, each of which has a `type` that determines
// its shape.
//
// Example:
//
// “`json
// [{ "type": "text", "text": "Hi, I'm Claude." }]
// “`
//
// If the request input `messages` ended with an `assistant` turn, then the
// response `content` will continue directly from that last turn. You can use this
// to constrain the model's output.
//
// For example, if the input `messages` were:
//
// “`json
// [
//
// {
// "role": "user",
// "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"
// },
// { "role": "assistant", "content": "The best answer is (" }
//
// ]
// “`
//
// Then the response `content` might be:
//
// “`json
// [{ "type": "text", "text": "B)" }]
// “`
Content []ContentBlockUnion `json:"content,required"`
// The model that will complete your prompt.\n\nSee
// [models](https://docs.anthropic.com/en/docs/models-overview) for additional
// details and options.
Model Model `json:"model,required"`
// Conversational role of the generated message.
//
// This will always be `"assistant"`.
Role constant.Assistant `json:"role,required"`
// The reason that we stopped.
//
// This may be one the following values:
//
// - `"end_turn"`: the model reached a natural stopping point
// - `"max_tokens"`: we exceeded the requested `max_tokens` or the model's maximum
// - `"stop_sequence"`: one of your provided custom `stop_sequences` was generated
// - `"tool_use"`: the model invoked one or more tools
//
// In non-streaming mode this value is always non-null. In streaming mode, it is
// null in the `message_start` event and non-null otherwise.
//
// Any of "end_turn", "max_tokens", "stop_sequence", "tool_use", "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
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) ToParam ¶
func (r Message) ToParam() MessageParam
func (*Message) UnmarshalJSON ¶
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 ¶
func (r MessageBatchIndividualResponse) RawJSON() string
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](/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.anthropic.com/en/docs/models-overview) for details.
MaxTokens int64 `json:"max_tokens,required"`
// Input messages.
//
// Our models are trained to operate on alternating `user` and `assistant`
// conversational turns. When creating a new `Message`, you specify the prior
// conversational turns with the `messages` parameter, and the model then generates
// the next `Message` in the conversation. Consecutive `user` or `assistant` turns
// in your request will be combined into a single turn.
//
// Each input message must be an object with a `role` and `content`. You can
// specify a single `user`-role message, or you can include multiple `user` and
// `assistant` messages.
//
// If the final message uses the `assistant` role, the response content will
// continue immediately from the content in that message. This can be used to
// constrain part of the model's response.
//
// Example with a single `user` message:
//
// “`json
// [{ "role": "user", "content": "Hello, Claude" }]
// “`
//
// Example with multiple conversational turns:
//
// “`json
// [
//
// { "role": "user", "content": "Hello there." },
// { "role": "assistant", "content": "Hi, I'm Claude. How can I help you?" },
// { "role": "user", "content": "Can you explain LLMs in plain English?" }
//
// ]
// “`
//
// Example with a partially-filled response from Claude:
//
// “`json
// [
//
// {
// "role": "user",
// "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"
// },
// { "role": "assistant", "content": "The best answer is (" }
//
// ]
// “`
//
// Each input message `content` may be either a single `string` or an array of
// content blocks, where each block has a specific `type`. Using a `string` for
// `content` is shorthand for an array of one content block of type `"text"`. The
// following input messages are equivalent:
//
// “`json
// { "role": "user", "content": "Hello, Claude" }
// “`
//
// “`json
// { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
// “`
//
// Starting with Claude 3 models, you can also send image content blocks:
//
// “`json
//
// {
// "role": "user",
// "content": [
// {
// "type": "image",
// "source": {
// "type": "base64",
// "media_type": "image/jpeg",
// "data": "/9j/4AAQSkZJRg..."
// }
// },
// { "type": "text", "text": "What is in this image?" }
// ]
// }
//
// “`
//
// We currently support the `base64` source type for images, and the `image/jpeg`,
// `image/png`, `image/gif`, and `image/webp` media types.
//
// See [examples](https://docs.anthropic.com/en/api/messages-examples#vision) for
// more input examples.
//
// Note that if you want to include a
// [system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
// the top-level `system` parameter — there is no `"system"` role for input
// messages in the Messages API.
//
// There is a limit of 100000 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"`
// Whether to incrementally stream the response using server-sent events.
//
// See [streaming](https://docs.anthropic.com/en/api/messages-streaming) for
// details.
Stream param.Opt[bool] `json:"stream,omitzero"`
// Amount of randomness injected into the response.
//
// Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0`
// for analytical / multiple choice, and closer to `1.0` for creative and
// generative tasks.
//
// Note that even with `temperature` of `0.0`, the results will not be fully
// deterministic.
Temperature param.Opt[float64] `json:"temperature,omitzero"`
// Only sample from the top K options for each subsequent token.
//
// Used to remove "long tail" low probability responses.
// [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).
//
// Recommended for advanced use cases only. You usually only need to use
// `temperature`.
TopK param.Opt[int64] `json:"top_k,omitzero"`
// Use nucleus sampling.
//
// In nucleus sampling, we compute the cumulative distribution over all the options
// for each subsequent token in decreasing probability order and cut it off once it
// reaches a particular probability specified by `top_p`. You should either alter
// `temperature` or `top_p`, but not both.
//
// Recommended for advanced use cases only. You usually only need to use
// `temperature`.
TopP param.Opt[float64] `json:"top_p,omitzero"`
// An object describing metadata about the request.
Metadata MetadataParam `json:"metadata,omitzero"`
// 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.anthropic.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.anthropic.com/en/docs/system-prompts).
System []TextBlockParam `json:"system,omitzero"`
// Configuration for enabling Claude's extended thinking.
//
// When enabled, responses include `thinking` content blocks showing Claude's
// thinking process before the final answer. Requires a minimum budget of 1,024
// tokens and counts towards your `max_tokens` limit.
//
// See
// [extended thinking](https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking)
// for details.
Thinking ThinkingConfigParamUnion `json:"thinking,omitzero"`
// How the model should use the provided tools. The model can use a specific tool,
// any available tool, decide by itself, or not use tools at all.
ToolChoice ToolChoiceUnionParam `json:"tool_choice,omitzero"`
// Definitions of tools that the model may use.
//
// If you include `tools` in your API request, the model may return `tool_use`
// content blocks that represent the model's use of those tools. You can then run
// those tools using the tool input generated by the model and then optionally
// return results back to the model using `tool_result` content blocks.
//
// Each tool definition includes:
//
// - `name`: Name of the tool.
// - `description`: Optional, but strongly-recommended description of the tool.
// - `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the
// tool `input` shape that the model will produce in `tool_use` output content
// blocks.
//
// For example, if you defined `tools` as:
//
// “`json
// [
//
// {
// "name": "get_stock_price",
// "description": "Get the current stock price for a given ticker symbol.",
// "input_schema": {
// "type": "object",
// "properties": {
// "ticker": {
// "type": "string",
// "description": "The stock ticker symbol, e.g. AAPL for Apple Inc."
// }
// },
// "required": ["ticker"]
// }
// }
//
// ]
// “`
//
// And then asked the model "What's the S&P 500 at today?", the model might produce
// `tool_use` content blocks in the response like this:
//
// “`json
// [
//
// {
// "type": "tool_use",
// "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
// "name": "get_stock_price",
// "input": { "ticker": "^GSPC" }
// }
//
// ]
// “`
//
// You might then run your `get_stock_price` tool with `{"ticker": "^GSPC"}` as an
// input, and return the following back to the model in a subsequent `user`
// message:
//
// “`json
// [
//
// {
// "type": "tool_result",
// "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
// "content": "259.75 USD"
// }
//
// ]
// “`
//
// Tools can be used for workflows that include running client-side tools and
// functions, or more generally whenever you want the model to produce a particular
// JSON structure of output.
//
// See our [guide](https://docs.anthropic.com/en/docs/tool-use) for more details.
Tools []ToolUnionParam `json:"tools,omitzero"`
// contains filtered or unexported fields
}
Messages API creation parameters for the individual request.
See the [Messages API reference](/en/api/messages) for full documentation on available parameters.
The properties MaxTokens, Messages, Model are required.
func (MessageBatchNewParamsRequestParams) 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 (u MessageBatchResultUnion) AsCanceled() (v MessageBatchCanceledResult)
func (MessageBatchResultUnion) AsErrored ¶
func (u MessageBatchResultUnion) AsErrored() (v MessageBatchErroredResult)
func (MessageBatchResultUnion) AsExpired ¶
func (u MessageBatchResultUnion) AsExpired() (v MessageBatchExpiredResult)
func (MessageBatchResultUnion) AsSucceeded ¶
func (u MessageBatchResultUnion) AsSucceeded() (v MessageBatchSucceededResult)
func (MessageBatchResultUnion) RawJSON ¶
func (u MessageBatchResultUnion) RawJSON() string
Returns the unmodified JSON received from the API
func (*MessageBatchResultUnion) UnmarshalJSON ¶
func (r *MessageBatchResultUnion) UnmarshalJSON(data []byte) error
type MessageBatchService ¶
type MessageBatchService struct {
Options []option.RequestOption
}
MessageBatchService contains methods and other services that help with interacting with the anthropic API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewMessageBatchService method instead.
func NewMessageBatchService ¶
func NewMessageBatchService(opts ...option.RequestOption) (r MessageBatchService)
NewMessageBatchService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*MessageBatchService) Cancel ¶
func (r *MessageBatchService) Cancel(ctx context.Context, messageBatchID string, opts ...option.RequestOption) (res *MessageBatch, err error)
Batches may be canceled any time before processing ends. Once cancellation is initiated, the batch enters a `canceling` state, at which time the system may complete any in-progress, non-interruptible requests before finalizing cancellation.
The number of canceled requests is specified in `request_counts`. To determine which requests were canceled, check the individual results within the batch. Note that cancellation may not result in any canceled requests if they were non-interruptible.
Learn more about the Message Batches API in our [user guide](/en/docs/build-with-claude/batch-processing)
func (*MessageBatchService) Delete ¶
func (r *MessageBatchService) Delete(ctx context.Context, messageBatchID string, opts ...option.RequestOption) (res *DeletedMessageBatch, err error)
Delete a Message Batch.
Message Batches can only be deleted once they've finished processing. If you'd like to delete an in-progress batch, you must first cancel it.
Learn more about the Message Batches API in our [user guide](/en/docs/build-with-claude/batch-processing)
func (*MessageBatchService) Get ¶
func (r *MessageBatchService) Get(ctx context.Context, messageBatchID string, opts ...option.RequestOption) (res *MessageBatch, err error)
This endpoint is idempotent and can be used to poll for Message Batch completion. To access the results of a Message Batch, make a request to the `results_url` field in the response.
Learn more about the Message Batches API in our [user guide](/en/docs/build-with-claude/batch-processing)
func (*MessageBatchService) List ¶
func (r *MessageBatchService) List(ctx context.Context, query MessageBatchListParams, opts ...option.RequestOption) (res *pagination.Page[MessageBatch], err error)
List all Message Batches within a Workspace. Most recently created batches are returned first.
Learn more about the Message Batches API in our [user guide](/en/docs/build-with-claude/batch-processing)
func (*MessageBatchService) ListAutoPaging ¶
func (r *MessageBatchService) ListAutoPaging(ctx context.Context, query MessageBatchListParams, opts ...option.RequestOption) *pagination.PageAutoPager[MessageBatch]
List all Message Batches within a Workspace. Most recently created batches are returned first.
Learn more about the Message Batches API in our [user guide](/en/docs/build-with-claude/batch-processing)
func (*MessageBatchService) New ¶
func (r *MessageBatchService) New(ctx context.Context, body MessageBatchNewParams, opts ...option.RequestOption) (res *MessageBatch, err error)
Send a batch of Message creation requests.
The Message Batches API can be used to process multiple Messages API requests at once. Once a Message Batch is created, it begins processing immediately. Batches can take up to 24 hours to complete.
Learn more about the Message Batches API in our [user guide](/en/docs/build-with-claude/batch-processing)
func (*MessageBatchService) ResultsStreaming ¶
func (r *MessageBatchService) ResultsStreaming(ctx context.Context, messageBatchID string, opts ...option.RequestOption) (stream *jsonl.Stream[MessageBatchIndividualResponse])
Streams the results of a Message Batch as a `.jsonl` file.
Each line in the file is a JSON object containing the result of a single request in the Message Batch. Results are not guaranteed to be in the same order as requests. Use the `custom_id` field to match results to requests.
Learn more about the Message Batches API in our [user guide](/en/docs/build-with-claude/batch-processing)
type MessageBatchSucceededResult ¶
type MessageBatchSucceededResult struct {
Message Message `json:"message,required"`
Type constant.Succeeded `json:"type,required"`
// 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" }] }
// “`
//
// Starting with Claude 3 models, you can also send image content blocks:
//
// “`json
//
// {
// "role": "user",
// "content": [
// {
// "type": "image",
// "source": {
// "type": "base64",
// "media_type": "image/jpeg",
// "data": "/9j/4AAQSkZJRg..."
// }
// },
// { "type": "text", "text": "What is in this image?" }
// ]
// }
//
// “`
//
// We currently support the `base64` source type for images, and the `image/jpeg`,
// `image/png`, `image/gif`, and `image/webp` media types.
//
// See [examples](https://docs.anthropic.com/en/api/messages-examples#vision) for
// more input examples.
//
// Note that if you want to include a
// [system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
// the top-level `system` parameter — there is no `"system"` role for input
// messages in the Messages API.
//
// There is a limit of 100000 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"`
// System prompt.
//
// A system prompt is a way of providing context and instructions to Claude, such
// as specifying a particular goal or role. See our
// [guide to system prompts](https://docs.anthropic.com/en/docs/system-prompts).
System MessageCountTokensParamsSystemUnion `json:"system,omitzero"`
// Configuration for enabling Claude's extended thinking.
//
// When enabled, responses include `thinking` content blocks showing Claude's
// thinking process before the final answer. Requires a minimum budget of 1,024
// tokens and counts towards your `max_tokens` limit.
//
// See
// [extended thinking](https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking)
// for details.
Thinking ThinkingConfigParamUnion `json:"thinking,omitzero"`
// How the model should use the provided tools. The model can use a specific tool,
// any available tool, decide by itself, or not use tools at all.
ToolChoice ToolChoiceUnionParam `json:"tool_choice,omitzero"`
// Definitions of tools that the model may use.
//
// If you include `tools` in your API request, the model may return `tool_use`
// content blocks that represent the model's use of those tools. You can then run
// those tools using the tool input generated by the model and then optionally
// return results back to the model using `tool_result` content blocks.
//
// Each tool definition includes:
//
// - `name`: Name of the tool.
// - `description`: Optional, but strongly-recommended description of the tool.
// - `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the
// tool `input` shape that the model will produce in `tool_use` output content
// blocks.
//
// For example, if you defined `tools` as:
//
// “`json
// [
//
// {
// "name": "get_stock_price",
// "description": "Get the current stock price for a given ticker symbol.",
// "input_schema": {
// "type": "object",
// "properties": {
// "ticker": {
// "type": "string",
// "description": "The stock ticker symbol, e.g. AAPL for Apple Inc."
// }
// },
// "required": ["ticker"]
// }
// }
//
// ]
// “`
//
// And then asked the model "What's the S&P 500 at today?", the model might produce
// `tool_use` content blocks in the response like this:
//
// “`json
// [
//
// {
// "type": "tool_use",
// "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
// "name": "get_stock_price",
// "input": { "ticker": "^GSPC" }
// }
//
// ]
// “`
//
// You might then run your `get_stock_price` tool with `{"ticker": "^GSPC"}` as an
// input, and return the following back to the model in a subsequent `user`
// message:
//
// “`json
// [
//
// {
// "type": "tool_result",
// "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
// "content": "259.75 USD"
// }
//
// ]
// “`
//
// Tools can be used for workflows that include running client-side tools and
// functions, or more generally whenever you want the model to produce a particular
// JSON structure of output.
//
// See our [guide](https://docs.anthropic.com/en/docs/tool-use) for more details.
Tools []MessageCountTokensToolUnionParam `json:"tools,omitzero"`
// contains filtered or unexported fields
}
func (MessageCountTokensParams) 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"`
OfTextEditor20250124 *ToolTextEditor20250124Param `json:",omitzero,inline"`
OfTextEditor20250429 *ToolTextEditor20250429Param `json:",omitzero,inline"`
OfWebSearchTool20250305 *WebSearchTool20250305Param `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) GetAllowedDomains ¶
func (u MessageCountTokensToolUnionParam) GetAllowedDomains() []string
Returns a pointer to the underlying variant's property, if present.
func (MessageCountTokensToolUnionParam) GetBlockedDomains ¶
func (u MessageCountTokensToolUnionParam) GetBlockedDomains() []string
Returns a pointer to the underlying variant's property, if present.
func (MessageCountTokensToolUnionParam) GetCacheControl ¶
func (u MessageCountTokensToolUnionParam) GetCacheControl() *CacheControlEphemeralParam
Returns a pointer to the underlying variant's CacheControl property, if present.
func (MessageCountTokensToolUnionParam) GetDescription ¶
func (u MessageCountTokensToolUnionParam) GetDescription() *string
Returns a pointer to the underlying variant's property, if present.
func (MessageCountTokensToolUnionParam) GetInputSchema ¶
func (u MessageCountTokensToolUnionParam) GetInputSchema() *ToolInputSchemaParam
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 ¶
func (u MessageCountTokensToolUnionParam) GetName() *string
Returns a pointer to the underlying variant's property, if present.
func (MessageCountTokensToolUnionParam) GetType ¶
func (u MessageCountTokensToolUnionParam) GetType() *string
Returns a pointer to the underlying variant's property, if present.
func (MessageCountTokensToolUnionParam) GetUserLocation ¶
func (u MessageCountTokensToolUnionParam) GetUserLocation() *WebSearchTool20250305UserLocationParam
Returns a pointer to the underlying variant's 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 {
// 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 {
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.anthropic.com/en/docs/models-overview) for details.
MaxTokens int64 `json:"max_tokens,required"`
// Input messages.
//
// Our models are trained to operate on alternating `user` and `assistant`
// conversational turns. When creating a new `Message`, you specify the prior
// conversational turns with the `messages` parameter, and the model then generates
// the next `Message` in the conversation. Consecutive `user` or `assistant` turns
// in your request will be combined into a single turn.
//
// Each input message must be an object with a `role` and `content`. You can
// specify a single `user`-role message, or you can include multiple `user` and
// `assistant` messages.
//
// If the final message uses the `assistant` role, the response content will
// continue immediately from the content in that message. This can be used to
// constrain part of the model's response.
//
// Example with a single `user` message:
//
// “`json
// [{ "role": "user", "content": "Hello, Claude" }]
// “`
//
// Example with multiple conversational turns:
//
// “`json
// [
//
// { "role": "user", "content": "Hello there." },
// { "role": "assistant", "content": "Hi, I'm Claude. How can I help you?" },
// { "role": "user", "content": "Can you explain LLMs in plain English?" }
//
// ]
// “`
//
// Example with a partially-filled response from Claude:
//
// “`json
// [
//
// {
// "role": "user",
// "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"
// },
// { "role": "assistant", "content": "The best answer is (" }
//
// ]
// “`
//
// Each input message `content` may be either a single `string` or an array of
// content blocks, where each block has a specific `type`. Using a `string` for
// `content` is shorthand for an array of one content block of type `"text"`. The
// following input messages are equivalent:
//
// “`json
// { "role": "user", "content": "Hello, Claude" }
// “`
//
// “`json
// { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
// “`
//
// Starting with Claude 3 models, you can also send image content blocks:
//
// “`json
//
// {
// "role": "user",
// "content": [
// {
// "type": "image",
// "source": {
// "type": "base64",
// "media_type": "image/jpeg",
// "data": "/9j/4AAQSkZJRg..."
// }
// },
// { "type": "text", "text": "What is in this image?" }
// ]
// }
//
// “`
//
// We currently support the `base64` source type for images, and the `image/jpeg`,
// `image/png`, `image/gif`, and `image/webp` media types.
//
// See [examples](https://docs.anthropic.com/en/api/messages-examples#vision) for
// more input examples.
//
// Note that if you want to include a
// [system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
// the top-level `system` parameter — there is no `"system"` role for input
// messages in the Messages API.
//
// There is a limit of 100000 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"`
// 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"`
// 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.anthropic.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.anthropic.com/en/docs/system-prompts).
System []TextBlockParam `json:"system,omitzero"`
// Configuration for enabling Claude's extended thinking.
//
// When enabled, responses include `thinking` content blocks showing Claude's
// thinking process before the final answer. Requires a minimum budget of 1,024
// tokens and counts towards your `max_tokens` limit.
//
// See
// [extended thinking](https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking)
// for details.
Thinking ThinkingConfigParamUnion `json:"thinking,omitzero"`
// How the model should use the provided tools. The model can use a specific tool,
// any available tool, decide by itself, or not use tools at all.
ToolChoice ToolChoiceUnionParam `json:"tool_choice,omitzero"`
// Definitions of tools that the model may use.
//
// If you include `tools` in your API request, the model may return `tool_use`
// content blocks that represent the model's use of those tools. You can then run
// those tools using the tool input generated by the model and then optionally
// return results back to the model using `tool_result` content blocks.
//
// Each tool definition includes:
//
// - `name`: Name of the tool.
// - `description`: Optional, but strongly-recommended description of the tool.
// - `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the
// tool `input` shape that the model will produce in `tool_use` output content
// blocks.
//
// For example, if you defined `tools` as:
//
// “`json
// [
//
// {
// "name": "get_stock_price",
// "description": "Get the current stock price for a given ticker symbol.",
// "input_schema": {
// "type": "object",
// "properties": {
// "ticker": {
// "type": "string",
// "description": "The stock ticker symbol, e.g. AAPL for Apple Inc."
// }
// },
// "required": ["ticker"]
// }
// }
//
// ]
// “`
//
// And then asked the model "What's the S&P 500 at today?", the model might produce
// `tool_use` content blocks in the response like this:
//
// “`json
// [
//
// {
// "type": "tool_use",
// "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
// "name": "get_stock_price",
// "input": { "ticker": "^GSPC" }
// }
//
// ]
// “`
//
// You might then run your `get_stock_price` tool with `{"ticker": "^GSPC"}` as an
// input, and return the following back to the model in a subsequent `user`
// message:
//
// “`json
// [
//
// {
// "type": "tool_result",
// "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
// "content": "259.75 USD"
// }
//
// ]
// “`
//
// Tools can be used for workflows that include running client-side tools and
// functions, or more generally whenever you want the model to produce a particular
// JSON structure of output.
//
// See our [guide](https://docs.anthropic.com/en/docs/tool-use) for more details.
Tools []ToolUnionParam `json:"tools,omitzero"`
// contains filtered or unexported fields
}
func (MessageNewParams) MarshalJSON ¶
func (r MessageNewParams) MarshalJSON() (data []byte, err error)
func (*MessageNewParams) UnmarshalJSON ¶
func (r *MessageNewParams) UnmarshalJSON(data []byte) error
type MessageNewParamsServiceTier ¶ added in v1.2.0
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.anthropic.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](/en/docs/build-with-claude/token-counting)
func (*MessageService) New ¶
func (r *MessageService) New(ctx context.Context, body MessageNewParams, opts ...option.RequestOption) (res *Message, err error)
Send a structured list of input messages with text and/or image content, and the model will generate the next message in the conversation.
The Messages API can be used for either single queries or stateless multi-turn conversations.
Learn more about the Messages API in our [user guide](/en/docs/initial-setup)
Note: If you choose to set a timeout for this request, we recommend 10 minutes.
func (*MessageService) NewStreaming ¶
func (r *MessageService) NewStreaming(ctx context.Context, body MessageNewParams, opts ...option.RequestOption) (stream *ssestream.Stream[MessageStreamEventUnion])
Send a structured list of input messages with text and/or image content, and the model will generate the next message in the conversation.
The Messages API can be used for either single queries or stateless multi-turn conversations.
Learn more about the Messages API in our [user guide](/en/docs/initial-setup)
Note: If you choose to set a timeout for this request, we recommend 10 minutes.
type MessageStartEvent ¶
type MessageStartEvent struct {
Message Message `json:"message,required"`
Type constant.MessageStart `json:"type,required"`
// 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].
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 {
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 ( ModelClaude3_7SonnetLatest Model = "claude-3-7-sonnet-latest" ModelClaude3_7Sonnet20250219 Model = "claude-3-7-sonnet-20250219" ModelClaude3_5HaikuLatest Model = "claude-3-5-haiku-latest" ModelClaude3_5Haiku20241022 Model = "claude-3-5-haiku-20241022" ModelClaudeSonnet4_20250514 Model = "claude-sonnet-4-20250514" ModelClaudeSonnet4_0 Model = "claude-sonnet-4-0" ModelClaude4Sonnet20250514 Model = "claude-4-sonnet-20250514" ModelClaude3_5SonnetLatest Model = "claude-3-5-sonnet-latest" ModelClaude3_5Sonnet20241022 Model = "claude-3-5-sonnet-20241022" ModelClaude_3_5_Sonnet_20240620 Model = "claude-3-5-sonnet-20240620" ModelClaudeOpus4_0 Model = "claude-opus-4-0" ModelClaudeOpus4_20250514 Model = "claude-opus-4-20250514" ModelClaude4Opus20250514 Model = "claude-4-opus-20250514" ModelClaude3OpusLatest Model = "claude-3-opus-latest" ModelClaude_3_Opus_20240229 Model = "claude-3-opus-20240229" // Deprecated: Will reach end-of-life on July 21st, 2025. Please migrate to a newer // model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for // more information. ModelClaude_3_Sonnet_20240229 Model = "claude-3-sonnet-20240229" ModelClaude_3_Haiku_20240307 Model = "claude-3-haiku-20240307" // Deprecated: Will reach end-of-life on July 21st, 2025. Please migrate to a newer // model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for // more information. ModelClaude_2_1 Model = "claude-2.1" // Deprecated: Will reach end-of-life on July 21st, 2025. Please migrate to a newer // model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for // more information. ModelClaude_2_0 Model = "claude-2.0" )
type 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) UnmarshalJSON ¶
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 ¶
func (r *ModelService) ListAutoPaging(ctx context.Context, params ModelListParams, opts ...option.RequestOption) *pagination.PageAutoPager[ModelInfo]
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 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 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 (r RedactedThinkingBlock) ToParam() RedactedThinkingBlockParam
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 ServerToolUsage ¶
type ServerToolUsage struct {
// 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 {
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"`
Input any `json:"input,required"`
Name constant.WebSearch `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
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) UnmarshalJSON ¶
func (r *ServerToolUseBlock) UnmarshalJSON(data []byte) error
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"`
// 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 "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 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) ToParam ¶
func (r TextBlock) ToParam() TextBlockParam
func (*TextBlock) UnmarshalJSON ¶
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"`
// 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) 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"`
// 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".
Type string `json:"type"`
// This field is from variant [CitationPageLocation].
EndPageNumber int64 `json:"end_page_number"`
// This field is from variant [CitationPageLocation].
StartPageNumber int64 `json:"start_page_number"`
// This field is from variant [CitationContentBlockLocation].
EndBlockIndex int64 `json:"end_block_index"`
// This field is from variant [CitationContentBlockLocation].
StartBlockIndex int64 `json:"start_block_index"`
// This field is from variant [CitationsWebSearchResultLocation].
EncryptedIndex string `json:"encrypted_index"`
// This field is from variant [CitationsWebSearchResultLocation].
Title string `json:"title"`
// This field is from variant [CitationsWebSearchResultLocation].
URL string `json:"url"`
JSON struct {
CitedText respjson.Field
DocumentIndex respjson.Field
DocumentTitle respjson.Field
EndCharIndex 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
// contains filtered or unexported fields
} `json:"-"`
}
TextCitationUnion contains all possible properties and values from CitationCharLocation, CitationPageLocation, CitationContentBlockLocation, CitationsWebSearchResultLocation.
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:
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) 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) UnmarshalJSON ¶
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 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.anthropic.com/en/docs/build-with-claude/extended-thinking)
// for details.
BudgetTokens int64 `json:"budget_tokens,required"`
// This field can be elided, and will marshal its zero value as "enabled".
Type constant.Enabled `json:"type,required"`
// contains filtered or unexported fields
}
The properties BudgetTokens, Type are required.
func (ThinkingConfigEnabledParam) 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"`
// 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 {
// 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 "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"`
// Description of what this tool does.
//
// Tool descriptions should be as detailed as possible. The more information that
// the model has about what the tool is and how to use it, the better it will
// perform. You can use natural language descriptions to reinforce important
// aspects of the tool input JSON schema.
Description param.Opt[string] `json:"description,omitzero"`
// Any of "custom".
Type ToolType `json:"type,omitzero"`
// Create a cache control breakpoint at this content block.
CacheControl CacheControlEphemeralParam `json:"cache_control,omitzero"`
// contains filtered or unexported fields
}
The properties InputSchema, Name are required.
func (ToolParam) MarshalJSON ¶
func (*ToolParam) UnmarshalJSON ¶
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"`
// 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 ¶
func (u ToolResultBlockParamContentUnion) GetCacheControl() *CacheControlEphemeralParam
Returns a pointer to the underlying variant's CacheControl property, if present.
func (ToolResultBlockParamContentUnion) GetCitations ¶
func (u ToolResultBlockParamContentUnion) GetCitations() []TextCitationParamUnion
Returns a pointer to the underlying variant's property, if present.
func (ToolResultBlockParamContentUnion) GetSource ¶
func (u ToolResultBlockParamContentUnion) GetSource() *ImageBlockParamSourceUnion
Returns a pointer to the underlying variant's property, if present.
func (ToolResultBlockParamContentUnion) GetText ¶
func (u ToolResultBlockParamContentUnion) GetText() *string
Returns a pointer to the underlying variant's property, if present.
func (ToolResultBlockParamContentUnion) GetType ¶
func (u ToolResultBlockParamContentUnion) GetType() *string
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 ToolTextEditor20250124Param ¶
type ToolTextEditor20250124Param struct {
// 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
// "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 ¶ added in v1.3.0
type ToolTextEditor20250429Param struct {
// 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
// "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 ¶ added in v1.3.0
func (r ToolTextEditor20250429Param) MarshalJSON() (data []byte, err error)
func (*ToolTextEditor20250429Param) UnmarshalJSON ¶ added in v1.3.0
func (r *ToolTextEditor20250429Param) UnmarshalJSON(data []byte) error
type ToolUnionParam ¶
type ToolUnionParam struct {
OfTool *ToolParam `json:",omitzero,inline"`
OfBashTool20250124 *ToolBash20250124Param `json:",omitzero,inline"`
OfTextEditor20250124 *ToolTextEditor20250124Param `json:",omitzero,inline"`
OfTextEditor20250429 *ToolTextEditor20250429Param `json:",omitzero,inline"`
OfWebSearchTool20250305 *WebSearchTool20250305Param `json:",omitzero,inline"`
// contains filtered or unexported fields
}
Only one field can be non-zero.
Use param.IsOmitted to confirm if a field is set.
func ToolUnionParamOfTool ¶
func ToolUnionParamOfTool(inputSchema ToolInputSchemaParam, name string) ToolUnionParam
func (ToolUnionParam) GetAllowedDomains ¶
func (u ToolUnionParam) GetAllowedDomains() []string
Returns a pointer to the underlying variant's property, if present.
func (ToolUnionParam) GetBlockedDomains ¶
func (u ToolUnionParam) GetBlockedDomains() []string
Returns a pointer to the underlying variant's 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) GetDescription ¶
func (u ToolUnionParam) GetDescription() *string
Returns a pointer to the underlying variant's property, if present.
func (ToolUnionParam) GetInputSchema ¶
func (u ToolUnionParam) GetInputSchema() *ToolInputSchemaParam
Returns a pointer to the underlying variant's property, if present.
func (ToolUnionParam) 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) GetType ¶
func (u ToolUnionParam) GetType() *string
Returns a pointer to the underlying variant's property, if present.
func (ToolUnionParam) GetUserLocation ¶
func (u ToolUnionParam) GetUserLocation() *WebSearchTool20250305UserLocationParam
Returns a pointer to the underlying variant's 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"`
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
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 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"`
// 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 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 {
// 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"`
// 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 {
CacheCreationInputTokens respjson.Field
CacheReadInputTokens 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) UnmarshalJSON ¶
type UsageServiceTier ¶ added in v1.2.0
type UsageServiceTier string
If the request used the priority, standard, or batch tier.
const ( UsageServiceTierStandard UsageServiceTier = "standard" UsageServiceTierPriority UsageServiceTier = "priority" UsageServiceTierBatch UsageServiceTier = "batch" )
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) 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 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"`
// Parameters for the user's location. Used to provide more relevant search
// results.
UserLocation WebSearchTool20250305UserLocationParam `json:"user_location,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 "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 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
}
Parameters for the user's location. Used to provide more relevant search results.
The property Type is required.
func (WebSearchTool20250305UserLocationParam) MarshalJSON ¶
func (r WebSearchTool20250305UserLocationParam) MarshalJSON() (data []byte, err error)
func (*WebSearchTool20250305UserLocationParam) UnmarshalJSON ¶
func (r *WebSearchTool20250305UserLocationParam) UnmarshalJSON(data []byte) error
type WebSearchToolRequestErrorErrorCode ¶
type WebSearchToolRequestErrorErrorCode string
const ( WebSearchToolRequestErrorErrorCodeInvalidToolInput WebSearchToolRequestErrorErrorCode = "invalid_tool_input" WebSearchToolRequestErrorErrorCodeMaxUsesExceeded WebSearchToolRequestErrorErrorCode = "max_uses_exceeded" WebSearchToolRequestErrorErrorCodeTooManyRequests WebSearchToolRequestErrorErrorCode = "too_many_requests" WebSearchToolRequestErrorErrorCodeQueryTooLong WebSearchToolRequestErrorErrorCode = "query_too_long" )
type WebSearchToolRequestErrorParam ¶
type WebSearchToolRequestErrorParam struct {
// Any of "invalid_tool_input", "unavailable", "max_uses_exceeded",
// "too_many_requests", "query_too_long".
ErrorCode WebSearchToolRequestErrorErrorCode `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 {
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 {
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) UnmarshalJSON ¶
func (r *WebSearchToolResultBlock) 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 WebSearchToolResultErrorErrorCode `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 ¶
func (u WebSearchToolResultBlockContentUnion) RawJSON() string
Returns the unmodified JSON received from the API
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"`
// 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 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 NewWebSearchToolRequestError ¶
func NewWebSearchToolRequestError(errorCode WebSearchToolRequestErrorErrorCode) WebSearchToolResultBlockParamContentUnion
func (WebSearchToolResultBlockParamContentUnion) MarshalJSON ¶
func (u WebSearchToolResultBlockParamContentUnion) MarshalJSON() ([]byte, error)
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".
ErrorCode WebSearchToolResultErrorErrorCode `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 WebSearchToolResultErrorErrorCode ¶
type WebSearchToolResultErrorErrorCode string
const ( WebSearchToolResultErrorErrorCodeInvalidToolInput WebSearchToolResultErrorErrorCode = "invalid_tool_input" WebSearchToolResultErrorErrorCodeMaxUsesExceeded WebSearchToolResultErrorErrorCode = "max_uses_exceeded" WebSearchToolResultErrorErrorCodeTooManyRequests WebSearchToolResultErrorErrorCode = "too_many_requests" WebSearchToolResultErrorErrorCodeQueryTooLong WebSearchToolResultErrorErrorCode = "query_too_long" )
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
encoding/json
Package json implements encoding and decoding of JSON as defined in RFC 7159.
|
Package json implements encoding and decoding of JSON as defined in RFC 7159. |
|
encoding/json/shims
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.21, and used by the Go 1.24 encoding/json package.
|
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.21, and used by the Go 1.24 encoding/json package. |
|
packages
|
|