Free, Unlimited Kimi K2.6 API
On this page
This tutorial will show you how to use Puter.js to access 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 library 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 K2.6
To generate text using Kimi K2.6, use the puter.ai.chat() function:
puter.ai.chat("Explain artificial intelligence in simple terms", { model: "moonshotai/kimi-k2.6" })
.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-k2.6" })
.then(response => {
puter.print(response);
});
</script>
</body>
</html>
Example 2: Code generation with Kimi K2.6
Kimi K2.6 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.6" }
)
.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-k2.6', 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-k2.6' }
).then(response => {
puter.print(response);
});
</script>
</body>
</html>
Example 5: Complex Reasoning with Kimi K2.6
Kimi K2.6 is 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-k2.6' }
).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.5, moonshotai/kimi-k2, or moonshotai/kimi-k2-thinking:
// 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 model
puter.ai.chat(
"Write a short poem about coding",
{ model: "moonshotai/kimi-k2" }
).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.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 model
puter.ai.chat(
<html>
<body>
<script src="https://js.puter.com/v2/"></script>
<script>
// 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 model
puter.ai.chat(<html>
<body>
<script src="https://js.puter.com/v2/"></script>
<script>
// 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 model
puter.ai.chat(
"Write a short poem about coding",
{ model: "moonshotai/kimi-k2" }
).then(response => {
puter.print("<h2>Using Kimi K2 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-k2
moonshotai/kimi-k2-0905
moonshotai/kimi-k2-thinking
moonshotai/kimi-k2.5
moonshotai/kimi-k2.6
That's it! You now have free access to Kimi's powerful AI capabilities using Puter.js. This allows you to build sophisticated multilingual applications with advanced AI features without needing API keys, backend infrastructure, or complex billing management.
Related
Free, Serverless AI and Cloud
Start creating powerful web applications with Puter.js in seconds!
Get Started Now