glean/providers/anthropic
Anthropic provider (Claude models), using the Messages API.
Thinking blocks (including redacted ones) are decoded with their signatures and sent back unchanged on the next turn, which Claude requires when thinking and tool use are combined.
Values
pub fn decode_response(
model_id: String,
body: String,
) -> Result(provider.GenerateResult, error.GleanError)
Decode a non-streaming Messages API response body. Public for tests.
pub fn default_config(
api_key api_key: String,
model model: String,
) -> config.ProviderConfig
The default configuration for this provider. Change it with the
glean/providers/config setters, then pass it to from_config.
pub fn encode_request(
model: String,
gen_request: provider.GenerateRequest,
stream: Bool,
) -> Result(String, error.GleanError)
Encode a Messages API request body. Public for tests.
pub fn from_config(
cfg: config.ProviderConfig,
) -> provider.Provider
Create an Anthropic provider from a full config.
pub fn new(
api_key api_key: String,
model model: String,
) -> provider.Provider
Create an Anthropic provider.
Example
let provider = anthropic.new(api_key: "sk-ant-...", model: "claude-sonnet-5-5")