Add Stripe to your agentic workflowsDeveloper preview
Use financial services with agents.
Use Stripe to run your agent business and enhance your agents’ functionality. By enabling access to financial services and tools, you allow your agents to help you earn and spend funds, expanding their capabilities.
Create Stripe objects
Use function calling to create and manage Stripe objects. For example, dynamically create Payment Links to accept funds, integrate into your support workflows to help customers, and scaffold test data.
The Stripe Agent Toolkit supports Vercel’s AI SDK, LangChain, and CrewAI. It works with any LLM provider that supports function calling and is compatible with Python and TypeScript.
Developer preview
Explore this SDK to integrate Stripe into agentic workflows. Because agent behavior is non-deterministic, use the SDK in test mode and run evaluations to assess your application’s performance. Additionally, use restricted API keys to limit access to the functionality your agent requires.
Charge for agent usage
Integrate usage-based billing to record usage. The Stripe Agent Toolkit offers native support for billing by prompt and completion token usage in the Vercel AI SDK. You can forward LLM costs directly to your users using a Customer and event_
s for input and output Meter Events.
import { StripeAgentToolkit } from '@stripe/agent-toolkit/ai-sdk'; import { openai } from '@ai-sdk/openai'; import { experimental_wrapLanguageModel as wrapLanguageModel, } from 'ai'; const model = wrapLanguageModel({ model: openai('gpt-4o'), middleware: stripeAgentToolkit.middleware({ billing: { customer: process.env.STRIPE_CUSTOMER_ID!, meters: { input: process.env.STRIPE_METER_INPUT!, output: process.env.STRIPE_METER_OUTPUT!, }, }, }), });
Usage-based billing gives you the flexibility to charge for any unit, such as by time. You can emit billing events directly, such as measuring duration:
import stripe import time start = time.time() # Run your agent workflow, LLM execution, etc. execute_agent() end = time.time() stripe.billing.MeterEvent.create( event_name="agent_execution", payload={ "value": end - start, "stripe_customer_id": "{{CUSTOMER_ID}}" }, )
Buy goods online
Use Stripe Issuing to create single-use virtual cards for your business purchases. This allows your agents to spend funds. The Issuing APIs allow you to programmatically approve or decline authorizations, ensuring your purchase intent matches the authorization. Spending controls allow you to set budgets and limit spending for your agents.
Next steps
- See the Agent quickstart for a full code example
- Download the agent toolkit on GitHub
- Follow our guide to build a B2B Payments integration with Issuing