NAME
Langertha::Engine::Anthropic - Anthropic API
VERSION
version 0.303
SYNOPSIS
use Langertha::Engine::Anthropic;
my $claude = Langertha::Engine::Anthropic->new(
api_key => $ENV{ANTHROPIC_API_KEY},
model => 'claude-sonnet-4-6',
response_size => 4096,
temperature => 0.7,
);
# Simple chat
my $response = $claude->simple_chat('Generate Perl Moose classes to represent GeoJSON data types');
print $response;
# Streaming
$claude->simple_chat_stream(sub {
my ($chunk) = @_;
print $chunk->content;
}, 'Tell me about Perl');
# Async with Future::AsyncAwait
use Future::AsyncAwait;
async sub ask_claude {
my $response = await $claude->simple_chat_f('What is the meaning of life?');
say $response;
}
DESCRIPTION
Provides access to Anthropic's Claude models via their API. Claude is a family of large language models known for helpfulness, harmlessness, and honesty.
Available models include claude-opus-4-6 (most capable), claude-sonnet-4-6 (balanced, default), and claude-haiku-4-5-20251001 (fastest). The default API endpoint is https://api.anthropic.com.
THIS API IS WORK IN PROGRESS
api_key
The Anthropic API key. If not provided, reads from LANGERTHA_ANTHROPIC_API_KEY environment variable. Get your key at https://console.anthropic.com/. Required.
api_version
The Anthropic API version header sent with every request. Defaults to 2023-06-01.
effort
Controls the depth of thinking for reasoning models. Values: low, medium, high. When set, passed as the effort parameter in the API request.
my $claude = Langertha::Engine::Anthropic->new(
api_key => $ENV{ANTHROPIC_API_KEY},
model => 'claude-opus-4-6',
effort => 'high',
);
inference_geo
Controls data residency for inference. Values: us, eu. When set, passed as the inference_geo parameter to keep processing in the specified region.
my $claude = Langertha::Engine::Anthropic->new(
api_key => $ENV{ANTHROPIC_API_KEY},
inference_geo => 'eu',
);
list_models
my $model_ids = $engine->list_models;
my $models = $engine->list_models(full => 1);
my $models = $engine->list_models(force_refresh => 1);
Fetches available models from the Anthropic API using cursor pagination. Returns an ArrayRef of model ID strings by default, or full model objects when full = 1> is passed. Results are cached for models_cache_ttl seconds (default: 3600). Pass force_refresh = 1> to bypass the cache.
_parse_rate_limit_headers
Parses anthropic-ratelimit-* headers from the HTTP response into a Langertha::RateLimit object. The raw hash captures extras like input-tokens-limit and output-tokens-limit.
SEE ALSO
https://status.anthropic.com/ - Anthropic service status
https://docs.anthropic.com/ - Official Anthropic documentation
Langertha::Role::Chat - Chat interface methods
Langertha::Role::Tools - MCP tool calling interface
Langertha::Role::Streaming - Streaming support (SSE format)
Langertha::Engine::Gemini - Another non-OpenAI-compatible engine
SUPPORT
Issues
Please report bugs and feature requests on GitHub at https://github.com/Getty/langertha/issues.
CONTRIBUTING
Contributions are welcome! Please fork the repository and submit a pull request.
AUTHOR
Torsten Raudssus <torsten@raudssus.de> https://raudss.us/
COPYRIGHT AND LICENSE
This software is copyright (c) 2026 by Torsten Raudssus.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.