Create and protect API Keys

Isolate application credentials, set permissions and quotas, and promptly deactivate them if they are leaked.

Create independent key

Open API Key and create separate keys for the application, development environment, and production environment. The name is used to identify the source of the call, do not think of the key itself as the name. Set grouping, expiration time, quota, model restrictions and IP restrictions according to the options supported by the page, and check whether the restrictions will block the actual deployment environment before saving.

Safe to use

The key is placed in the server environment variable or key management service, and the server calls this site. Mobile clients, browser scripts, and public desktop installers cannot securely store shared keys. In scenarios where individuals bring their own keys, local storage risks should also be clarified to avoid synchronizing to public configurations or analyzing logs.

Request to use Authorization: Bearer <API_KEY>. Don’t put keys in URLs, error screenshots, or ticket text. API call keys are different from background management credentials, please do not mix them.

Rotation and leakage handling

Create a new key first and deploy it to the caller, verify with minimal requests, and then deactivate the old key. When abnormal calls are discovered, the suspected leaked keys are immediately deactivated and the call records, deployment variables and code history are checked. Removing keys from the latest version of Git does not eliminate the risk of historical leaks.

Check access restrictions

Under the same account, different keys may use different grouping and model restrictions. Query /v1/models based on the key actually used in the failed request. Do not judge permissions based on the background model directory alone.

From creation to first call

  1. Log in to the console and enter API Key.
  2. Create a new key with identifiable uses, such as a development environment for testing applications.
  3. Check the grouping, validity period and available quota, and reserve the minimum necessary permissions first.
  4. Save the secret to a local protected configuration or deployment platform Secret without writing to the front-end build variables.
  5. Query the model using the key and complete a minimal text request.
  6. After confirming the source in Call Record, hand it over to the application for use.

For client configuration, please refer to the secure input method in Quick Start. The following example reads an already set environment variable:

curl --fail-with-body https://dunduntoken.com/v1/models   -H "Authorization: Bearer $DUNDUN_API_KEY"

How to verify restriction settings

Settings Pre-configuration checks Verification methods
Model restrictions The exact ID actually used by the application Query and call the target model with the same Key
IP restrictions Service exit address, including NAT and proxy Tested in real deployment environment
Expiration time Time zone and application maintenance window Rotate in advance to avoid failures during operation
Quota Long task, batch and retry budget Check actual consumption after small requests
Groups Available models and prices Different groups tested separately

The success of the list query does not mean that the inference will be successful, and the selected protocol still needs to be verified. 401 checks the credentials and status first, and handles permission or quota prompts in response. You cannot bypass restrictions by frequently generating new keys.