Prerequisites
Before installing ToolKit, you’ll need:- Pica Account - Free account for managing integrations
- Vercel AI SDK - Version 5.0.0 or higher with your provider’s package
- LLM Provider & API Key – You’ll need an API key from your preferred LLM provider (such as OpenAI, Anthropic, Google, xAI, Groq, Mistral, Cohere, etc.).
Supported providers include: OpenAI, Anthropic, Google, xAI, Groq, Mistral, Cohere, and many more.
Installation
Quick Start
1
Get your API key
- Create a Pica account (free to sign up)
- Navigate to API keys
- Create a new API key and set it as an environment variable:
.env
2
Connect an integration
Go to the Connections page and connect an integration (e.g., Gmail, Slack, Google Calendar). You’ll need at least one connection for your agent to interact with.
3
Initialize the ToolKit
Create a new
Pica
instance in your API route or server component:app/api/chat/route.ts
Configuration
ThePica
class accepts an API key and an optional configuration object:
Configuration Options
Array of connection keys to enable. Set to
["*"]
to enable all connections, or specify individual connection keys from your connections page. You can also programmatically get the connection keys from the List Connections API.Array of action IDs to enable. Set to
["*"]
to enable all actions, or specify individual action IDs from the available actions table.Control which HTTP methods the agent can use:
"read"
- Only GET requests (read-only access)"write"
- POST, PUT, PATCH requests (create/update operations)"admin"
- All HTTP methods including DELETE
Filter connections by a specific identity value (e.g., user ID, team ID). Use with
identityType
for multi-tenant applications.Specify the type of identity for connection filtering. Works with
identity
parameter.Enable AuthKit integration to allow users to connect new integrations through your agent. Adds the
promptToConnectIntegration
tool.Custom Pica API server URL for enterprise or development environments.
Additional HTTP headers to include in all API requests.
Core Methods
tools()
Returns a ToolSet compatible with Vercel AI SDK’s tools
parameter. This is the primary way to give your agent access to Pica’s integration capabilities.
listPicaConnections
- Lists all available connections (whenconnectors: ["*"]
)searchPlatformActions
- Searches for actions on a specific platformgetActionsKnowledge
- Retrieves detailed knowledge about specific actionsexecute
- Executes an action with the provided parameterspromptToConnectIntegration
- Prompts user to connect an integration (whenauthkit: true
)
systemPrompt
Returns the generated system prompt that instructs the agent on how to use Pica tools effectively.
generateSystemPrompt(userPrompt?, separator?)
Combines your custom system prompt with Pica’s system prompt. Useful when you have specific instructions for your agent.
Your custom system prompt to prepend
Separator between your prompt and Pica’s prompt
getConnectedIntegrations()
Retrieves all connected integrations for the configured scope.
getAvailableConnectors()
Retrieves all available connectors in Pica (150+ integrations).
getAvailableActions(platform)
Retrieves all available actions for a specific platform.
Usage Patterns
Standard Agent
A standard agent with full access to execute actions:app/api/chat/route.ts
Read-Only Agent
Restrict the agent to read-only operations:Scoped to Specific Connections
Limit the agent to specific connections:Multi-Tenant Agent
Filter connections by user identity:app/api/chat/route.ts
With AuthKit Integration
Allow users to connect new integrations through your agent:This feature works best when your application also uses AuthKit to let users connect integrations directly through your UI. The
promptToConnectIntegration
tool informs users they need to connect an integration, and AuthKit provides the interface to do so.Custom System Prompt
Combine your instructions with Pica’s:Complete Example
Here’s a complete Next.js API route with all the features:app/api/chat/route.ts
Demo Application
See a complete working example with user interface:ToolKit Demo
Interactive demo chat application showcasing Pica ToolKit with Vercel AI SDK
TypeScript Support
The ToolKit is written in TypeScript and includes full type definitions:Best Practices
Start with specific connections
Start with specific connections
Instead of
connectors: ["*"]
in production, specify exact connection keys. This reduces the agent’s context window and improves performance.Use permissions strategically
Use permissions strategically
Set appropriate permission levels based on your use case:
- Customer-facing agents: Use
"read"
or"write"
to prevent destructive operations - Internal automation: Use
"admin"
for full control
Combine with step limits
Combine with step limits
Prevent infinite loops by setting
stopWhen
in your Vercel AI SDK configuration:Handle multi-tenancy
Handle multi-tenancy
Always filter by identity in multi-user applications:
Monitor API usage
Monitor API usage
Each tool execution counts as an API request. Monitor usage in your Pica dashboard and view request activity in your logs.
Troubleshooting
No connections available
No connections available
Problem: Agent reports no connections are available.Solutions:
- Verify you’ve connected integrations in the Pica dashboard
- Check that
connectors
is set correctly (use["*"]
to enable all) - If using
identity
filtering, ensure the identity value matches your connections
Actions not executing
Actions not executing
Problem: Agent finds actions but can’t execute them.Solutions:
- Ensure
actions: ["*"]
or specific action IDs are configured - Check
permissions
level allows the required HTTP method - Verify the connection has proper authentication (re-authenticate if needed)
- Check for error messages in the agent’s response
System prompt too long
System prompt too long
Problem: Token limit exceeded due to large system prompt.Solutions:
- Reduce the number of connections with specific
connectors
array - Limit actions with specific
actions
array - Use a model with larger context window (e.g., GPT-5)
Authentication errors
Authentication errors
Problem: Getting 401 or authentication errors.Solutions:
- Verify
PICA_SECRET_KEY
environment variable is set correctly - Check API key is valid in settings
- Ensure connections are properly authenticated (check connection status)