NAME
Langertha::Engine::Remote - Base class for all remote engines
VERSION
version 0.503
SYNOPSIS
package My::Engine;
use Moose;
extends 'Langertha::Engine::Remote';
has '+url' => ( default => 'https://api.example.com' );
sub default_model { 'my-model' }
DESCRIPTION
Root base class for all HTTP-based LLM engines in Langertha. Composes Langertha::Role::JSON, Langertha::Role::HTTP, and Langertha::Role::PluginHost, and makes the url attribute required.
All engines in the distribution extend this class, either directly (Langertha::Engine::Anthropic, Langertha::Engine::Gemini, Langertha::Engine::Ollama, Langertha::Engine::AKI) or via the OpenAI-compatible intermediate class Langertha::Engine::OpenAIBase.
api_key_env
my $env = $class->api_key_env;
Class method returning the name of the environment variable this engine reads its API key from (LANGERTHA_*_API_KEY), or undef if the engine reads none at all. Derived from the class name by default; engines that share a vendor key override it (e.g. Langertha::Engine::AKIOpenAI reads LANGERTHA_AKI_API_KEY).
The name alone does not say whether the key is mandatory - pair it with "api_key_required".
api_key_required
my $needs_key = $class->api_key_required;
Class method returning true if the engine is unusable without credentials. Together with "api_key_env" it covers the three states an engine can be in:
required -
api_key_envnames a variable andapi_key_requiredis true. Cloud providers; building the engine without the key croaks.optional -
api_key_envnames a variable andapi_key_requiredis false. Local-first engines that also serve an authenticated deployment (Langertha::Engine::Ollama reaching Ollama Cloud, Langertha::Engine::LMStudio reaching a secured LM Studio): the variable unlocks that deployment, the engine works without it.none -
api_key_envisundefandapi_key_requiredis false. The engine reads no environment variable at all (Langertha::Engine::vLLM, Langertha::Engine::SGLang, Langertha::Engine::LlamaCpp, Langertha::Engine::Whisper); passapi_keyexplicitly when the server was started with one.
Derived from "api_key_env" by default, so only engines with an optional key override it.
rate_limit
my $rl = $engine->rate_limit;
Returns the Langertha::RateLimit from the most recent API response, or undef if that response carried no rate limit headers — a response without them clears the previous one, so the value always describes the latest response. Error responses count: a 429 (or any other non-2xx) is recorded before the request croaks or its future fails, on the synchronous and every asynchronous path, so a caller can read requests_remaining, the resets and "retry_after" in Langertha::RateLimit after catching the error. Engines whose wire has no rate-limit headers (Gemini, Ollama native, AKI native, LM Studio native) still get a rate limit when a response sends Retry-After or retry-after-ms: it carries only "retry_after" in Langertha::RateLimit and "raw" in Langertha::RateLimit.
has_rate_limit
if ($engine->has_rate_limit) { ... }
Returns true if the engine has rate limit data from the most recent response.
generation_kwargs_for
my @kwargs = $engine->generation_kwargs_for(%$controls);
Emits the wire-agnostic generation-parameter kwargs that every chat dialect shares - the reasoning_kwargs_for and prompt_cache_kwargs_for outputs, each gated by can() so engines without those roles stay quiet. %controls is the per-request controls hash from chat_f (karr #46), passed wholesale; keys it does not carry fall back to the engine attributes inside the underlying "reasoning_kwargs_for" in Langertha::Role::ReasoningEffort and "prompt_cache_kwargs_for" in Langertha::Role::PromptCache. Returned as a list suitable for spreading into a request body. Dialect-specific emission (temperature, response_format, seed, knobs_kwargs_for, inference_geo, ...) stays at the call site because each dialect positions those fields at a specific place in the body.
SEE ALSO
Langertha::Engine::OpenAIBase - Intermediate base for all OpenAI-compatible engines
Langertha::Engine::Anthropic - Anthropic Claude (extends this directly)
Langertha::Engine::Gemini - Google Gemini (extends this directly)
Langertha::Engine::Ollama - Ollama native API (extends this directly)
Langertha::Engine::AKI - AKI EU engine (extends this directly)
Langertha::Role::HTTP - HTTP transport with
url,user_agent, request buildersLangertha::Role::JSON - Shared JSON encoder/decoder
Langertha::Role::PluginHost - Plugin system with lifecycle events
Langertha::RateLimit - Rate limit data stored per-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.