Aug 15, 2025
How to Build a Reliable Stripe AI Agent with LangChain, OpenAI, and Galileo


Erin Mikail Staples
Senior Developer Advocate
Erin Mikail Staples
Senior Developer Advocate


AI agents are powerful, but when they handle real-world tasks like payments, reliability is everything. In this post, we’ll build an AI-powered agent that connects to Stripe using real APIs, powered by LangChain + OpenAI, and—here’s the kicker—instrumented with Galileo so you can see what’s happening under the hood in real time.
Let’s face it: AI agents are cool demos… until you need to answer to your boss why someone was able to purchase a car for $1 (true story).
Agents in ecommerce?
Fortunately, we’ll be building this with Galileo’s Agent Reliability tools — a sort of insurance policy for your agentic operations. You’ll see every tool call, API response, and error, and even track metrics like tool selection quality and response adherence.
What you’ll build
By the end of this tutorial, you’ll have built a Typescript/Node.js AI Agent using Stripe Agent Toolkit that:
Lists products and prices
Creates payment links.
Manages customer data.
Monitoring + safeguards in real-time
This agent has both a functional CLI and web interface for the agent, and of course, has Galileo incorporated for full agent reliability.
By the end of this tutorial, you’ll have:
Built a multi-tool AI agent that integrates with Stripe.
Logged tool spans and LLM reasoning steps with Galileo.
Learned how to measure performance, errors, and reliability signals for your agent.
And the biggest takeaway?
You’ll understand why reliability and evaluations is the difference between “cool prototype” and “production-ready agent”.😎
Why observability matters for AI agents
AI agents aren’t just fancy chatbots—they plan, decide, and act. They call APIs. They make choices. They take action. They (ideally) save you time, energy and effort.
This is all great in theory. When something breaks inside your agent, you can’t just console.log()
your way out of it, with an easy-to-comprehend error code staring right back at you.
Traditional software metrics like “test coverage” don’t work for agentic systems because outputs are contextual, not binary. The question isn’t: “Did it run?”, but rather; “Did it run the right tool, with the right data, in the right order, and return something meaningful?”
Let’s build a reliable ecommerce agent, together.
Building the agent
For the sake of jumping right into action, we’ll be starting from an existing Stripe agent application.
If you want to learn how to add Galileo to a brand-new agentic application, check out:
How to Create a Weather Vibes Agent
Requirements
Code editor of choice (VS Code, Cursor, Warp, etc.)
OpenAI API Key (Tutorial should cost you <$5 to complete)
Set up your Galileo account
If you haven’t already, create a free account at app.galileo.ai.
Sign Up & Create an Organization
When prompted, enter your organization name.
To dive right into this tutorial, skip onboarding by clicking the Galileo logo in the upper-left corner.
Note: You will not be able to revisit the onboarding screen later. No worries—Galileo Docs have everything you need.
Create a New Project
Click New Project in the upper-right corner.
Enter the following:
Project Name → e.g.,
stripe-agent-demo
Log Stream Name → e.g.,production
Generate an API Key
Click your profile icon (upper-right), go to API Keys.
Click Create New Key.Copy and store it securely (you’ll need this for your
.env
file).
Clone the repository
Clone the repo and move into the Stripe Agent Tool directory:
git clone https://github.com/rungalileo/sdk-examples.git cd sdk-examples/typescript/agent/stripe-agent-tool
Install dependencies
From inside stripe-agent-tool
:
npm
Configure your environment file
Rename the .env.example
file to .env
, and replace it with your keys. Make sure your .gitignore file is updated to include the .env
file.
# Stripe Configuration STRIPE_SECRET_KEY=sk_test_your_stripe_secret_key_here # OpenAI Configuration OPENAI_API_KEY=your_openai_api_key_here # Galileo Configuration GALILEO_API_KEY=your_galileo_api_key_here GALILEO_PROJECT=stripe-agent-demo GALILEO_LOG_STREAM=production # Agent Configuration AGENT_NAME=StripePaymentAgent AGENT_DESCRIPTION=An AI agent that helps with Stripe payment operations
Project structure + tech stack
Before we get into the thick of it, let’s dive into a few different things that matter within this project.
First, let’s look at the architecture of the stripe-agent-tool
:
typescript/agent/stripe-agent-tool/ ├── src/ │ ├── agent/ │ │ └── StripeAgent.ts # Core AI agent logic │ ├── config/environment.ts # Loads env variables │ ├── interactive.ts # CLI for chatting with the agent │ └── server.ts # API server for the agent └── package.json
We’ll focus on StripeAgent.ts
because that’s where LangChain, Stripe, and Galileo come together.
Within this application, we’re using a couple of different tools you may or may not have heard of — let’s break down the core tools and how they’re being used within this application.
LangChain → To manage reasoning and tool orchestration
Stripe Agent Toolkit → Converts Stripe API into tools the agent can use
OpenAI GPT-4 → “Brain” of the agent
Galileo Typescript SDK → Agent Reliability
Setting up your ecommerce store
In order to have products in your store, you'll have to load them up. Don't fret, this project includes script to populate your a space-themed product catalog for the popular store, "Galileo's Gizmos."
Set up the product catalog through these next steps:
Ensure your Stripe API key is configured in your
.env
fileRun the setup script:
npm run setup-products
How does the StripeAgent use the Stripe Agent Toolkit?
At the heart of this project is StripeAgent.ts, a LangChain-based agent that’s been wired up with real Stripe APIs using the Stripe Agent Toolkit.
So how does it actually work?
Let’s open up the main agent file: src/agent/StripeAgent.ts
Inside, you’ll find the following snippet:
import { StripeAgentToolkit } from '@stripe/agent-toolkit/langchain'; private initializeStripeToolkit(): void { this.stripeToolkit = new StripeAgentToolkit({ secretKey: env.stripe.secretKey, configuration: { actions: { products: { read: true, create: true }, prices: { read: true, create: true }, paymentLinks: { create: true }, }, }, }); }
What does this chunk of code do?
Loads your Stripe Secret Key + allows you to connect to your Stripe Dashboard.
Registers tools within the LangChain framework for different Stripe operations.
List_products
list_prices
Create_payment_link
Adding monitoring
From within the same file, look for where we initialize Galileo + invoke the GalileoCallback.
const { init, flush, GalileoCallback } = require('galileo'); async init() { await init(); this.galileoCallback = new GalileoCallback(true, true); }
What does this chunk of code do?
init()
→ Starts GalileoGalileoCallback
→ Captures:LLM prompts/responses
Tool calls
Execution time
Errors
At the end,
flush()
sends traces to Galileo
It’s this bit that allows us to send the traces to Galileo and take a peek on what’s happening under the hood.
Add a custom tool
The Stripe Agent Toolkit is great, but what if you want custom business logic?
Say… you want to combine items in steps, like get show the price and the payment link as part of the same tool?
const getPriceAndCreateLink = new DynamicTool({ name: 'get_price_and_create_payment_link', description: 'Create payment link by product name and quantity', func: async (input: string) => { const { product_name, quantity = 1 } = JSON.parse(input); const products = await stripe.products.list({ limit: 100 }); const product = products.data.find(p => p.name.toLowerCase() === product_name.toLowerCase()); if (!product) return `Product "${product_name}" not found`; const prices = await stripe.prices.list({ product: product.id, active: true }); if (!prices.data.length) return `No active price for "${product_name}"`; const link = await stripe.paymentLinks.create({ line_items: [{ price: prices.data[0].id, quantity }], }); return link.url; }, });
Run the agent
Once everything is configured, it’s time to run the agent—and experience it live!
Let's start by first compiling our code — run the following:
npm run build
Run it in the CLI
From your terminal:
npm
This launches a conversational interface where you can talk to your agent directly. Try commands like:
“List all available products.”
“Create a payment link for my mug.”
“Purchase Astronaut Ice cream”
Run the web version
Want a browser-based version? No problem.
npm
Head over to http://localhost:3000 to use the web version of the agent, complete with form inputs and real-time Stripe actions.

