The short answer: never treat the content field as the whole story. Print or log the full response object (or at least the id, model, finish_reason, usage, and any tool_calls) before you decide what the application should do next. That single habit removes more confusion than any amount of prompt tweaking.
I used to glance at the generated text, nod, and move on. Then a script in my home lab started producing fluent but wrong summaries after an upstream data change. The API had returned 200. The content looked reasonable. Only the usage numbers and a later manual check revealed that the prompt had grown and the model had started hallucinating structure. This article is the checklist I now follow on every new integration.
We will walk through the important fields, show what a real response looks like, and build the habit of inspecting evidence before changing code or prompts.
What This Solves
You want to stop guessing why a Grok call behaved a certain way. By the end of this post you will know:
Which fields are present on a typical chat completion or responses object
What finish_reason actually tells you
Why usage numbers are worth logging on every call
How to tell the difference between “the model returned text” and “my application can trust that text”
A minimal inspection pattern you can drop into any script
This is still foundation work. Later articles on tool calling and structured output will assume you already look at the full response.
Who Should Use This Approach
Anyone who has made at least one successful Grok API request and is ready to stop treating the content string as the only output that matters. If you have not yet authenticated and sent a first request, go back to the previous articles in this series. If you are already deep into tool-calling bugs, the inspection habits here still apply.
The Mental Model: Three Layers
Keep these separate in your head:
What the API returned — the JSON (or SDK object) containing id, model, choices, usage, finish_reason, and possibly tool_calls or refusal information.
What the model generated — the content (or structured data) inside that response.
What the application did with it — parsing, validation, tool execution, retries, logging, or display.
Most bugs live in the gap between layer 1 and layer 3. A tool_call object is a request from the model, not proof that your function ran. Valid-looking text is not proof that the underlying facts are correct. Schema-valid JSON is not proof that the data is true. We will keep repeating that distinction because it is the core of the site.
A Typical Response Shape
Using the OpenAI-compatible client for illustration (the native xAI client exposes equivalent information):

Python
completion = client.chat.completions.create(
model="grok-4-1-fast-reasoning",
messages=[
{"role": "system", "content": "Answer briefly and precisely."},
{"role": "user", "content": "What is the capital of France?"},
],
)A successful response object will contain at least:
id — unique identifier for this completion
model — the model that actually served the request
choices — list (usually length 1) of choice objects
Inside each choice:
message.role (almost always “assistant”)
message.content (the text, or null if a tool call is present)
message.tool_calls (if the model requested tools)
finish_reason
usage — token counts
Print the whole thing on the first few runs:
Python
import json
print(json.dumps(completion.model_dump(), indent=2, default=str))Or, if you prefer the native client, print the response object directly. The goal is the same: see the evidence before you decide what it means.
The Fields That Matter Most
finish_reason
This is the single most useful status signal after the HTTP status code.
"stop" — normal completion. The model decided it was finished.
"length" — hit a token limit. The content is truncated.
Tool-related reasons — the model wants the application to run one or more functions.
Other values — check the current documentation; new reasons appear as features evolve.
If you only look at content and ignore finish_reason, you will eventually treat a truncated or tool-requesting response as a normal answer.
usage
Python
print(completion.usage)You will typically see prompt_tokens, completion_tokens, total_tokens, and sometimes details about cached tokens. These numbers are the first hard evidence of cost and prompt size. When a request suddenly feels expensive or slow, the usage block is the place to start. Log it. Compare it across runs. Do not wait until the bill arrives.
id and model
The id lets you correlate logs later. The model field tells you what actually ran, which is useful when you are testing aliases or when the console default changes. Both are cheap to log and occasionally invaluable.
content vs tool_calls
If message.content is present and tool_calls is empty or absent, you have a normal text response. If tool_calls is present, the model is asking the application to do something. The content may be null or may contain a partial thought. Treat a tool_call as a structured request that still requires validation and execution by your code. Never assume the function already ran.
refusal or safety-related fields
Some responses include explicit refusal information. When present, surface it. Do not silently fall back to the content field and hope for the best.

A Minimal Inspection Helper
I keep a small function like this in early prototypes:
Python
def inspect_completion(completion, label: str = "grok") -> None:
print(f"\n=== {label} ===")
print(f"id: {completion.id}")
print(f"model: {completion.model}")
choice = completion.choices[0]
print(f"finish_reason: {choice.finish_reason}")
print(f"usage: {completion.usage}")
message = choice.message
if message.tool_calls:
print("tool_calls:")
for tc in message.tool_calls:
print(f" - {tc.function.name}: {tc.function.arguments}")
else:
content = message.content or ""
preview = content[:300] + ("..." if len(content) > 300 else "")
print(f"content preview: {preview}")Call it after every request while you are still learning the shape of the data. Later you can reduce it to structured logging. The important part is that the inspection happens before any downstream logic that consumes the content.
Common Ways People Guess (and How to Stop)
Guessing from content alone
“It looks right, so it must be fine.”
Counter: always check finish_reason and usage first.
Assuming a 200 means success
HTTP success only means the API accepted the request and returned a response object. It does not mean the content is correct, complete, or safe to execute.
Counter: treat the response object as data that still needs validation.
Ignoring tool_calls
Seeing text and not noticing that the model also (or instead) requested a tool.
Counter: explicitly check for the presence of tool_calls before treating the response as a final answer.
Treating schema-valid JSON as true
The model returned JSON that parses and matches a schema. That is necessary but nowhere near sufficient.
Counter: validate the values against independent sources or business rules whenever the stakes are non-zero.
Changing the prompt before inspecting the response
The classic loop: “It failed, so I must need a better prompt.”
Counter: log the full response, the exact model, and the usage numbers first. Many “prompt problems” are actually truncated outputs, unexpected tool calls, or silently growing context.
A Small Story from the Home Lab
One of my internal tools summarized overnight metrics and posted a short status note. For weeks it worked. Then the upstream metrics endpoint added a new field and increased the payload size. The Grok call still returned 200. The content was still grammatical English. Only the usage numbers showed that the prompt had roughly doubled, and a later human review showed that the model had started inventing plausible-looking numbers for the new field. The finish_reason was still “stop.” The content looked fine at a glance. The evidence that something had changed was sitting in the usage block the whole time.
After that I started logging usage and finish_reason on every call, even the ones I thought were simple. The extra lines of code have paid for themselves many times over.
Practical Checklist
I can print or log the full response object (or a structured subset)
I always look at finish_reason before trusting content
I log usage numbers at least during development and for any production path that matters
I explicitly check for tool_calls before treating a response as a final answer
I keep the model string and response id in the logs so I can correlate later
I remember that a 200 + fluent text is still only layer 1 of the three-layer model
When a Simpler Approach Is Better
If you are doing a one-off experiment in a notebook and will throw the code away, glancing at the content is fine. As soon as the call lives in a script, a service, or a scheduled job, inspect the structured fields. Do not wait for the first silent failure to teach you the lesson.
Closing
Reading a Grok API response well is less about memorizing every field and more about refusing to guess. Look at the finish_reason. Look at the usage. Look for tool_calls. Only then decide what the application should do with the content.
The model generates. The API returns. The application decides and verifies. Keep those responsibilities separate and most of the mystery disappears.
Build the request.
Explain every field you rely on.
Verify the response before you act on the content.
Build it. Explain it. Verify it.
Next we will compare the official SDK with direct HTTP (and the OpenAI-compatible client) so you can choose the right level of abstraction for the job.
Comments
No comments yet — be the first to share a thought.