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 Then load it with:
.env
file:Can I use open source models with Agency Swarm?
Can I use open source models with Agency Swarm?
Yes—you can use third-party models for simple, non–mission-critical tasks (usually one or two tools per agent). See Third-Party Models for more information. Keep in mind that many third-party models currently struggle with function calling.
How do I save and continue conversations?
How do I save and continue conversations?
To persist conversations between application restarts, implement callbacks that save and load the full message history from a local file. For example, define your callback functions: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 agency context inside your tools. Read more: Agency Context
- 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:
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.