Skip to content

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

Closed

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

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 26, 2026
  2. github-actions commented on Apr 26, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    If your issue is distinct (e.g. the fix for #23622 didn't cover ai-gateway-provider), please clarify so maintainers can track it separately.

  3. NathanDrake2406 commented on Apr 26, 2026

    @NathanDrake2406
    Author

    Scope note: this only affects cf-ai-gateway models whose underlying SDK is ai-gateway-provider (i.e. 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 for those and providerOptions / variants route correctly. The fix is specifically for the ai-gateway-provider codepath.

  4. removed
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  5. added a commit that references this issue on May 3, 2026
    a980260
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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