affaan-m/ECC · error · AuthenticationError
{msg}
Error message
{msg} What it means
AstraflowProvider.generate() catches every exception from the chat.completions call and string-matches the message. If '401' or 'authentication' appears in the message it re-raises as AuthenticationError(msg, provider=ASTRAFLOW). The message body is the underlying exception's str(). The provider re-uses the same msg variable for all three classified errors (auth, rate-limit, context-length), so the type is the discriminator, not the text.
Source
Thrown at src/llm/providers/astraflow.py:116
usage = None
if response.usage:
usage = {
"prompt_tokens": response.usage.prompt_tokens,
"completion_tokens": response.usage.completion_tokens,
"total_tokens": response.usage.total_tokens,
}
return LLMOutput(
content=choice.message.content or "",
tool_calls=tool_calls,
model=response.model,
usage=usage,
stop_reason=choice.finish_reason,
)
except Exception as e:
msg = str(e)
if "401" in msg or "authentication" in msg.lower():
raise AuthenticationError(msg, provider=self.provider_type) from e
if "429" in msg or "rate_limit" in msg.lower():
raise RateLimitError(msg, provider=self.provider_type) from e
if "context" in msg.lower() and "length" in msg.lower():
raise ContextLengthError(msg, provider=self.provider_type) from e
raise
def list_models(self) -> list[ModelInfo]:
return self._models.copy()
def validate_config(self) -> bool:
return bool(self.api_key)
def get_default_model(self) -> str:
return self.default_model
class AstraflowProvider(_AstraflowBaseProvider):
"""UModelVerse global endpoint using OpenAI-compatible chat completions."""View on GitHub (pinned to 01e15490f0)
Solutions
- Confirm ASTRAFLOW_API_KEY is exported and matches the dashboard value (no surrounding quotes or whitespace).
- For the CN provider, set ASTRAFLOW_CN_API_KEY and use ASTRAFLOW_CN_BASE_URL.
- Call provider.validate_config() before generate() — it returns bool(self.api_key) and catches a missing key cheaply.
- If the key is correct, verify it is provisioned for the requested model on the provider dashboard.
Example fix
# before
provider = AstraflowProvider()
out = provider.generate(llm_input)
# after
provider = AstraflowProvider()
if not provider.validate_config():
raise SystemExit('ASTRAFLOW_API_KEY not set')
try:
out = provider.generate(llm_input)
except AuthenticationError as e:
raise SystemExit(f'Auth failed for {e.provider}: check ASTRAFLOW_API_KEY') from e Defensive patterns
Strategy: try-catch
Validate before calling
from llm.providers.astraflow import AstraflowProvider
provider = AstraflowProvider()
if not provider.validate_config():
raise SystemExit('ASTRAFLOW_API_KEY not set or empty') Type guard
from llm.core.interface import AuthenticationError, LLMError
def is_auth_error(e: BaseException) -> bool:
return isinstance(e, AuthenticationError) or (
isinstance(e, LLMError) and e.code in {'401', 'authentication'}
) Try / catch
from llm.core.interface import AuthenticationError
try:
out = provider.generate(llm_input)
except AuthenticationError as e:
raise SystemExit(f'auth failed for {e.provider}; check ASTRAFLOW_API_KEY') from e Prevention
- Always call provider.validate_config() before the first generate().
- Use the CN provider (AstraflowCNProvider) with ASTRAFLOW_CN_API_KEY for the api.modelverse.cn endpoint.
- Rotate keys on a schedule and store them via a secret manager, not plaintext env files.
When it happens
Trigger: ASTRAFLOW_API_KEY (or ASTRAFLOW_CN_API_KEY for the CN provider) is missing, wrong, expired, or revoked; the key does not have permission for the requested model; the base_url points at a region where the key is not provisioned.
Common situations: Forgotten env var in CI; copy-paste typo in the key; rotated key not updated in deployment; using a CN key against the global endpoint or vice versa.
Related errors
- LLM returned empty or filtered response
- {self.__class__.__name__} must implement get_default_model
- LLM returned empty or filtered response
- README.md is missing the quick-start catalog summary
- Pass either config or PromptBuilder keyword options, not bot
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/7a3d11dbc38961d2.
Report an issue: GitHub.