blib/lib/Langertha/Engine/MiniMaxAnthropic.pm

filter: Statementstmt 72.7% 24 / 33 Branchbran 25.0% 1 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 83.3% 10 / 12 Podpod 50.0% 2 / 4 totaltotal 63.7% 37 / 58 CC 4 SCAR 9.6
CC
4
Cov
62%
_build_api_key
6.0
__ANON__
5.4
_build_static_models
2.0
CRAP 2.6
« blib/lib/Langertha/Engine/SGLang.pm ↑ Summary blib/lib/Langertha/Role/CachedContent.pm »
1 package Langertha::Engine::MiniMaxAnthropic;
2 # ABSTRACT: MiniMax API via Anthropic-compatible endpoint (legacy)
3 10 our $VERSION = '0.503';
4 10 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 10 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 10 extends 'Langertha::Engine::AnthropicBase';
8  
9 10 with 'Langertha::Role::StaticModels';
10  
11  
12 # AnthropicBase->chat_request appends '/v1/messages' to url; the default must
13 # therefore stop at '/anthropic' so the composed endpoint is a single
14 # '/anthropic/v1/messages' (a '/anthropic/v1' default double-stacks to
15 # '/anthropic/v1/v1/messages' -> HTTP 404 on every model).
16 has '+url' => (
17 lazy => 1,
18 19 ▶ default => sub { 'https://api.minimax.io/anthropic' },
Subroutine __ANON__: called CC=1 SCAR=0.0
19 10 );
20  
21 0 ▶sub _build_api_key {
Subroutine _build_api_key: not called CC=2 SCAR=17.9
22 0 my ( $self ) = @_;
23 return $ENV{LANGERTHA_MINIMAX_API_KEY}
24 0 ▶ || croak "".(ref $self)." requires LANGERTHA_MINIMAX_API_KEY or api_key set";
Condition0%0/3
$ENV{'LANGERTHA_MINIMAX_API_KEY'} || croak('' . ref($self) . ' requires LANGERTHA_MINIMAX_API_KEY or api_key set')
l!l&&r!l&&!r
000
MC/DC0%0/2
$ENV{'LANGERTHA_MINIMAX_API_KEY'} || croak('' . ref($self) . ' requires LANGERTHA_MINIMAX_API_KEY or api_key set')
$ENV{'LANGERTHA_MINIMAX_API_KEY'} croak('' . ref($self) . ' requires LANGERTHA_MINIMAX_API_KEY or api_key set')
Truth table0%0/3
A || B
A= $ENV{'LANGERTHA_MINIMAX_API_KEY'}B= croak('' . ref($self) . ' requires LANGERTHA_MINIMAX_API_KEY or api_key set')
ABresult
1X1
011
000
25 }
26  
27 19 ▶sub default_model { 'MiniMax-M3' }
Subroutine default_model: called CC=1 SCAR=0.0
Pod documented
28  
29 1 ▶sub api_key_env { 'LANGERTHA_MINIMAX_API_KEY' }
Subroutine api_key_env: called CC=1 SCAR=0.0
Pod documented
30  
31 63 ▶sub default_response_size { 4096 }
Subroutine default_response_size: called CC=1 SCAR=0.0
Pod undocumented
32  
33 0 ▶sub _build_static_models {[
Subroutine _build_static_models: not called CC=1 SCAR=6.9
34 0 { id => 'MiniMax-M3' },
35 { id => 'MiniMax-M2.7' },
36 { id => 'MiniMax-M2.5' },
37 { id => 'MiniMax-M2.5-highspeed' },
38 { id => 'MiniMax-M2.1' },
39 { id => 'MiniMax-M2.1-highspeed' },
40 { id => 'MiniMax-M2' },
41 ]}
42  
43 # MiniMax's /anthropic CreateMessageReq has a `thinking` object (default
44 # disabled on M3) but no `output_config` (openapi-chat-anthropic.json, advisor
45 # 2026-09-25, docs only; karr k209). That holds for every model on this
46 # endpoint, so the effort is stripped here rather than in a per-model
47 # Reasoning::Profile row; thinking:{type:adaptive} stays, since it is how an
48 # effort turns thinking on (ADR 0009 k209 update).
49 71 ▶around reasoning_kwargs_for => sub {
Subroutine __ANON__: called CC=3 SCAR=16.8
50 71 my ( $orig, $self, @args ) = @_;
51 71 my %kwargs = $self->$orig(@args);
52 63 ▶ if ( ref $kwargs{output_config} eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $kwargs{"output_config"} eq "HASH") 0 63 63
53 0 my %output_config = %{ $kwargs{output_config} };
54 0 delete $output_config{effort};
55 0 ▶ if (%output_config) { $kwargs{output_config} = \%output_config }
Branch: 1 branch
BranchTrueFalseTotal
if (%output_config) { } 0 0 0
56 0 else { delete $kwargs{output_config} }
57 }
58 63 return %kwargs;
59 10 };
60  
61 # This endpoint speaks the `thinking` on/off toggle (ADR 0023 k209 Update): the
62 # thinking-toggle Reasoning::Profile rows serialize as the toggle only on an
63 # engine that opts in here; the same model id elsewhere keeps its effort wire.
64 66 ▶sub _reasoning_thinking_toggle { 1 }
Subroutine _reasoning_thinking_toggle: called CC=1 SCAR=0.0
65  
66 # image_input (k266, ADR 0019 k266 Update): MiniMax-M3 takes image input, the
67 # M2.x line is text-only (llm-advisor, docs only, 2026-09-25) -- the same rows
68 # as Engine::MiniMax, the OpenAI face of the same service.
69 144 ▶sub model_capability_corrections {
Subroutine model_capability_corrections: called CC=1 SCAR=0.0
Pod undocumented
70 return (
71 144 qr/\A/ => { image_input => 0 },
72 qr/\AMiniMax-M3(?!\d)/ => { image_input => 1 },
73 );
74 }
75  
76 # Source blocks in a tool_result (karr k364, k371): deliberately 1, the
77 # Role::Tools default, stated here so nobody flips it to 0 as "undocumented".
78 # MiniMax's docs do not know `document` (RequestContentBlock.type enum is
79 # text | image | video | tool_use | tool_result | thinking | mid_conv_system;
80 # tool_result.content is "string or array of text/image", docs only), but a
81 # live probe 2026-09-30 (tool_use -> tool_result[text, document{base64
82 # application/pdf}], 1-page PDF reading a codeword) got HTTP 200 and the
83 # correct codeword from both MiniMax-M2.7 (text-only, 244 input tokens: text
84 # extracted without vision) and MiniMax-M3 (3159 input tokens: page seen as
85 # well). Gating on image_input would turn working PDF reading on M2.x into the
86 # placeholder. Only a PDF/base64 document was probed; a text-source document
87 # and search_result were NOT.
88 7 ▶sub _tool_result_source_blocks_on_wire { 1 }
Subroutine _tool_result_source_blocks_on_wire: called CC=1 SCAR=0.0
89  
90 10 __PACKAGE__->meta->make_immutable;
91  
92  
93 10 1;
94  
95 __END__
96  
97 =pod
98  
99 =encoding UTF-8
100  
101 =head1 NAME
102  
103 Langertha::Engine::MiniMaxAnthropic - MiniMax API via Anthropic-compatible endpoint (legacy)
104  
105 =head1 VERSION
106  
107 version 0.503
108  
109 =head1 SYNOPSIS
110  
111 use Langertha::Engine::MiniMaxAnthropic;
112  
113 my $minimax = Langertha::Engine::MiniMaxAnthropic->new(
114 api_key => $ENV{MINIMAX_API_KEY},
115 model => 'MiniMax-M3',
116 );
117  
118 print $minimax->simple_chat('Hello from Perl!');
119  
120 =head1 DESCRIPTION
121  
122 Provides access to L<MiniMax|https://www.minimax.io/> models via their
123 Anthropic-compatible endpoint at C<https://api.minimax.io/anthropic> (the
124 shared L<Langertha::Engine::AnthropicBase> appends the C</v1/messages> path).
125  
126 B<Historical note:> Until version 0.402 this was the default behavior of
127 L<Langertha::Engine::MiniMax>. MiniMax's C</anthropic> endpoint is a shim
128 over their native OpenAI-compatible API — it does not always re-parse
129 stringified tool-call arguments, which causes intermittent tool-calling
130 failures where the Anthropic SDK sees a wrapper object whose key rotates
131 between C<result>, C<arguments>, and the tool name. For new code prefer
132 L<Langertha::Engine::MiniMax>, which talks to MiniMax's native OpenAI
133 endpoint and avoids the shim. This class is retained for anyone who needs
134 the Anthropic wire format specifically.
135  
136 See L<Langertha::Engine::MiniMax> for the available models list.
137  
138 MiniMax's Anthropic-compatible request schema has no C<output_config>, so a
139 C<reasoning_effort> is not sent as C<output_config.effort>. It goes out as the
140 C<thinking> toggle instead: any level sends C<< { type =E<gt> 'adaptive' } >>,
141 which turns thinking on (the endpoint's default for C<MiniMax-M3> is thinking
142 off), and C<none> sends C<< { type =E<gt> 'disabled' } >> on C<MiniMax-M3>. The
143 M2.x models cannot turn thinking off, so C<none> sends nothing there.
144  
145 Get your API key at L<https://platform.minimax.io/> and set
146 C<LANGERTHA_MINIMAX_API_KEY> in your environment.
147  
148 =head1 SEE ALSO
149  
150 =over
151  
152 =item * L<Langertha::Engine::MiniMax> - Recommended MiniMax engine (OpenAI-compatible endpoint)
153  
154 =item * L<https://platform.minimax.io/docs/api-reference/text-anthropic-api> - MiniMax Anthropic API docs
155  
156 =item * L<Langertha::Engine::AnthropicBase> - Anthropic-compatible base class
157  
158 =back
159  
160 =head1 SUPPORT
161  
162 =head2 Issues
163  
164 Please report bugs and feature requests on GitHub at
165 L<https://github.com/Getty/langertha/issues>.
166  
167 =head2 IRC
168  
169 Join C<#langertha> on C<irc.perl.org> or message Getty directly.
170  
171 =head1 CONTRIBUTING
172  
173 Contributions are welcome! Please fork the repository and submit a pull request.
174  
175 =head1 AUTHOR
176  
177 Torsten Raudssus <getty@cpan.org>
178  
179 =head1 COPYRIGHT AND LICENSE
180  
181 This software is copyright (c) 2026 by Torsten Raudssus L<https://raudssus.de/>.
182  
183 This is free software; you can redistribute it and/or modify it under
184 the same terms as the Perl 5 programming language system itself.
185  
186 =cut
« blib/lib/Langertha/Engine/SGLang.pm ↑ Summary blib/lib/Langertha/Role/CachedContent.pm »