You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AiError: Bad input when using Cloudflare Workers AI — message content format mismatch #30381
Selecting any Cloudflare Workers AI model causes AiError: Bad input with schema validation failure. Messages are sent with inconsistent content field types in the same request.
Error
Bad Request: {"errors":{"message":"AiError: Bad input: Error: oneOf at '/' not met, 0 matches: required properties at '/' are 'prompt', Type mismatch of '/messages/0/content', 'array' not in 'string', Type mismatch of '/messages/1/content', 'string' not in 'array', required properties at '/messages/1' are 'role,content' (d9e09afe-fe49-4051-bc1d-8901f858ff52)","code":5006},"success":false,"result":{},"messages":[]}
Root Cause
A mix of Anthropic-style and OpenAI-style message formats in the same request:
Some messages have content as an array ([{type: "text", text: "..."}])
Others have content as a string ("...")
Cloudflare Workers AI expects OpenAI-compatible schema where content type is consistent.
To Reproduce
Configure opencode with Cloudflare Workers AI as provider
Select any Cloudflare Workers AI model
Start a conversation — error appears immediately
Environment
opencode version: 1.15.5 (Homebrew)
Provider: Cloudflare Workers AI
Platform: macOS
No custom system prompt
Plugins
superpowers
OpenCode version
1.15.13
Steps to reproduce
Configure opencode with Cloudflare Workers AI as provider
I’d like to take this one. I’ll trace the Cloudflare Workers AI request formatting path, reproduce the mixed message content shape (text string vs content array), and open a focused fix with regression tests.
It normalizes Cloudflare Workers AI mixed message content shapes (string + text-part arrays) into a consistent string form when safe, while preserving tool/non-text arrays unchanged.
{
"name": "AiError",
"internalCode": 5006,
"httpCode": 400,
"message": "AiError: Bad input: Error: oneOf at '/' not met, 0 matches: required properties at '/' are 'prompt', Type mismatch of '/messages/0/content', 'array' not in 'string', Type mismatch of '/messages/1/content', 'array' not in 'string', Type mismatch of '/messages/2/content', 'string' not in 'array', required properties at '/messages/2' are 'role,content', oneOf at '/' not met, 0 matches, required properties at '/' are 'input', required properties at '/' are 'requests' (a8e8e150-2ec6-4022-8c54-71e8e72eec57)",
"description": "Error: oneOf at '/' not met, 0 matches: required properties at '/' are 'prompt', Type mismatch of '/messages/0/content', 'array' not in 'string', Type mismatch of '/messages/1/content', 'array' not in 'string', Type mismatch of '/messages/2/content', 'string' not in 'array', required properties at '/messages/2' are 'role,content', oneOf at '/' not met, 0 matches, required properties at '/' are 'input', required properties at '/' are 'requests'",
"requestId": "a8e8e150-2ec6-4022-8c54-71e8e72eec57"
}
The previous PR (#30589) was closed by the automated cleanup bot due to age and lack of reactions, but the fix is the same — normalizing mixed content types for cloudflare-workers-ai messages.
@nexxeln could you please take a look when you get a chance? Thanks!
The previous PR (#30589) was closed by the automated cleanup bot due to age and lack of reactions, but the fix is the same — normalizing mixed content types for cloudflare-workers-ai messages.
@nexxeln could you please take a look when you get a chance? Thanks!
hey this looks good. and it gave me idea.. even if they dont approve PR we can use caveman like transformer here and inject it as plugin to enhance the output into string.
Bad Request: {"errors":[{"message":"AiError: Bad input: Error: oneOf at '/' not met, 0 matches: required properties at '/' are 'prompt', Type mismatch of '/messages/0/content', 'array' not in 'string', Type mismatch of '/messages/1/content', 'string' not in 'array', required properties at '/messages/1' are 'role,content', oneOf at '/' not met, 0 matches, required properties at '/' are 'input', required properties at '/' are 'requests' (802fcf5e-949a-4ad1-bf8b-608bb83ae5d6)","code":5006}],"success":false,"result":{},"messages":[]}
Activity
ulises-jeremias commentedon Jun 3, 2026
I’d like to take this one. I’ll trace the Cloudflare Workers AI request formatting path, reproduce the mixed message content shape (text string vs content array), and open a focused fix with regression tests.
ulises-jeremias commentedon Jun 3, 2026
Opened a fix PR with regression tests:
It normalizes Cloudflare Workers AI mixed message content shapes (string + text-part arrays) into a consistent string form when safe, while preserving tool/non-text arrays unchanged.
daton89 commentedon Jun 10, 2026
I've the same issue, @ulises-jeremias thanks for fixing it...
when do you plan to release it?
ulises-jeremias commentedon Jun 12, 2026
@nexxeln do you mind taking a look to this PR with the fix? #30589 👀
steelx commentedon Jul 7, 2026
any fix ?
steelx commentedon Jul 14, 2026
ulises-jeremias commentedon Jul 14, 2026
@steelx I just opened a new PR with the fix: #36850
The previous PR (#30589) was closed by the automated cleanup bot due to age and lack of reactions, but the fix is the same — normalizing mixed content types for cloudflare-workers-ai messages.
@nexxeln could you please take a look when you get a chance? Thanks!
steelx commentedon Jul 17, 2026
hey this looks good. and it gave me idea.. even if they dont approve PR we can use caveman like transformer here and inject it as plugin to enhance the output into string.
github-actions commentedon Sep 17, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.
kawpii commentedon Sep 27, 2026
Still get following with Cloudflare Workers AI:
Cloudlfare Workers Gateway did not work either.