FAQ
Find answers to common questions about Agency Swarm.
How do I set my OpenAI API key in my project?
How do I set my OpenAI API key in my project?
Set your API key in your code:
Or use a .env
file:
Then load it with:
What's the difference between using .cursorrules (with Cursor IDE) and 'agency-swarm genesis'?
What's the difference between using .cursorrules (with Cursor IDE) and 'agency-swarm genesis'?
There are two ways to create agents with AI:
-
Genesis Agency: A simple command-line tool that helps you create basic agent structures. Great for getting started or simple use cases. Just run
agency-swarm genesis
and follow the prompts. -
Cursor AI Code Editor: Use the
.cursorrules
file in Cursor IDE to create agents. This is the best option for both beginners and experienced developers since it gives you more control over the agent creation process.
Can I use open source models with Agency Swarm?
Can I use open source models with Agency Swarm?
Yes—you can use open source models for simple, non–mission-critical tasks (usually one or two tools per agent). See Open Source Models for more information. Keep in mind that many open source models currently struggle with function calling.
How do I save and continue conversations?
How do I save and continue conversations?
To persist threads between application restarts, implement thread callbacks that save and load thread IDs from a local file. For example, define your callback functions:
Then, pass these callbacks during your agency initialization to resume conversations:
This setup preserves your conversation context between runs.
How do I manage multiple users with Agency Swarm?
How do I manage multiple users with Agency Swarm?
To support multiple users/chats, you need to load and save thread IDs in your database accordingly. Each chat/user should have unique thread IDs. Ensure to check out our Deployment to Production guide for more information.
How can I transfer data between tools and agents?
How can I transfer data between tools and agents?
There are two ways to transfer data between tools and agents:
- Use shared state inside your tools. Read more: Shared State
- Create a tool (or modify an existing one) that uploads files to storage and outputs the file ID. This file ID can then be used by other tools or agents.
Why is the CodeInterpreter tool automatically added?
Why is the CodeInterpreter tool automatically added?
When file types like .json
, .docx
, or .pptx
are uploaded, CodeInterpreter is auto-added to process them. To change the agent’s behavior, update its instructions or create a custom file-handling tool.
How can I serve an Agency as an API using FastAPI?
How can I serve an Agency as an API using FastAPI?
Embed your agency within a FastAPI endpoint. For example:
How do I deploy my agency to production?
How do I deploy my agency to production?
Build a dedicated API backend (FastAPI is recommended) that manages authentication and persists thread state using callbacks. For more details, refer to our Deployment to Production guide.