Grok 2 API

Access Grok 2 from xAI using Puter.js AI API.

Get Started

Model Card

Grok 2 is xAI's frontier language model released in August 2024, featuring advanced capabilities in chat, coding, and reasoning with competitive performance against GPT-4 and Claude 3.5 Sonnet. It integrates real-time information from the X platform and offers improved reasoning over Grok 1.5.

Context Window

131K

tokens

Max Output

131,072

tokens

Input Cost

$2

per million tokens

Output Cost

$10

per million tokens

API Usage Example

Add Grok 2 to your app with just a few lines of code.
No API keys, no backend, no configuration required.

<html>
<body>
    <script src="https://js.puter.com/v2/"></script>
    <script>
        puter.ai.chat("Explain quantum computing in simple terms", {
            model: "x-ai/grok-2"
        }).then(response => {
            document.body.innerHTML = response.message.content;
        });
    </script>
</body>
</html>

View full documentation →

Get started with Puter.js

Add Grok 2 to your app without worrying about API keys or setup.

Read the Docs View Tutorials