damngoodprompts

Grok (xAI)

Prompting Grok

How to prompt Grok for coding, real-time research, X-aware workflows, and API use without confusing chat behavior with search/tool behavior.

Last reviewed: September 14, 2026Official docswebmobileapisearchcoding-agent
Tip

What this model is particularly good at:

  • Strong fit for users who need X-aware or real-time web-flavored workflows
  • Grok 4.6 is xAI's current frontier model for coding, agentic tasks, and knowledge work
  • API supports text, image input, server-side search tools, function calling, and structured outputs on supported Grok 4 family models

Current model routing

ModelStatusBest fitAPI ID
Grok 4.6defaultCoding, agentic tasks, engineering, and general knowledge workgrok-4.6
Grok Imagine APIspecializedImage and video generation/editingVaries by surface
Grok Voice APIspecializedVoice workflowsVaries by surface

Which model to choose

Use Grok 4.6 for text, coding, agentic, and knowledge-work tasks; xAI’s model page routes both Code and Chat to it. Use the specialized Imagine and Voice APIs for media and voice tasks instead of trying to get a text model to act like a media model.

Grok is popular enough to track because many users encounter it in consumer chat, X-linked workflows, and developer APIs. Its prompting value is strongest when the task benefits from web/X search or agentic coding behavior.

Prompting in Grok

In the GUI, be explicit about whether you want Grok to answer from general model knowledge, use web search, or use X-aware context where available. For current-events questions, name the time frame and tell it to distinguish sourced facts from interpretation.

For coding or build tasks, give the target file, failure, or desired behavior. Avoid long persona prompts; Grok’s model docs position the current text model around coding and agentic workflows, so the prompt should describe the work, not invent expertise.

Prompting through the API

xAI documents web search, X search, and code execution as server-side tools the model can orchestrate. For API work, this means current research is a tool/configuration choice, not something prompt wording alone can guarantee.

Grok’s API also supports function calling and structured outputs on current Grok 4 family models including Grok 4.6. xAI’s structured-output docs guarantee a schema-conformant response when you use supported schema features (response_format json_schema, or tool calls, which are implicitly strict). Use those features for typed data and external actions rather than relying on prose-only format instructions.

Current prompting guidance

  • Specify whether live search/X context should be used.
  • Ask for citations when using search.
  • Use structured outputs for parseable responses where supported.
  • For coding, state the failure and success criteria instead of scripting the whole investigation.
  • For image/video/voice, route to the specialized surface.

Examples

GUI prompt:

Use current web sources. Compare the last two official announcements about Grok's
coding capabilities and summarize what changed for developers. Cite each claim.

API request skeleton:

{
  "model": "grok-4.6",
  "input": "Fix this function and explain the bug: function median(a){a.sort();return a[a.length/2]}"
}

Prompt upgrade example:

Stale pattern: “You are a rebellious genius. Search the internet and tell me the truth.”

Better pattern: “Use web search for current facts, cite sources, and separate facts from interpretation.”

Source set