# Ajouter Stripe à vos workflows agentiques Utilisez les services financiers avec des agents. Utilisez Stripe pour gérer votre entreprise d’agents et améliorer les fonctionnalités de vos agents. En permettant l’accès à des services et outils financiers, vous élargissez les capacités de vos agents et leur permettez de vous aider à engranger et à dépenser des fonds. ## Création d’objets Stripe Utilisez l’appel de fonctions pour créer et gérer des objets Stripe. Par exemple, vous pouvez créer automatiquement des [liens de paiement](https://docs.stripe.com/payment-links.md) pour accepter des fonds, les intégrer à vos workflows de support pour aider vos clients, et mettre en place des données de test. La boîte à outils de l’agent Stripe prend en charge le [SDK Agents d’OpenAI](https://github.com/openai/openai-agents-python), le [SDK AI de Vercel](https://sdk.vercel.ai/), [LangChain](https://www.langchain.com/) et [CrewAI](https://www.crewai.com/). Elle fonctionne avec tout LLM qui prend en charge l’appel de fonctionnalités, et est compatible avec Python et TypeScript. #### SDK Agents d'OpenAI #### Python ```python import asyncio import os from agents import Agent, Runner from stripe_agent_toolkit.openai.toolkit import create_stripe_agent_toolkit async def main(): # Initialize toolkit - use restricted key (rk_*) for better security toolkit = await create_stripe_agent_toolkit( secret_key=os.getenv("STRIPE_SECRET_KEY") ) try: agent = Agent( name="Stripe Agent", instructions="Integrate with Stripe effectively to support business needs.", tools=toolkit.get_tools() ) assignment = "Create a payment link for a new product called \"Test\" with a price of $100." result = await Runner.run(agent, assignment) print(result.final_output) finally: await toolkit.close() if __name__ == "__main__": asyncio.run(main()) ``` #### SDK Vercel AI #### Node.js ```javascript import { createStripeAgentToolkit } from '@stripe/agent-toolkit/ai-sdk'; import { openai } from '@ai-sdk/openai'; import { generateText } from 'ai'; // Initialize toolkit - use restricted key (rk_*) for better security const toolkit = await createStripeAgentToolkit({ secretKey: process.env.STRIPE_SECRET_KEY!, configuration: {}, }); try { const result = await generateText({ model: openai('gpt-4o'), tools: { ...toolkit.getTools(), }, maxSteps: 5, prompt: 'Create a payment link for a new product called \"Test\" with a price of $100.', }); } finally { await toolkit.close(); } ``` #### LangChain #### Python ```python import asyncio import os from langchain_openai import ChatOpenAI from langchain.agents import AgentExecutor, create_structured_chat_agent from langchain.prompts import ChatPromptTemplate from stripe_agent_toolkit.langchain.toolkit import create_stripe_agent_toolkit async def main(): # Initialize toolkit - use restricted key (rk_*) for better security toolkit = await create_stripe_agent_toolkit( secret_key=os.getenv("STRIPE_SECRET_KEY") ) try: llm = ChatOpenAI(model="gpt-4") prompt = ChatPromptTemplate.from_messages([ ("system", "You are a helpful assistant that can interact with Stripe."), ("human", "{input}"), ("placeholder", "{agent_scratchpad}"), ]) tools = toolkit.get_tools() agent = create_structured_chat_agent(llm, tools, prompt) agent_executor = AgentExecutor(agent=agent, tools=tools) agent_executor.invoke({ "input": "Create a payment link for a new product called \"Test\" with a price of $100." }) finally: await toolkit.close() if __name__ == "__main__": asyncio.run(main()) ``` #### CrewAI #### Python ```python import asyncio import os from crewai import Agent, Task, Crew from stripe_agent_toolkit.crewai.toolkit import create_stripe_agent_toolkit async def main(): # Initialize toolkit - use restricted key (rk_*) for better security toolkit = await create_stripe_agent_toolkit( secret_key=os.getenv("STRIPE_SECRET_KEY") ) try: stripe_agent = Agent( role="Stripe Agent", goal="Integrate with Stripe effectively to support business needs.", backstory="You are a Stripe expert.", tools=[*toolkit.get_tools()] ) create_payment_link = Task( description="Create a payment link for a new product called \"Test\" with a price of $100.", expected_output="url", agent=stripe_agent ) crew = Crew( agents=[stripe_agent], tasks=[create_payment_link], planning=True ) crew.kickoff() finally: await toolkit.close() if __name__ == "__main__": asyncio.run(main()) ``` > Explorez ce SDK pour intégrer Stripe aux flux de travail d’agents. Le comportement des agents étant non déterministe, utilisez le SDK dans un [environnement de test](https://docs.stripe.com/sandboxes.md) et effectuez des évaluations pour analyser les performances de votre application. > > Pour des raisons de sécurité, nous vous recommandons vivement d’utiliser des [clés API restreintes](https://docs.stripe.com/keys.md#create-restricted-api-secret-key) (`rk_*`) afin de limiter l’accès de votre agent aux seules fonctionnalités nécessaires, notamment en mode production. La disponibilité des outils dépend des autorisations que vous configurez sur la clé restreinte.