Skip to content

xAI API

Programmatic access to Grok base models through an API

Visit official site

What xAI API is

The API is described as programmatic access to Grok base models with text and image input. It offers a 128,000-token context, function calling, system prompts and compatibility with OpenAI and Anthropic APIs.

What you can do with it

  • Call Grok base models from code
  • Send text and image input in a multimodal version
  • Use function calling and system prompts
  • Keep a 128,000-token context window

Application scenarios

  • Create chatbots with Grok models
  • Build image recognition apps from image input
  • Shape model behaviour with system prompts for business needs

Getting started

  • Register an account on the xAI console
  • Create an xAI API key in the console
  • Change base_url when using the OpenAI Python SDK
  • Read the xAI documentation for API usage

Pros & cons

✓ What we like

  • Compatible with OpenAI and Anthropic APIs to ease migration
  • Public beta includes 25 dollars of free API credits per user each month

! What to watch out for

  • Access runs through a public beta until the end of 2024
  • Migration relies on changing the base_url in the OpenAI Python SDK

FAQ

How long is the context?

The material states a 128,000-token context length.

Is there a free allowance?

During the public beta, each user gets 25 dollars of free API credits per month.

Last reviewed: 2026-11-15

More LLM API platform tools

View all →

How we review