---
title: "xAI REST API Review: Developer Experience, Docs & Pricing Rated"
description: "A hands-on review of the xAI REST API covering onboarding, documentation quality, developer portal features, and a final score of 19/30. See how xAI compares."
canonicalUrl: "https://zuplo.com/learning-center/xai-rest-api-review"
pageType: "learning-center"
authors: "adrian"
tags: "API Best Practices, APIs"
image: "https://zuplo.com/og?text=xAI%20REST%20API%20Review%3A%20DX%2C%20Docs%20%26%20Pricing"
---
## Introducing the xAI API

It's always an exciting day when a major tech company launches their first API,
and the internet was certainly buzzing when Elon announced the new
[xAI API](https://docs.x.ai/docs).

![xAI API release tweet](/media/posts/2024-10-21-xai-rest-api-review/image-1.png)

Most AI platform companies (ex. OpenAI and Anthropic) see a large amount of
traffic from companies integrating their REST APIs to add AI features to their
apps/websites. [xAI](https://x.ai/) has long been seen as an underdog in the AI
race, however with a [recent funding round of $6B](https://x.ai/news/series-b),
the platform has accelerated development to catch up with its rivals. The
question that lingered on my mind is if the developer experience of xAI might be
good enough to lure away users of OpenAI or Anthropic's APIs.

## xAI API Functionality

The xAI Rest API, powered by Grok, provides a robust set of capabilities for
developers to build AI-driven applications. The API grants access to
[Grok](https://x.ai/news/grok-2), a powerful large language model designed for
various tasks, including text and code generation, as well as image-related
functionalities.

Key capabilities include:

- **Text and Code**: The API can generate text and code, extract data, create
  summaries, and support various natural language processing tasks
- **Vision**: The API supports image generation, object identification, and
  visual analysis, which can be useful in applications that require visual data
  interpretation or content creation.
- **Function Calling**: It offers advanced function-calling capabilities,
  allowing developers to connect the model to external tools, which enables
  handling complex workflows involving external data and functions.
- **Model Options**: Developers can choose between Grok-2, which is optimized
  for complex reasoning tasks, and Grok-2 mini, a lighter model offering faster
  responses with a trade-off in output depth.

The API also supports streaming responses for real-time applications like
chatbots. It’s compatible with the
[OpenAI SDK](https://docs.x.ai/docs/guides/migration), making it easier for
developers familiar with that platform to integrate xAI with minimal
adjustments. (Note: Anthropic SDK compatibility, which was available at launch,
has since been deprecated.) For a deeper look at integrating the xAI API into
production systems, see our
[xAI API integration guide](/learning-center/xai-grok-api).

## Onboarding Experience

Getting started with the xAI REST API is quite straightforward. Simply create an
[xAI account](https://accounts.x.ai). You can choose to authenticate with your X
account, Google, Microsoft, or plain-old email + password.

![xAI login](/media/posts/2024-10-21-xai-rest-api-review/image-3.png)

From what I observed, there's a different onboarding for users coming from
free-mails (ex. gmail) compared to work email domains. The work-mail onboarding
flow guides you through creating an account, inviting team members, and
importantly - getting your first API key.

![xAI Company Signup](/media/posts/2024-10-21-xai-rest-api-review/image-5.png)

The free-mail version dumps you out to your account management screen with a
small button to go to the API console. Once you click the "API console" button,
it takes you to the same flow as above.

![xAI Account Management](/media/posts/2024-10-21-xai-rest-api-review/image-7.png)

### Getting Your API Key & Time To First Call

After signing up, you are prompted to create your first key, which is
provisioned immediately, and accompanied by a `curl` code sample.

![xAI API key onboarding](/media/posts/2024-10-21-xai-rest-api-review/image-6.png)

I really appreciate how quickly they aim to get users onboarded, this
significantly reduces the
[time-to-first-call](/learning-center/optimize-ttfc-with-api-keys) (TTFC),
especially since you just need an API key rather than a complicated JWT setup.
If you're weighing different approaches, our guide on
[API authentication best practices](/learning-center/api-authentication) covers
the trade-offs between API keys, OAuth, and JWTs.

Other than the weird flow for free-mail users, I was feeling really good about
the onboarding flow, until I actually tried making the API call. I was
immediately greeted by an error:

```json
{
  "code": "The caller does not have permission to execute the specified operation",
  "error": "Your new team 9e287ee1-ad55-41d6-91b4-24fe8ba21b40 has just been created and is still being initialized. Please try again shortly."
}
```

I navigated to the API console to see what was going on (I thought the key was
provisioned already?) and saw this banner up-top.

![team is initializing](/media/posts/2024-10-21-xai-rest-api-review/image-8.png)

How perplexing - what "initialization" needs to be made here? Their API Key
service seems to have already worked, and their models are already deployed - so
what is going on behind the scenes?

Disappointingly, this first call is also your last free one - you are forced to
pay for the API after receiving that initial error.
![out of credits](/media/posts/2024-10-21-xai-rest-api-review/image-9.png)

This feels like a bit of a bait & switch, the onboarding made me feel like there
was some sort of free-tier, but instead, I am forced to pay to get started. The
onboarding was very seamless up to this point, so despite this rug-pull, it
still deserves a respectable score.

**Onboarding Score: 7/10**

## xAI API Documentation Quality

Now let's move onto the API docs. They are split between the
[introductory materials](https://docs.x.ai/docs) and the
[API Reference](https://docs.x.ai/docs/api-reference) which is common. The
quickstart is just a more in-depth version of the onboarding flow, while the API
reference goes into more depth around topics like authentication and streaming.

The API reference is nicely laid out in the typical 2 column + navbar format.

![xAI Rest Endpoint example](/media/posts/2024-10-21-xai-rest-api-review/image-10.png)

Here are my pros and cons

**Pros**

- Nice layout
- Docs cover common usecases (ex. streaming)
- All query parameters, including optional fields are documented
- Some error codes are documented (ex. 400, 404)

**Cons**

- Many parameters lack descriptions so you have to infer what they mean from the
  examples provided
- Definition and Example tab are separate for no reason
- Headers needed are not documented inline
- Naming doesn't follow a consistent convention (ex. `Completions` vs
  `Create embeddings`)
- No interactive playground
- Many errors are undocumented or poorly documented

### xAI OpenAPI Specification

Does xAI offer an OpenAPI/Swagger spec? Initially, the answer was no because I
couldn't find a link to it anywhere. I did notice that their docs were bespoke
however, so I did some network tab sniffing and found it! The OpenAPI
specification lives at
[https://docs.x.ai/openapi.json](https://docs.x.ai/openapi.json).

In its raw form — the OpenAPI spec is not pretty. If you want to learn how an
OpenAPI spec can power great documentation, read our guide on
[generating API documentation from OpenAPI](/learning-center/generate-api-documentation-openapi).
I ran it through
[RateMyOpenAPI](https://ratemyopenapi.com/report/3186af9f-b0ac-4f8f-b400-8ba3966ebe9b),
and wasn't surprised by the low score.

![RateMyOpenAPI Score](/media/posts/2024-10-21-xai-rest-api-review/image-11.png)

The lack of interactive playground in the docs bothered me a lot, so I decided
to create my own. I had to modify the OpenAPI from its original state to make it
compliant with most tooling. Here's the
[end result](https://zudoku.dev/demo?api-url=https%3A%2F%2Fraw.githubusercontent.com%2Fzuplo-samples%2FxAI-OpenAPI%2Frefs%2Fheads%2Fmain%2FxAI-openapi.json).

You can find the full OpenAPI specification
[in this repository](https://github.com/zuplo-samples/xAI-OpenAPI/tree/main?tab=readme-ov-file).

### xAI Code Samples & SDKs

Unfortunately, the API Reference does not provide any code samples (not even
curl) beyond the onboarding sample. My
[Zudoku project](https://zudoku.dev/demo?api-url=https://raw.githubusercontent.com/zuplo-samples/xAI-OpenAPI/refs/heads/main/xAI-openapi.json)
above does include code samples in case you want them.

The [integration docs](https://docs.x.ai/docs/guides/migration) make reference
to a gRPC and Python SDK - but do not link to them. You can use the Grok API via
the OpenAI SDK - which makes migration easier, but isn't useful for developers
that aren't already using it.

Overall, I feel like this documentation is below average, especially compared to
other AI platform companies that offer richer docs, playgrounds, and SDKs. If
you're curious about what separates good API docs from bad ones, check out our
guide on
[must-have features for API documentation tools](/learning-center/top-api-documentation-tool-features).

**API Documentation Score: 3/10**

## xAI Developer Portal Features

The developer portal for the xAI API is actually quite robust in its feature
set. I suspect some engineers from X (formerly known as Twitter) were "loaned"
to help with this. An engineer named Toby Phalen provided a
[feature overview](https://x.com/TobyPhln/status/1848430127950270957) via X,
covering some prominent features of the dev portal.

### xAI API Usage Analytics

The API features a usage explorer which includes breakdowns by tokens and spend.

![xAI API Analytics](/media/posts/2024-10-21-xai-rest-api-review/image-12.png)

### xAI Billing & Pricing

Speaking of spend, you can easily connect a credit card to your account to start
purchasing credits. Pricing is determined by your choice of model. For example,
the `grok-beta` model costs $5 per million input text tokens, and $15 per
million output text tokens.

![model pricing](/media/posts/2024-10-21-xai-rest-api-review/image-15.png)

There isn't a spend estimate tool to help you understand the translation from
dollars to tokens - so you need to do your own math. If you're designing your
own API's pricing model, our breakdown of
[API pricing strategies](/learning-center/api-pricing-strategies) covers tiered,
usage-based, and hybrid approaches.

### xAI User Management

User management is quite simple, invite your coworkers by email and they will
get access. There is also a nice feature where you can verify a domain and
everyone who signs up with that domain will get access to your team.

![domain verification](/media/posts/2024-10-21-xai-rest-api-review/image-13.png)

### xAI Auth & Security

As stated earlier, we are a big fan of using
[API Keys](/learning-center/rebuttal-api-keys-can-do-everything) for API
authentication, and creating/managing keys is quite simple in the xAI console.

Account security is also top notch, with built-in session management and options
for multi-factor authentication.

![2FA](/media/posts/2024-10-21-xai-rest-api-review/image-14.png)

All things considered, this developer portal has everything you would expect
from a modern API, and some nice security features. For a deeper look at what
makes a great developer portal, see our guide on
[what a developer portal is and why it matters](/learning-center/what-is-a-developer-portal).

**Developer Portal Score: 9/10**

## xAI API Final Review Score: 19/30

Overall I'd give this API a **final score of 19/30** which is slightly above
average for an API - but I definitely expected more given how long it took to
release. Some obvious improvements to be made include:

- Free credits to get started
- Fully documented API docs with a playground and code samples
- First-party SDKs rather than reusing OpenAI's

It's a bit frustrating to give this API a low score, because it's _so close_ to
greatness, but falls flat right at the end.

## Should You Consider the xAI API?

The only reason to use the xAI API would be to get access to Grok, which differs
greatly from GPT or Claude in terms of moderation and safety. So in reality,
this API is likely your only option to use Grok. If you aren't too fussy about
the model, and want a better DevX, I would recommend using OpenAI or Anthropic.

## Alternatives to the xAI REST API

The only alternative I was able to find was via the
[OpenRouter platform](https://openrouter.ai/x-ai/grok-beta).

## Building a Better API DevX Than xAI

If you are revamping your API - and want to have:

- Automatically issued API Keys that _actually work_
- Autogenerated API documentation with code samples and a live playground
- Monetization system where you can offer a free tier
- Live usage analytics for yourself and your users

Then you need Zuplo - [get in touch](https://zuplo.com/meeting?utm_source=blog)!