Use this file to discover all available pages before exploring further.
Pica’s ToolKit works seamlessly with Mastra agents and workflows. Since Mastra uses the Vercel AI SDK under the hood, you can give your Mastra agents access to 200+ integrations with intelligent action execution powered by Pica’s knowledge base.
For complete configuration options (connectors, actions, permissions, identity scoping), see the Vercel AI SDK integration documentation. This page focuses on Mastra-specific usage patterns.
import { Agent } from '@mastra/core';import { Pica } from '@picahq/toolkit';// Initialize Pica ToolKitconst pica = new Pica(process.env.PICA_SECRET_KEY!, { connectors: ["*"], // Access all connected integrations actions: ["*"] // Access all available actions});// Create a Mastra agent with Pica toolsconst integrationAgent = new Agent({ name: 'integration-assistant', instructions: pica.systemPrompt, // Use Pica's system prompt model: { provider: 'openai', name: 'gpt-5' }, tools: pica.tools() // Load Pica tools});// Generate a responseconst result = await integrationAgent.generate( 'Send an email summary of today\'s meetings to the team');console.log(result.text);
The simplest setup - an agent with full access to integrations:
Example
import { Agent } from '@mastra/core';import { Pica } from '@picahq/toolkit';const pica = new Pica(process.env.PICA_SECRET_KEY!, { connectors: ["*"], actions: ["*"], permissions: "admin" // Full access});const agent = new Agent({ name: 'automation-agent', instructions: pica.systemPrompt, model: { provider: 'openai', name: 'gpt-5' }, tools: pica.tools()});// Use the agentconst response = await agent.generate( 'Create a new lead in Salesforce for John Doe at Acme Corp');
Combine Pica tools with Mastra’s memory capabilities:
Example
import { Agent } from '@mastra/core';import { Pica } from '@picahq/toolkit';const pica = new Pica(process.env.PICA_SECRET_KEY!, { connectors: ["*"], actions: ["*"]});const agent = new Agent({ name: 'context-aware-agent', instructions: pica.generateSystemPrompt( 'You are a helpful assistant with access to user integrations. Remember context from previous conversations.' ), model: { provider: 'anthropic', name: 'claude-3-5-sonnet-20241022' }, tools: pica.tools(), enableMemory: true // Enable Mastra memory});// Agent remembers previous contextawait agent.generate('What integrations do I have connected?', { threadId: 'user-123'});await agent.generate('Send an email using the last one mentioned', { threadId: 'user-123' // Same thread for context});
const pica = new Pica(process.env.PICA_SECRET_KEY!, { connectors: ["*"], actions: ["*"], permissions: "read" // Read-only access});const readOnlyAgent = new Agent({ name: 'data-retrieval-agent', instructions: pica.systemPrompt, model: { provider: 'openai', name: 'gpt-5' }, tools: pica.tools()});// Can read data but not modifyawait readOnlyAgent.generate('Show me my last 5 Gmail emails');
Combine your agent’s personality with Pica’s integration instructions:
const pica = new Pica(process.env.PICA_SECRET_KEY!, { connectors: ["*"], actions: ["*"]});const customInstructions = `You are a friendly sales assistant named Sarah.Your goal is to help sales teams manage their leads and follow-ups efficiently.Always be professional and concise in your communications.`;const agent = new Agent({ name: 'sarah-sales-assistant', instructions: pica.generateSystemPrompt(customInstructions), model: { provider: 'openai', name: 'gpt-5' }, tools: pica.tools()});
Use Pica-powered agents within Mastra workflows for deterministic multi-step processes. This gives you the flexibility of agentic tool calling combined with the reliability of workflow orchestration.
Use memory for context
Enable Mastra’s memory features alongside Pica tools so your agent can reference previous conversations when executing integration actions.