Skip to content

[BUG] Cloudflare providers show 'sdk.languageModel is not a function' when CLOUDFLARE_ACCOUNT_ID is missing #20398

@mchenco

Description

@mchenco

Description

When connecting cloudflare-workers-ai or cloudflare-ai-gateway via /connect and entering an API key, but without CLOUDFLARE_ACCOUNT_ID set as an environment variable, sending a message crashes with:

sdk.languageModel is not a function. (In 'sdk.languageModel(model.api.id)', 'sdk.languageModel' is undefined)

The custom loaders return { autoload: false } without a getModel when the env var is missing. Since the provider already exists in the providers map from /connect auth, the result is still processed but no model loader is registered. The fallback sdk.languageModel() runs and crashes.

Same issue affects cloudflare-ai-gateway when CLOUDFLARE_GATEWAY_ID is missing.

Plugins

None

OpenCode version

dev (latest)

Steps to reproduce

  1. Run /connect, select Cloudflare Workers AI, enter an API key
  2. Do NOT set CLOUDFLARE_ACCOUNT_ID environment variable
  3. Select a model and send a message
  4. See sdk.languageModel is not a function error

Screenshot and/or share link

No response

Operating System

All

Terminal

All

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

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