Authentication

API keys: how to create one, send it, limit it and revoke it.

On this page

Every API request carries an API key. You create keys on your dashboard; each one bills your prepaid credits.

Create a key

  1. Sign in to your dashboard and open API keys.
  2. Choose Create API key and give it a name that says where it runs, for example staging backend.
  3. If you like, set a spending cap in US dollars and an expiry (Never, or in 7, 30 or 90 days, or 1 year).
  4. Copy the key. It starts with dcode_sk_ and is shown only once.
  5. Add credits on the Billing page if your balance is empty (API Credits).

Send the key

In the OpenAI SDK format, send the key as a Bearer token in the Authorization header:

curl

curl https://api.dipoleml.com/v1/models \  -H "Authorization: Bearer $RAVEN_API_KEY"

python

import osfrom openai import OpenAIclient = OpenAI(    base_url="https://api.dipoleml.com/v1",    api_key=os.environ["RAVEN_API_KEY"],)print([m.id for m in client.models.list()])

In the Messages format, the key goes in the x-api-key header, as the Anthropic SDK sends it; Authorization: Bearer works there too.

Caps, expiry and revoking

  • Spending cap. Once a key has spent its cap in all, its requests are refused with 402 and key_limit_reached. Your balance and your other keys are not affected. Raise or remove the cap with Edit.
  • Expiry. After its expiry, a key's requests are refused with 401 and key_expired.
  • Revoking. A revoked key stops working at once and cannot be turned back on: its next request gets 401 and invalid_api_key.
  • Your account. While an account waits to be deleted, its keys are paused and answer 403 with account_pending_deletion. Signing in again restores the account.

To create, cap and revoke keys from a script, use Management Keys.

How keys bill

Keys bill prepaid credits, separate from every plan. A request is checked before it runs: if your balance is zero or below, it is refused with 402 and insufficient_credits. A request that runs is debited after it finishes, from the tokens it used, so the last request before your balance runs out can take it a little below zero. Prices and the debit formula are on API Credits.

You do not need an API key to use the Raven app or DCode: they use your sign-in. Keys are for your own code and tools.

Key errors

With no key, the API answers 401:

401 response
{  "error": {    "message": "Missing API key. Send 'Authorization: Bearer <your key>'. Create an account at https://dipoleml.com",    "type": "authentication_error",    "code": "missing_api_key"  }}

A wrong or revoked key gets the same status with the code invalid_api_key and the message Invalid, revoked, or expired credentials.

Codes

StatuscodeWhat to do
401missing_api_keySend the key in the header for your format.
401invalid_api_keyCopy the key again, or create a new one if it was revoked.
401key_expiredCreate a new key, or set a later expiry with Edit.
402key_limit_reachedRaise or remove the key's spending cap.
402insufficient_creditsAdd credits on the Billing page.
403account_pending_deletionSign in to restore the account.
403account_suspendedWrite to the address in the message.

Every other code is on Errors and limits.