-
Notifications
You must be signed in to change notification settings - Fork 615
Open
Labels
Description
Workaround can be found in: https://github.com/pavelgj/genkit-3968-workaround
Repro code:
package.json
{
"name": "cloudflare-test1",
"version": "0.0.0",
"private": true,
"scripts": {
"deploy": "wrangler deploy",
"dev": "wrangler dev",
"start": "wrangler dev"
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20251217.0",
"genkit-cli": "^1.26.0",
"typescript": "^5.9.3",
"wrangler": "^4.55.0"
},
"dependencies": {
"@genkit-ai/google-genai": "^1.26.0",
"genkit": "^1.26.0"
}
}tsconfig.json
{
"compilerOptions": {
"target": "es2021",
"lib": ["es2021"],
"module": "es2022",
"moduleResolution": "node",
"types": ["@cloudflare/workers-types"],
"resolveJsonModule": true,
"allowJs": true,
"checkJs": false,
"noEmit": true,
"isolatedModules": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
},
"include": ["src"]
}wrangler.toml
name = "cloudflare-test1"
main = "src/index.ts"
compatibility_date = "2024-09-23"
compatibility_flags = [ "nodejs_compat" ]src/index.ts
import { googleAI } from "@genkit-ai/google-genai";
import { genkit } from "genkit";
const ai = genkit({
plugins: [googleAI()],
model: googleAI.model("gemini-2.5-flash", {
temperature: 0.8,
}),
});
export interface Env {}
export default {
async fetch(
request: Request,
env: Env,
ctx: ExecutionContext
): Promise<Response> {
const { text } = await ai.generate({
prompt: `Tell me a joke about ${
((await request.json()) as any)?.subject ?? "banana"
}`,
});
return new Response(JSON.stringify({ message: text }), {
headers: {
"content-type": "application/json;charset=UTF-8",
},
});
},
};Run: npm run dev
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done