An OpenAI-compatible API server for AutoGen.
Project description
🧠 autogen-oaiapi
OpenAI-style Chat API server for AutoGen teams.
Deploy your own /v1/chat/completions endpoint using any AutoGen-compatible team configuration.
🚀 Try it? → Don’t forget to ⭐ the repo if useful!
A self-hosted, open-source alternative to OpenAI’s ChatCompletion API, built on top of Microsoft AutoGen.
🔍 Looking for:
- OpenAI-style API server you can run locally?
- An AutoGen-based ChatCompletion implementation?
- A FastAPI wrapper for multi-agent LLM orchestration?
You found it. 🚀
WARNING
NOW(autogen-agentchat == 0.5.5) limit supported.
Because of it has bug on deserialization
AssistantAgentwith tools.
✨ Features
- ✅ OpenAI-compatible API interface
- ✅ Plug in any AutoGen
GroupChatorSocietyOfMindAgent - ✅ Session-aware execution (per session_id)
- ✅ FastAPI-based server with
/v1/chat/completionsendpoint - ✅
stream=Trueresponse support (coming soon)
📦 Installation
pip install autogen-oaiapi
How to use?
Using just SIMPLE api!
example
client = OpenAIChatCompletionClient(
model="claude-3-5-haiku-20241022"
)
agent1 = AssistantAgent(name="writer", model_client=client)
agent2 = AssistantAgent(name="editor", model_client=client)
team = RoundRobinGroupChat(
participants=[agent1, agent2],
termination_condition=TextMentionTermination("TERMINATE")
)
server = Server(team=team, source_select="writer")
server.run(host="0.0.0.0", port=8000) # you could do not filled that args. default is that host="0.0.0.0", port=8000
Just write AutoGen team, and... Run it!
CURL call test! example
curl -X POST http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"session_id": "test-session",
"messages": [ { "role": "user", "content": "Please write 5 funny stories." } ]
}'
Demo
Multi team support
from autogen_oaiapi.server import Server
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.teams import RoundRobinGroupChat
from autogen_ext.models.openai import OpenAIChatCompletionClient
from autogen_agentchat.conditions import MaxMessageTermination, TextMentionTermination
client = OpenAIChatCompletionClient(
model="gpt-4.1-nano"
)
agent1 = AssistantAgent(name="writer", model_client=client)
agent2 = AssistantAgent(name="editor", model_client=client)
team = RoundRobinGroupChat(
participants=[agent1, agent2],
termination_condition=TextMentionTermination("TERMINATE"),
)
server = Server()
server.model.register(
name="TEST_TEAM",
actor=team,
source_select="writer",
)
server.run(port=8001)
or
from autogen_oaiapi.server import Server
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.teams import RoundRobinGroupChat
from autogen_ext.models.openai import OpenAIChatCompletionClient
from autogen_agentchat.conditions import MaxMessageTermination, TextMentionTermination
server = Server()
@server.model.register(name="TEST_TEAM_DECORATOR", source_select="writer")
def build_team():
client = OpenAIChatCompletionClient(
model="gpt-4.1-nano"
)
agent1 = AssistantAgent(name="writer", model_client=client)
agent2 = AssistantAgent(name="editor", model_client=client)
team = RoundRobinGroupChat(
participants=[agent1, agent2],
termination_condition=TextMentionTermination("TERMINATE"),
)
return team
server.run(port=8001)
Look at the example folder include more examples!
- simmple example
- function style register example
- decorator sytle register example
- JSON file style api_key register example
- Memory style api_key register example
Star History
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file autogen_oaiapi-0.0.7.tar.gz.
File metadata
- Download URL: autogen_oaiapi-0.0.7.tar.gz
- Upload date:
- Size: 20.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81091cdbc9cafcfcb717070f7790721d946a54a00686e10edaf99efc33fa1513
|
|
| MD5 |
958382d9e9ba327805c15cd94894eaa3
|
|
| BLAKE2b-256 |
e15dec21589f8a9aa4dc6cb4706a4c969d3b6a5a2b4537f0d353a208528b4855
|
File details
Details for the file autogen_oaiapi-0.0.7-py3-none-any.whl.
File metadata
- Download URL: autogen_oaiapi-0.0.7-py3-none-any.whl
- Upload date:
- Size: 25.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b837ede3ca390484ce13901e7eb726c091ea457e3380bd7989df0851f1c3a05
|
|
| MD5 |
b88b90d7f7bb4b6f1c8e261797711489
|
|
| BLAKE2b-256 |
fa78f3bf21c1112c1be4ab1f591bb799d6e5a8252cf1816f188e0f0633e7441f
|