blib/lib/Langertha/Engine/MiniMax.pm

filter: Statementstmt 100% 28 / 28 Branchbran n/a Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 11 / 11 Podpod 33.3% 1 / 3 totaltotal 87.2% 41 / 47 CC 2 SCAR 1.9
CC
2
Cov
94%
_build_api_key
2.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« blib/lib/Langertha/Engine/TSystems.pm ↑ Summary blib/lib/Langertha/Engine/Whisper.pm »
1 package Langertha::Engine::MiniMax;
2 # ABSTRACT: MiniMax API (OpenAI-compatible)
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::OpenAIBase';
8  
9 10 with map { 'Langertha::Role::'.$_ } qw(
10 StaticModels
11 Tools
12 );
13  
14  
15 57 ▶sub _build_supported_operations {[qw(
Subroutine _build_supported_operations: called CC=1 SCAR=0.0
16 createChatCompletion
17 )]}
18  
19 has '+url' => (
20 lazy => 1,
21 34 ▶ default => sub { 'https://api.minimax.io/v1' },
Subroutine __ANON__: called CC=1 SCAR=0.0
22 10 );
23  
24 1 ▶sub _build_api_key {
Subroutine _build_api_key: called CC=2 SCAR=8.1
25 1 my ( $self ) = @_;
26 return $ENV{LANGERTHA_MINIMAX_API_KEY}
27 1 ▶ || croak "".(ref $self)." requires LANGERTHA_MINIMAX_API_KEY or api_key set";
Condition33%1/3
$ENV{'LANGERTHA_MINIMAX_API_KEY'} || croak('' . ref($self) . ' requires LANGERTHA_MINIMAX_API_KEY or api_key set')
l!l&&r!l&&!r
100
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 table33%1/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
28 }
29  
30 46 ▶sub default_model { 'MiniMax-M3' }
Subroutine default_model: called CC=1 SCAR=0.0
Pod documented
31  
32 170 ▶sub default_response_size { 4096 }
Subroutine default_response_size: called CC=1 SCAR=0.0
Pod undocumented
33  
34 1 ▶sub _build_static_models {[
Subroutine _build_static_models: called CC=1 SCAR=0.0
35 1 { id => 'MiniMax-M3' },
36 { id => 'MiniMax-M2.7' },
37 { id => 'MiniMax-M2.5' },
38 { id => 'MiniMax-M2.5-highspeed' },
39 { id => 'MiniMax-M2.1' },
40 { id => 'MiniMax-M2.1-highspeed' },
41 { id => 'MiniMax-M2' },
42 ]}
43  
44 # MiniMax's current /v1/chat/completions schema (platform.minimax.io, verified
45 # 2026-09-01) is narrower than the role inventory promises: `tool_choice`,
46 # `response_format` and `parallel_tool_calls` are absent from the schema
47 # entirely. Function calling (the `tools` array) is supported, so tools_native
48 # stays; the selection, structured-output and parallel knobs are cleared so
49 # chat_f never builds a body around fields the wire drops. reasoning_effort is
50 # per model and lives in model_capability_corrections below.
51 236 ▶around engine_capabilities => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
52 236 my ( $orig, $self, @rest ) = @_;
53 236 my $caps = $self->$orig(@rest);
54 236 delete @{$caps}{ qw(
55 tool_choice_auto tool_choice_any tool_choice_none tool_choice_named
56 response_format_json_object response_format_json_schema
57 parallel_tool_use
58 ) };
59 236 return $caps;
60 10 };
61  
62 # Reasoning is per model (karr k209, openapi-chat-openai.json, advisor
63 # 2026-09-25, docs only). The wire has no effort field, only a binary
64 # thinking:{type: disabled|adaptive} toggle (default adaptive). MiniMax-M3
65 # honors it, so reasoning_effort is re-enabled there and its
66 # Reasoning::Profile row maps none -> disabled and every other level ->
67 # adaptive (all levels give the same depth). M2.x accepts disabled but keeps
68 # thinking on, and unknown ids are unchecked, so every other model keeps the
69 # flag cleared and Role::ReasoningEffort sends nothing (the k204 gate). The
70 # clear is the catch-all first row rather than layer 2, so the M3 row can win
71 # over it (ADR 0019 k209 Update).
72 # image_input follows the same shape (k266, llm-advisor, docs only,
73 # 2026-09-25): MiniMax-M3 takes image input, the M2.x line is text-only.
74 234 ▶sub model_capability_corrections {
Subroutine model_capability_corrections: called CC=1 SCAR=0.0
Pod undocumented
75 return (
76 234 qr/\A/ => { reasoning_effort => 0, image_input => 0 },
77 qr/\AMiniMax-M3(?!\d)/ => { reasoning_effort => 1, image_input => 1 },
78 );
79 }
80  
81 # This endpoint speaks the `thinking` on/off toggle (ADR 0023 k209 Update): the
82 # thinking-toggle Reasoning::Profile rows serialize as the toggle only on an
83 # engine that opts in here; the same model id elsewhere keeps its effort wire.
84 40 ▶sub _reasoning_thinking_toggle { 1 }
Subroutine _reasoning_thinking_toggle: called CC=1 SCAR=0.0
85  
86 10 __PACKAGE__->meta->make_immutable;
87  
88  
89 10 1;
90  
91 __END__
92  
93 =pod
94  
95 =encoding UTF-8
96  
97 =head1 NAME
98  
99 Langertha::Engine::MiniMax - MiniMax API (OpenAI-compatible)
100  
101 =head1 VERSION
102  
103 version 0.503
104  
105 =head1 SYNOPSIS
106  
107 use Langertha::Engine::MiniMax;
108  
109 my $minimax = Langertha::Engine::MiniMax->new(
110 api_key => $ENV{MINIMAX_API_KEY},
111 model => 'MiniMax-M3',
112 );
113  
114 print $minimax->simple_chat('Hello from Perl!');
115  
116 # Streaming
117 $minimax->simple_chat_stream(sub {
118 print shift->content;
119 }, 'Write a poem');
120  
121 # Tool calling
122 my $response = await $minimax->chat_with_tools_f('Search for Perl modules');
123  
124 =head1 DESCRIPTION
125  
126 Provides access to L<MiniMax|https://www.minimax.io/> models via their
127 native OpenAI-compatible endpoint at C<https://api.minimax.io/v1>.
128  
129 MiniMax is a Chinese AI company based in Shanghai offering large language
130 models with strong coding, reasoning, and agentic capabilities.
131  
132 B<Why the OpenAI endpoint, not the Anthropic one:> MiniMax also exposes an
133 C</anthropic> endpoint, but that endpoint is a shim — it does not always
134 re-parse stringified tool-call arguments, leading to intermittent tool-
135 calling failures where the Anthropic SDK sees a wrapper object whose key
136 rotates between C<result>, C<arguments>, and the tool name. The native
137 OpenAI-compatible endpoint avoids the shim entirely. If you need the
138 Anthropic wire format, use L<Langertha::Engine::MiniMaxAnthropic>.
139  
140 B<Available text models:>
141  
142 =over 4
143  
144 =item * C<MiniMax-M3> — Latest flagship (default).
145  
146 =item * C<MiniMax-M2.7> — Previous flagship.
147  
148 =item * C<MiniMax-M2.5> — ~200K context window, SOTA coding (80.2%
149 SWE-Bench Verified), agentic tool use, and search. (The 1M context figure
150 applies only to the M2.5 Lightning variant.)
151  
152 =item * C<MiniMax-M2.5-highspeed> — Same M2.5 performance with lower
153 latency. 205K context window.
154  
155 =item * C<MiniMax-M2.1> — 230B total parameters, 10B activated per
156 inference. Strong multilingual coding and reasoning.
157  
158 =item * C<MiniMax-M2.1-highspeed> — Same M2.1 performance with lower
159 latency.
160  
161 =item * C<MiniMax-M2> — 200K context, 128K max output. Function calling
162 and agentic capabilities.
163  
164 =back
165  
166 See L<https://platform.minimax.io/docs/guides/models-intro> for the full
167 model catalog including audio, video, and music models.
168  
169 B<Reasoning:> this endpoint has no effort level, only a C<thinking> toggle.
170 On C<MiniMax-M3>, C<reasoning_effort =E<gt> 'none'> sends
171 C<< thinking =E<gt> { type =E<gt> 'disabled' } >> and any other level sends
172 C<< { type =E<gt> 'adaptive' } >>; every level gives the same reasoning depth,
173 so do not expect graded effort. The M2.x models cannot turn thinking off and
174 take no reasoning control here (nothing is sent).
175  
176 Supports chat, streaming, tool calling, and structured output. Embeddings,
177 transcription, images, and documents are not supported via this endpoint.
178  
179 Get your API key at L<https://platform.minimax.io/> and set
180 C<LANGERTHA_MINIMAX_API_KEY> in your environment.
181  
182 =head1 SEE ALSO
183  
184 =over
185  
186 =item * L<Langertha::Engine::MiniMaxAnthropic> - MiniMax via legacy Anthropic-compatible endpoint
187  
188 =item * L<https://platform.minimax.io/docs/api-reference/text-openai-api> - MiniMax OpenAI-compatible API docs
189  
190 =item * L<Langertha::Engine::OpenAIBase> - Base class for OpenAI-compatible engines
191  
192 =item * L<Langertha::Role::Tools> - MCP tool calling interface
193  
194 =back
195  
196 =head1 SUPPORT
197  
198 =head2 Issues
199  
200 Please report bugs and feature requests on GitHub at
201 L<https://github.com/Getty/langertha/issues>.
202  
203 =head2 IRC
204  
205 Join C<#langertha> on C<irc.perl.org> or message Getty directly.
206  
207 =head1 CONTRIBUTING
208  
209 Contributions are welcome! Please fork the repository and submit a pull request.
210  
211 =head1 AUTHOR
212  
213 Torsten Raudssus <getty@cpan.org>
214  
215 =head1 COPYRIGHT AND LICENSE
216  
217 This software is copyright (c) 2026 by Torsten Raudssus L<https://raudssus.de/>.
218  
219 This is free software; you can redistribute it and/or modify it under
220 the same terms as the Perl 5 programming language system itself.
221  
222 =cut
« blib/lib/Langertha/Engine/TSystems.pm ↑ Summary blib/lib/Langertha/Engine/Whisper.pm »