> ## Documentation Index
> Fetch the complete documentation index at: https://langchain-docs-zh.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# StripeAgentToolkit 集成

> 使用 LangChain Python 与 StripeAgentToolkit 工具集成。

本指南为您提供快速入门指南，以使用Stripe的智能体工具包。

您可以在[Stripe的发布博客](https://stripe.dev/blog/adding-payments-to-your-agentic-workflows)或项目[PyPI页面](https://pypi.org/project/stripe-agent-toolkit/)中了解更多关于`StripeAgentToolkit`的内容。

## 概述

### 集成细节

| 类 | 包 | 可序列化 | [JS支持](https://github.com/stripe/agent-toolkit?tab=readme-ov-file#typescript) | 版本 |
| :- | :- | :-: | :-: | :-: |
| `StripeAgentToolkit` | [`stripe-agent-toolkit`](https://pypi.org/project/stripe-agent-toolkit) | ❌ | ✅ | ![PyPI - 版本](https://img.shields.io/pypi/v/stripe-agent-toolkit?style=flat-square\&label=%20) |

## 配置

此外部管理的包托管在Stripe团队管理的`stripe-agent-toolkit`项目中。

您可以使用`pip`安装该包以及langgraph以进行以下示例：

```python theme={null}
pip install --quiet -U langgraph stripe-agent-toolkit
```

### 凭据

除了安装包外，您还需要配置与Stripe账户的秘密密钥的集成，该密钥可在[Stripe仪表板](https://dashboard.stripe.com/account/apikeys)中找到。

```python theme={null}
import getpass
import os

if not os.environ.get("STRIPE_SECRET_KEY"):
    os.environ["STRIPE_SECRET_KEY"] = getpass.getpass("STRIPE API key:\n")
```

设置[LangSmith](https://smith.langchain.com)以获得最佳观测能力（此为可选配置）：

```python theme={null}
os.environ["LANGSMITH_TRACING"] = "true"
# os.environ["LANGSMITH_API_KEY"] = getpass.getpass()
```

## 实例化

此处展示如何创建Stripe Toolkit的实例

```python theme={null}
from stripe_agent_toolkit.langchain.toolkit import StripeAgentToolkit

stripe_agent_toolkit = StripeAgentToolkit(
    secret_key=os.getenv("STRIPE_SECRET_KEY"),
    configuration={
        "actions": {
            "payment_links": {
                "create": True,
            },
        }
    },
)
```

## 智能体

以下是使用langgraph创建基础智能体的方法：

```python theme={null}
from langchain_anthropic import ChatAnthropic
from langchain.agents import create_agent


model = ChatAnthropic(
    model="claude-sonnet-4-6",
)

langgraph_agent_executor = create_agent(model, stripe_agent_toolkit.get_tools())

input_state = {
    "messages": """
        Create a payment link for a new product called 'test' with a price
        of $100. Come up with a funny description about buy bots,
        maybe a haiku.
    """,
}

output_state = langgraph_agent_executor.invoke(input_state)

print(output_state["messages"][-1].content)
```

***

> 官方原文：[src/oss/python/integrations/tools/stripe.mdx](https://github.com/langchain-ai/docs/blob/main/src/oss/python/integrations/tools/stripe.mdx) · 非官方翻译，译文由 AI 生成，以英文原文为准。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.