> @picahq/ai

Install the Pica AI package to unlock powerful tools for the Vercel AI SDK

The Pica AI SDK is a powerful tool that allows you connect Pica with Vercel’s AI SDK for enhanced AI capabilities.

Installation

Install the Pica AI package:

npm install @picahq/ai

Examples

Install the required packages:

npm install ai openai @picahq/ai

Here’s an example of using Pica with OpenAI in a Next.js API route:

import { openai } from "@ai-sdk/openai";
import { convertToCoreMessages, streamText } from "ai";
import { Pica } from "@picahq/ai";

export async function POST(request: Request) {
  const { messages } = await request.json();

  const pica = new Pica(process.env.PICA_SECRET_KEY as string);

  const systemPrompt = await pica.generateSystemPrompt();

  const stream = streamText({
    model: openai("gpt-4o"),
    system: systemPrompt,
    tools: { ...pica.oneTool },
    messages: convertToCoreMessages(messages),
    maxSteps: 5,
  });

  return (await stream).toDataStreamResponse();
}

Demo

@picahq/onetool-demo

View on GitHub