Skip to main content

Express Plugin

The @genkit-ai/express plugin provides utilities for exposing Genkit flows and actions as REST APIs via Express HTTP servers. This enables you to serve AI capabilities over HTTP with minimal configuration.

Installation

Quick Start

Express Handler

Expose a single flow as an HTTP endpoint:

Flow Server

Quickly expose multiple flows:
Flows are automatically exposed at:
  • POST http://localhost:3500/menuSuggestionFlow
  • POST http://localhost:3500/reviewAnalysisFlow

Features

Streaming Support

Flows automatically support streaming responses:

Authentication

Add authentication using context providers:
Custom authentication middleware:

Durable Streaming (Beta)

Persist stream state for reconnection:

Client Usage

Use the Genkit client library to call flows:

Reconnect to Durable Streams

Configuration

Flow Server Options

Express Handler Options

Complete Examples

REST API with Multiple Endpoints

Authenticated API with Rate Limiting

Production Setup with CORS and Helmet

Best Practices

Error Handling

Input Validation

Monitoring