View Traces in Galileo
Now that your agent is running, head over to app.galileo.ai to see the observability in action.
Navigate to Traces in your project
stripe-agent-demo
Click on the most recent run
Root Span (conversation start)
LLM Span (model reasoning)
Tool Spans (Stripe API calls)
Metrics (latency, token cost)

Wrapping Up: From Demo to Dependable
You just built more than an AI assistant—you built a reliable, observable, and ecommerce agent.
Your Stripe-connected agent doesn’t just respond to prompts. It lists real products, creates real payment links, manages customer data, and most importantly—logs every step of the process with Galileo so you can see exactly what’s happening, when, and why.
No more guessing if the right tool was called. No more wondering which API call failed. No more “uh oh” moments in production without context.
You now have:
A multi-tool AI agent that speaks Stripe
Both a CLI + web interface for testing and deploying
Full trace-level observability with Galileo, down to the LLM span and tool output
A clear path for adding custom tools, additional logic, and evaluation metrics
And the biggest win? You didn’t just build an agent—you built trust.
Whether you're shipping this to internal teams, customers, or just experimenting with agentic design, you now have the framework (and safeguards) to move confidently from “cool prototype” to “production-ready.”
For more tutorials like this, follow along at galileo.ai or check out our cookbooks. In the meantime, if you’re wanting to buy me some ice cream, find me on GitHub, drop me an email, or toot at me on BlueSky.
AI agents are powerful, but when they handle real-world tasks like payments, reliability is everything. In this post, we’ll build an AI-powered agent that connects to Stripe using real APIs, powered by LangChain + OpenAI, and—here’s the kicker—instrumented with Galileo so you can see what’s happening under the hood in real time.
Let’s face it: AI agents are cool demos… until you need to answer to your boss why someone was able to purchase a car for $1 (true story).
Agents in ecommerce?
Fortunately, we’ll be building this with Galileo’s Agent Reliability tools — a sort of insurance policy for your agentic operations. You’ll see every tool call, API response, and error, and even track metrics like tool selection quality and response adherence.
What you’ll build
By the end of this tutorial, you’ll have built a Typescript/Node.js AI Agent using Stripe Agent Toolkit that:
Lists products and prices
Creates payment links.
Manages customer data.
Monitoring + safeguards in real-time
This agent has both a functional CLI and web interface for the agent, and of course, has Galileo incorporated for full agent reliability.
By the end of this tutorial, you’ll have:
Built a multi-tool AI agent that integrates with Stripe.
Logged tool spans and LLM reasoning steps with Galileo.
Learned how to measure performance, errors, and reliability signals for your agent.
And the biggest takeaway?
You’ll understand why reliability and evaluations is the difference between “cool prototype” and “production-ready agent”.😎
Why observability matters for AI agents
AI agents aren’t just fancy chatbots—they plan, decide, and act. They call APIs. They make choices. They take action. They (ideally) save you time, energy and effort.
This is all great in theory. When something breaks inside your agent, you can’t just console.log()
your way out of it, with an easy-to-comprehend error code staring right back at you.
Traditional software metrics like “test coverage” don’t work for agentic systems because outputs are contextual, not binary. The question isn’t: “Did it run?”, but rather; “Did it run the right tool, with the right data, in the right order, and return something meaningful?”
Let’s build a reliable ecommerce agent, together.
Building the agent
For the sake of jumping right into action, we’ll be starting from an existing Stripe agent application.
If you want to learn how to add Galileo to a brand-new agentic application, check out:
How to Create a Weather Vibes Agent
Requirements
Code editor of choice (VS Code, Cursor, Warp, etc.)
OpenAI API Key (Tutorial should cost you <$5 to complete)
Set up your Galileo account
If you haven’t already, create a free account at app.galileo.ai.
Sign Up & Create an Organization
When prompted, enter your organization name.
To dive right into this tutorial, skip onboarding by clicking the Galileo logo in the upper-left corner.
Note: You will not be able to revisit the onboarding screen later. No worries—Galileo Docs have everything you need.
Create a New Project
Click New Project in the upper-right corner.
Enter the following:
Project Name → e.g.,
stripe-agent-demo
Log Stream Name → e.g.,production
Generate an API Key
Click your profile icon (upper-right), go to API Keys.
Click Create New Key.Copy and store it securely (you’ll need this for your
.env
file).
Clone the repository
Clone the repo and move into the Stripe Agent Tool directory:
git clone https://github.com/rungalileo/sdk-examples.git cd sdk-examples/typescript/agent/stripe-agent-tool
Install dependencies
From inside stripe-agent-tool
:
npm
Configure your environment file
Rename the .env.example
file to .env
, and replace it with your keys. Make sure your .gitignore file is updated to include the .env
file.
# Stripe Configuration STRIPE_SECRET_KEY=sk_test_your_stripe_secret_key_here # OpenAI Configuration OPENAI_API_KEY=your_openai_api_key_here # Galileo Configuration GALILEO_API_KEY=your_galileo_api_key_here GALILEO_PROJECT=stripe-agent-demo GALILEO_LOG_STREAM=production # Agent Configuration AGENT_NAME=StripePaymentAgent AGENT_DESCRIPTION=An AI agent that helps with Stripe payment operations
Project structure + tech stack
Before we get into the thick of it, let’s dive into a few different things that matter within this project.
First, let’s look at the architecture of the stripe-agent-tool
:
typescript/agent/stripe-agent-tool/ ├── src/ │ ├── agent/ │ │ └── StripeAgent.ts # Core AI agent logic │ ├── config/environment.ts # Loads env variables │ ├── interactive.ts # CLI for chatting with the agent │ └── server.ts # API server for the agent └── package.json
We’ll focus on StripeAgent.ts
because that’s where LangChain, Stripe, and Galileo come together.
Within this application, we’re using a couple of different tools you may or may not have heard of — let’s break down the core tools and how they’re being used within this application.
LangChain → To manage reasoning and tool orchestration
Stripe Agent Toolkit → Converts Stripe API into tools the agent can use
OpenAI GPT-4 → “Brain” of the agent
Galileo Typescript SDK → Agent Reliability
Setting up your ecommerce store
In order to have products in your store, you'll have to load them up. Don't fret, this project includes script to populate your a space-themed product catalog for the popular store, "Galileo's Gizmos."
Set up the product catalog through these next steps:
Ensure your Stripe API key is configured in your
.env
fileRun the setup script:
npm run setup-products
How does the StripeAgent use the Stripe Agent Toolkit?
At the heart of this project is StripeAgent.ts, a LangChain-based agent that’s been wired up with real Stripe APIs using the Stripe Agent Toolkit.
So how does it actually work?
Let’s open up the main agent file: src/agent/StripeAgent.ts
Inside, you’ll find the following snippet:
import { StripeAgentToolkit } from '@stripe/agent-toolkit/langchain'; private initializeStripeToolkit(): void { this.stripeToolkit = new StripeAgentToolkit({ secretKey: env.stripe.secretKey, configuration: { actions: { products: { read: true, create: true }, prices: { read: true, create: true }, paymentLinks: { create: true }, }, }, }); }
What does this chunk of code do?
Loads your Stripe Secret Key + allows you to connect to your Stripe Dashboard.
Registers tools within the LangChain framework for different Stripe operations.
List_products
list_prices
Create_payment_link
Adding monitoring
From within the same file, look for where we initialize Galileo + invoke the GalileoCallback.
const { init, flush, GalileoCallback } = require('galileo'); async init() { await init(); this.galileoCallback = new GalileoCallback(true, true); }
What does this chunk of code do?
init()
→ Starts GalileoGalileoCallback
→ Captures:LLM prompts/responses
Tool calls
Execution time
Errors
At the end,
flush()
sends traces to Galileo
It’s this bit that allows us to send the traces to Galileo and take a peek on what’s happening under the hood.
Add a custom tool
The Stripe Agent Toolkit is great, but what if you want custom business logic?
Say… you want to combine items in steps, like get show the price and the payment link as part of the same tool?
const getPriceAndCreateLink = new DynamicTool({ name: 'get_price_and_create_payment_link', description: 'Create payment link by product name and quantity', func: async (input: string) => { const { product_name, quantity = 1 } = JSON.parse(input); const products = await stripe.products.list({ limit: 100 }); const product = products.data.find(p => p.name.toLowerCase() === product_name.toLowerCase()); if (!product) return `Product "${product_name}" not found`; const prices = await stripe.prices.list({ product: product.id, active: true }); if (!prices.data.length) return `No active price for "${product_name}"`; const link = await stripe.paymentLinks.create({ line_items: [{ price: prices.data[0].id, quantity }], }); return link.url; }, });
Run the agent
Once everything is configured, it’s time to run the agent—and experience it live!
Let's start by first compiling our code — run the following:
npm run build
Run it in the CLI
From your terminal:
npm
This launches a conversational interface where you can talk to your agent directly. Try commands like:
“List all available products.”
“Create a payment link for my mug.”
“Purchase Astronaut Ice cream”
Run the web version
Want a browser-based version? No problem.
npm
Head over to http://localhost:3000 to use the web version of the agent, complete with form inputs and real-time Stripe actions.

