Note: For a complete list of the tools that PayPal’s agent toolkit includes, see the agent tools reference.
Key features
The agent toolkit from PayPal enables you to:- Integrate with PayPal APIs to access orders, invoices, subscriptions, shipment tracking, transaction details, and dispute management through pre-built functions.
- Develop with your preferred tools, including:
- AI agent frameworks, such as Amazon Bedrock, CrewAI, LangChain, Model Context Protocol (MCP), OpenAI’s Agents SDK, and Vercel’s AI SDK
- Multiple languages, including TypeScript and Python
- Build custom agent capabilities to extend core PayPal features and connect with other toolkits to create multi-step agent workflows.
Best practices
To have the best integration experience, use these tips:- Sandbox environment: Always use the sandbox environment for initial testing to avoid real transactions.
- API keys: Keep your client ID, client secret, and API keys secure. Do not hard-code them in your source files.
- Environment variables: Use environment variables to manage sensitive data.
- Error handling: Implement error handling to ensure reliable integration.
- System prompts: Use well-defined system prompts to control the behavior of the agent.
1. Set up your environment
To prepare for an integration, set up your environment first.Python
Before you start, confirm that you have the prerequisites:- Python 3.11 or higher
- pip (Python package manager)
- A PayPal developer account for API credentials
- Set up a Python virtual environment.
- Install the required dependencies.
Note: For details about dependencies for a specific platform and the requirements.txt file, see the section for that platform on this page.
- Install the agent toolkit.
TypeScript
- Download and install Node.js version 18 or later from the official Node.js website.
- To install the agent toolkit, run
npm install @paypal/agent-toolkit
, or download the package from the GitHub repo. - Get your PayPal account’s client ID and secret from PayPal Developer Dashboard. You’ll need them to configure this library.
2. Integrate
PayPal’s agent toolkit supports Amazon Bedrock, CrewAI, LangChain, Model Context Protocol (MCP), OpenAI’s Agents SDK, and Vercel’s AI SDK. It works with LLM providers that support function calling and is compatible with TypeScript and Python. For integration steps, see the section for your AI platform: For information about setting up the front end for testing any of these integrations, see Build the front end.Amazon Bedrock
Complete the following steps to integrate the agent toolkit from PayPal with Amazon Bedrock. Amazon Bedrock passes the agent toolkit as a list of tools.- Set your environment variables by creating a .env file in
/typescript/examples/bedrock/
.
-
Add prompts to
userMessage
in/typescript/examples/bedrock/index.ts
. - Import PayPal’s agent toolkit into your code.
Note: Update placeholder values, likeYOUR_PAYPAL_CLIENT_ID
andYOUR_PAYPAL_SECRET
, with the app credentials from PayPal Developer Dashboard.
- Create a message, and send it to the model.
- Call tools to complete the user’s request.
CrewAI SDK
Complete the following steps to integrate the agent toolkit from PayPal with CrewAI. CrewAI passes the agent toolkit as a list of tools.- Set your environment variables.
Note: Update placeholder values, likeYOUR_PAYPAL_CLIENT_ID
andYOUR_PAYPAL_SECRET
, with the app credentials from PayPal Developer Dashboard.
- Install CrewAI SDK.
Recommended: Create a file called requirements.txt and add these dependencies to that file:
paypal-agent-toolkit
# CrewAI
crewai==0.76.2
crewai-tools==0.13.2
- Import PayPal Agent toolkit into your code.
Note: Update placeholder values, likeYOUR_PAYPAL_CLIENT_ID
andYOUR_PAYPAL_SECRET
, with the app credentials from PayPal Developer Dashboard.
LangChain AI SDK
Complete the following steps to integrate the agent toolkit from PayPal with the LangChain AI SDK. LangChain AI SDK passes the agent toolkit as a list of tools.- Set your environment variables:
Note: Update placeholder values, likeYOUR_PAYPAL_CLIENT_ID
andYOUR_PAYPAL_SECRET
, with the app credentials from PayPal Developer Dashboard.
- Install LangChain AI SDK.
Recommended: Create a file called requirements.txt and add these dependencies to that file:
paypal-agent-toolkit
# LangChain
langchain==0.3.23
langchain-openai==0.2.2
- Import PayPal Agent toolkit into your code.
Note: Update placeholder values, likeYOUR_PAYPAL_CLIENT_ID
andYOUR_PAYPAL_SECRET
, with the app credentials from PayPal Developer Dashboard.
Model Context Protocol
Model Context Protocol (MCP) supports managing and passing relevant information to models with appropriate context, so they operate properly within a given scope. Using this technology, PayPal developed an MCP server to enable merchants to use natural language with their favorite MCP client. To install the MCP server in a local configuration:-
Update the configuration file in your favorite MCP client:
- Open the MCP client.
- In the configuration settings for the client, locate the external tools or connectors configuration section, and add the PayPal connector configuration that follows this procedure. In Claude, for example, you add this to
~/Claude/claude_desktop_config.json
.
Note: Update placeholder values, like
YOUR_PAYPAL_CLIENT_ID
andYOUR_PAYPAL_SECRET
, with the app credentials from PayPal Developer Dashboard. Alternatively, you can set thePAYPAL_ACCESS_TOKEN
as an environment variable. You also can pass it as an argument using--access-token
inargs
.
Set thePAYPAL_ENVIRONMENT
toSANDBOX
for testing orPRODUCTION
for your production environment.- To update the configuration, run:
-
Test the integration:
- Quit and restart the MCP client to apply your changes.
- Ask the MCP client to perform one of the supported tasks. For example, ask the MCP client to list your PayPal invoices for the last month.
Tip: If your test doesn’t produce the results you expect, try these ideas from the Model Context Protocol site.
OpenAI Agents SDK
Complete the following steps to integrate PayPal’s agent toolkit with OpenAI’s Agents SDK. Agents SDK passes the agent toolkit as a list of tools.Generate OpenAI API keys
Complete the following steps to generate and store your OpenAI keys to use in your integration with PayPal’s agent toolkit.- Create an OpenAI account, and complete all registration steps.
- Generate your API keys:
- Log into OpenAI, and navigate to the API Keys section of your account.
- Select Create a new secret key.
- Save the generated key securely. You use this key in your
env.local
file for your agent toolkit integration.
Complete the OpenAI integration
Complete the following steps to integrate PayPal’s agent toolkit with OpenAI’s Agents SDK. Agents SDK passes the agent toolkit as a list of tools.- Import PayPal’s agent toolkit into your code.
Note: Update placeholder values, likeYOUR_PAYPAL_CLIENT_ID
andYOUR_PAYPAL_SECRET
, with the app credentials from PayPal Developer Dashboard.
- You can use the agent toolkit’s functions and other tools as your integration requires.
Vercel AI SDK
Complete the following steps to integrate PayPal’s agent toolkit with Vercel’s AI SDK. Vercel’s AI SDK passes the agent toolkit as a list of tools.- Set your environment variables.
Note: Update placeholder values, likeYOUR_PAYPAL_CLIENT_ID
andYOUR_PAYPAL_SECRET
, with the app credentials from PayPal Developer Dashboard.
- Install Vercel AI SDK.
- Import PayPal’s agent toolkit into your code.
Note: Update placeholder values, likeYOUR_PAYPAL_CLIENT_ID
andYOUR_PAYPAL_SECRET
, with the app credentials from PayPal Developer Dashboard.
- Use PayPal’s agent toolkit’s functions and other tools as your integration requires.
3. Build the front end
Using the Next.js framework, complete the following tasks.Create a Next.js project
If you don’t have a Next.js app already, create one.Create a chat interface
Modify app/page.tsx to create a chat interface for interacting with the PayPal agent.4. Test the integration
After you finish the integration, test it by setting up an API route. Execute this code inapp/api/chat/route.ts
.
5. Start the application
To start the application, executenpm run dev
, and visit http://localhost:3000.