NAME
Langertha::Engine::AnthropicBase - Base class for Anthropic-compatible engines
VERSION
version 0.503
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 the universal chat/streaming/tool roles plus the Anthropic wire envelope, which lives in Langertha::Role::AnthropicCompatible (parallel to the OpenAI envelope in Langertha::Role::OpenAICompatible). This class is a thin composition shell: the request/response/auth/stream/rate-limit envelope for the Anthropic dialect is owned by the role.
Concrete engines extending this class include Langertha::Engine::Anthropic, Langertha::Engine::AKIAnthropic, Langertha::Engine::MiniMaxAnthropic, Langertha::Engine::MoonshotAnthropic, and Langertha::Engine::LMStudioAnthropic.
Structured output (response_format) takes one of two wire paths depending on the engine. The first-party Langertha::Engine::Anthropic emits it natively as output_config.format (GA on the Claude Messages API), which streams as ordinary text and needs no post-processing. The legacy /anthropic shim engines have no native form and keep the ADR 0005 rewrite: a synthesized tool plus a forced tool_choice, whose tool_use input chat_response lifts back into Response.content. That lift has no streaming counterpart, so on a shim engine chat_stream_request consumes a response_format and croaks instead of silently streaming unstructured text — use "chat_f" in Langertha::Role::Chat or chat_request there. See ADR 0005.
THIS API IS WORK IN PROGRESS
default_model
Abstract. Subclasses must override this to return the default model name string. The base implementation croaks with a descriptive error message.
sub default_model { 'claude-sonnet-5' }
SEE ALSO
https://status.anthropic.com/ - Anthropic service status
https://docs.anthropic.com/ - Official Anthropic documentation
Langertha::Role::AnthropicCompatible - Anthropic wire envelope role
Langertha::Role::OpenAICompatible - The parallel OpenAI envelope role
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.
IRC
Join #langertha on irc.perl.org or message Getty directly.
CONTRIBUTING
Contributions are welcome! Please fork the repository and submit a pull request.
AUTHOR
Torsten Raudssus <getty@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2026 by Torsten Raudssus https://raudssus.de/.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.