genkitx-aws-bedrock
    Preparing search index...

    Interface LambdaOptions<C, T>

    Options for configuring the Lambda handler

    interface LambdaOptions<C extends ActionContext = ActionContext, T = unknown> {
        contextProvider?: ContextProvider<C, T>;
        cors?: boolean | CorsOptions;
        debug?: boolean;
        onError?: (
            error: Error,
        ) =>
            | { message: string; statusCode: number }
            | Promise<{ message: string; statusCode: number }>;
        streaming?: boolean;
    }

    Type Parameters

    Index

    Properties

    contextProvider?: ContextProvider<C, T>

    Context 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:

    • method: HTTP method ('GET', 'POST', etc.)
    • headers: Lowercase headers from the request
    • input: Parsed request body

    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
    );
    cors?: boolean | CorsOptions

    CORS configuration. Set to false to disable CORS headers.

    { origin: '*', methods: ['POST', 'OPTIONS'] }
    
    debug?: boolean

    Whether to log incoming events (for debugging).

    false
    
    onError?: (
        error: Error,
    ) =>
        | { message: string; statusCode: number }
        | Promise<{ message: string; statusCode: number }>

    Custom error handler for transforming errors before response.

    streaming?: boolean

    Whether 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.

    false
    
    export const handler = onCallGenkit(
    { streaming: true },
    myStreamingFlow
    );