Welcome to the Simple Agent API: a robust, production-ready application for serving Agents as an API. It includes: * A FastAPI server for handling API requests. * A PostgreSQL database for storing Agent sessions, knowledge, and memories. * A set of pre-built Agents to use as a starting point.
For more information, checkout Agno and give it a ⭐️
Follow these steps to get your Agent API up and running:
Prerequisites: docker desktop should be installed and running.
git clone https://github.com/agno-agi/agent-api.git
cd agent-api
We use GPT 4.1 as the default model, please export the OPENAI_API_KEY environment variable to get started.
export OPENAI_API_KEY="YOUR_API_KEY_HERE"
Note: You can use any model provider, just update the agents in the
/agentsfolder.
Run the application using docker compose:
docker compose up -d
This command starts:
* The FastAPI server, running on http://localhost:8000.
* The PostgreSQL database, accessible on localhost:5432.
Once started, you can: * Test the API at http://localhost:8000/docs.
http://localhost:8000 as a new endpoint. You can name it Agent API (or any name you prefer).https://github.com/user-attachments/assets/a0078ade-9fb7-4a03-a124-d5abcca6b562
When you're done, stop the application using:
docker compose down
The /agents folder contains pre-built agents that you can use as a starting point.
- Web Search Agent: A simple agent that can search the web.
- Agno Assist: An Agent that can help answer questions about Agno.
- Important: Make sure to load the agno_assist knowledge base before using this agent.
- Finance Agent: An agent that uses the YFinance API to get stock prices and financial data.
To setup your local virtual environment:
uvWe use uv for python environment and package management. Install it by following the the uv documentation or use the command below for unix-like systems:
curl -LsSf https://astral.sh/uv/install.sh | sh
Run the dev_setup.sh script. This will create a virtual environment and install project dependencies:
./scripts/dev_setup.sh
Activate the created virtual environment:
source .venv/bin/activate
(On Windows, the command might differ, e.g., .venv\Scripts\activate)
If you need to add or update python dependencies:
Add or update your desired Python package dependencies in the [dependencies] section of the pyproject.toml file.
The requirements.txt file is used to build the application image. After modifying pyproject.toml, regenerate requirements.txt using:
./scripts/generate_requirements.sh
To upgrade all existing dependencies to their latest compatible versions, run:
./scripts/generate_requirements.sh upgrade
Rebuild your Docker images to include the updated dependencies:
docker compose up -d --build
Need help, have a question, or want to connect with the community?
This repository includes a Dockerfile for building a production-ready container image of the application.
The general process to run in production is:
scripts/build_image.sh file and set your IMAGE_NAME and IMAGE_TAG variables../scripts/build_image.sh
OPENAI_API_KEY, database connection strings) are securely managed. Most cloud providers offer a way to set these as environment variables for your deployed service.Review the agent configurations in the /agents directory and ensure they are set up for your production needs (e.g., correct model versions, any production-specific settings).
Build Your Production Docker Image
scripts/build_image.sh script to set your desired IMAGE_NAME and IMAGE_TAG (e.g., your-repo/agent-api:v1.0.0).Run the script to build and push the image:
sh
./scripts/build_image.sh
Deploy to a Cloud Service With your image in a registry, you can deploy it to various cloud services that support containerized applications. Some common options include:
Serverless Container Platforms:
Container Orchestration Services:
Platform as a Service (PaaS) with Docker Support
Specialized Platforms:
The specific deployment steps will vary depending on the chosen provider. Generally, you'll point the service to your container image in the registry and configure aspects like port mapping (the application runs on port 8000 by default inside the container), environment variables, scaling parameters, and any necessary database connections.
docker-compose.yml sets up a PostgreSQL database for local development. In production, you will typically use a managed database service provided by your cloud provider (e.g., AWS RDS, Google Cloud SQL, Azure Database for PostgreSQL) for better reliability, scalability, and manageability.$ claude mcp add agent-api \
-- python -m otcore.mcp_server <graph>