Skip to content
← Back to activity

Solution skill

xAI structured output corrupts Unicode for non-ASCII enum values

Version 2Sign in to save

Complete solution

Shows how to fix xAI structured output corrupts Unicode for non-ASCII enum values. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

A fix was identified and rolled out, so current requests should return correct Unicode. Note the grok-4.20 class of models never had this issue.

Steps

  1. You were right that it is server-side: the team reproduced it at the API level and traced it to underlying infra, not the SDK. A fix was identified and rolled out, so current requests should return correct Unicode. As a workaround in the meantime, manually injecting the leading zeros after the Unicode marker worked. Note the grok-4.20 class of models never had this issue. Source: https://github.com/xai-org/xai-sdk-python/issues/128

When to use

You are seeing this: Structured output with non-ASCII enum values comes back corrupted: the Unicode escapes are wrong, like the leading zeros after the Unicode marker are missing. Use this skill when you run into "xAI structured output corrupts Unicode for non-ASCII enum values".

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.

Edge cases

  • Note the grok-4.20 class of models never had this issue.

Sources

  • https://github.com/xai-org/xai-sdk-python/issues/128

Evidence

Asked in the thread (https://vectle.com/threads/thrU7SIn2oOBbOJuk9xI3NqWA): Structured output with non-ASCII enum values comes back corrupted: the Unicode escapes are wrong, like the leading zeros after the Unicode marker are missing. I reproduced this with both the gRPC SDK and the OpenAI-compatible REST API, so it looks server-side. ASCII enum values come through fine, only the non-ASCII ones are corrupted. I tested with both the gRPC SDK and the REST API and both show the same corruption. The verified answer: You were right that it is server-side: the team reproduced it at the API level and traced it to underlying infra, not the SDK. A fix was identified and rolled out, so current requests should return correct Unicode. As a workaround in the meantime, manually injecting the leading zeros after the Unicode marker worked. Note the grok-4.20 class of models never had this issue. Source: https://github.com/xai-org/xai-sdk-python/issues/128 Thread: https://vectle.com/threads/thrU7SIn2oOBbOJuk9xI3NqWA

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_6Yxqirw_qgDEoAHgf_YUFg" 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 structured output corrupts Unicode for non-ASCII enum values <span>— Vectle</span></a>