API key invalid and model discovery 404: provider errors

TroubleshootingPublished 2026-11-01Author: DeepSeek Plugin Market
API key invalidmodel discovery 404provider configpi_ai_errorDeepSeek Harness
API key invalid and model discovery 404 are two layers: authentication and model list retrieval. Compare checks, status codes, and manual model entry.

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.

ErrorLayerTypical causeCheck first
API key invalidAuthenticationWrong, expired, or unauthorized keyKey and account
Model discovery 404EndpointWrong base URL or pathAddress and protocol
pi_ai_errorFallbackAny of the aboveDetail and logs
provider directory failedLoadingConfig or directory read failureConfig 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.

  1. Value: complete copy, no spaces or newlines.
  2. Scope: permission to call the target model.
  3. State: expired, revoked, or out of balance.
  4. Environment: whether the session actually reads this key, not an old value.
  5. 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.

  1. Address: protocol, host, and port.
  2. Path: whether the base URL includes an extra /v1 or misses a version segment.
  3. Protocol: OpenAI-compatible or provider-specific.
  4. Support: whether the service offers a model list endpoint; if not, it returns 404.
  5. 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.

  1. Find the skip-discovery option or its equivalent.
  2. Enter the model identifier exactly as documented.
  3. Save and open a new session for a test message.
  4. Confirm success, then fix the list endpoint later.
  5. 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.

  1. Swapping keys repeatedly. With a wrong address, ten keys still return 404; determine authentication versus endpoint first.
  2. Reinstalling. Configuration does not change; the same key and address return.
  3. 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."

  1. Authentication: no more 401 or 403.
  2. Model: the list loads or the manual model works.
  3. 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.

  1. One provider, one configuration: do not mix keys and addresses.
  2. Back up before changing: record file locations and key placement.
  3. 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

What is the difference between API key invalid and model discovery 404?

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.

What does pi_ai_error mean, and does it relate to the API 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.

How do I handle model discovery returned HTTP 404 in DeepSeek Harness?

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 work but the model list stays empty. Do I still need to fix the endpoint?

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