Skip to content

cf-ai-gateway silently drops reasoningEffort, variants, and other provider options (sdkKey/variants missing ai-gateway-provider case) #24432

Description

@NathanDrake2406

Description

Two bugs in packages/opencode/src/provider/transform.ts mean that for cf-ai-gateway models whose underlying SDK is ai-gateway-provider (i.e. OpenAI / openai-compatible upstreams), model options and variants never reach the actual SDK:

  1. sdkKey() has no case for "ai-gateway-provider". Falls back to model.providerID ("cloudflare-ai-gateway"), so providerOptions() produces { "cloudflare-ai-gateway": { reasoningEffort: "high", ... } }. But ai-gateway-provider/providers/unified creates the language model via createOpenAICompatible({ name: "Unified" }), and @ai-sdk/openai-compatible reads providerOptions from "openai-compatible" / "openaiCompatible" / "Unified" / "unified". None match "cloudflare-ai-gateway" → all options silently dropped.

  2. variants() switch has no case for "ai-gateway-provider", so it returns {}. Workflow variant: xhigh input is silently ignored for every cf-ai-gateway model on this codepath.

Net effect: bots on cf-ai-gateway OAI models run at OpenAI's default reasoning effort. The variant: "xhigh" input is dead config, and provider.cloudflare-ai-gateway.models.<id>.options.reasoningEffort in opencode.json is also dead.

Scope: only affects cf-ai-gateway models whose underlying SDK is ai-gateway-provider (OpenAI / openai-compatible upstreams). Anthropic and Google models on cf-ai-gateway resolve to bundled @ai-sdk/anthropic / @ai-sdk/google per models.dev, so sdkKey() returns the right key and providerOptions / variants route correctly for those. Fix is specifically for the ai-gateway-provider codepath.

Expected: sdkKey("ai-gateway-provider") should return "openai-compatible" (the underlying SDK), and variants() should dispatch on model.api.id prefix (openai/..., anthropic/..., etc.) like @ai-sdk/gateway already does.

OpenCode version

Reproduces on 1.4.11 and 1.14.25 (every version since cf-ai-gateway shipped).

Steps to reproduce

Either:

# bonk.yml
model: "cloudflare-ai-gateway/openai/gpt-5.4"
variant: "xhigh"

or

// opencode.json
{
  "provider": {
    "cloudflare-ai-gateway": {
      "models": {
        "openai/gpt-5.4": {
          "options": { "reasoningEffort": "high" }
        }
      }
    }
  }
}

Outgoing POST https://gateway.ai.cloudflare.com/v1/compat/chat/completions body has no reasoning_effort field.

Operating System

Linux, macOS

Impact

Every cf-ai-gateway user on OAI / openai-compatible upstreams wanting non-default reasoning effort, verbosity, or any other provider-specific option.

Related

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions