xAI API
API for Grok foundation modelsProgrammatic access to Grok models
Highlights
What you can do with it
- Build a chatbot on the Grok model
- Create an image recognition app
- Customize model behavior with system prompts
How to use it
- 1 Register at the xAI console
- 2 Create an API key
- 3 Point your SDK to the xAI base URL and use your key
- 4 Test with the free credits, then scale as needed
Who it is for
Pros
- Large context and multimodal input
- Easy migration from OpenAI and Anthropic APIs
- Free beta credits to test with
Limitations
- Beta credits and terms can change
- You pay for usage once credits run out
- Depends on an external service you do not control
What xAI API is
The xAI API offers developers programmatic access to the Grok series of foundation models. It supports both text and image inputs, with a context length of 128,000 tokens, along with function calls and system prompts. The API is fully compatible with OpenAI and Anthropic APIs, which makes migration simpler if you already use those tools. During public beta, which ran until the end of 2024, each user received $25 worth of free API credits per month. It is aimed at developers who want to build on the Grok models.
What you can do with it
Here is what the API supports:
- Build chatbots and apps on the Grok models
- Use text and image inputs together
- Call functions and set system prompts
- Migrate from OpenAI or Anthropic APIs with less work
Who it is for
It suits a few groups:
- Developers building with the Grok models
- Teams that need multimodal input
- Anyone moving from OpenAI or Anthropic APIs
What to watch out for
The $25 monthly credit was tied to public beta, and beta terms and credits can change or end, so check the current pricing before you depend on it. Once credits run out you pay for usage, so costs scale with how much you call the API. It depends on an external service you do not control, so availability and model behavior can change. Keep your API keys safe, and test with small calls before you scale up a project. Behavior may vary across browsers and devices, so test before production use and consult the help docs if errors appear. Features and interface details may change between versions, so review the latest notes on the page before you start.
FAQ
Is there free credit?
During public beta each user received $25 in free API credits per month.
What context length?
It supports a 128,000-token context.
Is it compatible with other APIs?
Yes, it is compatible with OpenAI and Anthropic APIs.
Why it is free
What the official page says: 免费
Free limits, trial length and features are decided by the official site and can change at any time.
Product preview
Screenshot archived from the listing page, for preview only.