Documentation
¶
Overview ¶
Package anthropic is the tacklr.Model for Claude models on the Claude API (the Messages API). It streams each request, replays thinking blocks unchanged, counts tokens with the API's count endpoint, and caches the stable prefix of each request.
Index ¶
- Variables
- type APIStatusError
- type Model
- func (m *Model) CountTokens(ctx context.Context, req tacklr.ModelRequest) (int, error)
- func (m *Model) Invoke(ctx context.Context, req tacklr.ModelRequest) (chan tacklr.LLMResponseChunk, error)
- func (m *Model) MaxContextWindow() (int, error)
- func (m *Model) ModelTelemetryIdentity() telemetry.ModelIdentity
- func (m *Model) SupportsMIME(mimeType string) bool
- func (m *Model) WithApiKey(key string) *Model
- func (m *Model) WithContextWindow(n int) *Model
- func (m *Model) WithEffort(effort string) *Model
- func (m *Model) WithMaxTokens(n int) *Model
- func (m *Model) WithModel(model string) *Model
- func (m *Model) WithURL(url string) *Model
Constants ¶
This section is empty.
Variables ¶
var ( // ErrIncompleteStream is a stream that closed before message_stop. ErrIncompleteStream = provider.ErrIncompleteStream // ErrMalformedStream is a stream event that is not valid JSON. ErrMalformedStream = provider.ErrMalformedStream )
Functions ¶
This section is empty.
Types ¶
type APIStatusError ¶
type APIStatusError = provider.APIStatusError
APIStatusError is an HTTP error answer from the API. Find it in a wrapped chain with errors.As.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model holds only model and endpoint settings. Each request carries its own prompt, so one Model is safe to share across sessions.
func New ¶
New is a client over client, whose requests carry their trace context (W3C traceparent). A nil client is http.DefaultClient's settings.
func (*Model) CountTokens ¶
CountTokens counts req's input tokens with the count endpoint. A gateway without the endpoint (HTTP 404) fails with tacklr.ErrCannotCount.
func (*Model) Invoke ¶
func (m *Model) Invoke(ctx context.Context, req tacklr.ModelRequest) (chan tacklr.LLMResponseChunk, error)
Invoke streams one response to req.
func (*Model) MaxContextWindow ¶
MaxContextWindow is the window WithContextWindow set, else the known window of the model id.
func (*Model) ModelTelemetryIdentity ¶
func (m *Model) ModelTelemetryIdentity() telemetry.ModelIdentity
ModelTelemetryIdentity names the provider and model for model spans.
func (*Model) SupportsMIME ¶
SupportsMIME reports the input types every Claude model accepts: text, JPEG, PNG, GIF and WebP images, and PDF documents. Any model id works, such as a Foundry deployment name: a Messages API serves Claude models.
func (*Model) WithApiKey ¶
WithApiKey sets the API key, sent as x-api-key.
func (*Model) WithContextWindow ¶
WithContextWindow sets the model's context window in tokens, for a model id the client does not know, such as a Foundry deployment name.
func (*Model) WithEffort ¶
WithEffort sets output_config.effort: low, medium, high, xhigh or max. Empty sends none, so the model's default applies. Defaults differ by model: claude-opus-5-5 defaults to medium.
func (*Model) WithMaxTokens ¶
WithMaxTokens sets max_tokens, the limit on each response. The default is 64,000.