Langertha/Engine/AKIOpenAI.pm

filter: Statementstmt 100% 17 / 17 Branchbran n/a Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 86.2% 25 / 29 CC 2 SCAR 3.1
CC
2
Cov
90%
_build_api_key
2.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.4
« Langertha/Engine/LMStudioAnthropic.pm ↑ Summary Langertha/Engine/Cerebras.pm »
1 package Langertha::Engine::AKIOpenAI;
2 # ABSTRACT: AKI.IO via OpenAI-compatible API
3 4 our $VERSION = '0.502';
4 4 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 4 extends 'Langertha::Engine::OpenAIBase';
8  
9 4 with 'Langertha::Role::Tools', 'Langertha::Role::HermesTools';
10  
11  
12 has '+url' => (
13 lazy => 1,
14 2 ▶ default => sub { 'https://aki.io/v1' },
Subroutine __ANON__: called CC=1 SCAR=0.0
15 4 );
16  
17 sub _build_api_key {
18 1 ▶ my ( $self ) = @_;
Subroutine _build_api_key: called CC=2 SCAR=8.1
19 return $ENV{LANGERTHA_AKI_API_KEY}
20 1 ▶ || croak "".(ref $self)." requires LANGERTHA_AKI_API_KEY or api_key set";
Condition33%1/3
$ENV{'LANGERTHA_AKI_API_KEY'} || croak('' . ref($self) . ' requires LANGERTHA_AKI_API_KEY or api_key set')
l!l&&r!l&&!r
100
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 table33%1/3
A || B
A= $ENV{'LANGERTHA_AKI_API_KEY'}B= croak('' . ref($self) . ' requires LANGERTHA_AKI_API_KEY or api_key set')
ABresult
1X1
011
000
21 }
22  
23  
24 2 ▶sub default_model { 'llama3-chat-8b' }
Subroutine default_model: called CC=1 SCAR=0.0
Pod documented
25  
26 1 ▶sub _build_supported_operations {[qw( createChatCompletion )]}
Subroutine _build_supported_operations: called CC=1 SCAR=0.0
27  
28 4 __PACKAGE__->meta->make_immutable;
29  
30  
31 4 1;
32  
33 __END__
34  
35 =pod
36  
37 =encoding UTF-8
38  
39 =head1 NAME
40  
41 Langertha::Engine::AKIOpenAI - AKI.IO via OpenAI-compatible API
42  
43 =head1 VERSION
44  
45 version 0.502
46  
47 =head1 SYNOPSIS
48  
49 use Langertha::Engine::AKIOpenAI;
50  
51 # Direct construction (use /v1 model names, NOT native AKI names)
52 my $aki = Langertha::Engine::AKIOpenAI->new(
53 api_key => $ENV{AKI_API_KEY},
54 model => 'llama3-chat-8b',
55 );
56  
57 print $aki->simple_chat('Hello!');
58  
59 # Streaming
60 $aki->simple_chat_stream(sub {
61 print shift->content;
62 }, 'Tell me about Perl');
63  
64 # Via AKI's openai() method (uses default model)
65 use Langertha::Engine::AKI;
66  
67 my $aki_native = Langertha::Engine::AKI->new(
68 api_key => $ENV{AKI_API_KEY},
69 model => 'llama3_8b_chat',
70 );
71 my $oai = $aki_native->openai; # warns: model not mapped, uses default
72 print $oai->simple_chat('Hello via OpenAI format!');
73  
74 =head1 DESCRIPTION
75  
76 Provides access to AKI.IO's OpenAI-compatible API at C<https://aki.io/v1>.
77 Composes L<Langertha::Role::OpenAICompatible> for the standard OpenAI format.
78  
79 AKI.IO is a European AI model hub (Germany) — fully GDPR-compliant with all
80 inference on EU infrastructure. Supports chat completions (with SSE streaming)
81 and dynamic model listing. Composes L<Langertha::Role::HermesTools> for MCP
82 tool calling via XML tags (AKI's C</v1> endpoint does not support native tool
83 parameters).
84  
85 Embeddings and transcription are not supported. For native AKI.IO API features
86 (C<top_k>, C<top_p>, C<max_gen_tokens>), use L<Langertha::Engine::AKI>.
87  
88 Get your API key at L<https://aki.io/> and set C<LANGERTHA_AKI_API_KEY>.
89  
90 B<THIS API IS WORK IN PROGRESS>
91  
92 =head2 api_key
93  
94 The AKI.IO API key. If not provided, reads from C<LANGERTHA_AKI_API_KEY>
95 environment variable. Sent as a Bearer token in the C<Authorization> HTTP
96 header. Required.
97  
98 =head1 SEE ALSO
99  
100 =over
101  
102 =item * L<Langertha::Engine::AKI> - Native AKI.IO API (with top_k, top_p, max_gen_tokens)
103  
104 =item * L<Langertha::Role::OpenAICompatible> - OpenAI API format role composed by this engine
105  
106 =item * L<https://aki.io/docs> - AKI.IO API documentation
107  
108 =back
109  
110 =head1 SUPPORT
111  
112 =head2 Issues
113  
114 Please report bugs and feature requests on GitHub at
115 L<https://github.com/Getty/langertha/issues>.
116  
117 =head2 IRC
118  
119 Join C<#langertha> on C<irc.perl.org> or message Getty directly.
120  
121 =head1 CONTRIBUTING
122  
123 Contributions are welcome! Please fork the repository and submit a pull request.
124  
125 =head1 AUTHOR
126  
127 Torsten Raudssus <getty@cpan.org>
128  
129 =head1 COPYRIGHT AND LICENSE
130  
131 This software is copyright (c) 2026 by Torsten Raudssus L<https://raudssus.de/>.
132  
133 This is free software; you can redistribute it and/or modify it under
134 the same terms as the Perl 5 programming language system itself.
135  
136 =cut
« Langertha/Engine/LMStudioAnthropic.pm ↑ Summary Langertha/Engine/Cerebras.pm »