Mead.Provider.Anthropic (mead v0.1.1)

Copy Markdown View Source

Mead.Provider backed by the Anthropic Messages API.

Options

  • :model - model identifier; defaults to "claude-sonnet-5-5".
  • :max_tokens - upper bound on the reply length; defaults to 1024.
  • :api_key - the key itself. When absent, the key is read from :api_key_file.
  • :api_key_file - a NAME=value file holding ANTHROPIC_API_KEY; defaults to ~/.config/anthropic/api.env.
  • :receive_timeout - milliseconds to wait for the reply; defaults to 25 seconds, below the default turn timeout so a slow provider reports its own reason first.
  • :maximum_retry_delay - milliseconds; the longest wait before a retry, even when the server asks for more with retry-after; defaults to 2 seconds.
  • :req_options - extra options merged into the Req request, used by tests to stub the network.

converse_stream/4 is converse/3 over server-sent events: it calls on_delta with each text fragment as it arrives and returns the same result, built by the same parser, so a stream and the equivalent plain body cannot disagree.

converse/3 also sends tools (omitted from the request when the list is empty) and returns the blocks of the answer; complete/2 is built on it and keeps returning the joined text. Blocks other than text and tool_use are dropped.

Requests are retried at most twice, and only after HTTP 429 or a 5xx status. A timeout or a transport error is never retried. The key travels only in the request header and is never part of a returned reason.