Cloudflare DevelopersCD
Cloudflare Developers2y ago
33 replies
kNite

Hi, I have a problem with Cloudflare

Hi, I have a problem with Cloudflare Workers + Hono + Cloudflare AI, I have a route defined (i.e. /v1/chat/completions) and when the user triggers that route I try to run env.AI.run([model], [etc]), but I get this error:
TypeError: Cannot read properties of undefined (reading 'AI')
. This is my Env interface:

interface Env {
    AI: any;
}

const env = (globalThis as any).env as Env


Also tried removing the
const env = [...]
and running AI inside a function with
function exampleFunction(env: Env)
but it also didn't work.
Was this page helpful?