View Traces in Galileo
Now that your agent is running, head over to app.galileo.ai to see the observability in action.
Navigate to Traces in your project
stripe-agent-demo
Click on the most recent run
Root Span (conversation start)
LLM Span (model reasoning)
Tool Spans (Stripe API calls)
Metrics (latency, token cost)

Wrapping Up: From Demo to Dependable
You just built more than an AI assistant—you built a reliable, observable, and ecommerce agent.
Your Stripe-connected agent doesn’t just respond to prompts. It lists real products, creates real payment links, manages customer data, and most importantly—logs every step of the process with Galileo so you can see exactly what’s happening, when, and why.
No more guessing if the right tool was called. No more wondering which API call failed. No more “uh oh” moments in production without context.
You now have:
A multi-tool AI agent that speaks Stripe
Both a CLI + web interface for testing and deploying
Full trace-level observability with Galileo, down to the LLM span and tool output
A clear path for adding custom tools, additional logic, and evaluation metrics
And the biggest win? You didn’t just build an agent—you built trust.
Whether you're shipping this to internal teams, customers, or just experimenting with agentic design, you now have the framework (and safeguards) to move confidently from “cool prototype” to “production-ready.”
For more tutorials like this, follow along at galileo.ai or check out our cookbooks. In the meantime, if you’re wanting to buy me some ice cream, find me on GitHub, drop me an email, or toot at me on BlueSky.
AI agents are powerful, but when they handle real-world tasks like payments, reliability is everything. In this post, we’ll build an AI-powered agent that connects to Stripe using real APIs, powered by LangChain + OpenAI, and—here’s the kicker—instrumented with Galileo so you can see what’s happening under the hood in real time.
Let’s face it: AI agents are cool demos… until you need to answer to your boss why someone was able to purchase a car for $1 (true story).
Agents in ecommerce?
Fortunately, we’ll be building this with Galileo’s Agent Reliability tools — a sort of insurance policy for your agentic operations. You’ll see every tool call, API response, and error, and even track metrics like tool selection quality and response adherence.
What you’ll build
By the end of this tutorial, you’ll have built a Typescript/Node.js AI Agent using Stripe Agent Toolkit that:
Lists products and prices
Creates payment links.
Manages customer data.
Monitoring + safeguards in real-time
This agent has both a functional CLI and web interface for the agent, and of course, has Galileo incorporated for full agent reliability.
By the end of this tutorial, you’ll have:
Built a multi-tool AI agent that integrates with Stripe.
Logged tool spans and LLM reasoning steps with Galileo.
Learned how to measure performance, errors, and reliability signals for your agent.
And the biggest takeaway?
You’ll understand why reliability and evaluations is the difference between “cool prototype” and “production-ready agent”.😎
Why observability matters for AI agents
AI agents aren’t just fancy chatbots—they plan, decide, and act. They call APIs. They make choices. They take action. They (ideally) save you time, energy and effort.
This is all great in theory. When something breaks inside your agent, you can’t just console.log()
your way out of it, with an easy-to-comprehend error code staring right back at you.
Traditional software metrics like “test coverage” don’t work for agentic systems because outputs are contextual, not binary. The question isn’t: “Did it run?”, but rather; “Did it run the right tool, with the right data, in the right order, and return something meaningful?”
Let’s build a reliable ecommerce agent, together.
Building the agent
For the sake of jumping right into action, we’ll be starting from an existing Stripe agent application.
If you want to learn how to add Galileo to a brand-new agentic application, check out:
How to Create a Weather Vibes Agent
Requirements
Code editor of choice (VS Code, Cursor, Warp, etc.)
OpenAI API Key (Tutorial should cost you <$5 to complete)
Set up your Galileo account
If you haven’t already, create a free account at app.galileo.ai.
Sign Up & Create an Organization
When prompted, enter your organization name.
To dive right into this tutorial, skip onboarding by clicking the Galileo logo in the upper-left corner.
Note: You will not be able to revisit the onboarding screen later. No worries—Galileo Docs have everything you need.
Create a New Project
Click New Project in the upper-right corner.
Enter the following:
Project Name → e.g.,
stripe-agent-demo
Log Stream Name → e.g.,production
Generate an API Key
Click your profile icon (upper-right), go to API Keys.
Click Create New Key.Copy and store it securely (you’ll need this for your
.env
file).
Clone the repository
Clone the repo and move into the Stripe Agent Tool directory:
git clone https://github.com/rungalileo/sdk-examples.git cd sdk-examples/typescript/agent/stripe-agent-tool
Install dependencies
From inside stripe-agent-tool
:
npm
Configure your environment file
Rename the .env.example
file to .env
, and replace it with your keys. Make sure your .gitignore file is updated to include the .env
file.
# Stripe Configuration STRIPE_SECRET_KEY=sk_test_your_stripe_secret_key_here # OpenAI Configuration OPENAI_API_KEY=your_openai_api_key_here # Galileo Configuration GALILEO_API_KEY=your_galileo_api_key_here GALILEO_PROJECT=stripe-agent-demo GALILEO_LOG_STREAM=production # Agent Configuration AGENT_NAME=StripePaymentAgent AGENT_DESCRIPTION=An AI agent that helps with Stripe payment operations
Project structure + tech stack
Before we get into the thick of it, let’s dive into a few different things that matter within this project.
First, let’s look at the architecture of the stripe-agent-tool
:
typescript/agent/stripe-agent-tool/ ├── src/ │ ├── agent/ │ │ └── StripeAgent.ts # Core AI agent logic │ ├── config/environment.ts # Loads env variables │ ├── interactive.ts # CLI for chatting with the agent │ └── server.ts # API server for the agent └── package.json
We’ll focus on StripeAgent.ts
because that’s where LangChain, Stripe, and Galileo come together.
Within this application, we’re using a couple of different tools you may or may not have heard of — let’s break down the core tools and how they’re being used within this application.
LangChain → To manage reasoning and tool orchestration
Stripe Agent Toolkit → Converts Stripe API into tools the agent can use
OpenAI GPT-4 → “Brain” of the agent
Galileo Typescript SDK → Agent Reliability
Setting up your ecommerce store
In order to have products in your store, you'll have to load them up. Don't fret, this project includes script to populate your a space-themed product catalog for the popular store, "Galileo's Gizmos."
Set up the product catalog through these next steps:
Ensure your Stripe API key is configured in your
.env
fileRun the setup script:
npm run setup-products
How does the StripeAgent use the Stripe Agent Toolkit?
At the heart of this project is StripeAgent.ts, a LangChain-based agent that’s been wired up with real Stripe APIs using the Stripe Agent Toolkit.
So how does it actually work?
Let’s open up the main agent file: src/agent/StripeAgent.ts
Inside, you’ll find the following snippet:
import { StripeAgentToolkit } from '@stripe/agent-toolkit/langchain'; private initializeStripeToolkit(): void { this.stripeToolkit = new StripeAgentToolkit({ secretKey: env.stripe.secretKey, configuration: { actions: { products: { read: true, create: true }, prices: { read: true, create: true }, paymentLinks: { create: true }, }, }, }); }
What does this chunk of code do?
Loads your Stripe Secret Key + allows you to connect to your Stripe Dashboard.
Registers tools within the LangChain framework for different Stripe operations.
List_products
list_prices
Create_payment_link
Adding monitoring
From within the same file, look for where we initialize Galileo + invoke the GalileoCallback.
const { init, flush, GalileoCallback } = require('galileo'); async init() { await init(); this.galileoCallback = new GalileoCallback(true, true); }
What does this chunk of code do?
init()
→ Starts GalileoGalileoCallback
→ Captures:LLM prompts/responses
Tool calls
Execution time
Errors
At the end,
flush()
sends traces to Galileo
It’s this bit that allows us to send the traces to Galileo and take a peek on what’s happening under the hood.
Add a custom tool
The Stripe Agent Toolkit is great, but what if you want custom business logic?
Say… you want to combine items in steps, like get show the price and the payment link as part of the same tool?
const getPriceAndCreateLink = new DynamicTool({ name: 'get_price_and_create_payment_link', description: 'Create payment link by product name and quantity', func: async (input: string) => { const { product_name, quantity = 1 } = JSON.parse(input); const products = await stripe.products.list({ limit: 100 }); const product = products.data.find(p => p.name.toLowerCase() === product_name.toLowerCase()); if (!product) return `Product "${product_name}" not found`; const prices = await stripe.prices.list({ product: product.id, active: true }); if (!prices.data.length) return `No active price for "${product_name}"`; const link = await stripe.paymentLinks.create({ line_items: [{ price: prices.data[0].id, quantity }], }); return link.url; }, });
Run the agent
Once everything is configured, it’s time to run the agent—and experience it live!
Let's start by first compiling our code — run the following:
npm run build
Run it in the CLI
From your terminal:
npm
This launches a conversational interface where you can talk to your agent directly. Try commands like:
“List all available products.”
“Create a payment link for my mug.”
“Purchase Astronaut Ice cream”
Run the web version
Want a browser-based version? No problem.
npm
Head over to http://localhost:3000 to use the web version of the agent, complete with form inputs and real-time Stripe actions.

