For Workes & Pages, what is the name of the domain?
https://ai-worker-image-gen.dsgamer777.workers.dev
What is the error message?
{ “httpCode”: 400, “internalCode”: 5006, “message”: “AiError: Bad input: must be object”, “name”: “AiError”, “skipSentry”: true, “description”: “must be object” }
What is the issue or error you’re encountering
I want to use Workers AI with AI gateway, but I get error and can’t use them together. The worker was working until around 4 days ago, but it doesn’t work now for something reason.
What steps have you taken to resolve the issue?
- Re-deployed without change anything
- It didn’t fix.
- Re-deployed with latest wrangler
- It didn’t fix.
- Re-deployed with delete the gateway (AiOptions) section from code
- It worked without the error but I want to use the AI gateway.
- Re-created entire repository and deploy with latest wrangler
- It didn’t fix.
I read below examples but the code seems not wrong for me.
What are the steps to reproduce the issue?
- Create a project with wrangler.
Environment:
- Windows 10
- Node.js 20.15.0
- Wrangler 3.65.1
- Write below code into src/index.ts
export default {
async fetch(request: Request, env: Env): Promise<Response> {
// generate image
const response = await env.AI.run(
'@cf/lykon/dreamshaper-8-lcm',
{
prompt: 'star',
},
{
gateway: {
id: 'my-gateway-id',
skipCache: false,
cacheTtl: 3000,
},
}
);
return new Response(response, {
headers: {
'content-type': 'image/png',
},
});
},
} satisfies ExportedHandler<Env>;
-
Deploy with
npx wrangler deploy
-
When I access to the workers endpoint, It raises error like below.
At endpoint:
Error 1101 Worker threw exception
At AI gateway:
{ "httpCode": 400, "internalCode": 5006, "message": "AiError: Bad input: must be object", "name": "AiError", "skipSentry": true, "description": "must be object" }
At run Workers AI locally with npx wrangler dev:
AiExternal: Couldn't fetch external AI provider response (400, Bad Request)