NAME
Langertha::Raider::EngineResolver - Internal choice of engine, model and API key for a raider
VERSION
version 0.503
SYNOPSIS
# Internal to Langertha-Raider -- no API promise.
my $resolver = Langertha::Raider::EngineResolver->new(
config => $config, # Langertha::Raider::Config
engine_options => { temperature => 0.2 }, # the -o pairs
engine => 'openai', # optional, -e
);
my $name = $resolver->engine_name; # 'openai'
my $class = $resolver->engine_class; # 'Langertha::Engine::OpenAI'
my %args = $resolver->engine_args(mcp_servers => \@clients);
my $engine = $resolver->build_engine(mcp_servers => \@clients);
DESCRIPTION
Internal module. Its interface may change without notice.
The provider choice of Langertha::Raider::Application: which engine (flag, -o engine=, engine: in .raider.yml, the first *_API_KEY in the environment, anthropic), which model and API key it is built with, and the constructor arguments of the Langertha engine class -- the .raider.yml engine options, the -o engine options on top, and the model and key. Builds nothing but the engine itself.
With "provider" (raider --provider) the provider activation decides engine, engine class, model and URL instead, and the API key comes only from the command line -- see "provider".
config
The Langertha::Raider::Config of the workspace. Required.
engine_options
HashRef of the -o KEY=VALUE options, raider's own keys (see "is_app_key" in Langertha::Raider::Config) included; only engine of those is read here.
provider
The completed activation of raider --provider ("activate_f" in Langertha::Raider::Provider::Activation), or none. With it:
"engine_name", "engine_class" and "model" are the activation's;
-o engine=,engine:,model:in .raider.yml, the table defaults and the*_API_KEYautodetection do not apply."engine_args" set
urlto the endpoint'sbase_url, whatever .raider.yml says."engine_args" set
connect_addressto the activation's: the address raider checked for the endpoint host. The engine connects there instead of resolving the name again (Langertha ADR 0037), whileHost, TLS SNI and the certificate check stay on the host name; neither-onor .raider.yml can change it. An activation without one croaks: an unpinned engine is never built in provider mode. The engine is built with its own HTTP clients (none is passed in), so no client is shared with another engine."api_key" comes only from
-kor-o api_key=: never from .raider.yml and never from the environment, andapi_keyis always passed to the engine (undefwithout a key), so the engine class does not read itsLANGERTHA_*_API_KEYeither. A key configured for another provider never reaches this one."build_engine" turns off redirects on the engine's synchronous user agent, so its requests stay on the endpoint's origin. With the pin, Langertha itself refuses a redirect to another host on every backend, and it keeps the key on its origin; but it follows a redirect on the same host to another port (still pinned, without the key), and raider's rule is the endpoint's origin, not only its address (chat requests are POSTs, which Langertha never redirects).
engine_name
Langertha engine class shortcut, passed as engine. Defaults to -o engine=, then to engine: in .raider.yml, then to the first *_API_KEY environment variable found, then to 'anthropic'.
engine_names
my @names = $resolver->engine_names; # ('anthropic', 'openai', ...)
Every engine name "engine_class" knows, always in the same order. Also callable on the class.
api_key_env_vars
my @vars = $resolver->api_key_env_vars; # ('ANTHROPIC_API_KEY', ...)
The API key environment variables of all "engine_names", in that order; engines without one are left out. Also callable on the class.
env_var_for_engine
my $var = $resolver->env_var_for_engine('openai'); # 'OPENAI_API_KEY'
The environment variable holding the API key of an engine; undef for engines without one (ollama) and unknown ones. Also callable on the class.
default_model_for_engine
my $model = $resolver->default_model_for_engine('openai'); # 'gpt-4o-mini'
The model an engine uses without an explicit -m: raider's cheap default from the built-in table, or -- for an engine the table does not list -- the engine class's own default_model. undef for an engine that requires an explicit model (e.g. openrouter). For display only; "model" imposes only the table default, never the engine's own. Also callable on the class.
model
Model identifier the engine is built with. Defaults to model in "engine_options", then model: in .raider.yml, then the per-engine cheap default from the built-in table. With no such default the value is empty and "engine_args" passes no model, so the engine's own default_model applies. An explicit model always wins.
has_model
True when a non-empty model resolves. False when no -m, -o model=, model: or table default is set, so "engine_args" leaves model off and the engine falls back to its own default_model.
api_key
API key for the engine. Defaults to api_key in "engine_options", then api_key: in .raider.yml, then the engine's environment variable ("env_var_for_engine"). An explicit api_key always wins.
api_key_env
Name of the environment variable of the current engine's API key, for display; undef for engines without one and with "provider".
engine_class
The Langertha engine class of "engine_name". Dies with Unknown engine: NAME for a name it does not know.
engine_yml_options
The engine options of .raider.yml for "engine_name" ("engine_options" in Langertha::Raider::Config).
cli_engine_options
The -o pairs that go to the engine: "engine_options" without raider's own keys.
engine_args
my %args = $resolver->engine_args(mcp_servers => \@clients);
Engine constructor arguments: .raider.yml then -o (-o wins), raider's own keys left out, then %extra. model and api_key go last: "model" and "api_key" already resolve flag over -o over .raider.yml, so an explicit -m / -k is never overwritten.
build_engine
my $engine = $resolver->build_engine(mcp_servers => \@clients);
Loads "engine_class" and builds it with "engine_args"; with "provider" the engine connects to the checked address and its synchronous user agent follows no redirect.
SEE ALSO
SUPPORT
Issues
Please report bugs and feature requests on GitHub at https://github.com/Getty/langertha-raider/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 <torsten@raudssus.de> https://raudssus.de/
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.