Grok 4.7 API

x-ai/grok-4.7
256K tokens · Input $1.60 / Output $4.80 / Cache Read $0.40 / 1M tokens · 320 / 960 / 80 credits

Grok 4.7 turns text instructions, code, and documents into implementations and analysis, with stronger self-verification and sustained reasoning across connected tasks. Clear requirements and test evidence help it track dependencies and refine proposed changes throughout a multi-turn review.

Grok 4.7

xAI · chat-completions

Chat with Grok 4.7

Provide relevant code or documents and describe the expected behavior and output format. Add test results in later turns to review and refine the answer.

Ctrl / ⌘ + Enter to send0 / 32,000

Continue with

Grok 4.7

Grok 4.7 is an xAI model for software engineering and professional knowledge work, built on a larger base model with extended reinforcement learning on difficult, long-running tasks. Its improved self-verification and context management help connect requirements, code, and evidence across a review. Provide text materials to generate implementations, explain failures, develop test cases, or turn technical documents into organized findings.

Why Choose Grok 4.7?

  • Connected code changesAnalyze requirements and related source files together to propose changes that account for dependencies across an implementation.

  • Stronger self-verificationUse the model's improved checking of its own work to examine assumptions, revisit a proposed fix, and explain the evidence behind a revision.

  • Sustained task reasoningExtended reinforcement learning on difficult, long-running tasks strengthens the model's ability to work through connected coding and analysis steps.

  • Technical document analysisWork through specifications, reports, and written research in the standard 256K-token context to identify requirements, dependencies, and open questions.

  • Practical test designTurn expected behavior and failure reports into test cases, boundary conditions, and a clear explanation of what each check establishes.

  • Iterative knowledge workDevelop findings and technical drafts over successive turns, supplying new evidence and review comments as the task develops.

Input Parameters

ParameterRequirementDescription
modelRequired

Set to x-ai/grok-4.7.

messagesRequired

A non-empty ordered array of messages. Each message contains role and string content; use system, user, or assistant roles.

temperatureOptional

Ranges from 0 to 2 and controls output randomness. Adjust temperature or top_p to guide output variation.

Default1
max_tokensOptional

A positive integer setting the output-token limit for this response. The playground offers 1–65,536 tokens and defaults to 4,096.

max_completion_tokensOptional

A positive integer setting the completion-token budget. Choose one output-budget field per request.

top_pOptional

Nucleus sampling probability from 0 to 1.

Default1
frequency_penaltyOptional

Ranges from -2 to 2. Positive values reduce repetition of frequently generated tokens.

Default0
presence_penaltyOptional

Ranges from -2 to 2. Positive values encourage new topics.

Default0
stopOptional

A stop string or an array of up to four stop strings. Generation stops when a sequence is encountered.

nOptional

An integer of at least 1 setting the number of completions to generate.

Default1
streamOptional

false returns complete JSON; true returns an SSE event stream.

Defaultfalsetrue

How to Use

  1. Provide the task and evidenceInclude the goal, relevant code or documents, constraints, and the expected result.

  2. Set the conversationUse System Prompt for review criteria or answer format, then write your request in Messages. API calls use model x-ai/grok-4.7.

  3. Choose the response budgetSet Max Tokens in the playground. For API calls, send messages and the output budget to /v1/chat/completions; stream selects JSON or SSE.

  4. Review and refineCheck the proposed implementation or analysis, then add test results and specific feedback in the next turn.

Pricing

Input, output, and cache-read usage is priced per 1M tokens and settled in credits using the reported token counts.

UsageRateDetails
Input$1.60 · 320 credits / 1M tokensInput tokens billed at the standard input rate.
Output$4.80 · 960 credits / 1M tokensOutput tokens reported for the generated response.
Cache Read$0.40 · 80 credits / 1M tokensInput tokens reported as cache reads use this rate.

Best Use Cases

  • Repository refactoringReview related files, plan changes to shared interfaces, and explain how the proposed edits fit the intended behavior.

  • Bug diagnosis and regression testsConnect a reproduction, source code, and error logs to a proposed fix and focused regression cases.

  • Technical research and writingSynthesize supplied reports and specifications into findings, design proposals, and technical drafts with explicit supporting evidence.

Pro Tips

  • For refactoring, include callers and shared types alongside the function being changed.
  • Ask for the proposed fix, the reason it works, and test cases covering the original failure.
  • Label document excerpts and ask the model to connect each finding to a supplied passage.
  • In follow-up turns, provide the actual test output and name the behavior that still needs attention.

Usage Notes

  • The standard context window is 256K tokens for the model described on this page.
  • The playground uses text conversation through Chat Completions and streams replies with SSE.
  • Max Tokens in the playground accepts integers from 1 to 65,536 and defaults to 4,096.
  • Send system instructions as a system message and preserve user and assistant messages in conversation order.

Related Models

Grok 4.7 API frequently asked questions

What is the Grok 4.7 API?

Grok 4.7 is an xAI model for coding and professional knowledge work. It turns text instructions, source code, and documents into implementations and analysis, with stronger self-verification and sustained reasoning across connected tasks. A larger base model and extended reinforcement learning on difficult tasks strengthen its checking of proposed changes and management of relevant context. You can call it programmatically or try it from the playground above.

What changed from Grok 4.6 to Grok 4.7?

Grok 4.7 uses a new, larger base model and a longer reinforcement learning run focused on harder, longer tasks. Its improvements include checking its own work and managing context during coding and knowledge work. Compare the two on the same source files, acceptance criteria, and test evidence to assess the results for your project.

How can Grok 4.7 help with a repository refactor?

Supply the files being changed together with their callers, shared types, and target behavior. Grok 4.7 can reason across these dependencies, propose connected edits, and explain the effect on each interface. Feed the resulting test output into the next turn to refine the proposal.

How does Grok 4.7 help check a bug fix?

Provide the failing input, observed result, expected behavior, and relevant code. Ask Grok 4.7 to trace the failure, explain why its proposed change addresses it, and produce regression cases. Its stronger self-verification is useful for reviewing the assumptions behind the proposed fix.

How can Grok 4.7 analyze long technical documents?

Place the relevant specifications and report excerpts in the standard 256K-token context, with section names and a clear question. Grok 4.7 can connect requirements across these materials and organize the findings. Ask it to name the supplied passages supporting each conclusion so the review stays tied to your sources.

How can Grok 4.7 turn requirements into test cases?

Give Grok 4.7 the required behavior, valid input ranges, and examples of failures. Ask for normal cases, boundary cases, and a reason for each assertion. After running the tests in your environment, provide the actual results for a focused follow-up review.

How can Grok 4.7 improve a technical design proposal?

Provide the design, constraints, dependencies, and alternatives being considered. Grok 4.7 can compare the approaches, identify assumptions, and draft a structured recommendation. Ask it to separate evidence from assumptions and tie proposed changes to your acceptance criteria.

How can Grok 4.7 help revise professional documents?

Supply the draft, source material, intended audience, and required format. Grok 4.7 can organize the argument, clarify technical explanations, and develop a revised draft using the supplied evidence. Continue with specific review comments to refine terminology and the level of detail.