@@ -155,6 +155,31 @@ fn minimax_token_plan_keys_resolve_to_china_endpoint_without_changing_internatio
155155 assert_eq ! ( china. setup_url, MINIMAX_CHINA_SETUP_URL ) ;
156156}
157157
158+ #[ test]
159+ fn minimax_token_plan_keys_route_to_china_even_when_openai_api_key_env_is_international ( ) {
160+ // Regression for issue #141 (upstream PR #188): users on the MiniMax
161+ // China Token Plan reported a `401 authorized_error` because their
162+ // `sk-cp-...` keys were being sent to `api.minimax.io`. Our fork
163+ // resolves the base URL from the *hint* (the actual key being used to
164+ // call the API), not from a stale `OPENAI_API_KEY` env value, so the
165+ // auto-switch must still kick in even when an unrelated international
166+ // OpenAI key is exported in the shell.
167+ let _lock = crate :: storage:: lock_test_env ( ) ;
168+ let _guard = EnvGuard :: save ( & [ "OPENAI_API_KEY" ] ) ;
169+ crate :: env:: set_var ( "OPENAI_API_KEY" , "sk-international-not-china" ) ;
170+
171+ let resolved = resolve_openai_compatible_profile_with_api_key_hint (
172+ MINIMAX_PROFILE ,
173+ Some ( "sk-cp-real-china-token" ) ,
174+ ) ;
175+ assert_eq ! (
176+ resolved. api_base, MINIMAX_CHINA_API_BASE ,
177+ "sk-cp-* keys must route to api.minimaxi.com regardless of an \
178+ unrelated international OPENAI_API_KEY in env"
179+ ) ;
180+ assert_eq ! ( resolved. setup_url, MINIMAX_CHINA_SETUP_URL ) ;
181+ }
182+
158183#[ test]
159184fn auth_issue_lan_openai_compatible_bases_are_valid_for_local_model_servers ( ) {
160185 assert_eq ! (
0 commit comments