Packages
claude_gleam
1.0.0
Gleam SDK for the Anthropic Claude API with agentic tool-use loop and BEAM concurrency
Current section
Files
Jump to
Current section
Files
src/claude/client.gleam
/// Configuration for the Anthropic API client.
pub type Config {
Config(
api_key: String,
base_url: String,
default_model: String,
default_max_tokens: Int,
)
}
/// Create a new Config with sensible defaults.
///
/// Defaults:
/// - base_url: "https://api.anthropic.com"
/// - default_model: "claude-sonnet-4-5-20250929"
/// - default_max_tokens: 4096
pub fn new(api_key: String) -> Config {
Config(
api_key: api_key,
base_url: "https://api.anthropic.com",
default_model: "claude-sonnet-4-5-20250929",
default_max_tokens: 4096,
)
}
/// Set the model on the config.
pub fn with_model(config: Config, model: String) -> Config {
Config(..config, default_model: model)
}
/// Set the base URL on the config.
pub fn with_base_url(config: Config, url: String) -> Config {
Config(..config, base_url: url)
}
/// Set the default max tokens on the config.
pub fn with_max_tokens(config: Config, max_tokens: Int) -> Config {
Config(..config, default_max_tokens: max_tokens)
}