cloudflare / cloudflare/ai

workers-ai-provider rejects the Unified Billing moonshotai/Kimi catalog slug before AI.run

Open
#634 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.2k
Forks
345
Avg merge
13h 31m
Merged PRs (30d)
1

Description

> [!NOTE]
> **Automated notice:** This issue was filed from [Stellar Raven](https://github.com/stellar-experimental/stellar-raven)'s automated evaluation pipeline. Evidence and a public source record are included below. The finding may still be incomplete or incorrect — please verify against the live surface before acting on it.

## Finding

`workers-ai-provider` 4.0.0 cannot delegate the Unified Billing catalog slug
`moonshotai/kimi-k3` when provider plugins are configured. The 26-entry gateway
registry omits `moonshotai`, so model construction throws
`Unknown gateway provider "moonshotai" (from slug "moonshotai/kimi-k3")` before
`AI.run` can dispatch it. The current npm `latest` is also 4.0.0, so this is not
an upgrade-only issue.

## Evidence

Minimal reproduction (no network call):

```ts
import { createWorkersAI } from "workers-ai-provider";
import { openai } from "workers-ai-provider/openai";

let calls = 0;
const binding = { async run() { calls++; throw new Error("should not run"); } };
const workersai = createWorkersAI({ binding, providers: [openai], resume: false });

workersai("moonshotai/kimi-k3");
// GatewayDelegateError: Unknown gateway provider "moonshotai" ...
// calls === 0
```

Expected: the slug selects the run transport and reaches `binding.run`, as it does
when `providers` is omitted. Actual: the delegate rejects it during registry
resolution. Raven keeps a second, providers-less instance solely for this prefix;
that sacrifices the provider-SDK normalization and gateway-delegate features for
Kimi while the primary instance remains configured for other vendors.

Additional recorded evidence:

- workers-ai-provider 4.0.0 installed from npm (latest dist-tag, verified 2026-08-06)
- deterministic local reproduction: `createWorkersAI({ binding, providers: [openai], resume: false })("moonshotai/kimi-k3")` throws before the mock binding's `run` is called (0 calls)
- registry exports 26 entries; `moonshotai` is absent, while `findProviderBySlug("moonshotai")` returns undefined
- source: node_modules/workers-ai-provider/src/gateway-delegate.ts:112-120 resolves slugs and throws the reproduced error
- consumer impact: src/demo/model-config.ts:148-164 and src/demo/chat.ts:315-360 need a separate providers-less createWorkersAI instance to use the binding run path

## Recommendation

Add a `moonshotai` registry entry for the Unified Billing run catalog using the
OpenAI wire format (the default `runWireFormat`) and mark it as having no native
gateway path unless Cloudflare supports one. This keeps the existing delegate
behavior for configured providers and removes the separate binding instance.

## Source Record

This was found by the downstream Raven eval/improvements loop and recorded as wai-001 (workers-ai-provider, discovered 2026-08-06).

Public source record: [improvements/workers-ai-provider/wai-001-moonshotai-catalog-slug-registry.md](https://github.com/stellar-experimental/stellar-raven/blob/main/improvements/workers-ai-provider/wai-001-moonshotai-catalog-slug-registry.md)

Immutable source snapshot: [4e2c3dbfad4a](https://github.com/stellar-experimental/stellar-raven/blob/4e2c3dbfad4a7d4563ade47f1f707935577b382e/improvements/workers-ai-provider/wai-001-moonshotai-catalog-slug-registry.md)

## Resolution Handoff

When a fix is deployed, please link the resolving issue or PR to the source record above and notify Raven through:

https://github.com/stellar-experimental/stellar-raven/issues/new?template=upstream-improvement-ready.yml&title=%5Bupstream-ready%5D%20wai-001%3A%20

Include the finding id, resolving issue/PR, deployed version or timestamp, and the smallest live recheck. Raven independently verifies the upstream surface before changing the finding to `fixed-upstream`; issue closure or a merged PR alone is not treated as proof. After a distinct reviewer repeats the live check, the active finding is retired to Raven's resolved ledger; a commit-pinned snapshot is preserved when available.

Contributor guide

Open the contributing guide

Research direction

Start by reading node_modules/workers-ai-provider/src/gateway-delegate.ts:112-120 and inspect the gateway registry plus findProviderBySlug("moonshotai"). Run the deterministic reproduction with createWorkersAI and the mock binding. Done means the moonshotai/kimi-k3 slug resolves with configured providers and reaches binding.run without the unknown-provider error.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
ai, api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.