View Traces in Galileo
Now that your agent is running, head over to app.galileo.ai to see the observability in action.
Navigate to Traces in your project
stripe-agent-demo
Click on the most recent run
Root Span (conversation start)
LLM Span (model reasoning)
Tool Spans (Stripe API calls)
Metrics (latency, token cost)

Wrapping Up: From Demo to Dependable
You just built more than an AI assistant—you built a reliable, observable, and ecommerce agent.
Your Stripe-connected agent doesn’t just respond to prompts. It lists real products, creates real payment links, manages customer data, and most importantly—logs every step of the process with Galileo so you can see exactly what’s happening, when, and why.
No more guessing if the right tool was called. No more wondering which API call failed. No more “uh oh” moments in production without context.
You now have:
A multi-tool AI agent that speaks Stripe
Both a CLI + web interface for testing and deploying
Full trace-level observability with Galileo, down to the LLM span and tool output
A clear path for adding custom tools, additional logic, and evaluation metrics
And the biggest win? You didn’t just build an agent—you built trust.
Whether you're shipping this to internal teams, customers, or just experimenting with agentic design, you now have the framework (and safeguards) to move confidently from “cool prototype” to “production-ready.”
For more tutorials like this, follow along at galileo.ai or check out our cookbooks. In the meantime, if you’re wanting to buy me some ice cream, find me on GitHub, drop me an email, or toot at me on BlueSky.
AI agents are powerful, but when they handle real-world tasks like payments, reliability is everything. In this post, we’ll build an AI-powered agent that connects to Stripe using real APIs, powered by LangChain + OpenAI, and—here’s the kicker—instrumented with Galileo so you can see what’s happening under the hood in real time.
Let’s face it: AI agents are cool demos… until you need to answer to your boss why someone was able to purchase a car for $1 (true story).
Agents in ecommerce?
Fortunately, we’ll be building this with Galileo’s Agent Reliability tools — a sort of insurance policy for your agentic operations. You’ll see every tool call, API response, and error, and even track metrics like tool selection quality and response adherence.
What you’ll build
By the end of this tutorial, you’ll have built a Typescript/Node.js AI Agent using Stripe Agent Toolkit that:
Lists products and prices
Creates payment links.
Manages customer data.
Monitoring + safeguards in real-time
This agent has both a functional CLI and web interface for the agent, and of course, has Galileo incorporated for full agent reliability.
By the end of this tutorial, you’ll have:
Built a multi-tool AI agent that integrates with Stripe.
Logged tool spans and LLM reasoning steps with Galileo.
Learned how to measure performance, errors, and reliability signals for your agent.
And the biggest takeaway?
You’ll understand why reliability and evaluations is the difference between “cool prototype” and “production-ready agent”.😎
Why observability matters for AI agents
AI agents aren’t just fancy chatbots—they plan, decide, and act. They call APIs. They make choices. They take action. They (ideally) save you time, energy and effort.
This is all great in theory. When something breaks inside your agent, you can’t just console.log()
your way out of it, with an easy-to-comprehend error code staring right back at you.
Traditional software metrics like “test coverage” don’t work for agentic systems because outputs are contextual, not binary. The question isn’t: “Did it run?”, but rather; “Did it run the right tool, with the right data, in the right order, and return something meaningful?”
Let’s build a reliable ecommerce agent, together.
Building the agent
For the sake of jumping right into action, we’ll be starting from an existing Stripe agent application.
If you want to learn how to add Galileo to a brand-new agentic application, check out:
How to Create a Weather Vibes Agent
Requirements
Code editor of choice (VS Code, Cursor, Warp, etc.)
OpenAI API Key (Tutorial should cost you <$5 to complete)
Set up your Galileo account
If you haven’t already, create a free account at app.galileo.ai.
Sign Up & Create an Organization
When prompted, enter your organization name.
To dive right into this tutorial, skip onboarding by clicking the Galileo logo in the upper-left corner.
Note: You will not be able to revisit the onboarding screen later. No worries—Galileo Docs have everything you need.
Create a New Project
Click New Project in the upper-right corner.
Enter the following:
Project Name → e.g.,
stripe-agent-demo
Log Stream Name → e.g.,production
Generate an API Key
Click your profile icon (upper-right), go to API Keys.
Click Create New Key.Copy and store it securely (you’ll need this for your
.env
file).
Clone the repository
Clone the repo and move into the Stripe Agent Tool directory:
git clone https://github.com/rungalileo/sdk-examples.git cd sdk-examples/typescript/agent/stripe-agent-tool
Install dependencies
From inside stripe-agent-tool
:
npm
Configure your environment file
Rename the .env.example
file to .env
, and replace it with your keys. Make sure your .gitignore file is updated to include the .env
file.
# Stripe Configuration STRIPE_SECRET_KEY=sk_test_your_stripe_secret_key_here # OpenAI Configuration OPENAI_API_KEY=your_openai_api_key_here # Galileo Configuration GALILEO_API_KEY=your_galileo_api_key_here GALILEO_PROJECT=stripe-agent-demo GALILEO_LOG_STREAM=production # Agent Configuration AGENT_NAME=StripePaymentAgent AGENT_DESCRIPTION=An AI agent that helps with Stripe payment operations
Project structure + tech stack
Before we get into the thick of it, let’s dive into a few different things that matter within this project.
First, let’s look at the architecture of the stripe-agent-tool
:
typescript/agent/stripe-agent-tool/ ├── src/ │ ├── agent/ │ │ └── StripeAgent.ts # Core AI agent logic │ ├── config/environment.ts # Loads env variables │ ├── interactive.ts # CLI for chatting with the agent │ └── server.ts # API server for the agent └── package.json
We’ll focus on StripeAgent.ts
because that’s where LangChain, Stripe, and Galileo come together.
Within this application, we’re using a couple of different tools you may or may not have heard of — let’s break down the core tools and how they’re being used within this application.
LangChain → To manage reasoning and tool orchestration
Stripe Agent Toolkit → Converts Stripe API into tools the agent can use
OpenAI GPT-4 → “Brain” of the agent
Galileo Typescript SDK → Agent Reliability
Setting up your ecommerce store
In order to have products in your store, you'll have to load them up. Don't fret, this project includes script to populate your a space-themed product catalog for the popular store, "Galileo's Gizmos."
Set up the product catalog through these next steps:
Ensure your Stripe API key is configured in your
.env
fileRun the setup script:
npm run setup-products
How does the StripeAgent use the Stripe Agent Toolkit?
At the heart of this project is StripeAgent.ts, a LangChain-based agent that’s been wired up with real Stripe APIs using the Stripe Agent Toolkit.
So how does it actually work?
Let’s open up the main agent file: src/agent/StripeAgent.ts
Inside, you’ll find the following snippet:
import { StripeAgentToolkit } from '@stripe/agent-toolkit/langchain'; private initializeStripeToolkit(): void { this.stripeToolkit = new StripeAgentToolkit({ secretKey: env.stripe.secretKey, configuration: { actions: { products: { read: true, create: true }, prices: { read: true, create: true }, paymentLinks: { create: true }, }, }, }); }
What does this chunk of code do?
Loads your Stripe Secret Key + allows you to connect to your Stripe Dashboard.
Registers tools within the LangChain framework for different Stripe operations.
List_products
list_prices
Create_payment_link
Adding monitoring
From within the same file, look for where we initialize Galileo + invoke the GalileoCallback.
const { init, flush, GalileoCallback } = require('galileo'); async init() { await init(); this.galileoCallback = new GalileoCallback(true, true); }
What does this chunk of code do?
init()
→ Starts GalileoGalileoCallback
→ Captures:LLM prompts/responses
Tool calls
Execution time
Errors
At the end,
flush()
sends traces to Galileo
It’s this bit that allows us to send the traces to Galileo and take a peek on what’s happening under the hood.
Add a custom tool
The Stripe Agent Toolkit is great, but what if you want custom business logic?
Say… you want to combine items in steps, like get show the price and the payment link as part of the same tool?
const getPriceAndCreateLink = new DynamicTool({ name: 'get_price_and_create_payment_link', description: 'Create payment link by product name and quantity', func: async (input: string) => { const { product_name, quantity = 1 } = JSON.parse(input); const products = await stripe.products.list({ limit: 100 }); const product = products.data.find(p => p.name.toLowerCase() === product_name.toLowerCase()); if (!product) return `Product "${product_name}" not found`; const prices = await stripe.prices.list({ product: product.id, active: true }); if (!prices.data.length) return `No active price for "${product_name}"`; const link = await stripe.paymentLinks.create({ line_items: [{ price: prices.data[0].id, quantity }], }); return link.url; }, });
Run the agent
Once everything is configured, it’s time to run the agent—and experience it live!
Let's start by first compiling our code — run the following:
npm run build
Run it in the CLI
From your terminal:
npm
This launches a conversational interface where you can talk to your agent directly. Try commands like:
“List all available products.”
“Create a payment link for my mug.”
“Purchase Astronaut Ice cream”
Run the web version
Want a browser-based version? No problem.
npm
Head over to http://localhost:3000 to use the web version of the agent, complete with form inputs and real-time Stripe actions.

