# Add Stripe to your agentic workflows Use financial services with agents. Use Stripe to run your agent business and enhance your agents’ functionality. By enabling access to financial services and tools, you allow your agents to help you earn and spend funds, expanding their capabilities. ## Create Stripe objects Use function calling to create and manage Stripe objects. For example, dynamically create [Payment Links](https://docs.stripe.com/payment-links.md) to accept funds, integrate into your support workflows to help customers, and scaffold test data. The Stripe agent toolkit supports [OpenAI’s Agents SDK](https://github.com/openai/openai-agents-python), [Vercel’s AI SDK](https://sdk.vercel.ai/), [LangChain](https://www.langchain.com/), and [CrewAI](https://www.crewai.com/). It works with any LLM provider that supports function calling and is compatible with Python and TypeScript. #### OpenAI Agents SDK #### Python ```python import asyncio import os from agents import Agent, Runner from stripe_agent_toolkit.openai.toolkit import create_stripe_agent_toolkit async def main(): # Initialize toolkit - use restricted key (rk_*) for better security toolkit = await create_stripe_agent_toolkit( secret_key=os.getenv("STRIPE_SECRET_KEY") ) try: agent = Agent( name="Stripe Agent", instructions="Integrate with Stripe effectively to support business needs.", tools=toolkit.get_tools() ) assignment = "Create a payment link for a new product called \"Test\" with a price of $100." result = await Runner.run(agent, assignment) print(result.final_output) finally: await toolkit.close() if __name__ == "__main__": asyncio.run(main()) ``` #### Vercel AI SDK #### Node.js ```javascript import { createStripeAgentToolkit } from '@stripe/agent-toolkit/ai-sdk'; import { openai } from '@ai-sdk/openai'; import { generateText } from 'ai'; // Initialize toolkit - use restricted key (rk_*) for better security const toolkit = await createStripeAgentToolkit({ secretKey: process.env.STRIPE_SECRET_KEY!, configuration: {}, }); try { const result = await generateText({ model: openai('gpt-4o'), tools: { ...toolkit.getTools(), }, maxSteps: 5, prompt: 'Create a payment link for a new product called \"Test\" with a price of $100.', }); } finally { await toolkit.close(); } ``` #### LangChain #### Python ```python import asyncio import os from langchain_openai import ChatOpenAI from langchain.agents import AgentExecutor, create_structured_chat_agent from langchain.prompts import ChatPromptTemplate from stripe_agent_toolkit.langchain.toolkit import create_stripe_agent_toolkit async def main(): # Initialize toolkit - use restricted key (rk_*) for better security toolkit = await create_stripe_agent_toolkit( secret_key=os.getenv("STRIPE_SECRET_KEY") ) try: llm = ChatOpenAI(model="gpt-4") prompt = ChatPromptTemplate.from_messages([ ("system", "You are a helpful assistant that can interact with Stripe."), ("human", "{input}"), ("placeholder", "{agent_scratchpad}"), ]) tools = toolkit.get_tools() agent = create_structured_chat_agent(llm, tools, prompt) agent_executor = AgentExecutor(agent=agent, tools=tools) agent_executor.invoke({ "input": "Create a payment link for a new product called \"Test\" with a price of $100." }) finally: await toolkit.close() if __name__ == "__main__": asyncio.run(main()) ``` #### CrewAI #### Python ```python import asyncio import os from crewai import Agent, Task, Crew from stripe_agent_toolkit.crewai.toolkit import create_stripe_agent_toolkit async def main(): # Initialize toolkit - use restricted key (rk_*) for better security toolkit = await create_stripe_agent_toolkit( secret_key=os.getenv("STRIPE_SECRET_KEY") ) try: stripe_agent = Agent( role="Stripe Agent", goal="Integrate with Stripe effectively to support business needs.", backstory="You are a Stripe expert.", tools=[*toolkit.get_tools()] ) create_payment_link = Task( description="Create a payment link for a new product called \"Test\" with a price of $100.", expected_output="url", agent=stripe_agent ) crew = Crew( agents=[stripe_agent], tasks=[create_payment_link], planning=True ) crew.kickoff() finally: await toolkit.close() if __name__ == "__main__": asyncio.run(main()) ``` > Learn how to use this SDK to integrate Stripe into agentic workflows. Because agent behavior is non-deterministic, use the SDK in a [sandbox](https://docs.stripe.com/sandboxes.md) and run evaluations to assess your application’s performance. > > For security, we strongly recommend using [restricted API keys](https://docs.stripe.com/keys.md#create-restricted-api-secret-key) (`rk_*`) to limit your agent’s access to only the functionality it requires, especially in live mode. Tool availability is determined by the permissions you configure on the restricted key.