npm version Pica LangChain Banner

@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.

Configuration

The Pica SDK can be configured with the following options:
OptionTypeRequiredDefaultDescription
serverUrlStringNohttps://api.picaos.comURL for self-hosted Pica server.
connectorsString[]NoList of connector keys to filter by. Pass [”*”] to initialize all available connectors, or specific connector keys to filter. If empty, no connections will be initialized
actionsString[]NoAll actionsList of action ids to filter by
permissions"read" | "write" | "admin"No"admin"Permissions for the Pica client. "read" will only allow GET requests, "write" will allow POST/PUT/PATCH requests, and "admin" will allow all methods.
identityStringNoNoneFilter connections by specific identifier.
identityType"user", "team", "project", "organization"NoNoneFilter connections by identity type.
authkitBooleanNofalseIf true, the SDK will use Authkit to connect to prompt the user to connect to a platform that they do not currently have access to
knowledgeAgentBooleanNofalseIf true, the SDK will never execute actions, but will use Pica’s knowledge to generate code. If true, use pica.intelligenceTool instead of pica.oneTool
knowledgeAgentConfigObjectNo{ includeEnvironmentVariables: true }Configuration for the Knowledge Agent. If includeEnvironmentVariables is true, the SDK will return a reminder to include environment variables in the output
const pica = new Pica(process.env.PICA_SECRET_KEY!, {
  serverUrl: "https://my-hosted-instance.com",
  connectors: [
    "test::gmail::default::0fc9f64d309349be8cccb63a02e16c2a",
    "test::notion::default::0fc9f64d309349be8cccb63a02e16c2a",
    "test::postgres::default::0fc9f64d309349be8cccb63a02e16c2a",
  ]
});

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!);

  const systemPrompt = await pica.generateSystemPrompt();

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

  return (await stream).toDataStreamResponse();
}

Demo

You can now use the chat interface directly in the Pica Dashboard.

@picahq/onetool-demo

View on GitHub
Want to learn more about Vercel AI SDK? Read the docs.