StripeAgentToolkit
This notebook provides a quick overview for getting started with Stripe's agent toolkit.
You can read more aboutStripeAgentToolkit
inStripe's launch blog or on the project'sPyPi page.
Overview
Integration details
Class | Package | Serializable | JS Support | Package latest |
---|---|---|---|---|
StripeAgentToolkit | stripe-agent-toolkit | ❌ | ✅ |
Setup
This externally-managed package is hosted out of thestripe-agent-toolkit
project, which is managed by Stripe's team.
You can install it, along with langgraph for the following examples, withpip
:
%pip install--quiet-U langgraph stripe-agent-toolkit
[1m[[0m[34;49mnotice[0m[1;39;49m][0m[39;49m A new release of pip is available: [0m[31;49m24.2[0m[39;49m -> [0m[32;49m24.3.1[0m
[1m[[0m[34;49mnotice[0m[1;39;49m][0m[39;49m To update, run: [0m[32;49mpip install --upgrade pip[0m
Note: you may need to restart the kernel to use updated packages.
Credentials
In addition to installing the package, you will need to configure the integration with your Stripe account's secret key, which is available in yourStripe Dashboard.
import getpass
import os
ifnot os.environ.get("STRIPE_SECRET_KEY"):
os.environ["STRIPE_SECRET_KEY"]= getpass.getpass("STRIPE API key:\n")
It's also helpful (but not needed) to set upLangSmith for best-in-class observability:
# os.environ["LANGSMITH_TRACING"] = "true"
# os.environ["LANGSMITH_API_KEY"] = getpass.getpass()
Instantiation
Here we show how to create an instance of the Stripe Toolkit
from stripe_agent_toolkit.crewai.toolkitimport StripeAgentToolkit
stripe_agent_toolkit= StripeAgentToolkit(
secret_key=os.getenv("STRIPE_SECRET_KEY"),
configuration={
"actions":{
"payment_links":{
"create":True,
},
}
},
)
Agent
Here's how to use the toolkit to create a basic agent in langgraph:
from langchain_anthropicimport ChatAnthropic
from langgraph.prebuiltimport create_react_agent
llm= ChatAnthropic(
model="claude-3-5-sonnet-20240620",
)
langgraph_agent_executor= create_react_agent(llm, 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)
Related
- Toolconceptual guide
- Toolhow-to guides