Best Practices and Common Mistakes
On this page
Updated November 3, 2026. Based on the xAI API reference:
max_completion_tokenscaps only the visible response; reasoning tokens don’t count toward it, andreasoning_effortcontrols their quantity. Source: Chat Completions.
Summary and Guardrails
This final lesson covers essential best practices and the most frequent mistakes when prompting with Grok. Treat it as a reference checklist to consult whenever you create or refine a prompt.
Best Practices
1. Structure Your Prompts Systematically
Always separate context, task, and constraints. The model finds a block of text harder to interpret than a prompt organized into sections.
2. Use the System Message for Permanent Instructions
Put anything that must apply to every exchange (language, format, tone, constraints) in the system message. Put situational instructions in user messages.
3. Provide Examples Instead of Descriptions
When the output format is complex, an example is worth a thousand words of description. Few-shot prompting is almost always more effective than a detailed explanation of the expected format.
4. Match the Model to the Task
- Simple and fast task:
grok-4.3orgrok-build-0.1(for code) - Complex reasoning task:
grok-4.20-0309-reasoningwith high effort - Image analysis:
grok-4.5with detail setting (low/high)
5. Adjust Temperature to the Goal
- Extraction, classification, factual: temperature 0 to 0.3
- Professional writing, summary: temperature 0.4 to 0.7
- Brainstorming, creativity: temperature 0.8 to 1.5
6. Test Using the seed Parameter
To objectively compare two prompt formulations, use the same seed. This eliminates variability due to randomness and lets you measure the impact of your change.
7. Build a Prompt Library
Keep your best prompts in a library organized by use case. A good prompt is an investment: it gains value with every reuse.
Common Mistakes
Mistake 1: Vague Prompts
The model isn’t telepathic. The more specific you are, the better the result.
Mistake 2: Ignoring Reasoning Model Limits
Grok reasoning models don’t support certain parameters: frequency_penalty, presence_penalty, and stop trigger an error. Allow a timeout of 3,600 seconds for complex tasks.
Mistake 3: Modifying History Mid-Conversation
The Grok API is stateless. Modifying history breaks the inference cache and degrades performance.
Mistake 4: Using Temperature and top_p Together
Changing temperature and top_p simultaneously produces unpredictable results. Choose one or the other.
Mistake 5: Overlooking Reasoning Tokens in Budget
On reasoning models, reasoning tokens add to the visible response and are billed at the output rate, but max_completion_tokens doesn’t cap them: it limits only the visible response. To control this cost, set the reasoning effort (reasoning_effort) and monitor reasoning_tokens in usage.
Mistake 6: Not Specifying Output Format
Without format instructions, the model chooses the format it deems appropriate. Always specify the expected format.
Mistake 7: Too Much Irrelevant Context
xAI documentation explicitly recommends excluding irrelevant information from context.
Mistake 8: Storing History with Images
Use store: false with requests containing images to avoid errors.
Course Summary
Over these 14 lessons, you learned to:
- Structure your prompts with clarity, context, and format (lessons 1-4)
- Leverage advanced techniques: few-shot, chain of thought, system instructions, iteration, multimodal (lessons 5-9)
- Apply prompting to real-world examples: writing, analysis, code (lessons 10-12)
- Build expert prompts by following a methodical process (lesson 13)
Prompting is a skill that improves with practice. Every prompt you refine enriches your experience and your library of reusable templates.
Key Takeaways
- Always structure your prompts into distinct sections
- Match the model and parameters to each task
- Provide examples rather than long descriptions
- Avoid classic mistakes: incompatible parameters, modified history, excessive context
- Document and reuse your best prompts
- Prompting is iterative: test, diagnose, adjust
Test Your Knowledge
After the expert workshop, a final check of Grok prompting techniques.
1. What is the system role for compared to the user and assistant roles?
Answer: The system role sets the lasting framework for the conversation—identity, rules, format—while user carries requests and assistant carries responses: application instructions don’t mix with the dialogue.
2. When lower temperature?
Answer: For factual tasks, extraction, and code, where variation is a defect; raise it for creativity—the setting follows the cost of a different answer from one run to the next.
3. What do you gain with chain of thought?
Answer: On reasoning tasks, asking for steps before the conclusion significantly reduces errors—the model unfolds instead of jumping to the plausible.
4. How to prompt in multimodal (text + image)?
Answer: By framing the analysis like text: precise question, criteria, output format—the image is data, the prompt remains the method.
5. Name two common mistakes to avoid.
Answer: Catch-all requests without structure or format, and lack of iteration—accepting the first output instead of refining; the course best practices are the exact opposite.
Clear framework, adapted settings, iterations: the techniques boil down to three moves—the workshop let you practice them, your projects will reap the returns.