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
Cohere route rejects image MIME types with uppercase letters #58937
The native Cohere route rejects image MIME types containing uppercase letters. Media.base64(data, "IMAGE/PNG") is classified as an image, but request compilation fails with Cohere Chat user messages only support text and media content for now. The same bytes with image/png work. The Chat, Responses, Messages, Converse and Gemini routes accept both spellings.
Thanks for the clear report. I could reproduce this on commit 32b5701, which is also the latest dev right now.
The script below builds the same Cohere request twice, without contacting Cohere:
Media.base64("aGVsbG8=", "image/png") produces an image_url block.
"IMAGE/PNG" fails with Cohere Chat user messages only support text and media content for now.
The Cohere route's image check (packages/ai/src/protocols/cohere-chat.ts) compares the media type case-sensitively against image/. The other routes lowercase it first, which is why they accept both spellings. I only tested the base64 case; your URL example with Image/Png goes through the same check, so I expect it to fail the same way.
Reproduction script (cohere-mime.ts)
// Run from packages/ai of an opencode checkout: bun /workspace/repro/cohere-mime.ts// Set AI_DIR to the packages/ai directory (default: /workspace/repo/packages/ai).constdir=process.env.AI_DIR??"/workspace/repo/packages/ai"const{LLM, Media, Message }=awaitimport(`${dir}/src/effect.ts`)const{ Cohere }=awaitimport(`${dir}/src/providers/cohere.ts`)const{ compileRequest }=awaitimport(`${dir}/src/route/client.ts`)const{Effect: E}=awaitimport("effect")constmodel=Cohere.configure({apiKey: "fixture"}).model("command-a-vision-07-2025")constcases: Array<[string,any]>=[["base64 image/png",Media.base64("aGVsbG8=","image/png")],["base64 IMAGE/PNG",Media.base64("aGVsbG8=","IMAGE/PNG")],]letfailed=falsefor(const[label,media]ofcases){constexit=awaitE.runPromiseExit(compileRequest(LLM.request({ model,prompt: Message.media(media)})))if(exit._tag==="Success"){console.log(`${label}: OK ->`,JSON.stringify(exit.value.body??exit.value).slice(0,200))}else{failed=trueconsole.log(`${label}: FAILED ->`,String(exit.cause).split("\n")[0])}}process.exit(failed ? 1 : 0)
Activity
opencode-agent commentedon Oct 25, 2026
Thanks for the clear report. I could reproduce this on commit
32b5701, which is also the latestdevright now.The script below builds the same Cohere request twice, without contacting Cohere:
Media.base64("aGVsbG8=", "image/png")produces animage_urlblock."IMAGE/PNG"fails withCohere Chat user messages only support text and media content for now.The Cohere route's image check (
packages/ai/src/protocols/cohere-chat.ts) compares the media type case-sensitively againstimage/. The other routes lowercase it first, which is why they accept both spellings. I only tested the base64 case; your URL example withImage/Pnggoes through the same check, so I expect it to fail the same way.Reproduction script (cohere-mime.ts)
Run it:
bun cohere-mime.ts