xAI Developer Documentation

Overview

Welcome to the xAI Developer Docs. Here, you’ll find everything you need to integrate Grok into your applications. xAI provides a robust API to access our latest models, including text generation, vision capabilities, and image generation. Start by creating an account at console.x.ai.

API Reference

Access the xAI API with a simple setup. Our REST API is compatible with OpenAI and Anthropic SDKs. Example:

curl -X POST "https://api.x.ai/v1/chat/completions" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "grok-3", "messages": [{"role": "user", "content": "Hello, Grok!"}]}'

Check the full API spec at OpenAPI Spec.

Models

Pricing

Pricing is per million tokens: $5 for input, $15 for output (e.g., grok-beta model). Full details are available in the xAI Console.

Guides

Learn to integrate Grok with step-by-step tutorials. Topics include API setup, model selection, and troubleshooting. Visit our Guides Section for more.