DeepSeek Harness API key lifecycle: create to revoke
An API key has five stages: create, store, use, rotate, revoke — and each has its own failure mode. Configuring one successfully only finishes stage one. Most "the key suddenly stopped working" and "calls still happen after uninstall" reports come from an incomplete rotation or cleanup.
Why treat an API key as a lifecycle
A key is a credential, not a setting. A wrong setting can be edited; a leaked credential can only be revoked. The five stages answer five questions: who uses it, where it lives, who can read it, how it changes, and how it dies. Miss one and it surfaces during an incident.
DeepSeek Harness API key create and store: naming and location
The first rule is distinguishability. Naming and allocation decide whether you can revoke one thing without stopping everything:
- One key per environment: local, staging, production;
- One key per purpose: daily sessions, CI, and billing or balance plugins;
- Names carry information, such as
dsh-dev-localordsh-ci-nightly; - Record ownership: requester, creation date, and machine;
- Never paste a key into sample configuration or documentation.
Sharing costs you clean revocation. One key across five people means a leak forces a full stop for everyone.
Creating it is only step one; step two is where it lands. DeepSeek Harness keeps credentials apart from ordinary configuration. Under DSH_HOME (~/.dsh):
| Content | Typical location | Notes |
|---|---|---|
| Settings | settings.yaml | Model, port, UI, non-sensitive |
| Credentials | credential file | Keys and secrets, kept separate |
| Sessions | sessions/ | Transcripts, may reference model names |
| Plugins | profiles/ | Dependencies and plugin config |
Tighten file permissions. Confirm only your user can read the file; chmod 777 on a shared machine publishes the key.
Restart after editing. Changing a file without restarting leaves the running process holding the old value, which reads as "I changed it and nothing happened".
Who reads the API key inside DeepSeek Harness
The main program is not the only reader; plugins and scripts read it too.
- The model call layer uses it for conversations;
- Balance and billing plugins use it to query quota or usage;
- Custom scripts and CI inject it through environment variables.
Three places leak keys in practice: shell history, exported configuration files, and screenshots. Before pasting logs, search for the key prefix and replace it.
Give plugins the minimum. A plugin that only reads a balance does not need conversation rights; issue it a separate key when possible.
Rotating an API key: add before removing
Rotation exists to avoid downtime, which fixes the order.
- Create a new key at the provider, named with the date;
- Write it into the credential store or environment while keeping the old one;
- Restart and verify with a minimal message;
- Move plugins and CI to the new key, verifying each;
- Revoke the old key only after all checks pass.
Removing first creates a gap. If the new key is not active yet, the service is simply down, and the failure looks like a network problem rather than a credential problem.
Watch usage for a day after rotating. Traffic should hand over from old to new; only when the old key's usage reaches zero is the switch complete (source).
Revoking an API key, leftover copies, and leak response
Revoking a key is not the same as cleaning the machine. Do both.
- Revoke or delete the key at the provider and confirm it is invalid;
- Remove the old value from local credential files, do not just comment it out;
- Check shell history, CI variables, container images, and exported environment;
- Check backups and configuration exports;
- After an uninstall, confirm whether the data directory was kept.
Uninstalling does not invalidate a key. The program leaves, the credential stays; treat uninstall as a file operation, not a security action. The full cleanup checklist is in credentials after uninstall.
Something more urgent sits next to leftovers: a leak. Stop the bleeding, then investigate, then review — the order cannot be reversed.
- Revoke the leaked key at the provider immediately;
- Enable a standby key and restore service;
- Read the leaked key's usage and call records to size the impact;
- Remove the exposure: logs, screenshots, repositories, chat history;
- Review how it leaked and change naming and distribution.
Do not delete logs before revoking. Logs size the blast radius; revocation is the step that stops the bleeding. Reversed, you lose the evidence.
API key checklist and next steps
Five stages, one bottom line each.
| Stage | Bottom line |
|---|---|
| Create | One per environment, traceable name |
| Store | Readable only by its owner |
| Use | Plugins get least privilege |
| Rotate | Add first, verify both ends |
| Revoke | Provider invalidated plus local cleanup |
All five must hold before the key is actually managed. Doing only create and store defers the risk.
Next steps: settle the API key's scope before its management. For key errors, read API key error troubleshooting. For post-uninstall credentials, read credentials after uninstall. For provider setup, read configuring model providers.
Sources: DeepSeek API docs, DeepSeek Harness docs, dsh CLI README
FAQ
Credentials are kept separately from ordinary settings under DSH_HOME, defaulting to ~/.dsh. Writing a key into the general settings file is the wrong place; use the credential store or a provider configuration, then restart so the running process picks it up.
The safe order for rotating a DeepSeek Harness API key is to add before removing. Create the new key, write it into the credential store or environment, restart, verify a message and any plugins, and only then revoke the old key. Deleting first creates an outage that looks like a network failure.
No: uninstalling DeepSeek Harness removes the program, not the API key. The key stays valid until it is revoked at the provider, and local copies may remain in files, shell history, or CI variables.
Revoke the leaked API key first. Revocation stops the bleeding; logs are the evidence you need to judge the blast radius. Deleting logs before revoking destroys the record you will want during the post-mortem.
Related Terms
- API key
- An API key is a credential that authenticates model requests and is billed to its owner, which is why it must be revocable per environment.— DeepSeek API docs
- credential store
- A credential store is the file or mechanism holding secrets separately from ordinary settings, so configuration can be shared without exposing keys.— dsh CLI README
- rotation
- Rotation is the process of replacing a credential with a new one while service continues, requiring the new value to be in place and verified before the old is revoked.— DeepSeek API docs
- DSH_HOME
- DSH_HOME is the data root for DeepSeek Harness, defaulting to ~/.dsh, holding settings, sessions, profiles, and credentials.— DeepSeek Harness docs
Sources
- DeepSeek API docs· DeepSeek
- DeepSeek Harness docs· deepseek-harness
- dsh CLI README· deepseek-ai