xAI API
Access xAI instantly with Puter.js, and add AI to any app in a few lines of code without backend or API keys.
// npm install @heyputer/puter.js
import { puter } from '@heyputer/puter.js';
puter.ai.chat("Explain AI like I'm five!", {
model: "x-ai/grok-4-1-fast"
}).then(response => {
console.log(response);
});
<html>
<body>
<script src="https://js.puter.com/v2/"></script>
<script>
puter.ai.chat("Explain AI like I'm five!", {
model: "x-ai/grok-4-1-fast"
}).then(response => {
console.log(response);
});
</script>
</body>
</html>
List of xAI Models
xAI: Grok 4.1 Fast
x-ai/grok-4-1-fast
Grok 4.1 Fast is xAI's best tool-calling model released November 2025, featuring a 2M context window and halved hallucination rates versus Grok 4 Fast. It comes in reasoning and non-reasoning modes and is optimized for agentic workflows with native support for web search, X search, and code execution.
ChatxAI: Grok 4.1 Fast Non-Reasoning
x-ai/grok-4-1-fast-non-reasoning
Grok 4.1 Fast Non-Reasoning is the low-latency, non-reasoning variant of Grok 4.1 Fast that skips extended chain-of-thought for speed-critical applications. It shares the same model weights and 2M context window as Grok 4.1 Fast but delivers instant responses without deliberation overhead, ideal for real-time customer support and streaming interactions.
ChatxAI: Grok Code Fast 1
x-ai/grok-code-fast-1
Grok Code Fast 1 is a speedy, economical reasoning model built from scratch specifically for agentic coding workflows, released August 2025. It excels at TypeScript, Python, Java, Rust, C++, and Go with a 256K context window and ~92 tokens/second throughput.
ChatxAI: Grok 4
x-ai/grok-4
Grok 4 is xAI's flagship reasoning model released July 2025, trained with unprecedented reinforcement learning scale on 200,000 GPUs. It features native tool use, real-time search integration, and Grok 4 Heavy achieves 50% on Humanity's Last Exam benchmark.
ChatxAI: Grok 4 Fast
x-ai/grok-4-fast
Grok 4 Fast is an optimized variant delivering performance similar to Grok 4 but using 40% fewer thinking tokens with a massive 2 million token context window. It offers up to 64x cost reduction versus early frontier models like OpenAI's o3.
ChatxAI: Grok 4 Fast Non-Reasoning
x-ai/grok-4-fast-non-reasoning
Grok 4 Fast Non-Reasoning is the speed-optimized, non-reasoning variant of Grok 4 Fast that bypasses extended chain-of-thought for instant responses. It uses the same unified architecture with a 2M context window but skips deliberation, delivering up to 342 tokens/second throughput for high-volume, latency-sensitive applications.
ChatxAI: Grok 4 0709
x-ai/grok-4-0709
Grok 4 0709 is the July 9, 2025 snapshot of xAI's flagship reasoning model, trained with reinforcement learning to use tools like a code interpreter and web browsing. It features a 256K context window, native tool use, parallel tool calling, and support for both image and text inputs.
ChatxAI: Grok 3 Beta
x-ai/grok-3-beta
Grok 3 Beta is the API-accessible version of Grok 3, xAI's most advanced model with superior reasoning, mathematics, coding, and world knowledge capabilities refined through large-scale reinforcement learning. It supports enterprise data extraction, coding, and text summarization tasks.
ChatxAI: Grok 3 Mini Beta
x-ai/grok-3-mini-beta
Grok 3 Mini Beta is the API version of Grok 3 Mini, a cost-efficient lightweight reasoning model with configurable reasoning effort (low/high) parameters. It excels at STEM tasks and logic-based problems while exposing transparent thinking traces.
ChatGrok 3
x-ai/grok-3
Grok 3 is xAI's flagship model launched February 2025, trained with 10x more compute on the Colossus supercluster with 200,000 GPUs. It features advanced reasoning through reinforcement learning, deep domain knowledge in finance/healthcare/law/science, and a 131K token context window.
ChatGrok 3 Fast
x-ai/grok-3-fast
Grok 3 Fast is a latency-optimized variant of Grok 3 using the same underlying model but served on faster infrastructure. It delivers quicker response times for latency-sensitive applications while maintaining equivalent reasoning quality and 131K context window.
ChatGrok 3 Mini
x-ai/grok-3-mini
Grok 3 Mini is a lightweight, cost-efficient reasoning model that thinks before responding, ideal for logic-based tasks that don't require deep domain knowledge. It features configurable reasoning effort and exposes accessible thinking traces for transparency.
ChatGrok 3 Mini Fast
x-ai/grok-3-mini-fast
Grok 3 Mini Fast is the speed-optimized variant of Grok 3 Mini, running on faster infrastructure for significantly quicker response times. It provides identical reasoning quality to Grok 3 Mini but is designed for latency-sensitive applications.
ChatGrok 2 Vision 1212
x-ai/grok-2-vision-1212
Grok 2 Vision 1212 is xAI's updated multimodal vision model released December 2024, featuring improved accuracy, instruction-following, and multilingual capabilities over the original Grok 2 Vision. It combines advanced visual comprehension with text understanding, excelling at object recognition, style analysis, and document-based question answering with a 32K context window.
ImageGrok 2 Image
x-ai/grok-2-image
Grok 2 Image is xAI's flagship text-to-image generation model powered by their Aurora engine, producing photorealistic visuals from text prompts. It excels at rendering precise visual details, legible text, logos, and realistic human portraits. The model supports generating up to 10 image variations per request and handles diverse styles from photorealism to illustration.
ChatGrok Beta
x-ai/grok-beta
Grok Beta was xAI's initial public API model released in late 2024, offering foundational chat and reasoning capabilities with 131K context window. It served as the enterprise API beta preview before being superseded by versioned Grok 2 models.
ChatGrok Vision Beta
x-ai/grok-vision-beta
Grok Vision Beta was the initial vision-enabled API model from xAI, providing image understanding and multimodal capabilities for processing text alongside visual inputs. It was released alongside grok-beta for enterprise API testing with an 8K context window.
ChatGrok 2
x-ai/grok-2
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.
ChatGrok 2 Vision
x-ai/grok-2-vision
Grok 2 Vision is a multimodal AI model that combines text and visual understanding capabilities, excelling at object recognition, visual math reasoning (MathVista), and document-based question answering (DocVQA). It supports image analysis with a 32K context window.
Frequently Asked Questions
The xAI API gives you access to models for AI chat and image generation. Through Puter.js, you can start using xAI models instantly with zero setup or configuration.
Puter.js supports a variety of xAI models, including xAI: Grok 4.1 Fast, xAI: Grok 4.1 Fast Non-Reasoning, xAI: Grok Code Fast 1, and more. Find all AI models supported by Puter.js in the AI model list.
With the User-Pays model, users cover their own AI costs through their Puter account. This means you can build apps without worrying about infrastructure expenses.
Puter.js is a JavaScript library that provides access to AI, storage, and other cloud services directly from a single API. It handles authentication, infrastructure, and scaling so you can focus on building your app.
Yes — the xAI API through Puter.js works with any JavaScript framework, Node.js, or plain HTML. Just include the library and start building. See the documentation for more details.