Text xAI

Grok API

Use the Grok API via RunAPI with a model skill, unified auth, and pay-as-you-go pricing.

runapi.ai
# Base URL
https://runapi.ai

# Endpoints
POST /v1/chat/completions
POST /v1/responses
POST /v1/messages
POST /v1beta/models/{model}:generateContent
POST /v1beta/models/{model}:streamGenerateContent
curl https://runapi.ai/v1/chat/completions \
  -H "Authorization: Bearer $RUNAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "grok-4.7",
  "messages": [
    {
      "role": "user",
      "content": "Review this rollout plan, identify the three highest-risk assumptions, and return a concise mitigation for each."
    }
  ]
}'
from openai import OpenAI

client = OpenAI(
    base_url="https://runapi.ai/v1",
    api_key="your-runapi-key"
)

response = client.chat.completions.create(
    model="grok-4.7",
    messages=[{"role": "user", "content": "Review this rollout plan, identify the three highest-risk assumptions, and return a concise mitigation for each."}]
)
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://runapi.ai/v1",
  apiKey: "your-runapi-key"
});

const response = await client.chat.completions.create({
  model: "grok-4.7",
  messages: [{ role: "user", content: "Review this rollout plan, identify the three highest-risk assumptions, and return a concise mitigation for each." }]
});
https://runapi.ai 5 endpoints
OVERVIEW

About Grok

Grok 4.5 and Grok 4.6 are xAI language models for reasoning, function tools, and structured output. Use the exact model ids grok-4.5 and grok-4.6 through RunAPI Responses or Chat Completions.

Provider
xAI
Modality
Text

Grok API endpoints

EndpointProtocol
POST /v1/chat/completionsOpenAI compatible
POST /v1/responsesOpenAI Responses
POST /v1/messagesAnthropic compatible
POST /v1beta/models/{model}:generateContentGemini generateContent
POST /v1beta/models/{model}:streamGenerateContentGemini streamGenerateContent

Available Versions

Variant Billing Pricing
grok-4.20-0309-non-reasoning 1K tokens Input $1.00-$2.00 / 1M tokens | Output $2.00-$4.00 / 1M tokens View →
grok-4.3 1K tokens Retired View →
grok-4.5 1K tokens Input $1.60-$3.20 / 1M tokens | Output $4.80-$9.60 / 1M tokens View →
grok-4.6 1K tokens Input $1.60-$3.20 / 1M tokens | Output $4.80-$9.60 / 1M tokens View →
grok-4.7 1K tokens Input $1.60-$3.20 / 1M tokens | Output $4.80-$9.60 / 1M tokens View →
PRICING

Grok Pricing

Endpoint Resolution Duration Price
response — — Input $1.00-$2.00 / 1M tokens | Output $2.00-$4.00 / 1M tokens
chat_completion — — Input $1.00-$2.00 / 1M tokens | Output $2.00-$4.00 / 1M tokens
message — — Input $1.00-$2.00 / 1M tokens | Output $2.00-$4.00 / 1M tokens

Prices shown for grok-4.20-0309-non-reasoning. Other variants retain their own endpoint pricing.

Agent integration

Run Grok From an Agent

HOW IT WORKS

Get Started with Grok

  1. Create an API key

    Sign up and generate an API key from the dashboard.

  2. Pick a version

    Choose the version that best matches your quality and cost requirements.

  3. Send a request

    Submit your prompt and parameters to the model's documented endpoint.

  4. Get your result

    Poll the task or set a webhook, then download the completed output.

CONTEXT

About Grok on RunAPI

Grok 4.5 and 4.6 serve conversational, coding, and agentic workloads through RunAPI with one API key, synchronous or streaming responses, and terminal usage reporting.

Provider
xAI
See all →
Modality
Text
Browse models →

Why Use Grok Through RunAPI

One auth, every provider

A single RunAPI API key unlocks the whole model catalog across all providers. No separate accounts to create, no API keys to rotate per integration, and no credential management overhead. Add a new model to your app by changing one parameter.

Unified pricing & billing

Per-call pricing in USD, billed monthly into a single invoice. No subscription tiers, no minimum spend, and failed generations are never charged. The pricing page and check_pricing API show exact costs before you commit to a model.

Schema-first SDK

Typed schemas, parameter constraints, and setup notes are packaged in the model skill so your implementation starts from the right contract. The skill loads into Claude Code, Codex, Gemini CLI, Cursor, and VS Code — your agent knows the correct request shape before you write a line of code.

Grok Questions

Which model ids should I use for Grok?

Use the public model ids grok-4.5 or grok-4.6 shown in the quickstart.

Can Grok call function tools through Responses?

Yes. Send flat Responses function definitions in tools and read the returned name and JSON arguments from function-call output items.

Do Grok 4.5 and 4.6 support structured JSON output?

Yes. Use text format with a strict JSON Schema for Responses, or response format for Grok Chat Completions.

How should I stream Grok Responses?

Treat a Responses stream as complete only after response.completed, terminal usage, and the final done marker.

Which variant should I start with?

Pick the cheapest variant that meets your quality bar. Most teams start on the fast variant and graduate to pro for production.

Is there a free tier?

Creating an account and API key is free. API calls use prepaid, pay-as-you-go billing; add funds before making requests.

SIMILAR MODELS

Similar Text Models

Start generating with Grok