Skip to content

AiError: Bad input when using Cloudflare Workers AI — message content format mismatch #30381

@Taimoorkhan1122

Description

@Taimoorkhan1122

Description

Bug Description

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

  1. Configure opencode with Cloudflare Workers AI as provider
  2. Select any Cloudflare Workers AI model
  3. 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

  1. Configure opencode with Cloudflare Workers AI as provider
  2. Select any Cloudflare Workers AI model
  3. Start a conversation — error appears immediately

Screenshot and/or share link

Image

Operating System

macOS 26.4.1 (25E253)

Terminal

Terminal

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions