microsoft/autogen · error · ValueError
model is required for when using a Github model with AzureAI
Error message
model is required for when using a Github model with AzureAIChatCompletionClient
What it means
Raised by AzureAIChatCompletionClient._validate_config when _is_github_model(config['endpoint']) is true (endpoint points at GitHub Models, e.g. https://models.github.ai/inference/) but no 'model' kwarg was given. GitHub Models hosts many models behind one endpoint, so the model id must be named explicitly.
Source
Thrown at python/packages/autogen-ext/src/autogen_ext/models/azure/_azure_ai_client.py:309
config = self._validate_config(kwargs) # type: ignore
self._model_info = config["model_info"] # type: ignore
self._client = self._create_client(config)
self._create_args = self._prepare_create_args(config)
self._actual_usage = RequestUsage(prompt_tokens=0, completion_tokens=0)
self._total_usage = RequestUsage(prompt_tokens=0, completion_tokens=0)
@staticmethod
def _validate_config(config: Dict[str, Any]) -> AzureAIChatCompletionClientConfig:
if "endpoint" not in config:
raise ValueError("endpoint is required for AzureAIChatCompletionClient")
if "credential" not in config:
raise ValueError("credential is required for AzureAIChatCompletionClient")
if "model_info" not in config:
raise ValueError("model_info is required for AzureAIChatCompletionClient")
validate_model_info(config["model_info"])
if _is_github_model(config["endpoint"]) and "model" not in config:
raise ValueError("model is required for when using a Github model with AzureAIChatCompletionClient")
return cast(AzureAIChatCompletionClientConfig, config)
@staticmethod
def _create_client(config: AzureAIChatCompletionClientConfig) -> ChatCompletionsClient:
# Only pass the parameters that ChatCompletionsClient accepts
# Remove 'model_info' and other client-specific parameters
client_config = {k: v for k, v in config.items() if k not in ("model_info",)}
return ChatCompletionsClient(**client_config) # type: ignore
@staticmethod
def _prepare_create_args(config: Mapping[str, Any]) -> Dict[str, Any]:
create_args = {k: v for k, v in config.items() if k in create_kwargs}
return create_args
def add_usage(self, usage: RequestUsage) -> None:
self._total_usage = RequestUsage(
self._total_usage.prompt_tokens + usage.prompt_tokens,
self._total_usage.completion_tokens + usage.completion_tokens,View on GitHub (pinned to 027ecf0a37)
Solutions
- Add the model kwarg, e.g. model='openai/gpt-4o' (org/model format used by GitHub Models)
- Alternatively point endpoint at an Azure AI Foundry deployment URL where the model is bound to the route
- Double-check the endpoint string: anything matching the GitHub Models host triggers this requirement even if unintended
Example fix
# before
client = AzureAIChatCompletionClient(
endpoint="https://models.github.ai/inference", credential=cred, model_info=info)
# after
client = AzureAIChatCompletionClient(
endpoint="https://models.github.ai/inference", credential=cred,
model="openai/gpt-4o", model_info=info,
) Defensive patterns
Strategy: validation
Validate before calling
def github_needs_model(endpoint: str, cfg: dict) -> bool:
return "models.github.ai" in endpoint and "model" not in cfg Prevention
- Always pass model when the endpoint host is models.github.ai
- Use org/model ids (e.g. 'openai/gpt-4o') for GitHub Models
- Add a config lint rule keyed on the endpoint URL
When it happens
Trigger: AzureAIChatCompletionClient(endpoint='https://models.github.ai/inference', credential=..., model_info=...) with model omitted.
Common situations: Using a GitHub personal access token against the Models inference endpoint and copying an Azure Foundry config that did not need 'model'; forgetting that model is only optional for non-GitHub endpoints.
Related errors
- endpoint is required for AzureAIChatCompletionClient
- credential is required for AzureAIChatCompletionClient
- model_info is required for AzureAIChatCompletionClient
- BING_API_KEY environment variable is not set
- Please set AZURE_OPENAI_API_KEY environment variable.
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/d0f18d32d59f3023.
Report an issue: GitHub.