@mayrlabs/ai-flow-runner
v0.4.0
Published
BYOAK Flow runner for MayR Labs
Downloads
14
Readme
@mayrlabs/ai-flow-runner
A lightweight abstraction layer over Genkit AI flows for MayR Labs apps. It simplifies defining typed AI prompts and flows using Google Gemini and Zod schemas.
🚀 Features
- 🧠 Define prompts and flows in a single step
- ✅ Type-safe with
zod - 🛠️ Powered by
genkitand Google Gemini - 🔁 Reusable across all MayR Labs projects
📦 Installation
This package is meant for internal use across MayR Labs projects.
npm install @mayrlabs/ai-flow-runnerUsage example
'use server';
import { createFlowRunner } from '@mayrlabs/ai-flow-runner';
import { z } from 'genkit';
const inputSchema = z.object({
topic: z.string().describe('The topic of the article.'),
});
const outputSchema = z.object({
titles: z.array(z.string()).describe('A list of 5 catchy and SEO-friendly article titles.'),
});
export type GenerateTitleSuggestionsInput = z.infer<typeof inputSchema>;
export type GenerateTitleSuggestionsOutput = z.infer<typeof outputSchema>;
export async function generateTitleSuggestions(
input: GenerateTitleSuggestionsInput,
apiKey: string
): Promise<GenerateTitleSuggestionsOutput> {
const flow = createFlowRunner(apiKey, {
name: 'generateTitleSuggestions',
inputSchema,
outputSchema,
prompt: `You are an expert copywriter specialising in creating catchy and SEO-friendly article titles.
Based on the provided topic, generate a list of 5 alternative titles.
Topic: {{{topic}}}`,
});
return flow(input);
}
API
createFlowRunner(apiKey, config)
Creates and returns a Genkit flow instance.
Parameters:
- apiKey: string - Your Google AI API Key
- config: FlowConfig<Input, Output>
interface FlowConfig<Input, Output> {
name: string;
inputSchema: z.ZodType<Input>;
outputSchema: z.ZodType<Output>;
prompt: string;
}Internal Package
This is a private utility for MayR Labs apps.
Do not use outside the MayR Labs ecosystem without permission. We're watching 👀
Roadmap
- Add support for multiple models (Claude, Mistral)
- Token usage tracking
- Prompt templating
- Prompt validation
- Flow caching
🧾 License MIT — but internal to MayR Labs. External usage not supported (yet).
