Smith::LLM::Anthropic
Inherits Smith::LLM::Provider < Reference < Object
Constants
API_VERSION = "2023-06-01"
DEFAULT_ENDPOINT = "https://api.anthropic.com/v1/messages"
DEFAULT_MAX_TOKENS = 4096
DEFAULT_MODEL = "claude-sonnet-5"
Constructors
new(api_key : String = ENV.fetch("ANTHROPIC_API_KEY", ""), default_model : String = DEFAULT_MODEL, timeouts : Timeouts = Timeouts.default, cache : Bool = true)
SourceInstance methods
api_key
Sourcecache?
Caching needs a minimum prefix length (1024 tokens on Sonnet/Opus, 2048 on Haiku); below that the 1.25x write surcharge buys nothing, hence the switch.
complete(request : Request) : Response
Sourcecomplete_streaming(request : Request, &on_delta : String -> Nil) : Response
Streaming entry point. The default does no streaming at all — it runs complete() and hands the text over in one piece.
That default is what makes deltas universal: callers always see them,
whether or not the provider streams, so neither the agent loop nor the
renderers need a special case. Providers override this; when streaming
is switched off they call super.
default_model
Sourcename
Source