// Require API key to match a specific value
export const handler = onCallGenkit(
{ contextProvider: requireApiKey('X-API-Key', process.env.API_KEY!) },
myFlow
);
// Or with a custom validation function
export const handler = onCallGenkit(
{
contextProvider: requireApiKey('X-API-Key', async (key) => {
const valid = await validateApiKey(key);
if (!valid) {
throw new UserFacingError('PERMISSION_DENIED', 'Invalid API key');
}
})
},
myFlow
);
Creates a context provider that requires an API key in a specific header.