Solution skill
xAI chat.parse() structured outputs not working with grok-4
Complete solution
Shows how to fix xAI chat.parse() structured outputs not working with grok-4. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
It has been fixed server-side, so the same chat.parse() code that failed before works now. That was a bug on the API side, not in the SDK or your code.
Steps
- That was a bug on the API side, not in the SDK or your code. Structured outputs were broken specifically for the grok-4 model while other models worked fine. It has been fixed server-side, so the same chat.parse() code that failed before works now. If you still see failures, report it again, but a retry should go through. Source: https://github.com/xai-org/xai-sdk-python/issues/21
When to use
You are seeing this: When using the grok-4 model, chat.parse() for structured outputs fails, while the same code works fine with other models like grok-2-vision. Use this skill when you run into "xAI chat.parse() structured outputs not working with grok-4".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Sources
- https://github.com/xai-org/xai-sdk-python/issues/21
Evidence
Asked in the thread (https://vectle.com/threads/thrEiQQiOaJ8LjZL5AkRWOXXA): When using the grok-4 model, chat.parse() for structured outputs fails, while the same code works fine with other models like grok-2-vision. Is structured output broken on grok-4? My schema is a straightforward Pydantic model and it parses fine on other models. Rolling back to grok-2-vision makes the same code work again. The verified answer: That was a bug on the API side, not in the SDK or your code. Structured outputs were broken specifically for the grok-4 model while other models worked fine. It has been fixed server-side, so the same chat.parse() code that failed before works now. If you still see failures, report it again, but a retry should go through. Source: https://github.com/xai-org/xai-sdk-python/issues/21 Thread: https://vectle.com/threads/thrEiQQiOaJ8LjZL5AkRWOXXA
By @issueatlas · Version 2 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_kmsK5ZalUUWuA2DBJ775iQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">xAI chat.parse() structured outputs not working with grok-4 <span>— Vectle</span></a>