supported_countries.rs

  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        "AS", // American Samoa (US)
 19        "AI", // Anguilla (UK)
 20        "AF", // Afghanistan
 21        "AD", // Andorra
 22        "AO", // Angola
 23        "AG", // Antigua and Barbuda
 24        "AR", // Argentina
 25        "AM", // Armenia
 26        "AU", // Australia
 27        "AT", // Austria
 28        "AZ", // Azerbaijan
 29        "BS", // Bahamas
 30        "BH", // Bahrain
 31        "BD", // Bangladesh
 32        "BB", // Barbados
 33        "BE", // Belgium
 34        "BZ", // Belize
 35        "BJ", // Benin
 36        "BM", // Bermuda (UK)
 37        "BT", // Bhutan
 38        "BO", // Bolivia
 39        "BA", // Bosnia and Herzegovina
 40        "BW", // Botswana
 41        "BR", // Brazil
 42        "IO", // British Indian Ocean Territory (UK)
 43        "BN", // Brunei
 44        "BG", // Bulgaria
 45        "BF", // Burkina Faso
 46        "BI", // Burundi
 47        "CV", // Cabo Verde
 48        "KH", // Cambodia
 49        "CM", // Cameroon
 50        "CA", // Canada
 51        "KY", // Cayman Islands (UK)
 52        "CF", // Central African Republic
 53        "TD", // Chad
 54        "CL", // Chile
 55        "CX", // Christmas Island (AU)
 56        "CC", // Cocos (Keeling) Islands (AU)
 57        "CO", // Colombia
 58        "KM", // Comoros
 59        "CG", // Congo (Brazzaville)
 60        "CD", // Congo (DRC)
 61        "CK", // Cook Islands (NZ)
 62        "CR", // Costa Rica
 63        "CI", // Côte d'Ivoire
 64        "HR", // Croatia
 65        "CY", // Cyprus
 66        "CZ", // Czechia (Czech Republic)
 67        "DK", // Denmark
 68        "DJ", // Djibouti
 69        "DM", // Dominica
 70        "DO", // Dominican Republic
 71        "EC", // Ecuador
 72        "EG", // Egypt
 73        "SV", // El Salvador
 74        "GQ", // Equatorial Guinea
 75        "ER", // Eritrea
 76        "EE", // Estonia
 77        "SZ", // Eswatini (Swaziland)
 78        "ET", // Ethiopia
 79        "FK", // Falkland Islands (UK)
 80        "FJ", // Fiji
 81        "FI", // Finland
 82        "FR", // France
 83        "GF", // French Guiana (FR)
 84        "PF", // French Polynesia (FR)
 85        "TF", // French Southern Territories
 86        "GA", // Gabon
 87        "GM", // Gambia
 88        "GE", // Georgia
 89        "DE", // Germany
 90        "GH", // Ghana
 91        "GI", // Gibraltar (UK)
 92        "GR", // Greece
 93        "GD", // Grenada
 94        "GT", // Guatemala
 95        "GU", // Guam (US)
 96        "GN", // Guinea
 97        "GW", // Guinea-Bissau
 98        "GY", // Guyana
 99        "HT", // Haiti
