Skip to main content
build_config_list() returns the [{model, base_url, api_key, api_type}] shape AutoGen expects, using the same env/keyfile resolution the CLI already performs.
from praisonaiagents import Agent
from praisonai_code.llm.config import build_config_list

config_list = build_config_list()
agent = Agent(name="autogen-bridge", llm=config_list[0]["model"])
agent.start("Summarise today's stand-up notes.")
The user starts an agent; PraisonAI resolves keys and models into an AutoGen-ready config_list first.

Quick Start

1

Standalone import

Set OPENAI_API_KEY in your environment, then:
from praisonaiagents import Agent
from praisonai_code.llm.config import build_config_list

config_list = build_config_list()
# → [{'model': 'gpt-4o-mini', 'base_url': 'https://api.openai.com/v1',
#     'api_key': 'sk-...', 'api_type': 'openai'}]
2

Agent-centric usage with AutoGen

Use build_config_list() inside a PraisonAI agent flow that bridges to an AutoGen adapter:
from praisonaiagents import Agent
from praisonai_code.llm.config import build_config_list

def autogen_task():
    config_list = build_config_list()
    return f"AutoGen config ready: model={config_list[0]['model']}"

agent = Agent(
    name="AutoGen Bridge",
    instructions="Bridge PraisonAI agents to the AutoGen ecosystem.",
    tools=[autogen_task],
)

agent.start("Build the AutoGen config and report the resolved model.")

How It Works


Return Shape

KeySource
modelLLMEndpoint.model — resolved from MODEL_NAME, OPENAI_MODEL_NAME, or provider default
base_urlLLMEndpoint.base_url — resolved from OPENAI_BASE_URL, OPENAI_API_BASE, or provider default
api_keyLLMEndpoint.api_key — resolved from provider-specific env var or stored credentials
api_typeAlways "openai" (AutoGen convention) — omitted when include_api_type=False

Parameters

ParameterTypeDefaultDescription
include_api_typeboolTrueSet False to match callers that historically omit AutoGen’s api_type field
from praisonai_code.llm.config import build_config_list

# Without api_type field
config = build_config_list(include_api_type=False)
# → [{'model': 'gpt-4o-mini', 'base_url': '...', 'api_key': '...'}]

The legacy import from praisonai.llm.config import build_config_list still works — it resolves to the same function object via a sys.modules shim. You do not need to migrate existing code. The unit test test_c5_backward_compat.py::test_module_identity asserts praisonai.llm.config is praisonai_code.llm.config.

Best Practices

Resolution is done at call time — set OPENAI_API_KEY (or the provider-appropriate env var like ANTHROPIC_API_KEY) before calling build_config_list().
import os
os.environ["MODEL_NAME"] = "anthropic/claude-3-5-sonnet-latest"
os.environ["ANTHROPIC_API_KEY"] = "sk-ant-..."

from praisonai_code.llm.config import build_config_list
config = build_config_list()
If you build many AutoGen agents in a hot loop, cache the result — the endpoint resolver reads disk (~/.praison/config) on every call:
from praisonai_code.llm.config import build_config_list

_cached_config = None

def get_config():
    global _cached_config
    if _cached_config is None:
        _cached_config = build_config_list()
    return _cached_config
For non-AutoGen consumers, prefer resolve_llm_endpoint() directly and avoid the api_type field — it returns a typed LLMEndpoint dataclass with model, base_url, and api_key fields:
from praisonai_code.llm.env import resolve_llm_endpoint

ep = resolve_llm_endpoint()
print(ep.model, ep.base_url)

LLM Endpoint Config

Endpoint precedence rules and provider routing

Model Catalogue

Choose the model that goes into the config_list

Standalone LLM Modules

All four LLM modules available in praisonai-code

PraisonAI Code CLI

The standalone runtime these modules power