# Stripe Agent Toolkit — Payments SDK for LLM Agents > Stripe Agent Toolkit gives LangChain, OpenAI Agents SDK, CrewAI, and Vercel AI SDK direct tool access to charges, customers, and refunds. ## Install Save as a script file and run: ## Quick Use 1. `pip install stripe-agent-toolkit` (or `npm install @stripe/agent-toolkit`) 2. Generate restricted key at dashboard.stripe.com/apikeys 3. Add toolkit tools to any LangChain / OpenAI / CrewAI agent --- ## Intro The Stripe Agent Toolkit is an official open-source SDK from Stripe that exposes Stripe's API as tool calls for LLM agents. Available in Python and TypeScript with first-class adapters for LangChain, OpenAI Agents SDK, CrewAI, and the Vercel AI SDK. Best for: AI shopping assistants, billing chatbots, refund support agents, anywhere an LLM needs to actually move money. Works with: any framework that accepts a tools list — Claude, GPT-4o, Gemini, Llama. Setup time: 3 minutes (npm/pip + STRIPE_SECRET_KEY). --- ### Install ```bash # Python pip install stripe-agent-toolkit # TypeScript npm install @stripe/agent-toolkit ``` ### LangChain (Python) ```python from stripe_agent_toolkit.langchain.toolkit import StripeAgentToolkit from langchain_openai import ChatOpenAI from langchain.agents import AgentExecutor, create_tool_calling_agent stripe_toolkit = StripeAgentToolkit( secret_key="sk_test_...", configuration={ "actions": { "payment_links": {"create": True}, "products": {"create": True, "read": True}, "prices": {"create": True}, "customers": {"read": True}, } }, ) llm = ChatOpenAI(model="gpt-4o") agent = create_tool_calling_agent(llm, stripe_toolkit.get_tools(), prompt) executor = AgentExecutor(agent=agent, tools=stripe_toolkit.get_tools()) executor.invoke({"input": "Create a $50 one-time product called Founders T-Shirt and give me the payment link."}) ``` ### OpenAI Agents SDK (TypeScript) ```typescript import { StripeAgentToolkit } from "@stripe/agent-toolkit/openai"; import OpenAI from "openai"; const stripe = new StripeAgentToolkit({ secretKey: process.env.STRIPE_SECRET_KEY!, configuration: { actions: { paymentLinks: { create: true }, invoices: { create: true, update: true }, }, }, }); const tools = stripe.getTools(); const openai = new OpenAI(); const completion = await openai.chat.completions.create({ model: "gpt-4o", messages: [{ role: "user", content: "Email Acme Corp a $5,000 invoice for the May retainer." }], tools, }); ``` ### Action surface | Resource | Available actions | |---|---| | Customers | create, read, update | | Products + Prices | create, read | | Payment Links | create | | Invoices + Items | create, update, finalize | | Refunds | create | | Subscriptions | read, update, cancel | ### Restricted keys Always use a Stripe **restricted key** (rk_live_...) scoped to only the actions the agent needs — never a full secret key. Generate at dashboard.stripe.com/apikeys → Restricted keys. --- ### FAQ **Q: Is the Agent Toolkit production-safe?** A: Yes — it's the same Stripe SDK underneath. The toolkit just narrows the action surface for LLM tool calling. Use restricted keys, scope actions, and treat any agent-initiated charge as user-confirmed (require a human-in-the-loop step before high-value writes). **Q: Does it support test mode?** A: Yes — pass any sk_test_... key. Stripe's test mode supports the entire API including payment links, subscriptions, refunds, with no real money moving. Test cards: 4242 4242 4242 4242. **Q: Can I add custom Stripe actions?** A: Yes — the toolkit exports a base Tool class. Subclass it, point at any Stripe API endpoint, register with the toolkit. Useful for org-specific workflows like custom metadata writes or Connect platform actions. --- ## Source & Thanks > Built by [Stripe](https://github.com/stripe). Licensed under MIT. > > [stripe/agent-toolkit](https://github.com/stripe/agent-toolkit) — ⭐ 1,400+ --- ## 快速使用 1. `pip install stripe-agent-toolkit`(或 `npm install @stripe/agent-toolkit`) 2. 在 dashboard.stripe.com/apikeys 生成受限 key 3. 把 toolkit tools 加进任何 LangChain / OpenAI / CrewAI agent --- ## 简介 Stripe Agent Toolkit 是 Stripe 官方开源 SDK,把 Stripe API 暴露成 LLM agent 的 tool call。Python 和 TypeScript 双版本,自带 LangChain / OpenAI Agents SDK / CrewAI / Vercel AI SDK 适配器。适合 AI 购物助手、计费聊天机器人、退款客服 agent —— 任何需要 LLM 实际动钱的场景。兼容任何接受 tools 列表的框架 —— Claude、GPT-4o、Gemini、Llama 都行。装机时间 3 分钟(npm/pip + STRIPE_SECRET_KEY)。 --- ### 安装 ```bash # Python pip install stripe-agent-toolkit # TypeScript npm install @stripe/agent-toolkit ``` ### LangChain(Python) ```python from stripe_agent_toolkit.langchain.toolkit import StripeAgentToolkit from langchain_openai import ChatOpenAI from langchain.agents import AgentExecutor, create_tool_calling_agent stripe_toolkit = StripeAgentToolkit( secret_key="sk_test_...", configuration={ "actions": { "payment_links": {"create": True}, "products": {"create": True, "read": True}, "prices": {"create": True}, "customers": {"read": True}, } }, ) llm = ChatOpenAI(model="gpt-4o") agent = create_tool_calling_agent(llm, stripe_toolkit.get_tools(), prompt) executor = AgentExecutor(agent=agent, tools=stripe_toolkit.get_tools()) executor.invoke({"input": "建一个 50 美元一次性商品「Founders T-Shirt」并返回支付链接。"}) ``` ### OpenAI Agents SDK(TypeScript) ```typescript import { StripeAgentToolkit } from "@stripe/agent-toolkit/openai"; import OpenAI from "openai"; const stripe = new StripeAgentToolkit({ secretKey: process.env.STRIPE_SECRET_KEY!, configuration: { actions: { paymentLinks: { create: true }, invoices: { create: true, update: true }, }, }, }); const tools = stripe.getTools(); const openai = new OpenAI(); const completion = await openai.chat.completions.create({ model: "gpt-4o", messages: [{ role: "user", content: "给 Acme Corp 开一张 5000 美元的 5 月留存费发票并发邮件。" }], tools, }); ``` ### 动作覆盖 | 资源 | 可用动作 | |---|---| | Customers | create / read / update | | Products + Prices | create / read | | Payment Links | create | | Invoices + Items | create / update / finalize | | Refunds | create | | Subscriptions | read / update / cancel | ### 受限 key agent 永远用 Stripe **受限 key**(rk_live_...),仅授权它需要的动作 —— 别用完整 secret key。在 dashboard.stripe.com/apikeys → Restricted keys 生成。 --- ### FAQ **Q: Agent Toolkit 生产环境安全吗?** A: 安全 —— 底层就是 Stripe SDK,只是把动作面缩窄给 LLM 调。用受限 key、限制动作、把 agent 发起的 charge 当作用户已确认处理(高价值写操作前加 human-in-the-loop)。 **Q: 支持测试模式吗?** A: 支持 —— 传任意 sk_test_... key 即可。Stripe 测试模式覆盖整套 API(payment link / subscription / refund 都有),不动真钱。测试卡号:4242 4242 4242 4242。 **Q: 能加自定义 Stripe 动作吗?** A: 能 —— toolkit 导出基础 Tool 类。继承它、指向任意 Stripe API endpoint、注册到 toolkit。适合组织专属流程,比如自定义 metadata 写入或 Connect 平台动作。 --- ## 来源与感谢 > Built by [Stripe](https://github.com/stripe). Licensed under MIT. > > [stripe/agent-toolkit](https://github.com/stripe/agent-toolkit) — ⭐ 1,400+ --- Source: https://tokrepo.com/en/workflows/stripe-agent-toolkit-payments-sdk-for-llm-agents Author: Stripe