workers-ai-provider does not work with openai/gpt-5.6 class models
- Dominant language
- TypeScript
- Stars
- 1.2k
- Forks
- 345
- Avg merge
- 13h 31m
- Merged PRs (30d)
- 1
Description
I was trying to use `workers-ai-provider` with `openai/gpt-5.6-luna` but I kept getting an error in AI Gateway
```
{ "error": "Model execution failed (User Input Error): Invalid value at input: Invalid input", "state": "Failed" }
```
I used a pretty basic example from https://github.com/cloudflare/ai/tree/main/packages/workers-ai-provider#third-party-models-via-ai-gateway
```ts
import { createWorkersAI } from "workers-ai-provider";
import { openai } from "workers-ai-provider/openai";
import { streamText } from "ai";
const workersai = createWorkersAI({
binding: env.AI,
providers: [openai], // opt-in; enables third-party routing
});
const result = streamText({
model: workersai("openai/gpt-5.6-luna"), // routed through AI Gateway
prompt: "Hello",
});
```
After some investigation by Opus, turns out it's because the gpt-5.6 class of models only support the OpenAI Response API wire format, but the `workers-ai-provider/openai` provider only does the OpenAI Completions API wire format.
The workaround was to use a custom provider
```ts
import { createOpenAI } from "@ai-sdk/openai";
/**
* `gpt-5.6-luna` only accepts the Responses API wire format, while the stock
* `workers-ai-provider/openai` plugin builds models with `.chat()`.
*/
const openaiResponses: ProviderPlugin = {
wireFormat: "openai",
create: ({ modelId, fetch, baseURL }) =>
createOpenAI({ apiKey: "unused", fetch, ...(baseURL ? { baseURL } : {}) }).responses(modelId),
};
const workersai = createWorkersAI({
binding: env.AI,
providers: [openaiResponses], // custom provider
});
```
Contributor guide
Research direction
Start with the workers-ai-provider/openai entry point and the third-party models via AI Gateway example linked in the issue. Compare the stock provider's Completions API behavior with the custom Responses API provider shown, then verify that the streamText example works with openai/gpt-5.6-luna.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100