Pre-requisites
Ensure you meet the following requirements to get started with the Cashfree Agent Toolkit:- Create a Cashfree Merchant Account.
- Log in to the Merchant Dashboard and generate App ID and Secret Key. Learn how to generate API keys.
- Ensure Node.js version 18 or later is installed.
Installation
Install the toolkit using your preferred package manager:Framework support
The toolkit supports multiple frameworks, exposed through sub-paths:| Framework | Import Path | Description |
|---|---|---|
| OpenAI | @cashfreepayments/agent-toolkit/openai | For Chat Completions API and Agents SDK |
| LangChain | @cashfreepayments/agent-toolkit/langchain | For LangChain agents |
| Vercel AI SDK | @cashfreepayments/agent-toolkit/ai-sdk | For Vercel’s AI SDK |
Usage
Each toolkit is initialised with your Cashfree credentials and environment configuration.Available tools
The toolkit provides the following tools for payment operations:| Tool | Description |
|---|---|
createOrder | Create a new order |
getOrder | Retrieve details of an existing order |
terminateOrder | Terminate or cancel an order |
createRefund | Initiate a refund for an order |
getAllRefunds | List all refunds for an order |
getRefund | Retrieve details of a specific refund |
orderPayUsingUpi | Pay for an order using UPI |
orderPayUsingNetbanking | Pay for an order using Netbanking |
orderPayUsingApp | Pay for an order using a payment app |
orderPayUsingPlainCard | Pay for an order using a plain card |
orderPayUsingSavedCard | Pay for an order using a saved card |
createCustomer | Create a new customer in Cashfree |
fetchCustomerInstruments | Fetch saved payment instruments for a customer |
Framework-specific examples
The following examples demonstrate how to use the toolkit with each supported framework.- OpenAI
- LangChain
- Vercel AI SDK
The OpenAI integration works with both Chat Completions API and the Agents SDK.For detailed OpenAI documentation, see the OpenAI integration guide.
Initialise the toolkit
Set up the Cashfree Agent Toolkit with your credentials and environment configuration.With Chat Completions API
Use the toolkit with OpenAI’s Chat Completions API by passing the tools as JSON schema.With OpenAI Agents SDK
Integrate the toolkit with OpenAI’s Agents SDK for building autonomous payment agents.Example payment agent
The following example demonstrates a complete payment agent using the OpenAI Agents SDK:Resources
Explore additional resources to help you get started with the Cashfree Agent Toolkit.GitHub Repository
View the source code, report issues, and contribute to the toolkit.
npm Package
View the package on npm for installation and version details.