Genkit JS API reference
    Preparing search index...

    Function fetchHandlers

    • Returns a Fetch handler for multiple actions with path-based routing. Express-like API: pass actions and optional path prefix, then call the returned handler with the request.

      Parameters

      • actions: (Action<any, any, any> | ActionWithOptions<any, any, any>)[]

        Array of actions (or ActionWithOptions) to expose; each is routed by path (action name or options.path)

      • OptionalpathPrefix: string

        Optional path prefix to strip from the URL (e.g., '/api')

      Returns (request: Request) => Promise<Response>

      A handler function that takes a Request and returns a Promise

      import { fetchHandlers } from '@genkit-ai/fetch';

      // Mount all actions under /api - routes by path (e.g. POST /api/hello, POST /api/models/gpt5)
      app.all('/api/*', (c) => fetchHandlers(actions, '/api')(c.req.raw));