Tutorials

Free, Unlimited Kwaipilot Kat API

This tutorial will show you how to use Puter.js to access the Kwaipilot Kat Coder capabilities for free, without needing API keys, backend, or server-side setup.

Puter is the pioneer of the "User-Pays" model, allowing developers to incorporate AI features into their applications with each user covering their own 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.

Getting Started

You can use Puter.js without any API keys or sign-ups. To start using Puter.js, include the following script tag in your HTML file, either in the <head> or <body> section:

<script src="https://js.puter.com/v2/"></script>

Nothing else is required to start using Puter.js for free access to Kwaipilot Kat capabilities.

Example 1Code Generation with Kat Coder

To generate code using Kwaipilot Kat Coder, use the puter.ai.chat() function:

puter.ai.chat("Write a simple Python function to calculate Fibonacci numbers", { model: "openrouter:kwaipilot/kat-coder-pro:free" })
    .then(response => {
        puter.print(response, {code: true});
    });

Full code example:

<html>
<body>
    <script src="https://js.puter.com/v2/"></script>
    <script>
        puter.ai.chat("Write a simple Python function to calculate Fibonacci numbers", { model: "openrouter:kwaipilot/kat-coder-pro:free" })
            .then(response => {
                puter.print(response, {code: true});
            });
    </script>
</body>
</html>

Example 2Conversational coding assistant

Kat Coder excels at conversational interactions for coding tasks. Here's an example of getting help with debugging:

<html>
<body>
    <script src="https://js.puter.com/v2/"></script>
    <script>
        puter.ai.chat(
            "I have a JavaScript function that's supposed to sort an array, but it's not working correctly. Can you help me identify the issue and fix it? Here's my code: function sortArray(arr) { return arr.sort(); }",
            { model: "openrouter:kwaipilot/kat-coder-pro:free" }
        ).then(response => {
            puter.print(response, {code: true});
        });
    </script>
</body>
</html>

This example demonstrates Kat Coder's ability to understand coding problems and provide detailed explanations and solutions.

Example 3Chinese language coding support

Kwaipilot Kat Coder has excellent Chinese language support:

<html>
<body>
    <script src="https://js.puter.com/v2/"></script>
    <script>
        puter.ai.chat(
            "请帮我写一个JavaScript函数,用于验证邮箱地址的格式是否正确。",
            { model: "openrouter:kwaipilot/kat-coder-pro:free" }
        ).then(response => {
            puter.print(response, {code: true});
        });
    </script>
</body>
</html>

This example demonstrates Kat Coder's ability to understand and respond in Chinese, making it perfect for applications targeting Chinese-speaking developers or requiring multilingual coding support.

Example 4Streaming code generation

For longer code generation tasks, you can use streaming to get results in real-time:

<html>
<body>
    <pre id="response"></pre>
    <script src="https://js.puter.com/v2/"></script>
    <script>
        async function streamResponse() {
            const outputCode = document.getElementById('response');

            const response = await puter.ai.chat(
                "Create a complete REST API server in Node.js with Express that includes user authentication, CRUD operations for blog posts, and error handling middleware",
                { model: 'openrouter:kwaipilot/kat-coder-pro:free', stream: true }
            );

            for await (const part of response) {
                if (part?.text) {
                    outputCode.innerHTML += part.text;
                }
            }
        }

        streamResponse();
    </script>
</body>
</html>

This example demonstrates streaming responses, which provides a better user experience by showing the AI's code generation as it's being produced rather than waiting for the complete response.

List of supported models

The following Kwaipilot Kat model is supported by Puter.js:

openrouter:kwaipilot/kat-coder-pro:free



That's it! You now have free access to Kwaipilot Kat's powerful coding capabilities using Puter.js. This allows you to build sophisticated development tools and coding assistants 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

Read the Docs Try the Playground