| 1 | package Langertha::Engine::AKI; | ||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: AKI.IO native API | ||||||||||||||||||||||||||||||||||||||||
| 3 | 16 | our $VERSION = '0.503'; | |||||||||||||||||||||||||||||||||||||||
| 4 | 16 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 5 | 16 | ▶ | use Carp qw( croak carp ); | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 6 | 16 | ▶ | use JSON::MaybeXS; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||
| 8 | 16 | extends 'Langertha::Engine::Remote'; | |||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||
| 10 | 16 | with map { 'Langertha::Role::'.$_ } qw( | |||||||||||||||||||||||||||||||||||||||
| 11 | Models | ||||||||||||||||||||||||||||||||||||||||
| 12 | Temperature | ||||||||||||||||||||||||||||||||||||||||
| 13 | SystemPrompt | ||||||||||||||||||||||||||||||||||||||||
| 14 | Chat | ||||||||||||||||||||||||||||||||||||||||
| 15 | Tools | ||||||||||||||||||||||||||||||||||||||||
| 16 | HermesTools | ||||||||||||||||||||||||||||||||||||||||
| 17 | ); | ||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||
| 19 | 23 | ▶ | sub _build_tool_wire_format { 'hermes' } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_tool_wire_format: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||
| 21 | # The native /api/call body has no tools field, so Hermes (tools in the system | ||||||||||||||||||||||||||||||||||||||||
| 22 | # prompt) is the only tool wire it can carry. Another tag would claim | ||||||||||||||||||||||||||||||||||||||||
| 23 | # tools_native (HermesTools keys on the resolved tag, k251) and then drop the | ||||||||||||||||||||||||||||||||||||||||
| 24 | # tools from the request -- fail loud instead. -- karr k254 | ||||||||||||||||||||||||||||||||||||||||
| 25 | 26 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 26 | 26 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 27 | 26 | my $fmt = $self->tool_wire_format; | |||||||||||||||||||||||||||||||||||||||
| 28 | 26 | ▶ | croak "".(ref $self)." cannot use tool_wire_format '$fmt': the native API only" | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 29 | ." speaks 'hermes'; use Langertha::Engine::AKIOpenAI (\$aki->openai) for native tools" | ||||||||||||||||||||||||||||||||||||||||
| 30 | unless $fmt eq 'hermes'; | ||||||||||||||||||||||||||||||||||||||||
| 31 | 24 | return; | |||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||
| 35 | 16 | has api_key => ( | |||||||||||||||||||||||||||||||||||||||
| 36 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||
| 37 | lazy_build => 1, | ||||||||||||||||||||||||||||||||||||||||
| 38 | ); | ||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | sub _build_api_key { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_api_key: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my ( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 41 | return $ENV{LANGERTHA_AKI_API_KEY} | ||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | || croak "".(ref $self)." requires LANGERTHA_AKI_API_KEY or api_key set"; | ||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$ENV{'LANGERTHA_AKI_API_KEY'} || croak('' . ref($self) . ' requires LANGERTHA_AKI_API_KEY or api_key set')
MC/DC0%0/2
$ENV{'LANGERTHA_AKI_API_KEY'} || croak('' . ref($self) . ' requires LANGERTHA_AKI_API_KEY or api_key set')
$ENV{'LANGERTHA_AKI_API_KEY'}
croak('' . ref($self) . ' requires LANGERTHA_AKI_API_KEY or api_key set')
Truth table0%0/3
A || B
A= $ENV{'LANGERTHA_AKI_API_KEY'}B= croak('' . ref($self) . ' requires LANGERTHA_AKI_API_KEY or api_key set')
| |||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||
| 46 | has '+url' => ( | ||||||||||||||||||||||||||||||||||||||||
| 47 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||
| 48 | 9 | ▶ | default => sub { 'https://aki.io' }, | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 49 | 16 | ); | |||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||
| 51 | # AKI's native /api/endpoints listing carries `minimax_m3` (endpoint_details | ||||||||||||||||||||||||||||||||||||||||
| 52 | # reports "MiniMax M3 428B", category chat) — AKI.IO's current-generation | ||||||||||||||||||||||||||||||||||||||||
| 53 | # MiniMax and the chosen default now that llama3_8b_chat is marked end-of-life | ||||||||||||||||||||||||||||||||||||||||
| 54 | # 2026-09-30. Verified live against the native endpoint listing on 2026-09-10. | ||||||||||||||||||||||||||||||||||||||||
| 55 | # MiniMax is a per-account gated endpoint: a key without the entitlement is | ||||||||||||||||||||||||||||||||||||||||
| 56 | # answered with "Client not authorized for endpoint minimax_m3!" (not a silent | ||||||||||||||||||||||||||||||||||||||||
| 57 | # fallback), so check $response->model / the error when it matters. -- karr k132 | ||||||||||||||||||||||||||||||||||||||||
| 58 | 5 | ▶ | sub default_model { 'minimax_m3' } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_model: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||
| 61 | 16 | ▶ | sub hermes_extract_content { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
hermes_extract_content: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 62 | 16 | my ( $self, $data ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 63 | 16 | return $data->{text}; | |||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||
| 66 | 16 | has top_k => ( | |||||||||||||||||||||||||||||||||||||||
| 67 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||
| 68 | isa => 'Num', | ||||||||||||||||||||||||||||||||||||||||
| 69 | predicate => 'has_top_k', | ||||||||||||||||||||||||||||||||||||||||
| 70 | ); | ||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||
| 73 | 16 | has top_p => ( | |||||||||||||||||||||||||||||||||||||||
| 74 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||
| 75 | isa => 'Num', | ||||||||||||||||||||||||||||||||||||||||
| 76 | predicate => 'has_top_p', | ||||||||||||||||||||||||||||||||||||||||
| 77 | ); | ||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||
| 80 | 16 | has max_gen_tokens => ( | |||||||||||||||||||||||||||||||||||||||
| 81 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||
| 82 | isa => 'Int', | ||||||||||||||||||||||||||||||||||||||||
| 83 | predicate => 'has_max_gen_tokens', | ||||||||||||||||||||||||||||||||||||||||
| 84 | ); | ||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||
| 87 | # Dynamic model listing | ||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||
| 89 | 1 | ▶ | sub list_models_request { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_models_request: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 90 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||
| 91 | return $self->generate_http_request( | ||||||||||||||||||||||||||||||||||||||||
| 92 | GET => $self->url.'/api/endpoints?key='.$self->api_key, | ||||||||||||||||||||||||||||||||||||||||
| 93 | 1 | ▶ | sub { $self->list_models_response(shift) }, | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 94 | 1 | ); | |||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||
| 97 | 1 | ▶ | sub list_models_response { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_models_response: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 98 | 1 | my ($self, $response) = @_; | |||||||||||||||||||||||||||||||||||||||
| 99 | 1 | my $data = $self->parse_response($response); | |||||||||||||||||||||||||||||||||||||||
| 100 | 1 | return $data->{endpoints}; | |||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | sub list_models { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_models: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | my ($self, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||
| 106 | # Check cache unless force_refresh requested | ||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | unless ($opts{force_refresh}) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | my $cache = $self->_models_cache; | |||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | if ($cache->{timestamp} && time - $cache->{timestamp} < $self->models_cache_ttl) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$cache->{"timestamp"} and time - $cache->{"timestamp"} < $self->models_cache_ttl
MC/DC0%0/2
$cache->{"timestamp"} and time - $cache->{"timestamp"} < $self->models_cache_ttl
$cache->{"timestamp"}
time - $cache->{"timestamp"} < $self->models_cache_ttl
Truth table0%0/3
A and B
A= $cache->{"timestamp"}B= time - $cache->{"timestamp"} < $self->models_cache_ttl
| |||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | return $opts{full} ? $cache->{models} : $cache->{model_ids}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||
| 114 | # Fetch from API | ||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | my $request = $self->list_models_request; | |||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my $response = $self->user_agent->request($request); | |||||||||||||||||||||||||||||||||||||||
| 117 | 0 | my $endpoints = $request->response_call->($response); | |||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||
| 119 | # Update cache | ||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | $self->_models_cache({ | |||||||||||||||||||||||||||||||||||||||
| 121 | timestamp => time, | ||||||||||||||||||||||||||||||||||||||||
| 122 | models => $endpoints, | ||||||||||||||||||||||||||||||||||||||||
| 123 | model_ids => $endpoints, | ||||||||||||||||||||||||||||||||||||||||
| 124 | }); | ||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | return $endpoints; | |||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||
| 130 | 1 | ▶ | sub endpoint_details_request { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
endpoint_details_request: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 131 | 1 | my ($self, $endpoint_name) = @_; | |||||||||||||||||||||||||||||||||||||||
| 132 | return $self->generate_http_request( | ||||||||||||||||||||||||||||||||||||||||
| 133 | GET => $self->url.'/api/endpoints/'.$endpoint_name.'?key='.$self->api_key, | ||||||||||||||||||||||||||||||||||||||||
| 134 | 1 | ▶ | sub { $self->endpoint_details_response(shift) }, | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 135 | 1 | ); | |||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||
| 138 | 1 | ▶ | sub endpoint_details_response { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
endpoint_details_response: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||
| 139 | 1 | my ($self, $response) = @_; | |||||||||||||||||||||||||||||||||||||||
| 140 | 1 | return $self->parse_response($response); | |||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | sub endpoint_details { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
endpoint_details: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | my ($self, $endpoint_name) = @_; | |||||||||||||||||||||||||||||||||||||||
| 145 | 0 | my $request = $self->endpoint_details_request($endpoint_name); | |||||||||||||||||||||||||||||||||||||||
| 146 | 0 | my $response = $self->user_agent->request($request); | |||||||||||||||||||||||||||||||||||||||
| 147 | 0 | return $request->response_call->($response); | |||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||
| 151 | # Chat | ||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||
| 153 | 10 | ▶ | sub chat_request { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
chat_request: called CC=8 SCAR=21.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 154 | 10 | my ( $self, $messages, %extra ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||
| 156 | # Canonical per-request controls (chat_f, karr #46) beat the engine | ||||||||||||||||||||||||||||||||||||||||
| 157 | # attributes on a per-key basis; the rest of %extra passes straight through. | ||||||||||||||||||||||||||||||||||||||||
| 158 | # AKI's native wire only honors temperature and max_gen_tokens; the other | ||||||||||||||||||||||||||||||||||||||||
| 159 | # canonical controls (response_format, seed, reasoning_effort, ...) have no | ||||||||||||||||||||||||||||||||||||||||
| 160 | # native placement here and are consumed without being emitted. | ||||||||||||||||||||||||||||||||||||||||
| 161 | 10 | ▶ | my $controls = delete $extra{controls} // {}; | ||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $extra{"controls"} // {}
MC/DC0%0/1
delete $extra{"controls"} // {}
delete $extra{"controls"}
Truth table50%1/2
A
A= delete $extra{"controls"}
| |||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||
| 163 | # The model is the endpoint; a per-request model names it there, never in | ||||||||||||||||||||||||||||||||||||||||
| 164 | # the body (karr k357). | ||||||||||||||||||||||||||||||||||||||||
| 165 | 10 | my $model = $self->_url_model( \%extra ); | |||||||||||||||||||||||||||||||||||||||
| 166 | return $self->generate_http_request( | ||||||||||||||||||||||||||||||||||||||||
| 167 | POST => $self->url.'/api/call/'.$model, | ||||||||||||||||||||||||||||||||||||||||
| 168 | 3 | ▶ | sub { $self->chat_response(shift) }, | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 169 | key => $self->api_key, | ||||||||||||||||||||||||||||||||||||||||
| 170 | chat_context => $self->encode_json_text($messages), | ||||||||||||||||||||||||||||||||||||||||
| 171 | exists $controls->{temperature} | ||||||||||||||||||||||||||||||||||||||||
| 172 | ? ( temperature => $controls->{temperature} ) | ||||||||||||||||||||||||||||||||||||||||
| 173 | : ( $self->has_temperature ? ( temperature => $self->temperature ) : () ), | ||||||||||||||||||||||||||||||||||||||||
| 174 | $self->has_top_k ? ( top_k => $self->top_k ) : (), | ||||||||||||||||||||||||||||||||||||||||
| 175 | $self->has_top_p ? ( top_p => $self->top_p ) : (), | ||||||||||||||||||||||||||||||||||||||||
| 176 | exists $controls->{max_tokens} | ||||||||||||||||||||||||||||||||||||||||
| 177 | ? ( max_gen_tokens => $controls->{max_tokens} ) | ||||||||||||||||||||||||||||||||||||||||
| 178 | 10 | ▶ | : ( $self->has_max_gen_tokens ? ( max_gen_tokens => $self->max_gen_tokens ) : () ), | ||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||
| 179 | wait_for_result => JSON->true, | ||||||||||||||||||||||||||||||||||||||||
| 180 | %extra, | ||||||||||||||||||||||||||||||||||||||||
| 181 | ); | ||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||
| 185 | 16 | ▶ | sub chat_response { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
chat_response: called CC=17 SCAR=28.4
| |||||||||||||||||||||||||||||||||||||||||
| 186 | 16 | my ( $self, $response ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 187 | 16 | my $data = $self->parse_response($response); | |||||||||||||||||||||||||||||||||||||||
| 188 | croak "".(ref $self)." API error: ".($data->{error} || 'unknown') | ||||||||||||||||||||||||||||||||||||||||
| 189 | 13 | ▶ | unless $data->{success}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$data->{'error'} || 'unknown'
MC/DC0%0/1
$data->{'error'} || 'unknown'
$data->{'error'}
Truth table50%1/2
A
A= $data->{'error'}
| |||||||||||||||||||||||||||||||||||||||||
| 190 | 12 | require Langertha::Response; | |||||||||||||||||||||||||||||||||||||||
| 191 | # The native endpoint composes Role::HermesTools (tool_wire_format 'hermes'), | ||||||||||||||||||||||||||||||||||||||||
| 192 | # so tool calls ride as <tool_call> tags in the model text. Route them onto | ||||||||||||||||||||||||||||||||||||||||
| 193 | # Response.tool_calls (ADR 0003) via the tag-aware role helpers rather than | ||||||||||||||||||||||||||||||||||||||||
| 194 | # leaving them buried in content; strip the tags from content when a call is | ||||||||||||||||||||||||||||||||||||||||
| 195 | # present. -- karr k123 | ||||||||||||||||||||||||||||||||||||||||
| 196 | 12 | my $tool_calls = $self->_raw_tool_calls($data); | |||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||
| 198 | # Native usage: the AKI wire names its token counts differently from the | ||||||||||||||||||||||||||||||||||||||||
| 199 | # OpenAI/Anthropic shapes, so normalize to the keys Langertha::Usage->from_hash | ||||||||||||||||||||||||||||||||||||||||
| 200 | # understands. num_cached_tokens is the same quantity as cached_tokens; it rides | ||||||||||||||||||||||||||||||||||||||||
| 201 | # in the usage hash so Response->usage->cached_tokens carries it and | ||||||||||||||||||||||||||||||||||||||||
| 202 | # Response->cached_tokens is lifted off that Usage (karr k197). It counts | ||||||||||||||||||||||||||||||||||||||||
| 203 | # prefix-cache *reads* (a subset of prompt_length, vLLM 16-token blocks, often | ||||||||||||||||||||||||||||||||||||||||
| 204 | # non-zero even on a first call); native and /v1 report the same numbers for | ||||||||||||||||||||||||||||||||||||||||
| 205 | # identical messages (live-verified 2026-09-25). Trust $response->model for which | ||||||||||||||||||||||||||||||||||||||||
| 206 | # model answered. -- karr k126, k197 | ||||||||||||||||||||||||||||||||||||||||
| 207 | my $usage = { | ||||||||||||||||||||||||||||||||||||||||
| 208 | defined $data->{prompt_length} ? ( prompt_tokens => $data->{prompt_length} ) : (), | ||||||||||||||||||||||||||||||||||||||||
| 209 | defined $data->{num_generated_tokens} ? ( completion_tokens => $data->{num_generated_tokens} ) : (), | ||||||||||||||||||||||||||||||||||||||||
| 210 | 12 | ▶ | defined $data->{num_cached_tokens} ? ( cached_tokens => $data->{num_cached_tokens} ) : (), | ||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||
| 211 | }; | ||||||||||||||||||||||||||||||||||||||||
| 212 | 12 | ▶ | undef $usage unless %$usage; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||
| 214 | # Timing: AKI reports durations already in SECONDS. Emit the engine-agnostic | ||||||||||||||||||||||||||||||||||||||||
| 215 | # total_seconds (ADR 0011) plus the native compute_seconds, and deliberately do | ||||||||||||||||||||||||||||||||||||||||
| 216 | # NOT emit a raw total_duration key -- Engine::Ollama uses that same key in | ||||||||||||||||||||||||||||||||||||||||
| 217 | # nanoseconds, so an AKI seconds value under it collides by a factor of 1e9. | ||||||||||||||||||||||||||||||||||||||||
| 218 | # -- karr k126 | ||||||||||||||||||||||||||||||||||||||||
| 219 | my $timing = { | ||||||||||||||||||||||||||||||||||||||||
| 220 | defined $data->{total_duration} ? ( total_seconds => $data->{total_duration} ) : (), | ||||||||||||||||||||||||||||||||||||||||
| 221 | 12 | ▶ | defined $data->{compute_duration} ? ( compute_seconds => $data->{compute_duration} ) : (), | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||
| 222 | }; | ||||||||||||||||||||||||||||||||||||||||
| 223 | 12 | ▶ | undef $timing unless %$timing; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||
| 225 | return Langertha::Response->new( | ||||||||||||||||||||||||||||||||||||||||
| 226 | content => ( @$tool_calls ? $self->_raw_text_content($data) : ( $data->{text} // '' ) ), | ||||||||||||||||||||||||||||||||||||||||
| 227 | raw => $data, | ||||||||||||||||||||||||||||||||||||||||
| 228 | $data->{job_id} ? ( id => $data->{job_id} ) : (), | ||||||||||||||||||||||||||||||||||||||||
| 229 | 12 | ▶ | $data->{model_name} ? ( model => $data->{model_name} ) : (), | ||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
Condition50%1/2
$data->{"text"} // ""
MC/DC0%0/1
$data->{"text"} // ""
$data->{"text"}
Truth table50%1/2
A
A= $data->{"text"}
| |||||||||||||||||||||||||||||||||||||||||
| 230 | $usage ? ( usage => $usage ) : (), | ||||||||||||||||||||||||||||||||||||||||
| 231 | $timing ? ( timing => $timing ) : (), | ||||||||||||||||||||||||||||||||||||||||
| 232 | @$tool_calls ? ( tool_calls => $tool_calls ) : (), | ||||||||||||||||||||||||||||||||||||||||
| 233 | ); | ||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||
| 237 | 2 | ▶ | sub openai { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
openai: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 238 | 2 | my ( $self, %args ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 239 | 2 | require Langertha::Engine::AKIOpenAI; | |||||||||||||||||||||||||||||||||||||||
| 240 | 2 | ▶ | unless (exists $args{model}) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 241 | 1 | carp "".(ref $self)."->openai: native model name cannot be mapped to /v1 model name automatically, using AKIOpenAI default model"; | |||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||
| 243 | 2 | ▶ | return Langertha::Engine::AKIOpenAI->new( | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||
| 244 | api_key => $self->api_key, | ||||||||||||||||||||||||||||||||||||||||
| 245 | $self->has_system_prompt ? ( system_prompt => $self->system_prompt ) : (), | ||||||||||||||||||||||||||||||||||||||||
| 246 | $self->has_temperature ? ( temperature => $self->temperature ) : (), | ||||||||||||||||||||||||||||||||||||||||
| 247 | %args, | ||||||||||||||||||||||||||||||||||||||||
| 248 | ); | ||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||
| 252 | 3 | ▶ | sub anthropic { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
anthropic: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 253 | 3 | my ( $self, %args ) = @_; | |||||||||||||||||||||||||||||||||||||||
| 254 | 3 | require Langertha::Engine::AKIAnthropic; | |||||||||||||||||||||||||||||||||||||||
| 255 | 3 | ▶ | unless (exists $args{model}) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 256 | 1 | carp "".(ref $self)."->anthropic: native model name cannot be mapped to /anthropic model name automatically, using AKIAnthropic default model"; | |||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||
| 258 | 3 | ▶ | return Langertha::Engine::AKIAnthropic->new( | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||
| 259 | api_key => $self->api_key, | ||||||||||||||||||||||||||||||||||||||||
| 260 | $self->has_system_prompt ? ( system_prompt => $self->system_prompt ) : (), | ||||||||||||||||||||||||||||||||||||||||
| 261 | $self->has_temperature ? ( temperature => $self->temperature ) : (), | ||||||||||||||||||||||||||||||||||||||||
| 262 | %args, | ||||||||||||||||||||||||||||||||||||||||
| 263 | ); | ||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||
| 267 | 16 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||
| 270 | 16 | 1; | |||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||
| 272 | __END__ | ||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||
| 274 | =pod | ||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||
| 276 | =encoding UTF-8 | ||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||
| 278 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||
| 280 | Langertha::Engine::AKI - AKI.IO native API | ||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||
| 282 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||
| 284 | version 0.503 | ||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||
| 286 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||
| 288 | use Langertha::Engine::AKI; | ||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||
| 290 | my $aki = Langertha::Engine::AKI->new( | ||||||||||||||||||||||||||||||||||||||||
| 291 | api_key => $ENV{AKI_API_KEY}, | ||||||||||||||||||||||||||||||||||||||||
| 292 | model => 'llama3_8b_chat', | ||||||||||||||||||||||||||||||||||||||||
| 293 | ); | ||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||
| 295 | print $aki->simple_chat('Hello from Perl!'); | ||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||
| 297 | # Get OpenAI-compatible API access | ||||||||||||||||||||||||||||||||||||||||
| 298 | my $aki_openai = $aki->openai; | ||||||||||||||||||||||||||||||||||||||||
| 299 | print $aki_openai->simple_chat('Hello via OpenAI format!'); | ||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||
| 301 | # Get Anthropic-compatible API access | ||||||||||||||||||||||||||||||||||||||||
| 302 | my $aki_anthropic = $aki->anthropic; | ||||||||||||||||||||||||||||||||||||||||
| 303 | print $aki_anthropic->simple_chat('Hello via Anthropic format!'); | ||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||
| 305 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||
| 307 | Provides access to AKI.IO's native API for running LLM inference. AKI.IO is | ||||||||||||||||||||||||||||||||||||||||
| 308 | a European AI model hub based in Germany; all inference runs on EU infrastructure, | ||||||||||||||||||||||||||||||||||||||||
| 309 | fully GDPR-compliant with no data leaving the EU. | ||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||
| 311 | The native API sends the API key as a C<key> field in the JSON request body | ||||||||||||||||||||||||||||||||||||||||
| 312 | (not as an HTTP header). Supports synchronous chat, temperature and sampling | ||||||||||||||||||||||||||||||||||||||||
| 313 | controls, dynamic endpoint listing, MCP tool calling via | ||||||||||||||||||||||||||||||||||||||||
| 314 | L<Langertha::Role::HermesTools>, OpenAI-compatible access via L</openai>, | ||||||||||||||||||||||||||||||||||||||||
| 315 | and Anthropic-compatible access via L</anthropic>. | ||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||
| 317 | Streaming is not yet supported in the native API. For streaming, use the | ||||||||||||||||||||||||||||||||||||||||
| 318 | OpenAI-compatible endpoint via C<< $aki->openai >>. | ||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||
| 320 | The native API has no C<tools>, C<tool_choice> or C<response_format> field: | ||||||||||||||||||||||||||||||||||||||||
| 321 | tools ride the system prompt (Hermes format), which cannot force a tool, so a | ||||||||||||||||||||||||||||||||||||||||
| 322 | C<tool_choice> other than C<auto> or C<none> is dropped with a warning. To | ||||||||||||||||||||||||||||||||||||||||
| 323 | force a tool or get structured output, use L<Langertha::Engine::AKIOpenAI> | ||||||||||||||||||||||||||||||||||||||||
| 324 | (C<< $aki->openai >>). | ||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||
| 326 | C<tool_wire_format> is fixed to C<hermes>: the constructor croaks on any other | ||||||||||||||||||||||||||||||||||||||||
| 327 | value, since the native body has no field to carry native tools. Use | ||||||||||||||||||||||||||||||||||||||||
| 328 | L<Langertha::Engine::AKIOpenAI> for OpenAI-format tools. | ||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||
| 330 | Get your API key at L<https://aki.io/> and set C<LANGERTHA_AKI_API_KEY>. | ||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||
| 332 | B<THIS API IS WORK IN PROGRESS> | ||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||
| 334 | =head2 api_key | ||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||
| 336 | The AKI.IO API key. If not provided, reads from C<LANGERTHA_AKI_API_KEY> | ||||||||||||||||||||||||||||||||||||||||
| 337 | environment variable. Sent as a C<key> field in the JSON request body | ||||||||||||||||||||||||||||||||||||||||
| 338 | (not as an HTTP header). Required. | ||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||
| 340 | =head2 default_model | ||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||
| 342 | Returns C<minimax_m3>, AKI.IO's current-generation MiniMax M3 (428B) on the | ||||||||||||||||||||||||||||||||||||||||
| 343 | native endpoint. This replaces C<llama3_8b_chat>, which AKI.IO marks | ||||||||||||||||||||||||||||||||||||||||
| 344 | end-of-life 2026-09-30. MiniMax is a B<per-account gated> endpoint: a key | ||||||||||||||||||||||||||||||||||||||||
| 345 | without the entitlement is answered with C<"Client not authorized for endpoint | ||||||||||||||||||||||||||||||||||||||||
| 346 | minimax_m3!"> rather than a silent model substitution, so check | ||||||||||||||||||||||||||||||||||||||||
| 347 | C<< $response->model >> if it matters which model replied. | ||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||
| 349 | =head2 top_k | ||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||
| 351 | top_k => 40 | ||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||
| 353 | Top-K sampling parameter. Controls the number of highest-probability tokens | ||||||||||||||||||||||||||||||||||||||||
| 354 | to consider at each generation step. | ||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||
| 356 | =head2 top_p | ||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||
| 358 | top_p => 0.9 | ||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||
| 360 | Top-P (nucleus) sampling parameter. Controls the cumulative probability | ||||||||||||||||||||||||||||||||||||||||
| 361 | threshold for token selection. | ||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||
| 363 | =head2 max_gen_tokens | ||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||
| 365 | max_gen_tokens => 1000 | ||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||
| 367 | Maximum number of tokens to generate in the response. | ||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||
| 369 | =head2 list_models | ||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||
| 371 | my $endpoints = $aki->list_models; | ||||||||||||||||||||||||||||||||||||||||
| 372 | my $endpoints = $aki->list_models(force_refresh => 1); | ||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||
| 374 | Fetches available endpoint names from the AKI.IO C<GET /api/endpoints> API. | ||||||||||||||||||||||||||||||||||||||||
| 375 | Returns an ArrayRef of endpoint names. Results are cached for C<models_cache_ttl> | ||||||||||||||||||||||||||||||||||||||||
| 376 | seconds (default: 3600). | ||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||
| 378 | =head2 endpoint_details | ||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||
| 380 | my $details = $aki->endpoint_details('llama3_8b_chat'); | ||||||||||||||||||||||||||||||||||||||||
| 381 | # Returns hashref with name, title, description, workers, parameter_description, etc. | ||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||
| 383 | Fetches detailed information about a specific endpoint from the AKI.IO | ||||||||||||||||||||||||||||||||||||||||
| 384 | C<GET /api/endpoints/{name}> API. Returns worker info, model metadata, | ||||||||||||||||||||||||||||||||||||||||
| 385 | and parameter descriptions. | ||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||
| 387 | =head2 chat_request | ||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||
| 389 | my $request = $aki->chat_request($messages, %extra); | ||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||
| 391 | Generates a native AKI.IO chat request. Posts to C</api/call/{model}> with | ||||||||||||||||||||||||||||||||||||||||
| 392 | messages encoded as JSON in the C<chat_context> field. Includes C<key>, | ||||||||||||||||||||||||||||||||||||||||
| 393 | C<temperature>, C<top_k>, C<top_p>, C<max_gen_tokens>, and | ||||||||||||||||||||||||||||||||||||||||
| 394 | C<wait_for_result> parameters as configured. A C<model> in C<%extra> (a | ||||||||||||||||||||||||||||||||||||||||
| 395 | per-request model from L<Langertha::Role::Chat/chat_f> or | ||||||||||||||||||||||||||||||||||||||||
| 396 | L<Langertha::Chat/model>) replaces C<{model}> in the URL for this request and | ||||||||||||||||||||||||||||||||||||||||
| 397 | is not sent in the body. Returns an HTTP request object. | ||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||
| 399 | =head2 chat_response | ||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||
| 401 | my $response = $aki->chat_response($http_response); | ||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||
| 403 | Parses a native AKI.IO chat response. Dies with an API error message if | ||||||||||||||||||||||||||||||||||||||||
| 404 | C<success> is false. Returns a L<Langertha::Response> with C<content>, | ||||||||||||||||||||||||||||||||||||||||
| 405 | C<id> (from the wire C<job_id>), C<model>, C<usage> (from C<prompt_length> / | ||||||||||||||||||||||||||||||||||||||||
| 406 | C<num_generated_tokens> / C<num_cached_tokens>), C<cached_tokens> (lifted off | ||||||||||||||||||||||||||||||||||||||||
| 407 | C<usage>), | ||||||||||||||||||||||||||||||||||||||||
| 408 | C<timing> (C<total_seconds> / C<compute_seconds>, both already in seconds), | ||||||||||||||||||||||||||||||||||||||||
| 409 | C<tool_calls> (Hermes C<E<lt>tool_callE<gt>> tags), and C<raw>. The native | ||||||||||||||||||||||||||||||||||||||||
| 410 | token counts differ from the OpenAI-compatible shim for the same prompt — | ||||||||||||||||||||||||||||||||||||||||
| 411 | check C<< $response->model >> for which model answered. | ||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||
| 413 | =head2 openai | ||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||
| 415 | my $oai = $aki->openai; | ||||||||||||||||||||||||||||||||||||||||
| 416 | my $oai = $aki->openai(model => 'llama3-chat-8b'); | ||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||
| 418 | Returns a L<Langertha::Engine::AKIOpenAI> instance configured with the same | ||||||||||||||||||||||||||||||||||||||||
| 419 | API key, system prompt, and temperature. Supports streaming and MCP tool | ||||||||||||||||||||||||||||||||||||||||
| 420 | calling. | ||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||
| 422 | B<Note:> The native AKI model name is B<not> carried over automatically | ||||||||||||||||||||||||||||||||||||||||
| 423 | because the C</v1> endpoint uses different model identifiers. If no C<model> | ||||||||||||||||||||||||||||||||||||||||
| 424 | is passed, the AKIOpenAI default model is used and a warning is emitted. | ||||||||||||||||||||||||||||||||||||||||
| 425 | Pass C<< model => '...' >> explicitly with a valid C</v1> model name to | ||||||||||||||||||||||||||||||||||||||||
| 426 | suppress the warning. | ||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||
| 428 | =head2 anthropic | ||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||
| 430 | my $anth = $aki->anthropic; | ||||||||||||||||||||||||||||||||||||||||
| 431 | my $anth = $aki->anthropic(model => 'gemma4-26b'); | ||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||
| 433 | Returns a L<Langertha::Engine::AKIAnthropic> instance configured with the | ||||||||||||||||||||||||||||||||||||||||
| 434 | same API key, system prompt, and temperature. URL defaults to | ||||||||||||||||||||||||||||||||||||||||
| 435 | C<https://aki.io/anthropic> (set on L<Langertha::Engine::AKIAnthropic> | ||||||||||||||||||||||||||||||||||||||||
| 436 | itself, so it is not carried over from the native engine's | ||||||||||||||||||||||||||||||||||||||||
| 437 | C<https://aki.io> base). | ||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||
| 439 | B<Note:> The native AKI model name is B<not> carried over automatically | ||||||||||||||||||||||||||||||||||||||||
| 440 | because the C</anthropic> endpoint uses different model identifiers. If no | ||||||||||||||||||||||||||||||||||||||||
| 441 | C<model> is passed, the AKIAnthropic default model is used and a warning is | ||||||||||||||||||||||||||||||||||||||||
| 442 | emitted. Pass C<< model => '...' >> explicitly with a valid C</anthropic> | ||||||||||||||||||||||||||||||||||||||||
| 443 | model name to suppress the warning. AKI.IO also silently routes unknown | ||||||||||||||||||||||||||||||||||||||||
| 444 | model IDs to MiniMax M2.5 — check C<< $response->model >> if it matters | ||||||||||||||||||||||||||||||||||||||||
| 445 | which model replied. | ||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||
| 447 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||
| 449 | =over | ||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||
| 451 | =item * L<Langertha::Engine::AKIOpenAI> - OpenAI-compatible AKI.IO access via L</openai> | ||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||
| 453 | =item * L<Langertha::Engine::AKIAnthropic> - Anthropic-compatible AKI.IO access via L</anthropic> | ||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||
| 455 | =item * L<https://aki.io/docs> - AKI.IO API documentation | ||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||
| 457 | =item * L<Langertha::Role::Chat> - Chat interface methods | ||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||
| 459 | =back | ||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||
| 461 | =head1 SUPPORT | ||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||
| 463 | =head2 Issues | ||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||
| 465 | Please report bugs and feature requests on GitHub at | ||||||||||||||||||||||||||||||||||||||||
| 466 | L<https://github.com/Getty/langertha/issues>. | ||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||
| 468 | =head2 IRC | ||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||
| 470 | Join C<#langertha> on C<irc.perl.org> or message Getty directly. | ||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||
| 472 | =head1 CONTRIBUTING | ||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||
| 474 | Contributions are welcome! Please fork the repository and submit a pull request. | ||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||
| 476 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||
| 478 | Torsten Raudssus <getty@cpan.org> | ||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||
| 480 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||
| 482 | This software is copyright (c) 2026 by Torsten Raudssus L<https://raudssus.de/>. | ||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||
| 484 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||
| 485 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||
| 487 | =cut | ||||||||||||||||||||||||||||||||||||||||