Documentation
¶
Index ¶
- func SetContentBlockCacheControl(block *schema.ContentBlock, ctrl *anthropic.CacheControlEphemeralParam) *schema.ContentBlock
- func SetToolInfoCacheControl(toolInfo *schema.ToolInfo, ctrl *anthropic.CacheControlEphemeralParam) *schema.ToolInfo
- func WithCustomHeaders(headers map[string]string) model.Option
- func WithExtraFields(fields map[string]any) model.Option
- func WithRequestTimeout(d time.Duration) model.Option
- func WithServerTools(tools []*ServerToolConfig) model.Option
- type BashCodeExecutionArguments
- type BashCodeExecutionResult
- type BashCodeExecutionResultBlock
- type BashCodeExecutionResultError
- type BashCodeExecutionResultType
- type BedrockConfig
- type CodeExecutionArguments
- type CodeExecutionOutput
- type CodeExecutionResult
- type CodeExecutionResultBlock
- type CodeExecutionResultError
- type CodeExecutionResultType
- type Config
- type EncryptedCodeExecutionResultBlock
- type GoogleVertexAIConfig
- type Model
- func (m *Model) Generate(ctx context.Context, input []*schema.AgenticMessage, opts ...model.Option) (outMsg *schema.AgenticMessage, err error)
- func (m *Model) GetType() string
- func (m *Model) IsCallbacksEnabled() bool
- func (m *Model) Stream(ctx context.Context, input []*schema.AgenticMessage, opts ...model.Option) (outStream *schema.StreamReader[*schema.AgenticMessage], err error)
- type ServerToolCallArguments
- type ServerToolConfig
- type ServerToolName
- type ServerToolResult
- type TextEditorCodeExecutionArguments
- type TextEditorCodeExecutionCreateResult
- type TextEditorCodeExecutionResult
- type TextEditorCodeExecutionResultError
- type TextEditorCodeExecutionResultType
- type TextEditorCodeExecutionStrReplaceResult
- type TextEditorCodeExecutionViewResult
- type ToolSearchToolBm25Arguments
- type ToolSearchToolReference
- type ToolSearchToolRegexArguments
- type ToolSearchToolResult
- type ToolSearchToolResultError
- type ToolSearchToolResultType
- type ToolSearchToolSearchResult
- type WebFetchArguments
- type WebFetchDocument
- type WebFetchDocumentCitations
- type WebFetchDocumentSource
- type WebFetchResult
- type WebFetchResultBlock
- type WebFetchResultError
- type WebFetchResultType
- type WebSearchArguments
- type WebSearchResult
- type WebSearchResultBlock
- type WebSearchResultError
- type WebSearchResultItem
- type WebSearchResultType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetContentBlockCacheControl ¶
func SetContentBlockCacheControl(block *schema.ContentBlock, ctrl *anthropic.CacheControlEphemeralParam) *schema.ContentBlock
SetContentBlockCacheControl sets a cache control on a content block. When a manual control is set, the top-level auto-cache will not override it.
func SetToolInfoCacheControl ¶
func SetToolInfoCacheControl(toolInfo *schema.ToolInfo, ctrl *anthropic.CacheControlEphemeralParam) *schema.ToolInfo
SetToolInfoCacheControl sets a cache control on a tool info. When a manual control is set, the top-level auto-cache will not override it.
func WithCustomHeaders ¶
WithCustomHeaders specifies custom HTTP headers to include in API requests.
func WithExtraFields ¶
WithExtraFields sets extra fields to include in the request body. These fields will be merged into the top-level JSON request body, overriding any existing fields with the same key.
Example:
WithExtraFields(map[string]any{
"service_tier": "default",
"metadata": map[string]any{"user_id": "user_123"},
})
The resulting request body will be:
{
"model": "claude-sonnet-4-20250514",
"messages": [...],
"service_tier": "default",
"metadata": {"user_id": "user_123"}
}
func WithRequestTimeout ¶ added in v0.1.3
WithRequestTimeout sets the timeout for each API request. This overrides the RequestTimeout set in Config for a single call.
func WithServerTools ¶
func WithServerTools(tools []*ServerToolConfig) model.Option
WithServerTools specifies server-side tools available to the model.
Types ¶
type BashCodeExecutionArguments ¶
type BashCodeExecutionArguments struct {
Command string `json:"command,omitempty" mapstructure:"command,omitempty"`
}
type BashCodeExecutionResult ¶
type BashCodeExecutionResult struct {
Type BashCodeExecutionResultType `json:"type,omitempty" mapstructure:"type,omitempty"`
Result *BashCodeExecutionResultBlock `json:"result,omitempty" mapstructure:"result,omitempty"`
Error *BashCodeExecutionResultError `json:"error,omitempty" mapstructure:"error,omitempty"`
}
type BashCodeExecutionResultBlock ¶
type BashCodeExecutionResultBlock struct {
Content []*CodeExecutionOutput `json:"content,omitempty" mapstructure:"content,omitempty"`
Stdout string `json:"stdout,omitempty" mapstructure:"stdout,omitempty"`
Stderr string `json:"stderr,omitempty" mapstructure:"stderr,omitempty"`
ReturnCode int64 `json:"return_code,omitempty" mapstructure:"return_code,omitempty"`
}
type BashCodeExecutionResultError ¶
type BashCodeExecutionResultError struct {
Code string `json:"code,omitempty" mapstructure:"code,omitempty"`
}
type BashCodeExecutionResultType ¶
type BashCodeExecutionResultType string
const ( BashCodeExecutionResultTypeResult BashCodeExecutionResultType = "bash_code_execution_result" BashCodeExecutionResultTypeError BashCodeExecutionResultType = "bash_code_execution_tool_result_error" )
type BedrockConfig ¶
type BedrockConfig struct {
// AccessKey is your Bedrock API Access key
// Obtain from: https://docs.aws.amazon.com/bedrock/latest/userguide/getting-started.html
// Optional.
AccessKey string
// SecretAccessKey is your Bedrock API Secret Access key
// Obtain from: https://docs.aws.amazon.com/bedrock/latest/userguide/getting-started.html
// Optional.
SecretAccessKey string
// SessionToken is your Bedrock API Session Token
// Obtain from: https://docs.aws.amazon.com/bedrock/latest/userguide/getting-started.html
// Optional.
SessionToken string
// Profile is your Bedrock API AWS profile
// This parameter is ignored if AccessKey and SecretAccessKey are provided
// Obtain from: https://docs.aws.amazon.com/bedrock/latest/userguide/getting-started.html
// Optional.
Profile string
// Region is your Bedrock API region
// Obtain from: https://docs.aws.amazon.com/bedrock/latest/userguide/getting-started.html
// Optional.
Region string
}
type CodeExecutionArguments ¶
type CodeExecutionArguments struct {
Code string `json:"code,omitempty" mapstructure:"code,omitempty"`
}
type CodeExecutionOutput ¶
type CodeExecutionOutput struct {
FileID string `json:"file_id,omitempty" mapstructure:"file_id,omitempty"`
}
type CodeExecutionResult ¶
type CodeExecutionResult struct {
Type CodeExecutionResultType `json:"type,omitempty" mapstructure:"type,omitempty"`
Result *CodeExecutionResultBlock `json:"result,omitempty" mapstructure:"result,omitempty"`
EncryptedResult *EncryptedCodeExecutionResultBlock `json:"encrypted_result,omitempty" mapstructure:"encrypted_result,omitempty"`
Error *CodeExecutionResultError `json:"error,omitempty" mapstructure:"error,omitempty"`
}
type CodeExecutionResultBlock ¶
type CodeExecutionResultBlock struct {
Content []*CodeExecutionOutput `json:"content,omitempty" mapstructure:"content,omitempty"`
Stdout string `json:"stdout,omitempty" mapstructure:"stdout,omitempty"`
Stderr string `json:"stderr,omitempty" mapstructure:"stderr,omitempty"`
ReturnCode int64 `json:"return_code,omitempty" mapstructure:"return_code,omitempty"`
}
type CodeExecutionResultError ¶
type CodeExecutionResultError struct {
Code string `json:"code,omitempty" mapstructure:"code,omitempty"`
}
type CodeExecutionResultType ¶
type CodeExecutionResultType string
const ( CodeExecutionResultTypeResult CodeExecutionResultType = "code_execution_result" CodeExecutionResultTypeEncrypted CodeExecutionResultType = "encrypted_code_execution_result" CodeExecutionResultTypeError CodeExecutionResultType = "code_execution_tool_result_error" )
type Config ¶
type Config struct {
// HTTPClient specifies the client to send HTTP requests.
// It is not applied when using Google Vertex AI.
// Optional.
HTTPClient *http.Client
// RequestTimeout specifies the timeout for each API request.
// Optional.
RequestTimeout time.Duration
// ByBedrock specifies the configuration for using AWS Bedrock.
// Optional.
ByBedrock *BedrockConfig
// ByGoogleVertexAI specifies the configuration for using Google Vertex AI.
// Optional.
ByGoogleVertexAI *GoogleVertexAIConfig
// BaseURL is the custom API endpoint URL
// Use this to specify a different API endpoint, e.g., for proxies or enterprise setups
// Optional.
BaseURL string
// APIKey is your Anthropic API key for direct Anthropic API access.
// Obtain from: https://console.anthropic.com/account/keys
// Optional when AuthToken is set.
APIKey string
// AuthToken is your Anthropic auth token for direct Anthropic API access.
// Optional when APIKey is set.
AuthToken string
// Model specifies which Claude model to use.
// Required.
Model string
// MaxTokens limits the maximum number of tokens in the response
// Range: 1 to model's context length
// Required.
MaxTokens int
// StopSequences specifies custom stop sequences
// The model will stop generating when it encounters any of these sequences
// Optional.
StopSequences []string
// DisableParallelToolUse specifies whether to disable parallel tool use.
// It only takes effect when AgenticToolChoice is set.
// Optional.
DisableParallelToolUse *bool
// Thinking specifies the configuration for Claude thinking mode.
// Optional.
Thinking *anthropic.ThinkingConfigParamUnion
// CustomHeaders specifies custom HTTP headers to include in API requests.
// CustomHeaders allows passing additional metadata or authentication information.
// Optional.
CustomHeaders map[string]string
// ExtraFields specifies extra fields to include in the request body.
// These fields will be merged into the top-level JSON request body, overriding any existing fields with the same key.
// Optional.
//
// Example:
//
// ExtraFields: map[string]any{
// "reasoning_effort": "high",
// "service_tier": "default",
// }
//
// The resulting request body will be:
//
// {
// "model": "o1",
// "messages": [...],
// "reasoning_effort": "high",
// "service_tier": "default"
// }
ExtraFields map[string]any
// CacheControl configures automatic prompt caching behavior.
// Top-level cache control automatically applies a cache_control marker to the last
// cacheable block in the request.
// Optional.
CacheControl *anthropic.CacheControlEphemeralParam
}
type EncryptedCodeExecutionResultBlock ¶
type EncryptedCodeExecutionResultBlock struct {
Content []*CodeExecutionOutput `json:"content,omitempty" mapstructure:"content,omitempty"`
EncryptedStdout string `json:"encrypted_stdout,omitempty" mapstructure:"encrypted_stdout,omitempty"`
Stderr string `json:"stderr,omitempty" mapstructure:"stderr,omitempty"`
ReturnCode int64 `json:"return_code,omitempty" mapstructure:"return_code,omitempty"`
}
type GoogleVertexAIConfig ¶
type GoogleVertexAIConfig struct {
// ProjectID is your Google Cloud project ID.
// Required for Google Vertex AI requests. If not set, automatically detected
// from ANTHROPIC_VERTEX_PROJECT_ID, GOOGLE_CLOUD_PROJECT, or GCLOUD_PROJECT
// environment variables.
ProjectID string
// Region is the Vertex AI region (e.g., "us-east5").
// Required for Google Vertex AI requests. If not set, automatically detected
// from CLOUD_ML_REGION environment variable.
// See: https://claude.ai/docs/en/google-vertex-ai
Region string
}
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
func (*Model) Generate ¶
func (m *Model) Generate(ctx context.Context, input []*schema.AgenticMessage, opts ...model.Option) (outMsg *schema.AgenticMessage, err error)
func (*Model) IsCallbacksEnabled ¶
func (*Model) Stream ¶
func (m *Model) Stream(ctx context.Context, input []*schema.AgenticMessage, opts ...model.Option) (outStream *schema.StreamReader[*schema.AgenticMessage], err error)
type ServerToolCallArguments ¶
type ServerToolCallArguments struct {
WebSearch *WebSearchArguments `json:"web_search,omitempty" mapstructure:"web_search,omitempty"`
WebFetch *WebFetchArguments `json:"web_fetch,omitempty" mapstructure:"web_fetch,omitempty"`
CodeExecution *CodeExecutionArguments `json:"code_execution,omitempty" mapstructure:"code_execution,omitempty"`
BashCodeExecution *BashCodeExecutionArguments `json:"bash_code_execution,omitempty" mapstructure:"bash_code_execution,omitempty"`
TextEditorCodeExecution *TextEditorCodeExecutionArguments `json:"text_editor_code_execution,omitempty" mapstructure:"text_editor_code_execution,omitempty"`
ToolSearchToolBm25 *ToolSearchToolBm25Arguments `json:"tool_search_tool_bm25,omitempty" mapstructure:"tool_search_tool_bm25,omitempty"`
ToolSearchToolRegex *ToolSearchToolRegexArguments `json:"tool_search_tool_regex,omitempty" mapstructure:"tool_search_tool_regex,omitempty"`
}
type ServerToolConfig ¶
type ServerToolConfig struct {
// WebSearch20260209 specifies the web search server tool with 20260209 version.
WebSearch20260209 *anthropic.WebSearchTool20260209Param
// WebFetch20260309 specifies the web fetch server tool with 20260309 version.
WebFetch20260309 *anthropic.WebFetchTool20260309Param
// CodeExecution20260120 specifies the code execution server tool with 20260120 version.
// This single request-side tool enables the runtime server tool names
// "code_execution", "bash_code_execution", and "text_editor_code_execution".
CodeExecution20260120 *anthropic.CodeExecutionTool20260120Param
// ToolSearchToolBm25_20251119 specifies the BM25 tool search server tool with
// 20251119 version.
ToolSearchToolBm25_20251119 *anthropic.ToolSearchToolBm25_20251119Param
// ToolSearchToolRegex20251119 specifies the regex tool search server tool with
// 20251119 version.
ToolSearchToolRegex20251119 *anthropic.ToolSearchToolRegex20251119Param
}
type ServerToolName ¶
type ServerToolName string
const ( ServerToolNameWebSearch ServerToolName = "web_search" ServerToolNameWebFetch ServerToolName = "web_fetch" ServerToolNameCodeExecution ServerToolName = "code_execution" ServerToolNameBashCodeExecution ServerToolName = "bash_code_execution" ServerToolNameTextEditorCodeExecution ServerToolName = "text_editor_code_execution" ServerToolNameToolSearchToolBm25 ServerToolName = "tool_search_tool_bm25" ServerToolNameToolSearchToolRegex ServerToolName = "tool_search_tool_regex" )
type ServerToolResult ¶
type ServerToolResult struct {
WebSearch *WebSearchResult `json:"web_search,omitempty" mapstructure:"web_search,omitempty"`
WebFetch *WebFetchResult `json:"web_fetch,omitempty" mapstructure:"web_fetch,omitempty"`
CodeExecution *CodeExecutionResult `json:"code_execution,omitempty" mapstructure:"code_execution,omitempty"`
BashCodeExecution *BashCodeExecutionResult `json:"bash_code_execution,omitempty" mapstructure:"bash_code_execution,omitempty"`
TextEditorCodeExecution *TextEditorCodeExecutionResult `json:"text_editor_code_execution,omitempty" mapstructure:"text_editor_code_execution,omitempty"`
ToolSearchToolBm25 *ToolSearchToolResult `json:"tool_search_tool_bm25,omitempty" mapstructure:"tool_search_tool_bm25,omitempty"`
ToolSearchToolRegex *ToolSearchToolResult `json:"tool_search_tool_regex,omitempty" mapstructure:"tool_search_tool_regex,omitempty"`
}
type TextEditorCodeExecutionArguments ¶
type TextEditorCodeExecutionArguments struct {
Command string `json:"command,omitempty" mapstructure:"command,omitempty"`
Path string `json:"path,omitempty" mapstructure:"path,omitempty"`
FileText string `json:"file_text,omitempty" mapstructure:"file_text,omitempty"`
OldStr string `json:"old_str,omitempty" mapstructure:"old_str,omitempty"`
NewStr string `json:"new_str,omitempty" mapstructure:"new_str,omitempty"`
}
type TextEditorCodeExecutionCreateResult ¶
type TextEditorCodeExecutionCreateResult struct {
IsFileUpdate bool `json:"is_file_update,omitempty" mapstructure:"is_file_update,omitempty"`
}
type TextEditorCodeExecutionResult ¶
type TextEditorCodeExecutionResult struct {
Type TextEditorCodeExecutionResultType `json:"type,omitempty" mapstructure:"type,omitempty"`
View *TextEditorCodeExecutionViewResult `json:"view,omitempty" mapstructure:"view,omitempty"`
Create *TextEditorCodeExecutionCreateResult `json:"create,omitempty" mapstructure:"create,omitempty"`
StrReplace *TextEditorCodeExecutionStrReplaceResult `json:"str_replace,omitempty" mapstructure:"str_replace,omitempty"`
Error *TextEditorCodeExecutionResultError `json:"error,omitempty" mapstructure:"error,omitempty"`
}
type TextEditorCodeExecutionResultType ¶
type TextEditorCodeExecutionResultType string
const ( TextEditorCodeExecutionResultTypeError TextEditorCodeExecutionResultType = "text_editor_code_execution_tool_result_error" TextEditorCodeExecutionResultTypeCreate TextEditorCodeExecutionResultType = "text_editor_code_execution_create_result" TextEditorCodeExecutionResultTypeStrReplace TextEditorCodeExecutionResultType = "text_editor_code_execution_str_replace_result" TextEditorCodeExecutionResultTypeView TextEditorCodeExecutionResultType = "text_editor_code_execution_view_result" )
type TextEditorCodeExecutionStrReplaceResult ¶
type TextEditorCodeExecutionStrReplaceResult struct {
OldStart int64 `json:"oldStart,omitempty" mapstructure:"oldStart,omitempty"`
OldLines int64 `json:"oldLines,omitempty" mapstructure:"oldLines,omitempty"`
NewStart int64 `json:"newStart,omitempty" mapstructure:"newStart,omitempty"`
NewLines int64 `json:"newLines,omitempty" mapstructure:"newLines,omitempty"`
Lines []string `json:"lines,omitempty" mapstructure:"lines,omitempty"`
}
type TextEditorCodeExecutionViewResult ¶
type TextEditorCodeExecutionViewResult struct {
FileType string `json:"file_type,omitempty" mapstructure:"file_type,omitempty"`
Content string `json:"content,omitempty" mapstructure:"content,omitempty"`
NumLines int64 `json:"numLines,omitempty" mapstructure:"numLines,omitempty"`
StartLine int64 `json:"startLine,omitempty" mapstructure:"startLine,omitempty"`
TotalLines int64 `json:"totalLines,omitempty" mapstructure:"totalLines,omitempty"`
}
type ToolSearchToolBm25Arguments ¶
type ToolSearchToolBm25Arguments struct {
Query string `json:"query,omitempty" mapstructure:"query,omitempty"`
}
type ToolSearchToolReference ¶
type ToolSearchToolReference struct {
ToolName string `json:"tool_name,omitempty" mapstructure:"tool_name,omitempty"`
}
type ToolSearchToolRegexArguments ¶
type ToolSearchToolRegexArguments struct {
Query string `json:"query,omitempty" mapstructure:"query,omitempty"`
}
type ToolSearchToolResult ¶
type ToolSearchToolResult struct {
Type ToolSearchToolResultType `json:"type,omitempty" mapstructure:"type,omitempty"`
SearchResult *ToolSearchToolSearchResult `json:"search_result,omitempty" mapstructure:"search_result,omitempty"`
Error *ToolSearchToolResultError `json:"error,omitempty" mapstructure:"error,omitempty"`
}
type ToolSearchToolResultType ¶
type ToolSearchToolResultType string
const ( ToolSearchToolResultTypeSearchResult ToolSearchToolResultType = "tool_search_tool_search_result" ToolSearchToolResultTypeError ToolSearchToolResultType = "tool_search_tool_result_error" )
type ToolSearchToolSearchResult ¶
type ToolSearchToolSearchResult struct {
ToolReferences []*ToolSearchToolReference `json:"tool_references,omitempty" mapstructure:"tool_references,omitempty"`
}
type WebFetchArguments ¶
type WebFetchArguments struct {
URL string `json:"url,omitempty" mapstructure:"url,omitempty"`
}
type WebFetchDocument ¶
type WebFetchDocument struct {
Source *WebFetchDocumentSource `json:"source,omitempty" mapstructure:"source,omitempty"`
Title string `json:"title,omitempty" mapstructure:"title,omitempty"`
Citations *WebFetchDocumentCitations `json:"citations,omitempty" mapstructure:"citations,omitempty"`
}
type WebFetchDocumentCitations ¶
type WebFetchDocumentCitations struct {
Enabled bool `json:"enabled,omitempty" mapstructure:"enabled,omitempty"`
}
type WebFetchDocumentSource ¶
type WebFetchResult ¶
type WebFetchResult struct {
Type WebFetchResultType `json:"type,omitempty" mapstructure:"type,omitempty"`
Result *WebFetchResultBlock `json:"result,omitempty" mapstructure:"result,omitempty"`
Error *WebFetchResultError `json:"error,omitempty" mapstructure:"error,omitempty"`
}
type WebFetchResultBlock ¶
type WebFetchResultBlock struct {
URL string `json:"url,omitempty" mapstructure:"url,omitempty"`
RetrievedAt string `json:"retrieved_at,omitempty" mapstructure:"retrieved_at,omitempty"`
Content *WebFetchDocument `json:"content,omitempty" mapstructure:"content,omitempty"`
}
type WebFetchResultError ¶
type WebFetchResultError struct {
Code string `json:"code,omitempty" mapstructure:"code,omitempty"`
}
type WebFetchResultType ¶
type WebFetchResultType string
const ( WebFetchResultTypeResult WebFetchResultType = "web_fetch_result" WebFetchResultTypeError WebFetchResultType = "web_fetch_tool_result_error" )
type WebSearchArguments ¶
type WebSearchArguments struct {
Query string `json:"query,omitempty" mapstructure:"query,omitempty"`
}
type WebSearchResult ¶
type WebSearchResult struct {
Type WebSearchResultType `json:"type,omitempty" mapstructure:"type,omitempty"`
Result *WebSearchResultBlock `json:"result,omitempty" mapstructure:"result,omitempty"`
Error *WebSearchResultError `json:"error,omitempty" mapstructure:"error,omitempty"`
}
type WebSearchResultBlock ¶
type WebSearchResultBlock struct {
Content []*WebSearchResultItem `json:"content,omitempty" mapstructure:"content,omitempty"`
}
type WebSearchResultError ¶
type WebSearchResultError struct {
Code string `json:"code,omitempty" mapstructure:"code,omitempty"`
}
type WebSearchResultItem ¶
type WebSearchResultItem struct {
Title string `json:"title,omitempty" mapstructure:"title,omitempty"`
URL string `json:"url,omitempty" mapstructure:"url,omitempty"`
EncryptedContent string `json:"encrypted_content,omitempty" mapstructure:"encrypted_content,omitempty"`
PageAge string `json:"page_age,omitempty" mapstructure:"page_age,omitempty"`
}
type WebSearchResultType ¶
type WebSearchResultType string
const ( WebSearchResultTypeResult WebSearchResultType = "web_search_result" WebSearchResultTypeError WebSearchResultType = "web_search_tool_result_error" )
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
cache
command
|
|
|
client_tool_search
command
|
|
|
generate
command
|
|
|
hosted_tool_search
command
|
|
|
stream_with_function_tool
command
|
|
|
stream_with_server_tool
command
|