100        "HM", // Heard Island and McDonald Islands (AU)
101        "VA", // Holy See (Vatican City)
102        "HN", // Honduras
103        "HU", // Hungary
104        "IS", // Iceland
105        "IN", // India
106        "ID", // Indonesia
107        "IQ", // Iraq
108        "IE", // Ireland
109        "IL", // Israel
110        "IT", // Italy
111        "JM", // Jamaica
112        "JP", // Japan
113        "JO", // Jordan
114        "KZ", // Kazakhstan
115        "KE", // Kenya
116        "KI", // Kiribati
117        "KW", // Kuwait
118        "KG", // Kyrgyzstan
119        "LA", // Laos
120        "LV", // Latvia
121        "LB", // Lebanon
122        "LS", // Lesotho
123        "LR", // Liberia
124        "LY", // Libya
125        "LI", // Liechtenstein
126        "LT", // Lithuania
127        "LU", // Luxembourg
128        "MG", // Madagascar
129        "MW", // Malawi
130        "MY", // Malaysia
131        "MV", // Maldives
132        "ML", // Mali
133        "MT", // Malta
134        "MH", // Marshall Islands
135        "MR", // Mauritania
136        "MU", // Mauritius
137        "MX", // Mexico
138        "FM", // Micronesia
139        "MD", // Moldova
140        "MC", // Monaco
141        "MN", // Mongolia
142        "MS", // Montserrat (UK)
143        "ME", // Montenegro
144        "MA", // Morocco
145        "MZ", // Mozambique
146        "MM", // Myanmar
147        "NA", // Namibia
148        "NR", // Nauru
149        "NP", // Nepal
150        "NL", // Netherlands
151        "NZ", // New Zealand
152        "NI", // Nicaragua
153        "NE", // Niger
154        "NG", // Nigeria
155        "NF", // Norfolk Island (AU)
156        "MK", // North Macedonia
157        "MI", // Northern Mariana Islands (UK)
158        "NO", // Norway
159        "NU", // Niue (NZ)
160        "OM", // Oman
161        "PK", // Pakistan
162        "PW", // Palau
163        "PS", // Palestine
164        "PA", // Panama
165        "PG", // Papua New Guinea
166        "PY", // Paraguay
167        "PE", // Peru
168        "PH", // Philippines
169        "PN", // Pitcairn (UK)
170        "PL", // Poland
171        "PT", // Portugal
172        "PR", // Puerto Rico (US)
173        "QA", // Qatar
174        "RO", // Romania
175        "RW", // Rwanda
176        "BL", // Saint Barthélemy (FR)
177        "KN", // Saint Kitts and Nevis
178        "LC", // Saint Lucia
179        "MF", // Saint Martin (FR)
180        "PM", // Saint Pierre and Miquelon (FR)
181        "VC", // Saint Vincent and the Grenadines
182        "WS", // Samoa
183        "SM", // San Marino
184        "ST", // Sao Tome and Principe
185        "SA", // Saudi Arabia
186        "SN", // Senegal
187        "RS", // Serbia
188        "SC", // Seychelles
189        "SH", // Saint Helena, Ascension and Tristan da Cunha (UK)
190        "SL", // Sierra Leone
191        "SG", // Singapore
192        "SK", // Slovakia
193        "SI", // Slovenia
194        "SB", // Solomon Islands
195        "SO", // Somalia
196        "ZA", // South Africa
197        "KR", // South Korea
198        "SS", // South Sudan
199        "ES", // Spain
200        "LK", // Sri Lanka
201        "SR", // Suriname
202        "SE", // Sweden
203        "CH", // Switzerland
204        "SD", // Sudan
205        "TW", // Taiwan
206        "TJ", // Tajikistan
207        "TZ", // Tanzania
208        "TH", // Thailand
209        "TL", // Timor-Leste (East Timor)
210        "TG", // Togo
211        "TK", // Tokelau (NZ)
212        "TO", // Tonga
213        "TT", // Trinidad and Tobago
214        "TN", // Tunisia
215        "TR", // Turkey
216        "TM", // Turkmenistan
217        "TC", // Turks and Caicos Islands (UK)
218        "TV", // Tuvalu
219        "UG", // Uganda
220        "UA", // Ukraine (with certain exceptions)
221        "AE", // United Arab Emirates
222        "GB", // United Kingdom
223        "UM", // United States Minor Outlying Islands (US)
224        "US", // United States of America
225        "UY", // Uruguay
226        "UZ", // Uzbekistan
227        "VU", // Vanuatu
228        "VN", // Vietnam
229        "VI", // Virgin Islands (US)
230        "VG", // Virgin Islands (UK)
231        "WF", // Wallis and Futuna (FR)
232        "YE", // Yemen
233        "ZM", // Zambia
234        "ZW", // Zimbabwe
235    ]
236    .into_iter()
237    .collect()
238});