Stripe Agent Toolkit 安装与配置指南
1. 项目基础介绍
Stripe Agent Toolkit 是一个开源项目,它为流行的智能体框架(如 OpenAI 的 Agent SDK、LangChain、CrewAI、Vercel 的 AI SDK 和 Model Context Protocol)提供了与 Stripe API 的集成。这个库支持 Python 和 TypeScript 两种编程语言,并基于 Stripe 的 Python 和 Node SDK 构建而成。它允许开发者通过函数调用来集成 Stripe API,实现创建支付链接、管理客户、产品、价格和订阅等功能。
2. 项目使用的关键技术和框架
- Stripe API: Stripe 提供的 API,允许开发者轻松处理在线支付、订阅和其他金融交易。
- Python: 一种广泛使用的高级编程语言,用于开发 Stripe Agent Toolkit 的 Python 部分。
- TypeScript: JavaScript 的超集,添加了静态类型选项,用于开发 Stripe Agent Toolkit 的 Node.js 部分。
- Model Context Protocol (MCP): 一个允许模型与外部工具进行交互的协议,用于集成智能体框架。
3. 项目安装和配置的准备工作与详细步骤
准备工作
在开始安装之前,请确保您的系统已安装以下依赖:
- Python 3.11+: 用于运行 Python 包。
- Node 18+: 用于运行 TypeScript 包。
- Git: 用于克隆项目代码。
安装步骤
Python 版本
-
克隆项目仓库:
git clone https://github.com/stripe/agent-toolkit.git cd agent-toolkit
-
安装 Python 包:
pip install .
或者,如果您只是想要使用该包而不是修改它,可以直接通过 pip 安装:
pip install stripe-agent-toolkit
TypeScript 版本
-
克隆项目仓库:
git clone https://github.com/stripe/agent-toolkit.git cd agent-toolkit
-
安装 Node.js 包:
npm install .
或者,如果您只是想要使用该包而不是修改它,可以直接通过 npm 安装:
npm install @stripe/agent-toolkit
配置步骤
-
获取 Stripe 帐户的秘密密钥。您可以在 Stripe 仪表板中找到它。
-
对于 Python 版本,配置 StripeAgentToolkit:
from stripe_agent_toolkit.openai.toolkit import StripeAgentToolkit stripe_agent_toolkit = StripeAgentToolkit( secret_key="sk_test_...", configuration={ "actions": { "payment_links": { "create": True, }, }, }, )
-
对于 TypeScript 版本,配置 StripeAgentToolkit:
import { StripeAgentToolkit } from "@stripe/agent-toolkit/langchain"; const stripeAgentToolkit = new StripeAgentToolkit({ secretKey: process.env.STRIPE_SECRET_KEY, configuration: { actions: { paymentLinks: { create: true, }, }, }, });
完成以上步骤后,您就可以开始使用 Stripe Agent Toolkit 来集成 Stripe API 了。请根据项目文档和需求进一步配置和使用相关的功能。