Skip to main content
This page covers everything the Grok series can do on the /v1/chat/completions endpoint. All conclusions come from hands-on testing against the APIYI gateway on July 13, 2026 (UTC+8).

Basic Chat and Streaming

All six models support the standard OpenAI format and streaming. stream_options: {"include_usage": true} is verified working (the final chunk carries complete usage):
Measured streaming time-to-first-token: 1.5–2.3 s across all models; non-streaming short Q&A completes in 1.7–5.1 s overall.

Chain-of-Thought (Reasoning)

This is the most commonly misunderstood billing aspect of the Grok series — read this section in full.

Which models emit chain-of-thought

Reasoning tokens count toward output billing. In one measured short Q&A, the visible answer was only 30 tokens but 586 output tokens were billed (556 of them reasoning). For high-frequency short Q&A, grok-4.20-0309-non-reasoning saves significantly.

Reading chain-of-thought and reasoning usage

The reasoning_effort parameter

reasoning_effort (e.g. "low" / "high") is accepted only by grok-4.5; grok-4.20-0309-reasoning explicitly rejects it with a 400 Model ... does not support parameter reasoningEffort. Do not hard-code this parameter in cross-model code.

Structured Outputs

The OpenAI-standard response_format: json_schema (strict mode) is supported. Verified passing on grok-4.5 / grok-4.3 / grok-build-0.1 / grok-4.20-0309-reasoning and the multi-agent model — all return JSON strictly conforming to the schema:

Function Calling

The OpenAI-standard tools / tool_choice fields and the full two-round tool-calling flow are supported (verified on grok-4.5 / grok-4.3 / grok-build-0.1):
Forced tool calls via tool_choice ({"type": "function", "function": {"name": "get_weather"}}) are also verified working.
This section is about client-side function calling (your code executes the tool). If you want xAI’s servers to search, run code, or connect to MCP for you, use the Responses API — see Web & X Search and Code Execution & MCP.

Vision Input (Image Understanding)

Grok 4.x chat models accept image input (jpg / png, up to 20MiB per image) in the OpenAI Vision format. Verified on grok-4.5 / grok-4.3 / grok-4.20-0309-non-reasoning — all correctly identified shapes and colors:
Prefer base64 data URLs. With external URLs, the image is fetched directly by xAI’s upstream servers — in testing, some image hosts (e.g. Wikimedia) reject server-side fetches, failing the request with image_download_error. If you must use external URLs, make sure the host allows server-side access and the URL points directly at the image file.

Prompt Caching (Automatic)

Grok prefix caching is automatic — zero configuration. In testing, the second same-prefix request onward hit 2688/2735 tokens, billed at the discounted cache rate:
Optimization: put stable content (system prompt, few-shot examples) at the front of your messages and variable content at the end to maximize prefix hits. The APIYI gateway runs in key-pool mode, so set reasonable expectations for hit rates (100% is not guaranteed); billing details in cache billing.

FAQ

You can’t. Internal reasoning is inherent to grok-4.5 / grok-4.3 / grok-build-0.1. If you don’t need chain-of-thought and want fast, cheap answers, use grok-4.20-0309-non-reasoning instead.
No. When replaying history in multi-turn conversations, send back only content (plus tool-calling fields). reasoning_content is not a standard field — feeding it back just inflates input tokens.
Chain-of-thought consumes the output budget too. If max_tokens is too small, reasoning can eat the whole budget and truncate the visible answer. For reasoning models, start at 2048 or higher.
Yes, they’re accepted normally. Note that reasoning-class models are less sensitive to sampling parameters than traditional models, so tuning value is limited.

Grok Overview

Model lineup, pricing, and capability matrix

Web & X Search

Hands-on with server-side live-search tools