Tutorials

Free, Unlimited Microsoft Phi API

This tutorial will show you how to use Puter.js to access Microsoft's powerful Phi AI models for free, without any API keys or usage restrictions. Using Puter.js, you can leverage models like Phi 4, Phi 4 Reasoning Plus, Phi 4 Multimodal Instruct, and Phi 3.5.

Puter is the pioneer of the "User-Pays" model, which allows developers to add AI capabilities to their applications while users cover their own usage costs. This model enables developers to access advanced AI features for free, without any API keys or server-side setup.

Getting Started

Puter.js works without any API keys. 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>

You're now ready to use Puter.js for free access to Microsoft Phi capabilities. No API keys or sign-ups are required.

Example 1: Basic Chat with Phi 4

Here's a simple example showing how to generate text using Microsoft Phi 4:

<html>
<body>
    <script src="https://js.puter.com/v2/"></script>
    <script>
        puter.ai.chat("Explain the concept of machine learning in simple terms", {
            model: 'microsoft/phi-4'
        }).then(response => {
            puter.print(response);
        });
    </script>
</body>
</html>

Using the puter.ai.chat() function, you can generate text using Microsoft Phi 4, which provides excellent performance for general conversational tasks and reasoning.

Example 2: Complex Reasoning with Phi 4 Reasoning Plus

Microsoft Phi 4 Reasoning Plus is designed for complex reasoning tasks and sophisticated problem-solving:

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

            // Phi 4 Reasoning Plus with streaming
            outputDiv.innerHTML += '<h2>Phi 4 Reasoning Plus Response:</h2>';
            const response = await puter.ai.chat(
                "Explain the theory of relativity and its implications for space travel",
                {
                    model: 'microsoft/phi-4-reasoning-plus',
                    stream: true
                }
            );

            for await (const part of response) {
                if (part?.text) {
                    outputDiv.innerHTML += part.text.replaceAll('\n', '<br>');
                }
            }
        }

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

Example 3: Image Analysis with Phi 4 Multimodal Instruct

Microsoft Phi 4 Multimodal Instruct supports image analysis and multimodal capabilities. Here's how to analyze an image:

<html>
<body>
    <script src="https://js.puter.com/v2/"></script>
    <img src="https://assets.puter.site/doge.jpeg" id="image">
    <script>
        puter.ai.chat(
            "Describe what you see in this image in detail",
            "https://assets.puter.site/doge.jpeg",
            { model: 'microsoft/phi-4-multimodal-instruct' }
        ).then(response => {
            puter.print(response);
        });
    </script>
</body>
</html>

List of Supported Microsoft Phi Models

The following Microsoft Phi models are supported by Puter.js:

microsoft/phi-4-reasoning-plus
microsoft/phi-4-multimodal-instruct
microsoft/phi-4
microsoft/phi-3.5-mini-128k-instruct
microsoft/phi-3-mini-128k-instruct
microsoft/phi-3-medium-128k-instruct

That's it! You now have free access to Microsoft's powerful Phi models using Puter.js. This allows you to add sophisticated AI capabilities to your web applications without worrying about API keys or usage limits.

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