1// Package anthropic provides an implementation of the fantasy AI SDK for Anthropic's language models.
 2package anthropic
 3
 4import "charm.land/fantasy"
 5
 6// ProviderOptions represents additional options for the Anthropic provider.
 7type ProviderOptions struct {
 8	SendReasoning          *bool                   `json:"send_reasoning"`
 9	Thinking               *ThinkingProviderOption `json:"thinking"`
10	DisableParallelToolUse *bool                   `json:"disable_parallel_tool_use"`
11}
12
13// Options implements the ProviderOptions interface.
14func (o *ProviderOptions) Options() {}
15
16// ThinkingProviderOption represents thinking options for the Anthropic provider.
17type ThinkingProviderOption struct {
18	BudgetTokens int64 `json:"budget_tokens"`
19}
20
21// ReasoningOptionMetadata represents reasoning metadata for the Anthropic provider.
22type ReasoningOptionMetadata struct {
23	Signature    string `json:"signature"`
24	RedactedData string `json:"redacted_data"`
25}
26
27// Options implements the ProviderOptions interface.
28func (*ReasoningOptionMetadata) Options() {}
29
30// ProviderCacheControlOptions represents cache control options for the Anthropic provider.
31type ProviderCacheControlOptions struct {
32	CacheControl CacheControl `json:"cache_control"`
33}
34
35// Options implements the ProviderOptions interface.
36func (*ProviderCacheControlOptions) Options() {}
37
38// CacheControl represents cache control settings for the Anthropic provider.
39type CacheControl struct {
40	Type string `json:"type"`
41}
42
43// NewProviderOptions creates new provider options for the Anthropic provider.
44func NewProviderOptions(opts *ProviderOptions) fantasy.ProviderOptions {
45	return fantasy.ProviderOptions{
46		Name: opts,
47	}
48}
49
50// NewProviderCacheControlOptions creates new cache control options for the Anthropic provider.
51func NewProviderCacheControlOptions(opts *ProviderCacheControlOptions) fantasy.ProviderOptions {
52	return fantasy.ProviderOptions{
53		Name: opts,
54	}
55}
56
57// ParseOptions parses provider options from a map for the Anthropic provider.
58func ParseOptions(data map[string]any) (*ProviderOptions, error) {
59	var options ProviderOptions
60	if err := fantasy.ParseOptions(data, &options); err != nil {
61		return nil, err
62	}
63	return &options, nil
64}