OptionalcontextContext provider that parses request data and returns context for the flow. This follows the same pattern as express, next.js, and other Genkit integrations.
The context provider receives a RequestData object containing:
Return an ActionContext object that will be available via getContext() in the flow. Throw UserFacingError for authentication/authorization failures.
import { UserFacingError } from 'genkit';
const authProvider: ContextProvider = async (req) => {
const token = req.headers['authorization'];
if (!token) {
throw new UserFacingError('UNAUTHENTICATED', 'Missing auth token');
}
const user = await verifyToken(token);
return { auth: { user } };
};
export const handler = onCallGenkit(
{ contextProvider: authProvider },
myFlow
);
OptionalcorsCORS configuration. Set to false to disable CORS headers.
OptionaldebugWhether to log incoming events (for debugging).
OptionalonCustom error handler for transforming errors before response.
OptionalstreamingWhether to return a streaming Lambda handler instead of a standard one.
When true, onCallGenkit returns a StreamifyHandler that uses
awslambda.streamifyResponse for real incremental streaming via
Lambda Function URLs with InvokeMode: RESPONSE_STREAM.
The streaming handler is compatible with streamFlow from genkit/beta/client.
For clients sending Accept: text/event-stream, it writes SSE chunks
incrementally. Otherwise it falls back to a buffered JSON response.
Options for configuring the Lambda handler