Skip to main content

A simple tool to deploy OpenAI Agents as FastAPI web services.

Project description

AgentServe

A simple and efficient tool to deploy OpenAI Agents as FastAPI web services.

Overview

AgentServe is a lightweight wrapper that allows you to easily serve OpenAI Agents as web services. It provides a simple API for interacting with agents, supporting both synchronous and streaming responses.

Installation

pip install openai-agentserve

Or with Poetry:

poetry add openai-agentserve

Requirements

  • Python 3.8+
  • FastAPI
  • Uvicorn
  • OpenAI Agents SDK

Quick Start

from agents import Agent
from agentserve import serve

# Initialize your agent
my_agent = Agent(name="Assistant", instructions="You are a helpful assistant")

# Serve the agent on port 8000
serve(agent=my_agent, port=8000)

Usage Examples

Invoking the API

The API supports both streaming and non-streaming responses.

Streaming Response

import requests

url = "http://localhost:8000/invoke"

response = requests.post(url, json={
    "input": "please tell me a about the history of the world",
    "stream": True
    }, stream=True)
for i, line in enumerate(response.iter_lines()):
    if line:
        decoded_line = line.decode('utf-8').strip()
        print(decoded_line)

Non-Streaming Response

import requests

url = "http://localhost:8000/invoke"

response = requests.post(url, json={
    "input": "please tell me about the history of the world",
    "stream": False
})
result = response.json()
print(result)

API Documentation

AgentServe provides interactive API documentation through two interfaces:

ReDoc Documentation

Access the ReDoc documentation at /redoc when your server is running:

http://localhost:8000/redoc

ReDoc provides a clean, organized interface with:

  • Detailed endpoint descriptions
  • Request/response examples
  • Interactive API testing
  • Schema documentation
  • Endpoint grouping by tags

Swagger UI Documentation

Access the Swagger UI documentation at /docs:

http://localhost:8000/docs

Swagger UI provides:

  • Interactive API testing
  • Request/response visualization
  • Schema exploration
  • Try-it-out functionality

OpenAPI Schema

The OpenAPI schema is available at /openapi.json:

http://localhost:8000/openapi.json

This can be used with any OpenAPI-compatible tools or documentation generators.

Development

For information about CI/CD pipelines and GitHub Actions workflows, see .github/workflows/README.md.

Development Workflow

  1. Fork the repository
  2. Create a feature branch:
    git checkout -b feature/your-feature-name
    
  3. Make your changes
  4. Run local checks:
    poetry install
    poetry run pytest
    poetry run black .
    poetry run isort .
    poetry run flake8
    
  5. Commit your changes:
    git add .
    git commit -m "feat: your feature description"
    
  6. Push to your fork:
    git push origin feature/your-feature-name
    
  7. Create a Pull Request

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

openai_agentserve-0.0.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

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

openai_agentserve-0.0.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file openai_agentserve-0.0.0.tar.gz.

File metadata

  • Download URL: openai_agentserve-0.0.0.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.12.7 Darwin/21.6.0

File hashes

Hashes for openai_agentserve-0.0.0.tar.gz
Algorithm Hash digest
SHA256 12e3fadaf4dc2203293f584d9d60d1b513ecd0e360b6bccb40c6a0e4cc59929f
MD5 314e52f208a6b960b30c1621b0dccdbb
BLAKE2b-256 efe13a73009763d8707a8fd90aa4b1507db1b7007091397cbf445e0d598ef911

See more details on using hashes here.

File details

Details for the file openai_agentserve-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: openai_agentserve-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.12.7 Darwin/21.6.0

File hashes

Hashes for openai_agentserve-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f209826bfdacdb4298ce4efaa1c989bf3e46f887f14e0197bb46aeabdccefc7c
MD5 7fd01c677d5fc2d8b29afed5842057c9
BLAKE2b-256 98daf7f0277dac563c58e464f3a14ad0379c6d99139d6f6e613583069c128473

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