Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class BaseOpenAIClientConfiguration(CreateArguments, total=False):
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
extra_body: Dict[str, object] | None
"""Additional parameters to pass to the OpenAI API. This is passed directly to the underlying OpenAI client."""


# See OpenAI docs for explanation of these parameters
Expand Down Expand Up @@ -120,6 +122,7 @@ class BaseOpenAIClientConfigurationConfigModel(CreateArgumentsConfigModel):
add_name_prefixes: bool | None = None
include_name_in_message: bool | None = None
default_headers: Dict[str, str] | None = None
extra_body: Dict[str, object] | None = None


# See OpenAI docs for explanation of these parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3378,3 +3378,30 @@ async def test_reasoning_effort_validation() -> None:
}

ChatCompletionClient.load_component(config)


def test_openai_client_config_includes_extra_body() -> None:
"""Test that extra_body is included in config serialization/deserialization."""
from autogen_ext.models.openai import OpenAIChatCompletionClient
from autogen_ext.models.openai.config import OpenAIClientConfigurationConfigModel

config = OpenAIClientConfigurationConfigModel(
model="gpt-4",
api_key="test-key",
extra_body={"enable_thinking": False},
model_info={
"vision": False,
"function_calling": True,
"json_output": True,
"family": "unknown",
"structured_output": True,
},
)

# Verify extra_body is in the config
assert config.extra_body == {"enable_thinking": False}

# Verify it serializes correctly
dumped = config.model_dump(exclude_none=True)
assert "extra_body" in dumped
assert dumped["extra_body"] == {"enable_thinking": False}