from agentsjson.core import ToolFormat# Format the flows data for the promptflows_context = core.flows_prompt(flows)# Create the system promptsystem_prompt = f"""You are an AI assistant that helps users interact with the Stripe API.You have access to the following API flows:{flows_context}Analyze the user's request and use the appropriate API flows to accomplish the task.You must give your arguments for the tool call as Structued Outputs JSON with keys `parameters` and `requestBody`"""
Configure authentication:
Copy
Ask AI
from agentsjson.core.models.auth import AuthType, BearerAuthConfigauth = BearerAuthConfig(type=AuthType.BEARER, token=STRIPE_API_KEY)
Run your agent:
Copy
Ask AI
from openai import OpenAIfrom agentsjson.core.executor import execute_flowsclient = OpenAI(api_key=OPENAI_API_KEY)query = "Create a new Stripe product for tie-die tshirts priced at $10, $15, and $30 for small, medium, and large sizes"response = client.chat.completions.create( model="gpt-4o", messages=[ {"role": "system", "content": system_prompt}, {"role": "user", "content": query} ], tools=core.flows_tools(flows, format=ToolFormat.OPENAI), temperature=0)response = execute_flows(response, format=core.ToolFormat.OPENAI, bundle=data, flows=flows, auth=auth)response