feat(opencode): native OpenAI and Anthropic passthroughs for Cloudflare AI Gateway (#42634)

Co-authored-by: Keefe Tang <keefe@pentagram.me>
This commit is contained in:
Aiden Cline
2026-08-16 23:53:20 -05:00
committed by GitHub
parent 2f09b45ac8
commit a7dd1d6ca8
5 changed files with 265 additions and 105 deletions
@@ -61,16 +61,5 @@ export async function CloudflareAIGatewayAuthPlugin(_input: PluginInput): Promis
},
],
},
"chat.params": async (input, output) => {
if (input.model.providerID !== "cloudflare-ai-gateway") return
// The unified gateway routes through @ai-sdk/openai-compatible, which
// always emits max_tokens. OpenAI reasoning models (gpt-5.x, o-series)
// reject that field and require max_completion_tokens instead, and the
// compatible SDK has no way to rename it. Drop the cap so OpenAI falls
// back to the model's default output budget.
if (!input.model.api.id.toLowerCase().startsWith("openai/")) return
if (!input.model.capabilities.reasoning) return
output.maxOutputTokens = undefined
},
}
}