【技术文档摘要】:

此仓库是构建基于Stripe的AI驱动产品和服务的一站式商店。
它包含一系列SDK,帮助您将Stripe与LLMs和代理框架集成,包括:
@stripe/agent-toolkit - 通过函数调用将Stripe API与流行的代理框架集成——提供Python和TypeScript版本。@stripe/ai-sdk - 将Stripe的计费基础设施与Vercel的ai和@ai-sdk库集成。@stripe/token-meter - 将Stripe的计费基础设施与来自OpenAI、Anthropic和Google Gemini的原生SDK集成,无需任何框架依赖。Stripe在https://mcp.stripe.com托管了一个远程MCP服务器。这允许通过OAuth进行安全的MCP客户端访问。查看文档这里。
Stripe代理工具包还在模型上下文协议 (MCP)格式中暴露了工具。或者,要使用npx运行本地Stripe MCP服务器,请使用以下命令:
npx -y @stripe/mcp --tools=all --api-key=YOUR_STRIPE_SECRET_KEY
详情请参阅MCP。
Stripe的代理工具包使流行的代理框架(包括OpenAI的代理SDK、LangChain、CrewAI和Vercel的AI SDK)能够通过函数调用与Stripe API集成。该库并不涵盖整个Stripe API。它支持Python和TypeScript,并直接建立在Stripe的Python和Node SDK之上。
下面提供了基本说明,但请参阅Python和TypeScript包以获取更多信息。
除非您想修改该包,否则不需要此源代码。如果您只是想使用该包,请运行:
pip install stripe-agent-toolkit
库需要使用您的账户密钥进行配置,该密钥可在您的Stripe仪表板中找到。
from stripe_agent_toolkit.openai.toolkit import StripeAgentToolkit
stripe_agent_toolkit = StripeAgentToolkit(
secret_key="sk_test_...",
configuration={
"actions": {
"payment_links": {
"create": True,
},
}
},
)
该工具包与OpenAI的代理SDK、LangChain和CrewAI兼容,并且可以作为工具列表传递。例如:
from agents import Agent
stripe_agent = Agent(
name="Stripe Agent",
instructions="您是集成Stripe方面的专家",
tools=stripe_agent_toolkit.get_tools()
)
有关OpenAI的代理SDK、LangChain和CrewAI的示例,请参见/examples。
在某些情况下,您可能希望提供默认值,以便在请求时使用。当前,account上下文值允许您为您的连接账户进行API调用。
stripe_agent_toolkit = StripeAgentToolkit(
secret_key="sk_test_...",
configuration={
"context": {
"account": "acct_123"
}
}
)
除非您想修改该包,否则不需要此源代码。如果您只是想使用该包,请运行:
npm install @stripe/agent-toolkit
库需要使用您的账户密钥进行配置,该密钥可在您的Stripe仪表板中找到。此外,configuration允许您指定可以使用工具包执行的操作类型。
import { StripeAgentToolkit } from "@stripe/agent-toolkit/langchain";
const stripeAgentToolkit = new StripeAgentToolkit({
secretKey: process.env.STRIPE_SECRET_KEY!,
configuration: {
actions: {
paymentLinks: {
create: true,
},
},
},
});
该工具包与LangChain和Vercel的AI SDK兼容,并且可以作为工具列表传递。例如:
import { AgentExecutor, createStructuredChatAgent } from "langchain/agents";
const tools = stripeAgentToolkit.getTools();
const agent = await createStructuredChatAgent({
llm,
tools,
prompt,
});
const agentExecutor = new AgentExecutor({
agent,
tools,
});
在某些情况下,您可能希望提供默认值,以便在请求时使用。当前,account上下文值允许您为您的连接账户进行API调用。
const stripeAgentToolkit = new StripeAgentToolkit({
secretKey: process.env.STRIPE_SECRET_KEY!,
configuration: {
context: {
account: "acct_123",
},
},
});
请参阅Stripe MCP文档以获取支持的方法列表。