Add http client property in serialized config
What happened?
Describe the bug When using company's customized model, if we do not pass the http_client parameter, the endpoint will reject our access
To Reproduce Using the simple code: def load_config(file_path: str = os.path.join(os.path.dirname(file), "model_config.yaml")): with open(file_path, "r") as file: if file_path.endswith('.json'): config_data = json.load(file) elif file_path.endswith('.yaml'): config_data = yaml.safe_load(file) if len(config_data['config'].get("api_key", "")) == 0: config_data['config']['api_key'] = os.getenv("AZURE_API_KEY") if config_data['config']['model'].startswith("gemini-"): config_data['config']["http_client"] = httpx.AsyncClient(verify=False) return config_data
model_config = load_config() model_client = OpenAIChatCompletionClient(**model_config['config'])
Expected behavior We can pass http_client property to AsyncOpenAI(http_client=xxx)
Screenshots N/A
Additional context Add http_client to BaseOpenAIClientConfiguration,such as: class BaseOpenAIClientConfiguration(CreateArguments, total=False): model: str api_key: str timeout: Union[float, None] ...... http_client: AsyncClient | None
Which packages was the bug in?
Python Extensions (autogen-ext)
AutoGen library version.
Python 0.7.5
Other library version.
No response
Model used
gemini-2.5-pro
Model provider
Azure OpenAI
Other model provider
No response
Python version
3.12
.NET version
None
Operating system
None
I analyzed this issue but couldn't identify the affected files. Could you please provide more details about which files need to be modified?
I analyzed this issue but couldn't identify the affected files. Could you please provide more details about which files need to be modified?
I analyzed this issue but couldn't identify the affected files. Could you please provide more details about which files need to be modified? @priteesshhh
file path: https://github.com/microsoft/autogen/blob/main/python/packages/autogen-ext/src/autogen_ext/models/openai/config/init.py
#Add the http_client property to BaseOpenAIClientConfiguration, such as: class BaseOpenAIClientConfiguration(CreateArguments, total=False): model: str api_key: str timeout: Union[float, None] max_retries: int model_capabilities: ModelCapabilities # type: ignore model_info: ModelInfo add_name_prefixes: bool """What functionality the model supports, determined by default from model name but is overriden if value passed.""" include_name_in_message: bool """Whether to include the 'name' field in user message parameters. Defaults to True. Set to False for providers that don't support the 'name' field.""" default_headers: Dict[str, str] | None http_client: AsyncClient | None
Hi @zhangshan123 i'd like to contribute to this issue. I understand this involves adding an HTTP client property to the serialized configuration. I've also found that model clients use dump_component() for serialization (e.g. in _openai_client.py).
My plan is to:
- Investigate how HTTP clients are currently configured in model clients (OpenAI, Anthropic, etc.)
- Identify where the HTTP client property should be added to the serialized config
- Ensure the HTTP client is properly serialized/deserialized when using dump_component() and load_component()
- Add appropriate tests to verify serialization works correctly
Could you provide a bit more context on:
- Which specific HTTP client property needs to be serialized? (e.g., timeout, connection pool settings, custom headers?) 2.Are there any specific model clients this should apply to or should it be a general feature?
I'm ready to start once I have clarification. Thanks