NAME
Langertha::Engine::MoonshotAnthropic - Moonshot AI Kimi API via Anthropic-compatible endpoint
VERSION
version 0.503
SYNOPSIS
use Langertha::Engine::MoonshotAnthropic;
my $moonshot = Langertha::Engine::MoonshotAnthropic->new(
api_key => $ENV{MOONSHOT_API_KEY},
model => 'kimi-k3',
);
print $moonshot->simple_chat('Hello from Perl!');
DESCRIPTION
Provides access to Moonshot AI's Kimi models via their Anthropic-compatible endpoint at https://api.moonshot.ai/anthropic (the shared Langertha::Engine::AnthropicBase appends the /v1/messages path). This is the endpoint Moonshot documents for Claude Code / Anthropic-SDK clients.
For new code prefer Langertha::Engine::Moonshot, which talks to Moonshot's native OpenAI-compatible endpoint. This class is retained for callers that need the Anthropic wire format specifically.
See Langertha::Engine::Moonshot for the available models list.
On kimi-k3, reasoning_effort goes out as output_config.effort when it is low, high or max; any other level is dropped and the server default (max) applies. K3 always reasons and Kimi's Messages API has no thinking request field for it, so none is sent (thinking_display has no effect on K3).
On the K2.x line Kimi takes no effort here, only a thinking toggle, so reasoning_effort becomes thinking => { type => 'enabled' } for any level; none sends { type => 'disabled' } on kimi-k2.6 and nothing on kimi-k2.7-code, which cannot turn thinking off. Every level gives the same depth. A thinking_display adds display to an on toggle. Not verified against the live API: whether Kimi requires budget_tokens with enabled (none is sent), whether it accepts display there, and whether kimi-k2.7-code accepts a request with no thinking field. Other K2 ids take no reasoning control on this endpoint.
On kimi-k3 a json_schema response_format goes out natively as output_config.format (with the schema closed, as on first-party Anthropic), so it also streams; a json_object, and every response_format on the K2.x models, still use the synthesized-tool rewrite of the /anthropic shims.
max_tokens defaults to 16000 on the thinking Kimi models, as on Langertha::Engine::Moonshot; an explicit response_size is sent as given.
Kimi fixes temperature server-side on every current model, so none is sent; a temperature other than 1 is dropped with a warning.
image_input is claimed for the same vision models as on Langertha::Engine::Moonshot (kimi-k3, kimi-k2.6, kimi-k2.7-code), so an image a tool returns reaches them as an image block in the tool_result. Kimi's schema takes no document or search_result there, so an embedded text resource goes out as a text block, a PDF as a text placeholder, and a native document / search_result block as its text (with a warning).
Get your API key at https://platform.kimi.ai/ and set LANGERTHA_MOONSHOT_API_KEY in your environment.
SEE ALSO
Langertha::Engine::Moonshot - Recommended Moonshot engine (OpenAI-compatible endpoint)
https://platform.kimi.ai/docs/api/overview - Kimi API docs
Langertha::Engine::AnthropicBase - Anthropic-compatible base class
SUPPORT
Issues
Please report bugs and feature requests on GitHub at https://github.com/Getty/langertha/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 <getty@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2026 by Torsten Raudssus https://raudssus.de/.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.