{"id":10934,"library":"genkit-cli","title":"Genkit CLI","description":"Genkit is an open-source framework by Google for building and deploying AI-powered applications, available with JavaScript/TypeScript, Go, and Python SDKs. The `genkit-cli` package provides the command-line interface for interacting with the Genkit framework, facilitating development tasks such as project initialization, running local development servers, deploying flows, and inspecting traces. The current stable version of the JavaScript/TypeScript CLI is 1.32.0, with minor updates and release candidates released frequently, indicating active development. Key differentiators include its multi-language SDK support, integration with Google's AI services (like Vertex AI and Google GenAI), and a local development UI for visualizing AI application flows and traces.","status":"active","version":"1.32.0","language":"javascript","source_language":"en","source_url":"https://github.com/firebase/genkit","tags":["javascript","genkit","ai","genai","generative-ai"],"install":[{"cmd":"npm install genkit-cli","lang":"bash","label":"npm"},{"cmd":"yarn add genkit-cli","lang":"bash","label":"yarn"},{"cmd":"pnpm add genkit-cli","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[],"quickstart":{"code":"# 1. Install the Genkit CLI globally\nnpm install -g genkit-cli\n\n# 2. Initialize a new Genkit project (select 'TypeScript' and a plugin like 'Google AI')\n# This creates a genkit.ts config file and boilerplate.\ngenkit init\n\n# 3. Configure your Genkit project and define a simple flow (e.g., in src/index.ts)\n# Make sure to set environment variables like GOOGLE_API_KEY or GEMINI_API_KEY.\n# For example, in a .env file or by exporting:\n# export GOOGLE_API_KEY=\"YOUR_API_KEY\"\n\n// src/index.ts (example configuration and flow)\nimport { configureGenkit, defineFlow, generate, z } from '@genkit-ai/core';\nimport { googleGenai } from '@genkit-ai/google-genai';\n\nexport default configureGenkit({\n  plugins: [\n    googleGenai({ apiKey: process.env.GOOGLE_API_KEY ?? '' }),\n  ],\n  flowRegistry: [\n    defineFlow(\n      {\n        name: 'helloWorldFlow',\n        inputSchema: z.string().describe('Name to greet'),\n        outputSchema: z.string().describe('Greeting message'),\n      },\n      async (name) => {\n        const response = await generate({ \n          model: 'gemini-pro', \n          prompt: `Hello, ${name}! Generate a short, friendly greeting.`, \n          config: { temperature: 0.7 }\n        });\n        return response.text();\n      }\n    ),\n  ],\n  logLevel: 'debug',\n  enableTracing: true,\n});\n\n// 4. Start the local Genkit development UI\n# This command starts your app in dev mode and launches a local web UI (typically http://localhost:3400 or 4000).\n# You can then interact with 'helloWorldFlow' via the UI.\ngenkit start -- npx tsx --watch src/index.ts\n\n# 5. Run a flow directly from the CLI (optional)\n# genkit flow:run helloWorldFlow '{\"name\": \"Genkit User\"}'","lang":"typescript","description":"This quickstart demonstrates how to install the Genkit CLI, initialize a new Genkit project, configure it with the Google AI plugin, define a simple AI flow, and then run it using the local development UI. It includes setting up environment variables for API keys and assumes a basic TypeScript project setup."},"warnings":[{"fix":"Review the `@genkit-ai/google-genai` plugin documentation for current model availability and migrate to recommended or alternative models.","message":"Some Imagen and Veo models were deprecated in `genkit-cli` v1.32.0 and later versions of `@genkit-ai/google-genai` plugin. Users relying on these specific models should migrate to supported alternatives.","severity":"deprecated","affected_versions":">=1.32.0"},{"fix":"Upgrade your Node.js environment to version 20 or higher (e.g., using `nvm install 20` and `nvm use 20`).","message":"The Genkit framework, particularly for Node.js/TypeScript, requires Node.js v20 or higher. Older Node.js versions (e.js., v16, v18) will result in errors and prevent `genkit-cli` from functioning correctly.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"If `curl -sL cli.genkit.dev | bash` fails, manually download the correct binary for your architecture from the Genkit GitHub releases or use `npm install -g genkit-cli` directly.","message":"The `genkit-cli` install script `cli.genkit.dev` may serve an incorrect binary (e.g., arm64 instead of x64) on certain macOS architectures, leading to installation failures.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Consult the Genkit documentation for the new middleware package and adapt any custom middleware implementations to align with the updated patterns.","message":"The introduction of a new `generate` middleware and `@genkit-ai/middleware` package in `v1.33.0-rc.0` (and subsequent stable releases) may necessitate refactoring for existing users who implemented custom middleware patterns. While not strictly a breaking change in the CLI itself, it signals evolving API patterns within the Genkit ecosystem.","severity":"gotcha","affected_versions":">=1.33.0-rc.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Run `npm install -g genkit-cli` to install the CLI globally. If the issue persists, ensure your shell's PATH includes the directory where npm installs global packages.","cause":"The `genkit-cli` package was not installed globally, or the global npm bin directory is not in your system's PATH.","error":"genkit: command not found"},{"fix":"Stop the conflicting process, or specify a different port for the Genkit UI using the `--port` or `-p` option, e.g., `genkit start --port 4001 -- npx tsx src/index.ts`.","cause":"The default port for the Genkit Developer UI (often 3400 or 4000) is already being used by another process on your system.","error":"Error: listen EADDRINUSE: address already in use :::3400 (or other port)"},{"fix":"Obtain an API key from your model provider (e.g., Google AI Studio for Gemini). Set it as an environment variable before running Genkit, for example: `export GOOGLE_API_KEY='YOUR_API_KEY'`.","cause":"The Genkit configuration (e.g., in `genkit.ts`) requires an API key for the chosen AI model provider (e.g., Google AI), but it was not provided or correctly loaded from environment variables.","error":"No Google AI API key was provided. Please pass in a valid API key through the 'apiKey' field."},{"fix":"Ensure your `package.json` has `\"type\": \"module\"` and your `tsconfig.json` targets `ES2020` or higher with `\"module\": \"NodeNext\"` or `\"ESNext\"`. Use `npx tsx` for direct execution of TypeScript files in development, or compile to ESM and run.","cause":"This often indicates a module resolution issue, potentially an ESM/CommonJS conflict, or an incorrect import statement when trying to use `@genkit-ai/core` in a TypeScript/Node.js environment not correctly configured for ESM.","error":"TypeError: (0 , _core.configureGenkit) is not a function"}],"ecosystem":"npm"}