Skip to main content

An OpenAI-compatible API server for AutoGen.

Project description

🧠 autogen-oaiapi

GitHub stars Downloads

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 AssistantAgent with tools.

✨ Features

  • OpenAI-compatible API interface
  • ✅ Plug in any AutoGen GroupChat or SocietyOfMindAgent
  • ✅ Session-aware execution (per session_id)
  • ✅ FastAPI-based server with /v1/chat/completions endpoint
  • stream=True response 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

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

Star History Chart

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

autogen_oaiapi-0.0.7.tar.gz (20.1 kB view details)

Uploaded Source

Built Distribution

autogen_oaiapi-0.0.7-py3-none-any.whl (25.2 kB view details)

Uploaded Python 3

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

Hashes for autogen_oaiapi-0.0.7.tar.gz
Algorithm Hash digest
SHA256 81091cdbc9cafcfcb717070f7790721d946a54a00686e10edaf99efc33fa1513
MD5 958382d9e9ba327805c15cd94894eaa3
BLAKE2b-256 e15dec21589f8a9aa4dc6cb4706a4c969d3b6a5a2b4537f0d353a208528b4855

See more details on using hashes here.

File details

Details for the file autogen_oaiapi-0.0.7-py3-none-any.whl.

File metadata

File hashes

Hashes for autogen_oaiapi-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 4b837ede3ca390484ce13901e7eb726c091ea457e3380bd7989df0851f1c3a05
MD5 b88b90d7f7bb4b6f1c8e261797711489
BLAKE2b-256 fa78f3bf21c1112c1be4ab1f591bb799d6e5a8252cf1816f188e0f0633e7441f

See more details on using hashes here.

Supported by

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