Direct answer
“Grok coding” can mean choosing a coding model for an application or using Grok Build, a separate coding agent that works in a repository. xAI’s model documentation describes Grok Build 0.1 (grok-build-0.1) as a coding model with function calling and structured outputs, and lists a 256,000-token context window. It describes Grok 4.7 (grok-4.7) as a model for code and other tasks, with a 500,000-token context window. The Grok Build CLI is a separate agent product; do not treat it as another name for the API model. (docs.x.ai)
Start with Grok Build 0.1 if you want to evaluate the coding-focused API model at its lower standard token rates. Compare Grok 4.7 if you need its larger context window or want to test xAI’s broader model for coding. Model descriptions are not evidence that either will work better on your codebase: evaluate both on representative tasks before choosing.
Which Grok option should you evaluate?
| Option | What it is | When to shortlist it |
|---|---|---|
Grok Build 0.1 (grok-build-0.1) |
Coding-focused API model; xAI lists function calling, structured outputs, reasoning, and a 256K context window. | Try for coding-oriented API tasks, while checking the higher-context pricing threshold below. |
Grok 4.7 (grok-4.7) |
xAI’s model for code and other tasks; listed with a 500K context window and configurable reasoning. | Compare for larger-context tasks or when you want to evaluate a broader model on code. |
| Grok Build CLI | A separate coding agent for repository workflows. | Evaluate when you need an agent around a project, not just a model endpoint. |
The model page lists grok-code-fast-1 and related names as aliases for grok-build-0.1. For new API code, use the canonical model ID shown in the current model documentation rather than assuming an older alias will remain available. (docs.x.ai)
An API model does not, by itself, inspect your local repository or run its tests. Function calling lets a model request functions that your application defines and executes; the application remains responsible for those actions and their safeguards. The CLI is a distinct repository-agent option. (docs.x.ai)
Test coding fit on your own tasks
Treat model selection as an evaluation, not a verdict based on a model label or a benchmark number. Use the same representative tasks for each candidate and score:
- Correctness: Does the proposed change fix the issue without breaking nearby behavior?
- Tests: Do existing tests pass, and does the change include a useful test for the bug or feature?
- Repository understanding: Does the model identify relevant files and constraints before proposing a patch?
- Tool behavior: If you provide tools, does it request the right one, handle the result, and stop when the task is complete?
- Cost and latency: Record actual token use and elapsed time across several runs, including unsuccessful attempts.
A useful trial could include explaining an unfamiliar module, implementing a contained feature with an acceptance test, and repairing a failing test. Use the same repository snapshot and prompts, review the diffs, and run your own project checks. This tests fit for your codebase without relying on unverified benchmark or speed claims.
For agent workflows, keep patch application and command execution under your control: validate diffs, run tests in an appropriate environment, and require human review for consequential security or architecture changes. These are workflow safeguards, not model guarantees.
Use the direct xAI API
xAI’s quickstart demonstrates the Responses API at /v1/responses with grok-4.7, using Bearer-token authentication. The Responses reference documents output as typed items in an output array, including message content of type output_text. The quickstart demonstrates this route with Grok 4.7; the retrieved documentation does not explicitly confirm the same route for Grok Build 0.1, so do not silently substitute that model ID in this example. (docs.x.ai)
Set XAI_API_KEY to an API key created in the xAI Console. This example saves the response before extracting its text. curl --fail-with-body returns a failure for an unsuccessful HTTP status while preserving the response body; set -e stops the script before the JSON extraction if the request fails.
set -e
export XAI_API_KEY='your_api_key'
curl --fail-with-body --silent --show-error \
-o response.json \
-w 'HTTP %{http_code}\n' \
https://api.x.ai/v1/responses \
-H "Authorization: Bearer $XAI_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "grok-4.7",
"input": "Review this function for a correctness bug and propose a minimal fix: function median(a) { a.sort(); return a[a.length / 2]; }"
}'
jq -er '[.output[]? | select(.type == "message") | .content[]? | select(.type == "output_text") | .text] | join("") | select(length > 0)' response.json
This asks for a review and suggested fix; it does not let the API inspect a local repository or execute tests. For an agent, your application must supply and control the relevant tools. The example is based on the documented Grok 4.7 Responses request and response format; it has not been executed here. (docs.x.ai)
For production, xAI documents per-model limits for each API team, including requests per second and tokens per minute; limits vary by model and team tier. Exceeding a limit returns HTTP 429. The error guide says to reduce the request rate or request a higher limit. Treat 429 as a signal to slow down and handle it explicitly; the retrieved guidance does not prescribe a retry schedule. Errors such as 400, 401, 403, 404, and 422 indicate request, authentication, permission, model/URL, or field-format problems to correct rather than blindly retry. (docs.x.ai)
API pricing and a worked estimate
The xAI pricing table lists standard API prices in USD per million tokens. For requests with prompts under 200,000 tokens, Grok Build 0.1 is listed at $1.00 per million input tokens, $0.20 per million cached input tokens, and $2.00 per million output tokens. Grok 4.7 is listed at $2.00 input, $0.50 cached input, and $6.00 output per million tokens. Their listed context windows are 256,000 and 500,000 tokens, respectively; context capacity is not the same as the pricing threshold. (docs.x.ai)
At a prompt of 200,000 tokens or more, the pricing table lists higher rates: Grok Build 0.1 at $2.00 input, $0.40 cached input, and $4.00 output per million tokens; Grok 4.7 at $4.00 input, $1.00 cached input, and $12.00 output per million. The table says that once a request’s prompt reaches the model’s long-context threshold, the higher rates apply to all tokens in that request. Thus, a model’s context window can exceed 200K while a request still crosses into the higher-price tier. The rates below the threshold and these higher-tier rates were listed in xAI’s pricing documentation as checked November 8, 2026. (docs.x.ai)
Illustrative estimate: Suppose a workload uses 2 million uncached input tokens and 500,000 output tokens across requests, with each request’s prompt below 200,000 tokens. At Grok Build 0.1’s listed standard rates:
- Input: 2 × $1.00 = $2.00
- Output: 0.5 × $2.00 = $1.00
- Estimated total: $3.00, before separately priced tools or other applicable charges.
This is arithmetic based on listed rates, not a measured workload. Actual cost depends on token use, caching, prompt length, and tool calls; xAI says tool requests can incur both token charges and tool-invocation charges. For long-context work, use the higher rates for every token in any request whose prompt reaches 200,000 tokens. (docs.x.ai)
Data handling and operational checks
For the API, xAI’s security FAQ says requests and responses are encrypted at rest and stored for 30 days by default for auditing, and says API data is not used for training without explicit permission. Before sending sensitive code, confirm whether your team has Zero Data Retention (ZDR), what it covers, and whether it is compatible with the Responses features your integration needs. The retrieved security excerpt does not establish ZDR eligibility or all of its storage and feature-compatibility effects. Do not assume API retention settings describe every coding-agent or IDE integration. (docs.x.ai)
For an initial trial, use a non-sensitive repository or sanitized test case, keep credentials out of prompts and source history, and check the data-handling terms for the specific route you plan to use. In CI or an agent loop, record token usage and enforce limits; ask for a proposed patch, then validate it and run tests before applying it to important code.
Bottom line
Shortlist Grok Build 0.1 for a coding-focused API evaluation, and compare Grok 4.7 when its larger context or broader model role fits your workload. Keep the 200,000-token pricing threshold separate from context capacity, and account for the higher rates on the entire request once that prompt threshold is reached. The documented direct Responses example here uses Grok 4.7; verify model-route support before adapting it to Grok Build 0.1. Choose based on your own task results, measured cost, and operational requirements—not unsupported speed or benchmark claims. If you need a repository-operating agent rather than an API model, assess Grok Build CLI separately.
Sources
Grok Build 0.1 — xAI API model details
Responses API and Chat Completions comparison
