Private
Public Access
Fix: Configure base_url dynamically for MiniMax
This resolves the 401 Unauthorized/invalid api_id error by letting the MiniMax client default to api.minimax.io/v1 (like the model listing logic) or read a custom base_url from credentials.toml.
This commit is contained in:
+5
-2
@@ -2075,7 +2075,9 @@ def _list_minimax_models(api_key: str) -> list[str]:
|
|||||||
try:
|
try:
|
||||||
openai = _require_warmed("openai")
|
openai = _require_warmed("openai")
|
||||||
OpenAI = openai.OpenAI
|
OpenAI = openai.OpenAI
|
||||||
client = OpenAI(api_key=api_key, base_url="https://api.minimax.io/v1")
|
creds = _load_credentials()
|
||||||
|
base_url = creds.get("minimax", {}).get("base_url") or "https://api.minimax.io/v1"
|
||||||
|
client = OpenAI(api_key=api_key, base_url=base_url)
|
||||||
models_list = client.models.list()
|
models_list = client.models.list()
|
||||||
found = [m.id for m in models_list]
|
found = [m.id for m in models_list]
|
||||||
if found:
|
if found:
|
||||||
@@ -2138,7 +2140,8 @@ def _ensure_minimax_client() -> None:
|
|||||||
api_key = creds.get("minimax", {}).get("api_key")
|
api_key = creds.get("minimax", {}).get("api_key")
|
||||||
if not api_key:
|
if not api_key:
|
||||||
raise ValueError("MiniMax API key not found in credentials.toml")
|
raise ValueError("MiniMax API key not found in credentials.toml")
|
||||||
_minimax_client = openai.OpenAI(api_key=api_key, base_url="https://api.minimax.chat/v1")
|
base_url = creds.get("minimax", {}).get("base_url") or "https://api.minimax.io/v1"
|
||||||
|
_minimax_client = openai.OpenAI(api_key=api_key, base_url=base_url)
|
||||||
|
|
||||||
def _ensure_grok_client() -> Any:
|
def _ensure_grok_client() -> Any:
|
||||||
global _grok_client
|
global _grok_client
|
||||||
|
|||||||
Reference in New Issue
Block a user