Skip to content

Commit 7e55afc

Browse files
fix(voice) reject ignored explicit-client options (#4527)
1 parent 3e0dc82 commit 7e55afc

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

src/agents/voice/models/openai_model_provider.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,11 @@ def __init__(
5959
agent_registration: Optional agent registration configuration.
6060
"""
6161
if openai_client is not None:
62-
if api_key is not None or base_url is not None:
63-
raise UserError("Don't provide api_key or base_url if you provide openai_client")
62+
if any(value is not None for value in (api_key, base_url, organization, project)):
63+
raise UserError(
64+
"Don't provide api_key, base_url, organization, or project if you provide "
65+
"openai_client"
66+
)
6467
self._client: AsyncOpenAI | None = openai_client
6568
else:
6669
self._client = None

tests/voice/test_openai_model_provider.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
[
1717
{"api_key": "other_key"},
1818
{"base_url": "https://example.com"},
19+
{"organization": "org_test"},
20+
{"project": "proj_test"},
1921
{"api_key": "other_key", "base_url": "https://example.com"},
2022
],
2123
)

0 commit comments

Comments
 (0)