Free, Unlimited Kimi API
On this page
This tutorial will show you how to use Puter.js to access Kimi K3, Kimi K2.7 Code, Kimi K2.6, Kimi K2.5, Kimi K2, and Kimi K2 Thinking capabilities for free, without needing API keys, backend, or server-side setup. Puter.js allows you to provide your users with powerful multilingual AI capabilities without any server-side setup.
Puter is the pioneer of the "User-Pays" model, which allows developers to incorporate AI capabilities into their applications while each user covers their own usage costs. This model enables developers to offer advanced AI capabilities to users at no cost to themselves, without any API keys or server-side setup.
Puter.js is also an especially good fit for AI coding assistants, agents, and vibe coding platforms (Claude Code, Codex, OpenCode, Lovable, Replit, and the rest). With no keys to manage and no backend in the loop, whatever these tools generate is ready to run end-to-end the moment it's created. No outside accounts, no services to spin up, no credentials to paste. That clears away a major source of security headaches and the configuration step that normally trips up AI-built apps before they ever launch.
Getting Started
To use Puter.js, import our npm module in your project:
// npm install @heyputer/puter.js
import { puter } from '@heyputer/puter.js';
Or alternatively, add our script via CDN if you are working directly with HTML, simply add it to the <head> or <body> section of your code:
<script src="https://js.puter.com/v2/"></script>
Nothing else is required to start using Puter.js for free access to Kimi capabilities.
Example 1: Basic text generation with Kimi K3
To generate text using Kimi K3, use the puter.ai.chat() function:
puter.ai.chat("Explain artificial intelligence in simple terms", { model: "moonshotai/kimi-k3" })
.then(response => {
puter.print(response);
});
Full code example:
<html>
<body>
<script src="https://js.puter.com/v2/"></script>
<script>
puter.ai.chat("Explain artificial intelligence in simple terms", { model: "moonshotai/kimi-k3" })
.then(response => {
puter.print(response);
});
</script>
</body>
</html>
Example 2: Code generation with Kimi K2.7 Code
Kimi K2.7 Code excels at code generation tasks. Here's how to use it for writing code:
<html>
<body>
<script src="https://js.puter.com/v2/"></script>
<script>
puter.ai.chat(
"Write a Python function that implements binary search on a sorted array",
{ model: "moonshotai/kimi-k2.7-code" }
)
.then(response => {
puter.print(response, {code: true});
});
</script>
</body>
</html>
Example 3: Streaming responses for better user experience
For longer responses, you can use streaming to get results in real-time:
<html>
<body>
<div id="response"></div>
<script src="https://js.puter.com/v2/"></script>
<script>
async function streamResponse() {
const outputDiv = document.getElementById('response');
const response = await puter.ai.chat(
"Write a detailed comparison between traditional programming and AI-assisted development",
{model: 'moonshotai/kimi-k3', stream: true}
);
for await (const part of response) {
if (part?.text) {
outputDiv.innerHTML += part.text;
}
}
}
streamResponse();
</script>
</body>
</html>
This example demonstrates streaming responses, which provides a better user experience by showing the AI's response as it's generated rather than waiting for the complete response.
Example 4: Image Analysis
To analyze images, simply provide an image URL to puter.ai.chat():
<html>
<body>
<script src="https://js.puter.com/v2/"></script>
<script>
puter.ai.chat(
"What do you see in this image?",
"https://assets.puter.site/doge.jpeg",
{ model: 'moonshotai/kimi-k3' }
).then(response => {
puter.print(response);
});
</script>
</body>
</html>
Example 5: Complex Reasoning with Kimi K3
Kimi K3 runs in an always-on thinking mode, which makes it particularly good at reasoning and complex problem-solving:
<html>
<body>
<script src="https://js.puter.com/v2/"></script>
<script>
puter.ai.chat(
"What would be the environmental impact of replacing all cars with electric vehicles? Consider both positive and negative effects.",
{ model: 'moonshotai/kimi-k3' }
).then(response => {
puter.print(response);
});
</script>
</body>
</html>
Example 6: Using different Kimi models
You can specify different Kimi models using the model parameter, for example moonshotai/kimi-k2.6, moonshotai/kimi-k2.5, or moonshotai/kimi-k2-thinking:
// Using Kimi K2.6 model
puter.ai.chat(
"Write a short poem about coding",
{ model: "moonshotai/kimi-k2.6" }
).then(response => {
puter.print(response);
});
// Using Kimi K2.5 model
puter.ai.chat(
"Write a short poem about coding",
{ model: "moonshotai/kimi-k2.5" }
).then(response => {
puter.print(response);
});
// Using Kimi K2 Thinking model
puter.ai.chat(
"Write a short poem about coding",
{ model: "moonshotai/kimi-k2-thinking" }
).then(response => {
puter.print(response);
});
Full code example:
<html>
<body>
<script src="https://js.puter.com/v2/"></script>
<script>
// Using Kimi K2.6 model
puter.ai.chat(
"Write a short poem about coding",
{ model: "moonshotai/kimi-k2.6" }
).then(response => {
puter.print("<h2>Using Kimi K2.6 model</h2>");
puter.print(response);
});
// Using Kimi K2.5 model
puter.ai.chat(
<html>
<body>
<script src="https://js.puter.com/v2/"></script>
<script>
// Using Kimi K2.6 model
puter.ai.chat(
"Write a short poem about coding",
{ model: "moonshotai/kimi-k2.6" }
).then(response => {
puter.print("<h2>Using Kimi K2.6 model</h2>");
puter.print(response);
});
// Using Kimi K2.5 model
puter.ai.chat(<html>
<body>
<script src="https://js.puter.com/v2/"></script>
<script>
// Using Kimi K2.6 model
puter.ai.chat(
"Write a short poem about coding",
{ model: "moonshotai/kimi-k2.6" }
).then(response => {
puter.print("<h2>Using Kimi K2.6 model</h2>");
puter.print(response);
});
// Using Kimi K2.5 model
puter.ai.chat(
"Write a short poem about coding",
{ model: "moonshotai/kimi-k2.5" }
).then(response => {
puter.print("<h2>Using Kimi K2.5 model</h2>");
puter.print(response);
});
// Using Kimi K2 Thinking model
puter.ai.chat(
"Write a short poem about coding",
{ model: "moonshotai/kimi-k2-thinking" }
).then(response => {
puter.print("<h2>Using Kimi K2 Thinking model</h2>");
puter.print(response);
});
</script>
</body>
</html>
List of supported models
The following Kimi models are supported by Puter.js:
moonshotai/kimi-k3
moonshotai/kimi-k2.7-code
moonshotai/kimi-k2.7-code-fast
moonshotai/kimi-k2.7-code-highspeed
moonshotai/kimi-k2.6
moonshotai/kimi-k2.5
moonshotai/kimi-k2-thinking
moonshotai/kimi-k2-0905
moonshotai/kimi-k2
The following Moonshot AI models are also supported by Puter.js:
moonshotai/moonshot-v1-auto
moonshotai/moonshot-v1-128k
moonshotai/moonshot-v1-128k-vision-preview
moonshotai/moonshot-v1-32k
moonshotai/moonshot-v1-32k-vision-preview
moonshotai/moonshot-v1-8k
moonshotai/moonshot-v1-8k-vision-preview
Conclusion
Using Puter.js, you can gain access to Kimi and Moonshot AI models without having to set up the AI server yourself. And thanks to the User-Pays model, your users cover their own AI usage, not you as the developer. This means you can build powerful applications without worrying about AI usage costs.
You can find all AI features supported by Puter.js in the documentation.
Related
Ship a Full-Stack App with One Prompt
Build an AI chat app using Puter.js
Coding manually? see the guide