API key invalid and model discovery 404: provider errors
API key invalid and model discovery 404 are two layers: "who you are" and "which models exist." Mixing them leads to swapping keys when the real problem is the base URL.
Two errors, separate first
The symptoms look similar; the tests differ.
| Error | Layer | Typical cause | Check first |
|---|---|---|---|
| API key invalid | Authentication | Wrong, expired, or unauthorized key | Key and account |
| Model discovery 404 | Endpoint | Wrong base URL or path | Address and protocol |
| pi_ai_error | Fallback | Any of the above | Detail and logs |
| provider directory failed | Loading | Config or directory read failure | Config and permissions |
Authentication asks "do you have permission"; endpoint failure asks "is the address right." Both break requests, but the fixes are different.
pi_ai_error is not the root cause. It is a fallback label with detail behind it; staring at the label hides the error.
Layer one: key and permissions
Check value, scope, and state.
- Value: complete copy, no spaces or newlines.
- Scope: permission to call the target model.
- State: expired, revoked, or out of balance.
- Environment: whether the session actually reads this key, not an old value.
- Provider: the key and base URL belong to the same service.
Keys and endpoints must pair. Using provider A's key with provider B's URL always fails authentication; it looks like a bad key, but it is a mixed configuration.
Restart or reload after changing a key. A running process may hold the old value.
Layer two: model discovery and address
Check address, path, protocol, and support.
- Address: protocol, host, and port.
- Path: whether the base URL includes an extra /v1 or misses a version segment.
- Protocol: OpenAI-compatible or provider-specific.
- Support: whether the service offers a model list endpoint; if not, it returns 404.
- Network: whether a proxy or gateway rewrites the request.
Base URL syntax is the most common mistake, and 404 is not a bad key. Authentication failures usually return 401 or 403, while 404 points to address or path; read the status code before changing configuration (source).
Recovery: skip discovery, enter manually
When the model list fails, manual entry is the fastest recovery.
- Find the skip-discovery option or its equivalent.
- Enter the model identifier exactly as documented.
- Save and open a new session for a test message.
- Confirm success, then fix the list endpoint later.
- Return to automatic discovery once it works.
Manual entry does not reduce usability. Automatic discovery is convenience; working matters more than a populated list. Match the name character for character: case, version suffix, and namespace all matter.
Three common misreads
Three reactions waste time.
- Swapping keys repeatedly. With a wrong address, ten keys still return 404; determine authentication versus endpoint first.
- Reinstalling. Configuration does not change; the same key and address return.
- Deleting the session. Session data and provider configuration are separate; deletion does not fix 404.
All three skip the status code. 401 and 404 point to different layers; read them first.
Collect evidence before changing. Record the full error, request address, and time.
Verify after fixing
Three checks, not just "saved."
- Authentication: no more 401 or 403.
- Model: the list loads or the manual model works.
- Request: a new session replies, and logs show the right address and model.
All three must pass. Passing only the first may mean a different error remains.
Keep a fix record. What changed, to what value, and the result; reuse it next time.
Prevention: separate configuration layers
Three habits keep provider configuration clean.
- One provider, one configuration: do not mix keys and addresses.
- Back up before changing: record file locations and key placement.
- Change one item at a time: address, key, and model separately.
Configuration is infrastructure, not a one-time setup. Records beat guessing.
Next steps
Read the status code, then fix the layer. For general key errors, read API key error troubleshooting. For incomplete model lists, read Model list incomplete. For provider setup, read How to configure models.
Sources: DeepSeek Harness docs, dsh CLI README, deepseek-harness repository
FAQ
API key invalid and model discovery 404 differ in layer. The first is authentication of the key or account, while the second is model list retrieval with a possibly valid key.
pi_ai_error is a fallback provider error category that may contain authentication, network, or model-not-found causes. Read the attached detail, not just the label.
For model discovery returned HTTP 404, check whether the base URL includes the correct path and version, then whether the provider supports model listing. If not, enter the model name manually.
Manual models that work with an empty model list need no fix for use. Automatic discovery is a convenience, and fixing the endpoint is optional.
Related Terms
- API key
- An API key is the credential for model service calls; scope and expiry are set by the provider, and an invalid key returns an authentication error.— DeepSeek Harness docs
- model discovery
- Model discovery queries a provider for available models, usually through a /v1/models-style endpoint; failure prevents automatic model filling.— DeepSeek Harness docs
- base URL
- base URL is the root address of a model service including protocol, host, and any version path; a wrong value causes 404s.— DeepSeek Harness docs
- pi_ai_error
- pi_ai_error is a fallback provider call error category; the specific cause appears in attached information and logs.— DeepSeek Harness docs
Sources
- DeepSeek Harness docs· deepseek-harness
- dsh CLI README· deepseek-ai
- deepseek-harness repository· deepseek-ai