stripe-best-practices
stripe-best-practices — a Claude Code skill from stripe/ai
Features
- ✓Integrate Stripe with LLMs and agent frameworks
- ✓SDKs for Python and TypeScript
- ✓Model Context Protocol (MCP) support
- ✓Stripe Agent Toolkit for popular frameworks
- ✓Detailed documentation and setup guides
Installation Guide
want to use the package run:
pip install stripe-agent-toolkit##### Requirements
#### Usage
The library needs to be configured with your account's secret key which is
available in your [Stripe Dashboard][api-keys]. We strongly recommend using a [Restricted API Key][restricted-keys] (rk_*) for better security and granular permissions. Tool availability is determined by the permissions you configure on the restricted key.
from stripe_agent_toolkit.openai.toolkit import create_stripe_agent_toolkit
async def main():
toolkit = await create_stripe_agent_toolkit(secret_key="rk_test_...")
tools = toolkit.get_tools()
# ... use tools ...
await toolkit.close() # Clean up when doneThe toolkit works with OpenAI's Agent SDK, LangChain, and CrewAI and can be passed as a list of tools. For example:
from agents import Agent
async def main():
toolkit = await create_stripe_agent_toolkit(secret_key="rk_test_...")
stripe_agent = Agent(
name="Stripe Agent",
instructions="You are an expert at integrating with Stripe",
tools=toolkit.get_tools()
)
# ... use agent ...
await toolkit.close()Examples for OpenAI's Agent SDK,LangChain, and CrewAI are included in [/examples](/tools/python/examples).
##### Context
In some cases you will want to provide values that serve as defaults when making requests. Currently, the account context value enables you to make API calls for your connected accounts.
toolkit = await create_stripe_agent_toolkit(
secret_key="rk_test_...",
configuration={
"context": {
"account": "acct_123"
}
}
)TypeScript
#### Installation
You don't need this source code unless you want to modify the package. If you just
want to use the package run:
npm install @stripe/agent-toolkit##### Requirements
##### Migrating from v0.8.x
If you're upgrading from v0.8.x, see the [Migration Guide](/tools/typescript/MIGRATION.md) for breaking changes.
#### Usage
The library needs to be configured with your account's secret key which is available in your [Stripe Dashboard][api-keys]. We strongly recommend using a [Restricted API Key][restricted-keys] (rk_*) for better security and granular permissions. Tool availability is determined by the permissions you configure on the restricted key.
import { createStripeAgentToolkit } from "@stripe/agent-toolkit/langchain";
const toolkit = await createStripeAgentToolkit({
secretKey: process.env.STRIPE_SECRET_KEY!,
configuration: {},
});
const tools = toolkit.getTools();
// ... use tools ...
await toolkit.close(); // Clean up when done##### Tools
The toolkit works with LangChain and Vercel's AI SDK and can be passed as a list of tools. For example:
import { AgentExecutor, createStructuredChatAgent } from "langchain/agents";
import { createStripeAgentToolkit } from "@stripe/agent-toolkit/langchain";
const toolkit = await createStripeAgentToolkit({
secretKey: process.env.STRIPE_SECRET_KEY!,
configuration: {},
});
const tools = toolkit.getTools();
const agent = await createStructuredChatAgent({
llm,
tools,
prompt,
});
const agentExecutor = new AgentExecutor({
agent,
tools,
});##### Context
In some cases you will want to provide values that serve as defaults when making requests. Currently, the account context value enables you to make API calls for your connected accounts.
const toolkit = await createStripeAgentToolkit({
secretKey: process.env.STRIPE_SECRET_KEY!,
configuration: {
context: {
account: "acct_123",
},
},
});