1use std::collections::HashSet;
2use std::sync::LazyLock;
3
4/// Returns whether the given country code is supported by OpenAI.
5///
6/// https://platform.openai.com/docs/supported-countries
7pub fn is_supported_country(country_code: &str) -> bool {
8 SUPPORTED_COUNTRIES.contains(&country_code)
9}
10
11/// The list of country codes supported by OpenAI.
12///
13/// https://platform.openai.com/docs/supported-countries
14static SUPPORTED_COUNTRIES: LazyLock<HashSet<&'static str>> = LazyLock::new(|| {
15 vec![
16 "AL", // Albania
17 "DZ", // Algeria
18 "AF", // Afghanistan
19 "AD", // Andorra
20 "AO", // Angola
21 "AG", // Antigua and Barbuda
22 "AR", // Argentina
23 "AM", // Armenia
24 "AU", // Australia
25 "AT", // Austria
26 "AZ", // Azerbaijan
27 "BS", // Bahamas
28 "BH", // Bahrain
29 "BD", // Bangladesh
30 "BB", // Barbados
31 "BE", // Belgium
32 "BZ", // Belize
33 "BJ", // Benin
34 "BT", // Bhutan
35 "BO", // Bolivia
36 "BA", // Bosnia and Herzegovina
37 "BW", // Botswana
38 "BR", // Brazil
39 "BN", // Brunei
40 "BG", // Bulgaria
41 "BF", // Burkina Faso
42 "BI", // Burundi
43 "CV", // Cabo Verde
44 "KH", // Cambodia
45 "CM", // Cameroon
46 "CA", // Canada
47 "CF", // Central African Republic
48 "TD", // Chad
49 "CL", // Chile
50 "CO", // Colombia
51 "KM", // Comoros
52 "CG", // Congo (Brazzaville)
53 "CD", // Congo (DRC)
54 "CR", // Costa Rica
55 "CI", // Côte d'Ivoire
56 "HR", // Croatia
57 "CY", // Cyprus
58 "CZ", // Czechia (Czech Republic)
59 "DK", // Denmark
60 "DJ", // Djibouti
61 "DM", // Dominica
62 "DO", // Dominican Republic
63 "EC", // Ecuador
64 "EG", // Egypt
65 "SV", // El Salvador
66 "GQ", // Equatorial Guinea
67 "ER", // Eritrea
68 "EE", // Estonia
69 "SZ", // Eswatini (Swaziland)
70 "ET", // Ethiopia
71 "FJ", // Fiji
72 "FI", // Finland
73 "FR", // France
74 "GA", // Gabon
75 "GM", // Gambia
76 "GE", // Georgia
77 "DE", // Germany
78 "GH", // Ghana
79 "GR", // Greece
80 "GD", // Grenada
81 "GT", // Guatemala
82 "GN", // Guinea
83 "GW", // Guinea-Bissau
84 "GY", // Guyana
85 "HT", // Haiti
86 "VA", // Holy See (Vatican City)
87 "HN", // Honduras
88 "HU", // Hungary
89 "IS", // Iceland
90 "IN", // India
91 "ID", // Indonesia
92 "IQ", // Iraq
93 "IE", // Ireland
94 "IL", // Israel
95 "IT", // Italy
96 "JM", // Jamaica
97 "JP", // Japan
98 "JO", // Jordan
99 "KZ", // Kazakhstan
100 "KE", // Kenya
101 "KI", // Kiribati
102 "KW", // Kuwait
103 "KG", // Kyrgyzstan
104 "LA", // Laos
105 "LV", // Latvia
106 "LB", // Lebanon
107 "LS", // Lesotho
108 "LR", // Liberia
109 "LY", // Libya
110 "LI", // Liechtenstein
111 "LT", // Lithuania
112 "LU", // Luxembourg
113 "MG", // Madagascar
114 "MW", // Malawi
115 "MY", // Malaysia
116 "MV", // Maldives
117 "ML", // Mali
118 "MT", // Malta
119 "MH", // Marshall Islands
120 "MR", // Mauritania
121 "MU", // Mauritius
122 "MX", // Mexico
123 "FM", // Micronesia
124 "MD", // Moldova
125 "MC", // Monaco
126 "MN", // Mongolia
127 "ME", // Montenegro
128 "MA", // Morocco
129 "MZ", // Mozambique
130 "MM", // Myanmar
131 "NA", // Namibia
132 "NR", // Nauru
133 "NP", // Nepal
134 "NL", // Netherlands
135 "NZ", // New Zealand
136 "NI", // Nicaragua
137 "NE", // Niger
138 "NG", // Nigeria
139 "MK", // North Macedonia
140 "NO", // Norway
141 "OM", // Oman
142 "PK", // Pakistan
143 "PW", // Palau
144 "PS", // Palestine
145 "PA", // Panama
146 "PG", // Papua New Guinea
147 "PY", // Paraguay
148 "PE", // Peru
149 "PH", // Philippines
150 "PL", // Poland
151 "PT", // Portugal
152 "QA", // Qatar
153 "RO", // Romania
154 "RW", // Rwanda
155 "KN", // Saint Kitts and Nevis
156 "LC", // Saint Lucia
157 "VC", // Saint Vincent and the Grenadines
158 "WS", // Samoa
159 "SM", // San Marino
160 "ST", // Sao Tome and Principe
161 "SA", // Saudi Arabia
162 "SN", // Senegal
163 "RS", // Serbia
164 "SC", // Seychelles
165 "SL", // Sierra Leone
166 "SG", // Singapore
167 "SK", // Slovakia
168 "SI", // Slovenia
169 "SB", // Solomon Islands
170 "SO", // Somalia
171 "ZA", // South Africa
172 "KR", // South Korea
173 "SS", // South Sudan
174 "ES", // Spain
175 "LK", // Sri Lanka
176 "SR", // Suriname
177 "SE", // Sweden
178 "CH", // Switzerland
179 "SD", // Sudan
180 "TW", // Taiwan
181 "TJ", // Tajikistan
182 "TZ", // Tanzania
183 "TH", // Thailand
184 "TL", // Timor-Leste (East Timor)
185 "TG", // Togo
186 "TO", // Tonga
187 "TT", // Trinidad and Tobago
188 "TN", // Tunisia
189 "TR", // Turkey
190 "TM", // Turkmenistan
191 "TV", // Tuvalu
192 "UG", // Uganda
193 "UA", // Ukraine (with certain exceptions)
194 "AE", // United Arab Emirates
195 "GB", // United Kingdom
196 "US", // United States of America
197 "UY", // Uruguay
198 "UZ", // Uzbekistan
199 "VU", // Vanuatu
200 "VN", // Vietnam
201 "YE", // Yemen
202 "ZM", // Zambia
203 "ZW", // Zimbabwe
204 ]
205 .into_iter()
206 .collect()
207});