View Traces in Galileo
Now that your agent is running, head over to app.galileo.ai to see the observability in action.
Navigate to Traces in your project
stripe-agent-demo
Click on the most recent run
Root Span (conversation start)
LLM Span (model reasoning)
Tool Spans (Stripe API calls)
Metrics (latency, token cost)

Wrapping Up: From Demo to Dependable
You just built more than an AI assistant—you built a reliable, observable, and ecommerce agent.
Your Stripe-connected agent doesn’t just respond to prompts. It lists real products, creates real payment links, manages customer data, and most importantly—logs every step of the process with Galileo so you can see exactly what’s happening, when, and why.
No more guessing if the right tool was called. No more wondering which API call failed. No more “uh oh” moments in production without context.
You now have:
A multi-tool AI agent that speaks Stripe
Both a CLI + web interface for testing and deploying
Full trace-level observability with Galileo, down to the LLM span and tool output
A clear path for adding custom tools, additional logic, and evaluation metrics
And the biggest win? You didn’t just build an agent—you built trust.
Whether you're shipping this to internal teams, customers, or just experimenting with agentic design, you now have the framework (and safeguards) to move confidently from “cool prototype” to “production-ready.”
For more tutorials like this, follow along at galileo.ai or check out our cookbooks. In the meantime, if you’re wanting to buy me some ice cream, find me on GitHub, drop me an email, or toot at me on BlueSky.
Erin Mikail Staples
Erin Mikail Staples
Erin Mikail Staples
Erin Mikail Staples