NAME
Langertha::Engine::AnthropicBase - Base class for Anthropic-compatible engines
VERSION
version 0.305
SYNOPSIS
package My::AnthropicCompatible;
use Moose;
extends 'Langertha::Engine::AnthropicBase';
has '+url' => ( default => sub { 'https://api.example.com' } );
sub _build_api_key { $ENV{MY_API_KEY} || die "MY_API_KEY required" }
sub default_model { 'my-model-v1' }
__PACKAGE__->meta->make_immutable;
DESCRIPTION
Intermediate base class for engines speaking the Anthropic-compatible /v1/messages format. Extends Langertha::Engine::Remote and composes models/chat/streaming plus Anthropic-style tool calling and response parsing.
Concrete engines extending this class include Langertha::Engine::Anthropic, Langertha::Engine::MiniMax, and Langertha::Engine::LMStudioAnthropic.
THIS API IS WORK IN PROGRESS
api_key
Anthropic-compatible API key sent as x-api-key. Subclasses typically override _build_api_key to read a provider-specific environment variable.
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.