Arcade with OpenAI Agents
Arcade provides seamless integration with the OpenAI Agents Library and OpenAI Agents JS , allowing you to enhance your AI agents with powerful tools including Gmail, LinkedIn, GitHub, and many more. This integration is available through the agents-arcade
package for Python and our JavaScript client library .
Installation
Install the necessary packages to get started:
Python
pip install agents-arcade arcadepy
Make sure you have your Arcade API key ready. Get an API key if you don’t already have one.
Key features
- Easy integration with the OpenAI Agents framework
- Access to all Arcade toolkits including Google, GitHub, LinkedIn, X, and more
- Create custom tools with the Arcade Tool SDK
- Manage user authentication for tools that require it
- Asynchronous support compatible with OpenAI’s Agent framework
Basic usage
Here’s a simple example of using Arcade tools with OpenAI Agents:
Python
from agents import Agent, Runner
from arcadepy import AsyncArcade
from agents_arcade import get_arcade_tools
from agents_arcade.errors import AuthorizationError
async def main():
# Initialize the Arcade client
client = AsyncArcade()
# Get tools from the "gmail" toolkit
tools = await get_arcade_tools(client, toolkits=["gmail"])
# Create an agent with Gmail tools
google_agent = Agent(
name="Gmail agent",
instructions="You are a helpful assistant that can assist with Gmail API calls.",
model="gpt-4o-mini",
tools=tools,
)
try:
# Run the agent with a unique user_id for authorization
result = await Runner.run(
starting_agent=google_agent,
input="What are my latest emails?",
context={"user_id": "{arcade_user_id}"},
)
print("Final output:\n\n", result.final_output)
except AuthorizationError as e:
print("Please Login to Google:", e)
if __name__ == "__main__":
import asyncio
asyncio.run(main())
Handling authorization
Python
When a user needs to authorize access to a tool (like Google or GitHub), the agent will raise an AuthorizationError
with a URL for the user to visit:
try:
# Run agent code
# ...
except AuthorizationError as e:
# Display the authorization URL to the user
print(f"Please visit this URL to authorize: {e}")
After visiting the URL and authorizing access, the user can run the agent again with the same user_id
, and it will work without requiring re-authorization.
Available toolkits
Arcade provides a variety of toolkits you can use with your agents:
- Google Suite: Gmail, Calendar, Drive, Docs
- Social Media: LinkedIn, X
- Development: GitHub
- Web: Web search, content extraction
- And more: Weather, financial data, etc.
For a full list of available toolkits, visit the Arcade Toolkits documentation.
Next steps
Ready to start building with Arcade and OpenAI Agents? Check out these guides:
- Using Arcade tools - Learn the basics of using Arcade tools with OpenAI Agents
- Managing user authorization - Handle tool authorization efficiently
- Creating custom tools - Build your own tools with the Arcade Tool SDK
Enjoy exploring Arcade and building powerful AI-enabled applications!