Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/genkit-ai/genkit/llms.txt

Use this file to discover all available pages before exploring further.

Genkit flows are plain functions. You choose how to expose them over HTTP — either with the built-in flow server or with a framework adapter like Express, Flask, or FastAPI. Once they are wrapped in an HTTP handler they can run anywhere: Cloud Run, Firebase Cloud Functions, Fly.io, AWS, bare-metal servers, or any container platform.

Two deployment patterns

Flow server

Zero-config: Genkit automatically wraps every registered flow as a POST /<flowName> endpoint. Best when you want to expose all flows quickly.

Framework adapter

Mount individual flows inside an existing Express, Flask, FastAPI, or net/http app. Best when you need full control over routes, middleware, and auth.

Flow server

The flow server is the fastest path to a running HTTP API. Each language has a slightly different API.
Use startFlowServer from @genkit-ai/express to start an Express server that exposes each flow at POST /<flowName>.
import { genkit } from 'genkit';
import { googleAI } from '@genkit-ai/google-genai';
import { startFlowServer } from '@genkit-ai/express';

const ai = genkit({ plugins: [googleAI()] });

const menuFlow = ai.defineFlow('menuSuggestion', async (theme: string) => {
  const { text } = await ai.generate(`Suggest a menu for a ${theme} restaurant.`);
  return text;
});

startFlowServer({
  flows: [menuFlow],
  port: 8080,
});
The server reads the PORT environment variable if port is not set, and defaults to 3400.

Framework adapter pattern

For more control — custom auth middleware, additional routes, or integration with an existing service — mount flows individually inside a framework you already use.
import { expressHandler } from '@genkit-ai/express';
import express from 'express';
import { UserFacingError } from 'genkit';
import type { ContextProvider, RequestData } from 'genkit/context';

const authProvider: ContextProvider<{ user: string }> = (req: RequestData) => {
  const token = req.headers['authorization'];
  if (!token) throw new UserFacingError('UNAUTHENTICATED', 'Missing auth token');
  return { user: verifyToken(token) };
};

const app = express();
app.use(express.json());

app.post('/menuSuggestion', expressHandler(menuFlow, { contextProvider: authProvider }));

app.listen(8080);

Disabling the dev reflection server in production

In development, Genkit starts a local reflection API server on port 4000 (used by the Dev UI). This server must not run in production.
Never run the Genkit reflection server (GENKIT_ENV=dev) in a production deployment. It exposes an unauthenticated API for inspecting and invoking all registered flows and actions.
Set the environment variable before starting your server:
export GENKIT_ENV=production
In Python and Go the reflection server is only started automatically when GENKIT_ENV=dev; removing that variable is sufficient.

Wire format

Every flow — regardless of language — accepts and returns a consistent JSON envelope:
// Request
{ "data": <your flow input> }

// Response
{ "result": <your flow output> }
Streaming responses use server-sent events:
data: {"message": <chunk>}
data: {"message": <chunk>}
data: {"result": <final output>}

Next steps

Firebase Cloud Functions

Deploy flows as HTTPS callable Firebase Functions.

Cloud Run

Run containerised Genkit apps on Google Cloud Run.

Observability

Traces, metrics, and logs for production Genkit apps.

Flows

Learn how flows work and how to define them.

Build docs developers (and LLMs) love