Flowise Provider
The Flowise provider allows you to easily integrate Flowise chatflows with your applications using the AI SDK.
Setup
The Flowise provider is available in the @ahmedrowaihi/flowise-vercel-ai-sdk-provider module. You can install it with:
pnpm add @ahmedrowaihi/flowise-vercel-ai-sdk-provider
Provider Instance
You can import the provider factory from @ahmedrowaihi/flowise-vercel-ai-sdk-provider:
import { createFlowiseProvider } from '@ahmedrowaihi/flowise-vercel-ai-sdk-provider';Quick Start
Using a Reusable Provider
Create a file called .env.local and add your Flowise configuration:
FLOWISE_BASE_URL=https://your-flowise-instance.comFLOWISE_API_KEY=your_api_key_optionalimport { createFlowiseProvider } from '@ahmedrowaihi/flowise-vercel-ai-sdk-provider';import { generateText } from 'ai';
const flowise = createFlowiseProvider({ baseUrl: process.env.FLOWISE_BASE_URL!, apiKey: process.env.FLOWISE_API_KEY,});
const { text } = await generateText({ model: flowise('your-chatflow-id'), prompt: 'Write a vegetarian lasagna recipe for 4 people.',});Using a One-shot Model
import { createFlowiseModel } from '@ahmedrowaihi/flowise-vercel-ai-sdk-provider';import { generateText } from 'ai';
const { text } = await generateText({ model: createFlowiseModel({ baseUrl: process.env.FLOWISE_BASE_URL!, apiKey: process.env.FLOWISE_API_KEY, chatflowId: 'your-chatflow-id', }), prompt: 'Write a vegetarian lasagna recipe for 4 people.',});Streaming Example
import { streamText } from 'ai';import { createFlowiseProvider } from '@ahmedrowaihi/flowise-vercel-ai-sdk-provider';
const flowise = createFlowiseProvider({ baseUrl: process.env.FLOWISE_BASE_URL!, apiKey: process.env.FLOWISE_API_KEY,});
const result = streamText({ model: flowise('your-chatflow-id'), prompt: 'Write a story about a robot learning to cook.',});
return result.toDataStreamResponse();More Information
For more information and advanced usage, see the Flowise provider documentation.