Documentation Index Fetch the complete documentation index at: https://www.cashfree.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
The Cashfree Payments Agent Toolkit enables popular agent frameworks including LangChain, Vercel’s AI SDK, and OpenAI’s Agents SDK to integrate with Cashfree APIs through function calling. Build AI-powered payment agents that can create orders, process refunds, and manage customers programmatically.
Pre-requisites
Ensure you meet the following requirements to get started with the Cashfree Agent Toolkit:
Installation
Install the toolkit using your preferred package manager:
npm install @cashfreepayments/agent-toolkit
Framework support
The toolkit supports multiple frameworks, exposed through sub-paths:
Framework Import path Description OpenAI @cashfreepayments/agent-toolkit/openaiFor Chat Completions API and Agents SDK LangChain @cashfreepayments/agent-toolkit/langchainFor LangChain agents Vercel AI SDK @cashfreepayments/agent-toolkit/ai-sdkFor Vercel’s AI SDK
Usage
Each toolkit is initialised with your Cashfree credentials and environment configuration.
OpenAI
LangChain
Vercel AI SDK
import {
CashfreeAgentToolkit ,
CFEnvironment ,
} from '@cashfreepayments/agent-toolkit/openai' ;
const environment = CFEnvironment . SANDBOX ; // or PRODUCTION
const clientId = process . env . CASHFREE_CLIENT_ID ;
const clientSecret = process . env . CASHFREE_CLIENT_SECRET ;
const cashfree = new CashfreeAgentToolkit ( environment , clientId , clientSecret );
The toolkit provides the following tools for payment operations:
Tool Description createOrderCreate a new order getOrderRetrieve details of an existing order terminateOrderTerminate or cancel an order createRefundInitiate a refund for an order getAllRefundsList all refunds for an order getRefundRetrieve details of a specific refund orderPayUsingUpiPay for an order using UPI orderPayUsingNetbankingPay for an order using Netbanking orderPayUsingAppPay for an order using a payment app orderPayUsingPlainCardPay for an order using a plain card orderPayUsingSavedCardPay for an order using a saved card createCustomerCreate a new customer in Cashfree fetchCustomerInstrumentsFetch 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. Set up the Cashfree Agent Toolkit with your credentials and environment configuration. import {
CashfreeAgentToolkit ,
CFEnvironment ,
} from "@cashfreepayments/agent-toolkit/openai" ;
const cashfreeToolkit = new CashfreeAgentToolkit (
CFEnvironment . SANDBOX ,
process . env . CASHFREE_CLIENT_ID ,
process . env . CASHFREE_CLIENT_SECRET ,
);
With Chat Completions API Use the toolkit with OpenAI’s Chat Completions API by passing the tools as JSON schema. Chat Completions
Access individual tools
const completion = await openai . chat . completions . create ({
model: 'gpt-4o' ,
messages: [...],
tools: cashfreeToolkit . getTools (), // Returns JSON schema
});
With OpenAI Agents SDK Integrate the toolkit with OpenAI’s Agents SDK for building autonomous payment agents. import { Agent } from "@openai/agents" ;
const agent = new Agent ({
model: "gpt-4o" ,
tools: cashfreeToolkit . getAgentTools (),
});
For detailed OpenAI documentation, see the OpenAI integration guide . The LangChain integration enables LangChain agents to integrate with Cashfree APIs. Set up the Cashfree Agent Toolkit with your credentials and environment configuration. import {
CashfreeAgentToolkit ,
CFEnvironment ,
} from "@cashfreepayments/agent-toolkit/langchain" ;
const cashfreeToolkit = new CashfreeAgentToolkit (
CFEnvironment . SANDBOX ,
process . env . CASHFREE_CLIENT_ID ,
process . env . CASHFREE_CLIENT_SECRET ,
);
Load all available Cashfree payment tools into your LangChain agent or select specific tools your agent needs for more focused functionality. import { createAgent } from "langchain" ;
const tools = cashfreeToolkit . getTools ();
const agent = createAgent ({ model , tools });
For detailed LangChain documentation, see the LangChain integration guide . The Vercel AI SDK integration enables Vercel’s AI SDK to integrate with Cashfree APIs through function calling. Set up the Cashfree AI SDK Toolkit with your credentials and environment configuration. import {
CashfreeAISDKToolkit ,
CFEnvironment ,
} from "@cashfreepayments/agent-toolkit/ai-sdk" ;
const cashfreeToolkit = new CashfreeAISDKToolkit (
CFEnvironment . SANDBOX ,
process . env . CASHFREE_CLIENT_ID ,
process . env . CASHFREE_CLIENT_SECRET ,
);
Use tools with generateText Load all available Cashfree payment tools for comprehensive functionality or select specific tools your application needs for more focused functionality. import { generateText } from "ai" ;
import { openai } from "@ai-sdk/openai" ;
const result = await generateText ({
model: openai ( "gpt-4o" ),
tools: {
createOrder: cashfreeToolkit . tools . createOrder ,
getOrder: cashfreeToolkit . tools . getOrder ,
},
prompt: "Create an order for Rs. 500" ,
});
For detailed Vercel AI SDK documentation, see the AI SDK integration guide .
Example payment agent
The following example demonstrates a complete payment agent using the OpenAI Agents SDK:
import { Agent , run } from '@openai/agents' ;
import {
CashfreeAgentToolkit ,
CFEnvironment ,
} from '@cashfreepayments/agent-toolkit/openai' ;
// Initialize the toolkit
const cashfree = new CashfreeAgentToolkit (
CFEnvironment . SANDBOX ,
process . env . CASHFREE_CLIENT_ID ,
process . env . CASHFREE_CLIENT_SECRET
);
// Create an agent with all payment tools
const agent = new Agent ({
name: 'Payment Agent' ,
instructions: 'You are a helpful payment assistant.' ,
model: 'gpt-4o' ,
tools: cashfree . getAgentTools (),
});
// Run the agent
const result = await run (
agent ,
'Look up customer cust_123 and create an order for Rs. 500'
);
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.