@@ -445,6 +445,14 @@ class Model(BaseModel):
445
445
assert isinstance (response , Model )
446
446
assert response .foo == 2
447
447
448
+ def test_base_url_setter (self ) -> None :
449
+ client = OpenAI (base_url = "https://example.com/from_init" , api_key = api_key , _strict_response_validation = True )
450
+ assert client .base_url == "https://example.com/from_init/"
451
+
452
+ client .base_url = "https://example.com/from_setter" # type: ignore[assignment]
453
+
454
+ assert client .base_url == "https://example.com/from_setter/"
455
+
448
456
def test_base_url_env (self ) -> None :
449
457
with update_env (OPENAI_BASE_URL = "http://localhost:5000/from/env" ):
450
458
client = OpenAI (api_key = api_key , _strict_response_validation = True )
@@ -1102,6 +1110,16 @@ class Model(BaseModel):
1102
1110
assert isinstance (response , Model )
1103
1111
assert response .foo == 2
1104
1112
1113
+ def test_base_url_setter (self ) -> None :
1114
+ client = AsyncOpenAI (
1115
+ base_url = "https://example.com/from_init" , api_key = api_key , _strict_response_validation = True
1116
+ )
1117
+ assert client .base_url == "https://example.com/from_init/"
1118
+
1119
+ client .base_url = "https://example.com/from_setter" # type: ignore[assignment]
1120
+
1121
+ assert client .base_url == "https://example.com/from_setter/"
1122
+
1105
1123
def test_base_url_env (self ) -> None :
1106
1124
with update_env (OPENAI_BASE_URL = "http://localhost:5000/from/env" ):
1107
1125
client = AsyncOpenAI (api_key = api_key , _strict_response_validation = True )
0 commit comments