Skip to main content
Grok is xAI’s flagship model family. The current generation (Grok 4.x) spans five product lines — flagship general-purpose, long-context standard, reasoning/non-reasoning variants, code-focused, and multi-agent collaboration — all available on APIYI. xAI’s official API is itself OpenAI-compatible (Chat Completions + Responses API) with no separate proprietary protocol, so calling Grok through APIYI with the OpenAI SDK gives you the full feature set, including official server-side tools (web search, X search, code execution, Remote MCP). This documentation group is based on a full hands-on test against the APIYI gateway on July 13, 2026 (UTC+8) — 56 request/response logs — so every capability boundary stated here is verified.
🚀 Highlights: grok-4.5 is xAI’s newest flagship released on July 8, 2026 (knowledge cutoff February 2026), built for coding and agentic tasks; grok-4.3 and the grok-4.20 series offer a 1M-token context window; the Responses API tools web_search / x_search / code_interpreter / MCP are all verified working on APIYI, and X search is a capability unique to Grok.

Model Lineup

grok-4.5

Flagship · Code & GeneralxAI’s most intelligent model, 500K context, built for coding, agentic tasks, and knowledge work.

grok-4.3

Standard Workhorse1M context at roughly 60% of the flagship price — the balanced choice for everyday chat and mid-level reasoning.

grok-4.20 Variants

Reasoning / Non-Reasoning-reasoning and -non-reasoning share the same price and 1M context; pick based on whether you want chain-of-thought.

grok-build-0.1

Code-Focused256K context and the lowest price in the series — ideal for high-frequency code completion and light coding tasks.

grok-4.20-multi-agent-beta-0309

Multi-Agent CollaborationMultiple agents work in parallel on complex research tasks. Special billing profile — see Multi-Agent Model.

More Capability Pages

Chat/reasoning/vision: Chat & Reasoning; live search: Web & X Search.

Pricing

Listed prices match xAI’s official pricing (verified item-by-item against the APIYI pricing API on 2026-07-13). APIYI’s discount comes from recharge promotions.
Model IDContextInputOutputPositioning
grok-4.5500K$2.00 / 1M tokens$6.00 / 1M tokensFlagship: code / agents / general
grok-4.31M$1.25 / 1M tokens$2.50 / 1M tokensStandard workhorse
grok-4.20-0309-reasoning1M$1.25 / 1M tokens$2.50 / 1M tokensReasoning variant
grok-4.20-0309-non-reasoning1M$1.25 / 1M tokens$2.50 / 1M tokensNon-reasoning (fast, low-cost)
grok-4.20-multi-agent-beta-03091M$1.25 / 1M tokens$2.50 / 1M tokensMulti-agent (billing amplification!)
grok-build-0.1256K$1.00 / 1M tokens$2.00 / 1M tokensCode-focused
  • The aliases grok-code-fast / grok-code-fast-1 are also callable (connectivity verified); see the model info page for their pricing.
  • Cached input tokens are billed at a discounted rate. Grok prefix caching is automatic — no configuration needed; see cache billing.
  • List prices match xAI official; stack recharge promotions for lower effective cost.

Verified Capability Matrix

Tested on 2026-07-13 (UTC+8) against the APIYI gateway (✅ verified working; — not covered, expected identical on the same architecture):
Capabilitygrok-4.5grok-4.34.20-reasoning4.20-non-reasoninggrok-build-0.1multi-agent
Basic chat
Streaming (with usage)
Chain-of-thought reasoning_content✅ on by default✅ on by default❌ off by design✅ on by defaultinternal only
reasoning_effort parameter❌ explicitly rejected
Structured Outputs (json_schema)
Function calling / Tool Use
Vision input (image understanding)
Prompt caching (automatic)
Responses API + server-side tools

Endpoints

