NAME
Langertha::Engine::Moonshot - Moonshot AI Kimi API (OpenAI-compatible)
VERSION
version 0.503
SYNOPSIS
use Langertha::Engine::Moonshot;
my $moonshot = Langertha::Engine::Moonshot->new(
api_key => $ENV{MOONSHOT_API_KEY},
model => 'kimi-k3',
);
print $moonshot->simple_chat('Hello from Perl!');
# Streaming
$moonshot->simple_chat_stream(sub {
print shift->content;
}, 'Write a poem');
# Tool calling
my $response = await $moonshot->chat_with_tools_f('Search for Perl modules');
DESCRIPTION
Provides access to Moonshot AI's Kimi models via their native OpenAI-compatible endpoint at https://api.moonshot.ai/v1.
Moonshot AI is a Beijing-based AI company; their Kimi models are natively multimodal (text, image, and video input) with strong coding, reasoning, and agentic capabilities. kimi-k3 offers a 1M-token context window; the K2.x legacy models below remain at 256K.
Why the OpenAI endpoint: Moonshot also exposes an Anthropic-compatible /anthropic endpoint; if you need the Anthropic wire format, use Langertha::Engine::MoonshotAnthropic. The native OpenAI-compatible endpoint is the recommended default.
Available models:
kimi-k3— Current flagship (default). Kimi's most capable model: 2.8 trillion parameters, native visual understanding, 1M context, frontier reasoning and agentic tasks.kimi-k2.7-code— Dedicated coding model: more reliable instruction following in long contexts and higher coding task success. 256K context.kimi-k2.7-code-highspeed— High-speed variant ofkimi-k2.7-code(~180 tokens/s, up to ~260 tokens/s in short-context scenarios).kimi-k2.6— Previous multimodal model: thinking and non-thinking modes, dialogue and Agent tasks. 256K context.
Sunset: kimi-k2.5 and the moonshot-v1-* generation series are no longer available to newly registered users and reach full platform sunset on 2026-08-31; they are deliberately no longer listed here. The older kimi-k2 preview series was discontinued on 2026-05-25.
See https://platform.kimi.ai/docs/models for the full model catalog.
Reasoning note: reasoning control differs per model family on this endpoint. The K2.x line uses a Kimi-specific top-level thinking object ({ type => 'enabled' } / { type => 'disabled' }), not the OpenAI-wire reasoning_effort field. On kimi-k2.6 this engine serializes reasoning_effort onto that toggle: none sends thinking => { type => 'disabled' }, any other level thinking => { type => 'enabled' } (every level gives the same depth), and no reasoning_effort field goes out. kimi-k2.7-code and kimi-k2.7-code-highspeed always think and must not be sent a thinking field, so the engine does not advertise reasoning_effort there and sends nothing. This K2.x wire is taken from Moonshot's documentation and is not verified against the live API. kimi-k3 instead accepts a top-level reasoning_effort of low / high / max and defaults to max server-side when the field is omitted; it always reasons. On kimi-k3 the engine sends reasoning_effort when it is one of those three values and drops any other level, so the server default applies.
Temperature: every current Kimi model fixes temperature server-side and rejects other values, so this engine never sends one; a temperature other than 1 is dropped with a warning.
Response size: Kimi counts reasoning toward max_tokens and recommends at least 16000 while thinking is on, so kimi-k3, kimi-k2.7-code, kimi-k2.7-code-highspeed and kimi-k2.6 default to 16000 (per model, so kimi-k2.6 keeps 16000 even with reasoning_effort => 'none'); other ids keep 4096. An explicit response_size is always sent as given.
Supports chat, streaming, tool calling, and structured output. Embeddings, transcription, and image generation are not supported via this endpoint.
Get your API key at https://platform.kimi.ai/ and set LANGERTHA_MOONSHOT_API_KEY in your environment.
SEE ALSO
Langertha::Engine::MoonshotAnthropic - Moonshot via Anthropic-compatible endpoint
https://platform.kimi.ai/docs/api/overview - Kimi OpenAI-compatible API docs
Langertha::Engine::OpenAIBase - Base class for OpenAI-compatible engines
Langertha::Role::Tools - MCP tool calling interface
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.