Skip to content

Commit 2634b87

Browse files
feat(api): add Australia, India, and Japan residency options (#4246)
## Summary Select the Australia, India, or Japan API endpoint with the data_residency client option. ## Changes - Accept au, in, and jp when creating or copying a client. Validation: `pytest tests/test_data_residency_contract.py -n 0` passed all 59 tests on Python 3.10.16. Co-authored-by: markstuart-oai <[email protected]>
1 parent b4aee4c commit 2634b87

4 files changed

Lines changed: 14 additions & 8 deletions

File tree

‎.castiron.stats.yml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
schema_version: 1
2-
generation_id: adbc6820-e7f1-4d48-aa27-b891b2b96f34
2+
generation_id: a723736b-5fd7-4f1c-8bb6-591eccdd281a
33
openapi_spec_hash: 7a100725044be3f3a874d0c2b8f05009
44
openapi_transformed_spec_hash: 575878ed4503aa9ea08d5a30d30521a7
5-
config_hash: 6305db264c15c7fb32c1a792518d9c79
6-
codegen_sha: 9083c45367587d52944e7fc35c3ff7afaa56c5ab
7-
codegen_hash: 1fea7bbe33cafa2df1f0335d15cec7ae3d0b542149846f05f6876c6c8bb6332d
5+
config_hash: 6ff703b9a9d812681e4e2a4d3a3d6922
6+
codegen_sha: 90b2f8b85520c8b94620ace3c6736b379478781e
7+
codegen_hash: 92653932f81ae408ec9ca2dca9c5568ea1e03554fccf83af4d27bca946575539

‎scripts/castiron/generated-files.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
},
1616
"src/openai/_data_residency.py": {
1717
"mode": "100644",
18-
"sha256": "ba3ff963256d4bafe09779326e1537b34f19e9f16f270568c6cb58774898c0ab"
18+
"sha256": "0e88921105c6e331c33a4762f76c90cbb7049c4f7ea5348fb2ca81e9660010e6"
1919
},
2020
"src/openai/_module_client.py": {
2121
"mode": "100644",
@@ -8159,7 +8159,7 @@
81598159
},
81608160
"tests/test_data_residency_contract.py": {
81618161
"mode": "100644",
8162-
"sha256": "9ad47179a75947000975b25b27878d80d0b9150989a3c10dd4687521e3cdda9c"
8162+
"sha256": "3a99e2fe54866a0e8dc892a4152b0a2c21f43fbe2e90a97af1ed579ced960633"
81638163
},
81648164
"tests/test_multipart_encoding.py": {
81658165
"mode": "100644",

‎src/openai/_data_residency.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@
99
from ._types import NotGiven
1010
from ._exceptions import OpenAIError
1111

12-
DataResidency = Literal["global", "us", "eu", "ae"]
12+
DataResidency = Literal["global", "us", "eu", "ae", "au", "in", "jp"]
1313

1414
_DATA_RESIDENCY_BASE_URLS: dict[DataResidency, str] = {
1515
"global": "https://api.openai.com/v1",
1616
"us": "https://us.api.openai.com/v1",
1717
"eu": "https://eu.api.openai.com/v1",
1818
"ae": "https://ae.api.openai.com/v1",
19+
"au": "https://au.api.openai.com/v1",
20+
"in": "https://in.api.openai.com/v1",
21+
"jp": "https://jp.api.openai.com/v1",
1922
}
2023

2124

@@ -36,5 +39,5 @@ def resolve_data_residency(
3639
if provider is not None:
3740
raise OpenAIError("The `data_residency` and `provider` arguments are mutually exclusive")
3841
if not isinstance(cast(object, data_residency), str) or data_residency not in _DATA_RESIDENCY_BASE_URLS:
39-
raise ValueError("Invalid `data_residency`; expected one of 'global', 'us', 'eu', or 'ae'")
42+
raise ValueError("Invalid `data_residency`; expected one of 'global', 'us', 'eu', 'ae', 'au', 'in', or 'jp'")
4043
return _DATA_RESIDENCY_BASE_URLS[data_residency]

‎tests/test_data_residency_contract.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
("us", "https://us.api.openai.com/v1"),
1616
("eu", "https://eu.api.openai.com/v1"),
1717
("ae", "https://ae.api.openai.com/v1"),
18+
("au", "https://au.api.openai.com/v1"),
19+
("in", "https://in.api.openai.com/v1"),
20+
("jp", "https://jp.api.openai.com/v1"),
1821
]
1922

2023

0 commit comments

Comments
 (0)