EndpointMethodPurpose
/v1/chat/completionsPOSTChat / reasoning / function calling / structured outputs / vision (shared by all models; select via model)
/v1/responsesPOSTResponses API: web search, X search, code execution, Remote MCP and other server-side tools
The following are NOT supported on APIYI (verified — avoid these pitfalls):
  • Legacy Completions (/v1/completions): rejected upstream — the entire Grok 4.x line is a reasoning architecture and does not support raw text completion at the official level
  • Legacy live-search parameter search_parameters: removed by xAI (verified 410). All live search goes through Responses API tools — see Web & X Search
  • Batch API / Files: not routed by the gateway; not applicable to key-pool mode
  • Deferred Completions (deferred: true): the parameter is silently ignored — the request executes synchronously and is billed normally. Do not rely on it
  • Collections Search (RAG / file_search): requires collections pre-built in the xAI console; not applicable to key-pool mode
  • Context Compaction (/v1/responses/compact), Priority Processing (service_tier: "priority" — falls back to default in testing), WebSocket mode, mTLS authentication: all unsupported

Quick Start

curl -X POST "https://api.apiyi.com/v1/chat/completions" \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-4.5",
    "messages": [
      {"role": "user", "content": "Introduce yourself in one sentence"}
    ]
  }'
from openai import OpenAI

client = OpenAI(
    api_key="sk-your-api-key",
    base_url="https://api.apiyi.com/v1"
)

resp = client.chat.completions.create(
    model="grok-4.5",
    messages=[{"role": "user", "content": "Introduce yourself in one sentence"}]
)
print(resp.choices[0].message.content)
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: 'sk-your-api-key',
  baseURL: 'https://api.apiyi.com/v1',
});

const resp = await client.chat.completions.create({
  model: 'grok-4.5',
  messages: [{ role: 'user', content: 'Introduce yourself in one sentence' }],
});
console.log(resp.choices[0].message.content);
Which model to pick: default to grok-4.3 (1M context, balanced price); upgrade to grok-4.5 for coding agents and complex tasks; use grok-4.20-0309-non-reasoning for fast, low-cost answers (no chain-of-thought, cheapest output); grok-build-0.1 for high-frequency code completion; and only reach for the multi-agent model on complex research tasks (mind its billing amplification).

Billing Note: Reasoning Tokens

grok-4.5 / grok-4.3 / grok-build-0.1 reason internally by default: responses include reasoning_content, and reasoning tokens count toward output billing. In testing, a short answer showed just 30 visible tokens but billed 586 output tokens (556 of them reasoning). For cost-sensitive short Q&A, switch to grok-4.20-0309-non-reasoning. Details in Chat & Reasoning.

FAQ

No separate proprietary protocol. xAI’s official REST API is OpenAI-compatible: /v1/chat/completions (chat) plus /v1/responses (Responses API and server-side tools). Point the OpenAI SDK at https://api.apiyi.com/v1 and you get the full feature set — there is no “compatibility-mode downgrade”.
Use the Responses API: tools: [{"type": "web_search"}] (or x_search). The legacy search_parameters field on Chat Completions has been removed by xAI (verified 410) — do not use it. See Web & X Search.
This is normal. All Grok 4.x models self-identify simply as “Grok 4” (the multi-agent model calls itself Oppie) and won’t report exact version numbers like 4.5 / 4.3. Verify identity via the model field in your request and the response, not the model’s self-introduction.
No. Grok prefix caching is automatic; check hits via usage.prompt_tokens_details.cached_tokens (in testing, the second same-prefix request hit 2688/2735 tokens). The gateway runs in key-pool mode, so set reasonable expectations for hit rates — see cache billing.
A 400 error. Limits differ per model: grok-4.5 is 500K, grok-4.3 and the 4.20 series are 1M, grok-build-0.1 is 256K. Summarize, chunk, or use RAG retrieval for longer content.
4xx client errors (bad parameters / auth failures) are not billed; requests that successfully return tokens are billed by actual usage. Note that deferred: true is silently ignored — the request actually runs synchronously and is billed normally.

Chat & Reasoning

Streaming, chain-of-thought, structured outputs, function calling, vision, caching

Web & X Search

Hands-on with the Responses API web_search / x_search tools

Code Execution & MCP

Server-side Python sandbox and Remote MCP integration

Multi-Agent Model

Capabilities and billing profile of the multi-agent model

Grok 4.5 Launch Deep-Dive

In-depth look at xAI’s newest flagship

Model Info

All available models and groups