Connect Microsoft AutoGen (v0.4) & AG2 to byesu API
Key facts: In modern AutoGen v0.4 (
autogen-agentchat+autogen-ext[openai]), setbase_url="https://byesu.com/v1"onOpenAIChatCompletionClientand pass an explicitmodel_infodictionary so non-OpenAI IDs likeclaude-opus-5-5anddeepseek-v4-pronever raiseValueError: model_info is required. Classic AG2 (llm_config) works over the exact same/v1endpoint andautogroup key.
The AutoGen ecosystem spans two widely deployed Python APIs: Microsoft's async, event-driven AutoGen v0.4+ (autogen-agentchat) and classic llm_config-based AG2 (ag2 / v0.2). Connecting either stack to byesu lets multi-agent teams pair claude-opus-5-5, gpt-6.2-sol, gemini-4-argon, and deepseek-v4-pro under one pay-as-you-go API key.
Quick configuration
- OpenAI-compatible
base_url:https://byesu.com/v1(covers all vendors viaOpenAIChatCompletionClientorllm_config) - Anthropic-native
base_url:https://byesu.com(no/v1, forautogen-ext[anthropic]+0.1xcache reads) - API Key:
BYESU_API_KEY="sk-..."in the defaultautogroup (Sign up & get key)
Option 1: Modern AutoGen v0.4 (autogen-agentchat + model_info Fix)
Install the official v0.4 packages:
pip install "autogen-agentchat" "autogen-ext[openai]"
export BYESU_API_KEY="sk-your-byesu-token"Why ValueError: model_info is required Happens — and How to Fix It
OpenAIChatCompletionClient validates model against a built-in table of legacy OpenAI model names. Whenever you pass a non-OpenAI identifier (claude-opus-5-5, deepseek-v4-pro, gemini-4-argon) or a newer generation (gpt-6.2-sol), AutoGen throws:
ValueError: model_info is required when model name is not a valid OpenAI modelPassing an explicit model_info dictionary resolves this cleanly and tells AutoGen's runtime which capabilities (vision, function_calling, json_output, structured_output) each agent supports:
import asyncio
import os
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.conditions import MaxMessageTermination
from autogen_agentchat.teams import RoundRobinGroupChat
from autogen_ext.models.openai import OpenAIChatCompletionClient
BYESU_KEY = os.environ["BYESU_API_KEY"]
BYESU_V1 = "https://byesu.com/v1"
# Multimodal + tool-capable model_info (Claude 5.5, GPT-6.2, Gemini 4 Argon)
MULTIMODAL_TOOL_INFO = {
"vision": True,
"function_calling": True,
"json_output": True,
"family": "unknown",
"structured_output": True,
}
# Text-only + tool-capable model_info (DeepSeek V4 Pro)
TEXT_TOOL_INFO = {
"vision": False,
"function_calling": True,
"json_output": True,
"family": "unknown",
"structured_output": True,
}
async def main() -> None:
architect_client = OpenAIChatCompletionClient(
model="claude-opus-5-5",
api_key=BYESU_KEY,
base_url=BYESU_V1,
model_info=MULTIMODAL_TOOL_INFO,
timeout=150.0,
)
verifier_client = OpenAIChatCompletionClient(
model="deepseek-v4-pro",
api_key=BYESU_KEY,
base_url=BYESU_V1,
model_info=TEXT_TOOL_INFO,
timeout=120.0,
)
architect = AssistantAgent(
name="architect",
model_client=architect_client,
system_message="Propose a concise PostgreSQL advisory-lock migration runner in Python.",
)
verifier = AssistantAgent(
name="verifier",
model_client=verifier_client,
system_message="Check connection-pool session affinity pitfalls in PgBouncer transaction mode.",
)
team = RoundRobinGroupChat(
[architect, verifier],
termination_condition=MaxMessageTermination(max_messages=3),
)
result = await team.run(task="Design a zero-race schema migration lock for 8 replicas.")
for msg in result.messages:
print(f"[{msg.source}]: {msg.content}\n")
await architect_client.close()
await verifier_client.close()
asyncio.run(main())Optional: Native Anthropic Client (0.1x Prompt Caching)
If your AutoGen v0.4 team relies heavily on Claude 5.5 with large shared system prompts, autogen-ext[anthropic] speaks native /v1/messages to https://byesu.com (without /v1), preserving 0.1x cache-read billing (Prompt Caching guide):
import os
from autogen_ext.models.anthropic import AnthropicChatCompletionClient
claude_native = AnthropicChatCompletionClient(
model="claude-sonnet-5-5",
api_key=os.environ["BYESU_API_KEY"],
base_url="https://byesu.com", # NO /v1 suffix
model_info=MULTIMODAL_TOOL_INFO,
)Option 2: Classic AutoGen v0.2 / AG2 (llm_config Compatibility)
Maintaining an existing AG2 (pip install "ag2[openai]") codebase? Pass base_url: "https://byesu.com/v1" inside config_list:
import os
from autogen import AssistantAgent, UserProxyAgent
config_list = [
{
"model": "claude-sonnet-5-5",
"api_key": os.environ["BYESU_API_KEY"],
"base_url": "https://byesu.com/v1",
},
{
"model": "gpt-6.1-sol",
"api_key": os.environ["BYESU_API_KEY"],
"base_url": "https://byesu.com/v1",
},
]
llm_config = {
"config_list": config_list,
"timeout": 150,
}
assistant = AssistantAgent("coder", llm_config=llm_config)
user_proxy = UserProxyAgent("user", code_execution_config=False, human_input_mode="NEVER")
user_proxy.initiate_chat(assistant, message="Write an exponential backoff decorator with full jitter.", max_turns=1)Production Best Practices
- Omit fixed
temperatureon Claude 5.5 and GPT-6.2: Do not add"temperature": 0tollm_configorOpenAIChatCompletionClientwhen callingclaude-opus-5-5,claude-sonnet-5-5, orgpt-6.2-sol— fixed sampling parameters trigger HTTP400(Claude 400 temperature fix, OpenAImax_tokensfix). - Set
vision: Falsefor text-only models: Keeping"vision": Falseondeepseek-v4-proprevents AutoGen multimodal message adapters from sending raw image blocks to text-only endpoints. - Timeouts & billing: Set
timeout >= 120–150s based on real p95 data in the December 2026 Production Latency & Uptime Report. Usage bills pay-as-you-go per token in the byesu Console with live rates shown after sign-in; compare snippets in the Config Generator or see CrewAI Setup and LangChain Setup.
FAQ
How do I fix ValueError: model_info is required in AutoGen v0.4?
Pass model_info={"vision": True, "function_calling": True, "json_output": True, "family": "unknown", "structured_output": True} (or "vision": False for text-only models) to OpenAIChatCompletionClient.
Does AutoGen v0.4 work with Claude, GPT-6.2, Gemini, and DeepSeek on one byesu key?
Yes. All default auto group models work over base_url="https://byesu.com/v1" using a single BYESU_API_KEY (Choosing a Group).
Can classic AutoGen v0.2 / AG2 llm_config connect to byesu API?
Yes. Add "base_url": "https://byesu.com/v1" and "api_key": os.environ["BYESU_API_KEY"] to each item in config_list.
Can AutoGen v0.4 also call byesu's native Anthropic /v1/messages endpoint?
Yes. Use AnthropicChatCompletionClient from autogen-ext[anthropic] with base_url="https://byesu.com" (without /v1).