Skip to main content

A FastAPI extension for building API-first AI agent services

Project description

Agent Gateway

Agent Gateway

PyPI version Python License: MIT CI

A FastAPI extension for building API-first AI agent services. Define agents, tools, and skills as markdown files, then serve them as a production-ready API with authentication, persistence, scheduling, notifications, and more.

Quick Start

pip install agents-gateway[all]

# Scaffold a new project
agents-gateway init myproject
cd myproject

# Start the server
agents-gateway serve

Your agent API is now running at http://localhost:8000 with interactive docs at /docs.

Define an Agent

Create a markdown file at workspace/agents/assistant/AGENT.md:

---
description: A helpful assistant that answers questions
skills:
  - general-tools
memory:
  enabled: true
---

You are a helpful assistant. Answer questions clearly and concisely.

That's it — the agent is now available via the API.

Add a Tool

File-based tool

Create workspace/tools/http-example/TOOL.md:

---
name: http-example
description: Make an HTTP GET request and return the response
parameters:
  url:
    type: string
    description: The URL to fetch
    required: true
---

Add a handler in workspace/tools/http-example/handler.py:

import httpx

async def handler(url: str) -> str:
    async with httpx.AsyncClient() as client:
        resp = await client.get(url)
        return resp.text

Code-based tool

Register tools directly in Python:

from agent_gateway import Gateway

gw = Gateway(workspace="./workspace")

@gw.tool(agent="assistant")
def add_numbers(a: float, b: float) -> float:
    """Add two numbers together."""
    return a + b

Use the API

# Invoke an agent (single-turn)
curl -X POST http://localhost:8000/v1/agents/assistant/invoke \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_KEY" \
  -d '{"message": "What is 2 + 3?"}'

# Chat with an agent (multi-turn)
curl -X POST http://localhost:8000/v1/agents/assistant/chat \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_KEY" \
  -d '{"message": "Hello!"}'

Features

  • Markdown-defined agents — Define agents, tools, and skills as markdown files with YAML frontmatter
  • Multi-LLM support — Use any model supported by LiteLLM (OpenAI, Gemini, Anthropic, Ollama, etc.)
  • Built-in authentication — API key and OAuth2/JWT auth out of the box
  • Persistence — SQLite or PostgreSQL storage for conversations, executions, and audit logs
  • Dashboard — Built-in web dashboard for monitoring agents, executions, and conversations
  • Scheduling — Cron-based agent scheduling via APScheduler
  • Notifications — Slack and webhook notification backends with per-agent rules
  • Async execution — Queue-based async processing with Redis or RabbitMQ
  • Telemetry — OpenTelemetry instrumentation with console or OTLP export
  • Structured output — Pydantic model or JSON Schema output validation
  • Agent memory — Automatic memory extraction and recall across conversations
  • Streaming — Server-sent events (SSE) for real-time chat responses
  • Input/output schemas — JSON Schema validation for agent inputs and outputs
  • CLI — Project scaffolding, agent listing, and dev server via agents-gateway CLI
  • Lifecycle hooksbefore_invoke, after_invoke, on_error hooks for custom logic

Configuration

Configure your gateway with workspace/gateway.yaml:

server:
  port: 8000

model:
  default: "gemini/gemini-2.0-flash"
  temperature: 0.1

memory:
  enabled: true

Or configure programmatically:

from agent_gateway import Gateway

gw = Gateway(
    workspace="./workspace",
    title="My Agent Service",
)

# Fluent API for backends
gw.use_api_key_auth(api_key="your-key")
gw.use_sqlite("sqlite+aiosqlite:///data.db")
gw.use_slack_notifications(bot_token="xoxb-...", default_channel="#alerts")

Installation Extras

Install only what you need:

pip install agents-gateway[sqlite]       # SQLite persistence
pip install agents-gateway[postgres]     # PostgreSQL persistence
pip install agents-gateway[redis]        # Redis queue backend
pip install agents-gateway[rabbitmq]     # RabbitMQ queue backend
pip install agents-gateway[oauth2]       # OAuth2/JWT authentication
pip install agents-gateway[slack]        # Slack notifications
pip install agents-gateway[dashboard]    # Web dashboard
pip install agents-gateway[otlp]        # OTLP telemetry export
pip install agents-gateway[all]          # Everything

Documentation

Full documentation is available at vince-nyanga.github.io/agents-gateway.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agents_gateway-0.1.57.tar.gz (1.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agents_gateway-0.1.57-py3-none-any.whl (677.3 kB view details)

Uploaded Python 3

File details

Details for the file agents_gateway-0.1.57.tar.gz.

File metadata

  • Download URL: agents_gateway-0.1.57.tar.gz
  • Upload date:
  • Size: 1.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for agents_gateway-0.1.57.tar.gz
Algorithm Hash digest
SHA256 8b76e06f27fa3cf0b918acb79a1ed1a6fb626187cd484c0ffafe9e14b68469f3
MD5 ce1c57cfbb046d848103f2cb7bb717bc
BLAKE2b-256 13674f9f8afcf9ad692d37d7172b32518b9e770db24593fab469a3e8ddd9dd70

See more details on using hashes here.

File details

Details for the file agents_gateway-0.1.57-py3-none-any.whl.

File metadata

  • Download URL: agents_gateway-0.1.57-py3-none-any.whl
  • Upload date:
  • Size: 677.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for agents_gateway-0.1.57-py3-none-any.whl
Algorithm Hash digest
SHA256 b5742d132a1c26b6f9df09d989df26929fd1fe03ca39ea021f7fd950385c8bfe
MD5 7be9966decaad48fc999a967ee075b95
BLAKE2b-256 7d1c70726f577061fc05617107bfebd10da3137a8243db27e79b669ca4649e6f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page