Integration & Automation#
This section covers how to integrate MassGen into your applications and automate workflows. MassGen offers multiple integration paths for different use cases.
Choosing Your Integration#
Method |
Best For |
Key Features |
|---|---|---|
HTTP Server |
API gateways, proxies, external apps |
OpenAI-compatible endpoints, SSE streaming |
Python API |
Application integration, automation scripts |
Async-first, full control, direct access |
LiteLLM |
Existing LiteLLM users, LangChain integration |
OpenAI-compatible, drop-in replacement |
Automation Mode |
Background execution, CI/CD pipelines |
Headless, non-interactive, scriptable |
Guides in This Section#
OpenAI-compatible API
massgen servecommand/v1/chat/completionsendpointStreaming via SSE
Config-as-Authority mode
Direct Python integration
massgen.run()async APImassgen.build_config()programmatic configLiteLLM provider registration
Full control over execution
Headless execution
Background execution
CI/CD integration
Status file monitoring
Non-interactive mode
External frameworks
AG2 framework integration
LangChain compatibility
Custom backends
External tools
Quick Examples#
# Start the server with a config
massgen serve --config balanced.yaml --port 4000
# Any OpenAI-compatible client works
from openai import OpenAI
client = OpenAI(base_url="http://localhost:4000/v1", api_key="unused")
response = client.chat.completions.create(
model="massgen", # Ignored when config is provided
messages=[{"role": "user", "content": "Your question"}]
)
print(response.choices[0].message.content) # Final answer
print(response.choices[0].message.reasoning_content) # Traces
import asyncio
import massgen
async def main():
result = await massgen.run(
query="Analyze this problem",
models=["gpt-5", "claude-sonnet-4-5-20250929"]
)
print(result["final_answer"])
asyncio.run(main())
import litellm
from massgen import register_with_litellm
register_with_litellm()
response = litellm.completion(
model="massgen/build",
messages=[{"role": "user", "content": "Your question"}],
optional_params={"models": ["openai/gpt-5", "anthropic/claude-sonnet-4-5-20250929"]}
)
print(response.choices[0].message.content)
# Run in automation mode (headless)
massgen --automation --model gpt-5 "Your question"
# Monitor with status file
massgen --automation --status-file status.json "Your query"