Documentation
¶
Overview ¶
anthropic implements an API client for the Anthropic Messages API. https://docs.anthropic.com/en/api/getting-started
Index ¶
- func GenerateRequest(model string, session *schema.Conversation, opts ...opt.Opt) (any, error)
- func WithAfterId(id string) opt.Opt
- func WithBeforeId(id string) opt.Opt
- func WithCachedSystemPrompt(value string) opt.Opt
- func WithJSONOutput(schema *jsonschema.Schema) opt.Opt
- func WithLimit(limit uint) opt.Opt
- func WithMaxTokens(value uint) opt.Opt
- func WithOutputConfig(value string) opt.Opt
- func WithServiceTier(value string) opt.Opt
- func WithStopSequences(values ...string) opt.Opt
- func WithSystemPrompt(value string) opt.Opt
- func WithTemperature(value float64) opt.Opt
- func WithThinking(budgetTokens uint) opt.Opt
- func WithToolChoice(name string) opt.Opt
- func WithToolChoiceAny() opt.Opt
- func WithToolChoiceAuto() opt.Opt
- func WithToolChoiceNone() opt.Opt
- func WithTopK(value uint) opt.Opt
- func WithTopP(value float64) opt.Opt
- func WithUser(value string) opt.Opt
- type Client
- func (c *Client) GetModel(ctx context.Context, name string, opts ...opt.Opt) (*schema.Model, error)
- func (c *Client) ListModels(ctx context.Context, opts ...opt.Opt) ([]schema.Model, error)
- func (*Client) Name() string
- func (c *Client) WithSession(ctx context.Context, model schema.Model, session *schema.Conversation, ...) (*schema.Message, *schema.Usage, error)
- func (c *Client) WithoutSession(ctx context.Context, model schema.Model, message *schema.Message, ...) (*schema.Message, *schema.Usage, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateRequest ¶
GenerateRequest builds a generate request from options without sending it. Useful for testing and debugging.
func WithAfterId ¶
WithAfterId sets the cursor for forward pagination
func WithBeforeId ¶
WithBeforeId sets the cursor for backward pagination
func WithCachedSystemPrompt ¶
WithCachedSystemPrompt sets the system prompt with caching enabled
func WithJSONOutput ¶
func WithJSONOutput(schema *jsonschema.Schema) opt.Opt
WithJSONOutput sets the output format to JSON with the given schema
func WithMaxTokens ¶
WithMaxTokens sets the maximum number of tokens to generate (minimum 1)
func WithOutputConfig ¶
WithOutputConfig sets the output effort ("low", "medium", or "high")
func WithServiceTier ¶
WithServiceTier sets the service tier for the request ("auto" or "standard_only")
func WithStopSequences ¶
WithStopSequences sets custom stop sequences for the request
func WithSystemPrompt ¶
WithSystemPrompt sets the system prompt for the request
func WithTemperature ¶
WithTemperature sets the temperature for the request (0.0 to 1.0)
func WithThinking ¶
WithThinking enables extended thinking with the specified token budget (minimum 1024)
func WithToolChoice ¶
WithToolChoice forces the model to use a specific tool by name
func WithToolChoiceAny ¶
WithToolChoiceAny forces the model to use one of the available tools
func WithToolChoiceAuto ¶
WithToolChoiceAuto lets the model decide whether to use tools
func WithToolChoiceNone ¶
WithToolChoiceNone prevents the model from using any tools
Types ¶
type Client ¶
type Client struct {
*client.Client
*modelcache.ModelCache
}
func (*Client) ListModels ¶
ListModels returns all available models from the Anthropic API