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
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature-name
- Make your changes
- Run local checks:
poetry install poetry run pytest poetry run black . poetry run isort . poetry run flake8
- Commit your changes:
git add . git commit -m "feat: your feature description"
- Push to your fork:
git push origin feature/your-feature-name
- 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.
Metadata
Release files for openai-agentserve 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| openai_agentserve-0.0.1.tar.gz | 6.3 kB | Without provenance | Details for openai_agentserve-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| openai_agentserve-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for openai_agentserve-0.0.1-py3-none-any.whl |
Total release size: 13.6 kB
Release files / openai_agentserve-0.0.1.tar.gz
| Download URL | openai_agentserve-0.0.1.tar.gz |
|---|---|
| Size | 6.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
78137184ab199b8b909b162ab1c18200acb24ae33e7e5bc3729b1d4726b00b7a
|
|
BLAKE2b-256 checksum How to use checksums |
a2afd8a7143649ae0ee3e6f1e30593634ed5b93f7f32326c495ad073ef6cf540
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.5 CPython/3.12.7 Darwin/21.6.0
|
Release files / openai_agentserve-0.0.1-py3-none-any.whl
| Download URL | openai_agentserve-0.0.1-py3-none-any.whl |
|---|---|
| Size | 7.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5164538f70e40406cf13dba59dba6ab6d5a3476a3c60c605461b82befacca732
|
|
BLAKE2b-256 checksum How to use checksums |
c5fa95c3f065ca253d59db6c74ef20f8380307bcf88adb95e634c1db08e6a7f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.5 CPython/3.12.7 Darwin/21.6.0
|
Security for openai-agentserve 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.