diff --git a/chat.go b/chat.go index 9719f6b92..8ec747889 100644 --- a/chat.go +++ b/chat.go @@ -88,10 +88,17 @@ const ( ChatMessagePartTypeImageURL ChatMessagePartType = "image_url" ) +// CacheControlConfig for anthropic prompt cache control. +type CacheControlConfig struct { + Type string `json:"type,omitempty"` + TTL string `json:"ttl,omitempty"` +} + type ChatMessagePart struct { - Type ChatMessagePartType `json:"type,omitempty"` - Text string `json:"text,omitempty"` - ImageURL *ChatMessageImageURL `json:"image_url,omitempty"` + Type ChatMessagePartType `json:"type,omitempty"` + Text string `json:"text,omitempty"` + ImageURL *ChatMessageImageURL `json:"image_url,omitempty"` + CacheControl *CacheControlConfig `json:"cache_control,omitempty"` } type ChatCompletionMessage struct { @@ -344,8 +351,9 @@ const ( ) type Tool struct { - Type ToolType `json:"type"` - Function *FunctionDefinition `json:"function,omitempty"` + Type ToolType `json:"type"` + Function *FunctionDefinition `json:"function,omitempty"` + CacheControl *CacheControlConfig `json:"cache_control,omitempty"` } type ToolChoice struct { diff --git a/common.go b/common.go index d1936d656..267f33076 100644 --- a/common.go +++ b/common.go @@ -9,6 +9,7 @@ type Usage struct { TotalTokens int `json:"total_tokens"` PromptTokensDetails *PromptTokensDetails `json:"prompt_tokens_details"` CompletionTokensDetails *CompletionTokensDetails `json:"completion_tokens_details"` + CacheReadInputTokens int `json:"cache_read_input_tokens"` } // CompletionTokensDetails Breakdown of tokens used in a completion.