The @inkeep/ai-sdk-provider package is a custom AI SDK provider that exposes Inkeep agents through the Vercel AI SDK. This lets you call your agents with generateText() and streamText().
import { generateText } from 'ai';import { createInkeep } from '@inkeep/ai-sdk-provider';const inkeep = createInkeep({ baseURL: process.env.INKEEP_AGENTS_RUN_API_URL, // Required, for local development this is typically http://localhost:3003 apiKey: '<your-agent-api-key>', // Created in the Agents Dashboard headers: { // Optional if you are developing locally and don't want to use an api key 'x-inkeep-agent-id': 'your-agent-id', 'x-inkeep-tenant-id': 'your-tenant-id', 'x-inkeep-project-id': 'your-project-id', },});const { text } = await generateText({ model: inkeep(), prompt: 'What is the weather in NYC?',});console.log(text);
import { streamText } from 'ai';import { createInkeep } from '@inkeep/ai-sdk-provider';const inkeep = createInkeep({ baseURL: process.env.INKEEP_AGENTS_RUN_API_URL, apiKey: '<your-agent-api-key>', // The agent ID is encoded in the API key headers: { 'x-emit-operations': 'true', // Enable tool event streaming },});const result = await streamText({ model: inkeep(), prompt: 'Plan an event in NYC',});for await (const chunk of result.textStream) { process.stdout.write(chunk);}
To receive tool call and result events in your stream, include the x-emit-operations header:
const inkeep = createInkeep({ baseURL: process.env.INKEEP_AGENTS_RUN_API_URL, apiKey: '<your-agent-api-key>', // The agent ID is encoded in the API key headers: { 'x-emit-operations': 'true', },});const result = await streamText({ model: inkeep(), prompt: 'Search for recent papers on AI',});for await (const event of result.fullStream) { switch (event.type) { case 'tool-call': console.log(`Calling: ${event.toolName}`); break; case 'tool-result': console.log(`Result: ${event.toolName}`); break; }}