The xAI API exposes Grok models, media generation and server-side tools through a developer account. Use this hub to connect the right interface with its billing rules, team controls and practical first request.

What xAI offers through the API

xAI’s developer platform spans text generation, Imagine media services and Voice. These capabilities have separate request surfaces and usage units. Begin by choosing the output your application needs; a text model entry is not a substitute for an image or speech-generation endpoint. Official documentation.

Map the complete workflow before choosing a model. A document assistant needs retrieval, an answer and evidence that supports it. A coding workflow needs a proposed change and a way to evaluate that change. A media workflow needs an asset that meets the requested properties. Keep the model’s generation step separate from the application’s decisions about whether the result is acceptable.

The current quickstart demonstrates the Responses endpoint at https://api.x.ai/v1/responses and the native xai-sdk Python client. An OpenAI-compatible client is another documented option when configured with the xAI base URL and key. Official documentation.

Choose one interface for your baseline and retain the smallest working example. A migration becomes harder to assess if it simultaneously changes the endpoint, model, message construction and error wrapper. Keep a saved set of tasks and expected properties, then introduce each new capability with an explicit reason.

The native Python client uses gRPC and provides chat helpers such as chat.create, append and sample. Its timeout and exception behavior differ from those of a generic REST client. That distinction matters when translating an HTTP troubleshooting example into native SDK code. Official documentation.

Account ownership is part of a reliable integration. Identify the team that pays for a request, the person who can restrict credentials and the operator who responds to spending changes. Use purpose-specific keys and keep deployment configuration separate from experimental notebooks. A working request should be traceable without exposing its credential.

xAI documents server-side search tools. Fresh retrieval is an explicit tool choice; the model’s name alone does not establish access to current information. Inspect the returned citations and actual tool usage before presenting an answer as grounded in a retrieved source. Official documentation.

For a first evaluation, disable optional tools and request a small text response. Establish that the credential, model and response parser work together. Add retrieval, structured output or media only after that baseline is clear. Record what changed and judge the result against the original task, not only whether the request returned successfully.

Per-request cost tracking is exposed with the response. The native client offers a convenience cost property, while REST responses include an integer cost field in usage. Preserve those observations when evaluating a multi-step application so spending can be attributed to completed work. Official documentation.

The sections below link the operating reference: pricing for charge conditions, models for identifiers, keys for console setup, limits for traffic planning and errors for diagnosis. Use them together when deciding whether a prototype can become a maintained service.

Pricing at a glance

Pricing at a glance
SummaryVerified value
Lowest input price modelgrok-build-0.1
Input price$1 per 1M tokens
Output price$2 per 1M tokens
Free accessNo universal ongoing free inference allowance was established in the last successful check.

Last verified · Source ↗

Text rates distinguish ordinary input, cached input and output, with context-dependent conditions for applicable models. Tool and media operations have their own charges. Official documentation.

Read the xAI pricing explanation before comparing a token-only estimate with a full agent workflow.

Models available

Model catalog
ModelOfficial identifierModalitiesContext tokensInput USD / 1MOutput USD / 1MStatus
grok-4.20-0309-non-reasoninggrok-4.20-0309-non-reasoningtext, image1,000,000$1.25$2.5Active
grok-4.20-0309-reasoninggrok-4.20-0309-reasoningtext, image1,000,000$1.25$2.5Active
grok-4.20-multi-agent-0309grok-4.20-multi-agent-0309text, image1,000,000$1.25$2.5Active
grok-4.3grok-4.3text, image1,000,000$1.25$2.5Active
grok-4.5grok-4.5text, image500,000$2$6Active
grok-4.6grok-4.6text, image500,000$2$6Active
grok-build-0.1grok-build-0.1text, image256,000$1$2Active

Last verified · Source ↗

Use the Grok model reference to inspect exact identifiers, modalities and lifecycle notes. A display label should never be turned into a guessed request value.

Free tier and how to get a key

The official billing documentation was checked. No universal ongoing free inference allowance was established by that source. Promotional or account-specific credits require a check in your account. Read the official terms ↗

Last verified · Source ↗

The console’s billing documentation centers on team credits and invoiced billing. Check the actual team offer before assuming free API access. Official documentation.

Follow xAI key creation and the free-access checks before running unattended calls.

Rate limits and tiers

Team capacity is model-specific and includes short-window request enforcement alongside token limits. Budget and throughput are separate operating controls. Official documentation.

Open xAI rate limits when planning bursts or background jobs.

Service status

No incidents declared on the official status page. Live service details are published separately there.

Checked 12 Sep 2026 17:15 UTC · Official status ↗

Check the xAI errors guide for a request-specific problem. A public service indicator cannot establish that a particular team or key has permission.

Start in 5 minutes

import os
from xai_sdk import Client
from xai_sdk.chat import user

client = Client(api_key=os.environ["XAI_API_KEY"], timeout=60)
chat = client.chat.create(model="grok-4.6")
chat.append(user("Describe a useful model API application in one sentence."))
response = chat.sample()
print(response.content)

Run the native xAI Python tutorial for explicit timeout handling and an intentionally invalid model. The example is source code, not a claimed successful inference transcript.

Recent changes

  1. xAI · grok-build-0.1 — MetadataRecord updated; consult the linked source for details. → Record updated; consult the linked source for details.Source ↗
  2. xAI · grok-4.6 — MetadataRecord updated; consult the linked source for details. → Record updated; consult the linked source for details.Source ↗
  3. xAI · grok-4.5 — MetadataRecord updated; consult the linked source for details. → Record updated; consult the linked source for details.Source ↗
  4. xAI · grok-4.3 — MetadataRecord updated; consult the linked source for details. → Record updated; consult the linked source for details.Source ↗
  5. xAI · grok-4.20-multi-agent-0309 — MetadataRecord updated; consult the linked source for details. → Record updated; consult the linked source for details.Source ↗
  6. xAI · grok-4.20-0309-reasoning — MetadataRecord updated; consult the linked source for details. → Record updated; consult the linked source for details.Source ↗
  7. xAI · grok-4.20-0309-non-reasoning — MetadataRecord updated; consult the linked source for details. → Record updated; consult the linked source for details.Source ↗
  8. xAI · grok-build-0.1 — MetadataRecord updated; consult the linked source for details. → Record updated; consult the linked source for details.Source ↗
  9. xAI · grok-4.6 — MetadataRecord updated; consult the linked source for details. → Record updated; consult the linked source for details.Source ↗
  10. xAI · grok-4.5 — MetadataRecord updated; consult the linked source for details. → Record updated; consult the linked source for details.Source ↗

Subscribe to the changelog RSS feed

Review observed changes before replacing a pinned model or revising a budget. Keep a copy of the source and your workload assumptions when approving an operational change.

Use the AI API cost calculator to turn the model and workload you are considering into an estimate.

Last verified · Source ↗

Frequently asked questions

Does a Grok model automatically search current information?
No. Enable the relevant documented server-side search tool when current retrieval is needed and inspect its result. Official documentation.
Can I use an OpenAI-compatible client?
Yes. The quickstart shows the OpenAI client with the xAI base URL and credential. Official documentation.
Why do native SDK errors look unlike HTTP errors?
The native Python SDK uses gRPC. Diagnose its status and details in that transport’s terms. Official documentation.
What account owns an API key?
xAI inference keys are bound to a team and associated with the user who creates them. Official documentation.
Where can I inspect actual request cost?
Read the response’s cost tracking fields. The native client exposes a convenience property, and REST usage includes the raw cost value. Official documentation.

Sources

Last verified · Source ↗