API Documentation

What's up, Developers?

First time xAI API or Large Language Model API user? Go to the Introduction for a brief background on Grok and interacting with LLM through API.


Ready to build? Go to our Hitchhiker's Guide to Grok.



With just two line changes to your code, you're on Grok! Our API endpoint is designed to be compatible with OpenAI and Anthropic SDKs except capabilities not offered by the SDK.

You might want to read our guide Migration from Other Providers for more information and caveats.

OpenAI SDK

Anthropic SDK

Change the model in your request to one of the models on xAI and you're all set!


If you have any questions or feedback, feel free to email us at support@x.ai.

Happy Grokking! 😎