How to Get a DeepSeek API Key

Last verified: October 4, 2026

You get a DeepSeek API key from the official DeepSeek Platform, not from a third-party key generator or from a random tutorial page. DeepSeek’s official API reference says you must create an API key first before using the DeepSeek API, and authentication uses Bearer Auth. DeepSeek API reference

A DeepSeek API key is different from simply using the free DeepSeek chat app. The app is for normal chat use; the API key is a developer credential used to call DeepSeek models from code, backend services, agent tools, or apps.

The basic flow is simple: sign in to the official DeepSeek Platform, create an API key in the API key management area, copy it, store it safely as an environment variable such as DEEPSEEK_API_KEY, verify that your account has the required billing or balance, and test the key with the current DeepSeek base URL and model name.

Do not expose a DeepSeek API key in browser JavaScript, mobile app code, public GitHub repositories, screenshots, notebooks, logs, or shared prompts. DeepSeek’s Open Platform Terms say the API key is a necessary credential for calling the Open Platform API and that developers should keep it secure, avoid sharing or disclosing it, and not expose it in browser or other client-side code. DeepSeek Open Platform Terms of Service

Quick answer: where do you create a DeepSeek API key?

Create the key inside the official DeepSeek Platform. DeepSeek’s public API docs link to the platform when they tell users to apply for or create an API key.

QuestionAnswer
Where do you get a DeepSeek API key?From the official DeepSeek Platform.
Is the API key the same as the chat app?No. The API key is for programmatic API access.
How is the key used?As a Bearer token in the Authorization header.
What base URL should you use?https://api.deepseek.com for the OpenAI-compatible format.
What model should you test first?Use a current model ID from DeepSeek docs, such as deepseek-flash.
Is the API free?No. DeepSeek publishes token-based API pricing and deducts usage from topped-up or granted balance.

What you need before creating a DeepSeek API key

Before you create the key, prepare the basics:

  • An official DeepSeek Platform account.
  • Access to the API key management area after signing in.
  • A safe place to store the key, such as environment variables or a secrets manager.
  • A backend environment where you can call the API without exposing the key to users.
  • Current model information from DeepSeek’s Models & Pricing page.
  • Billing or balance readiness if you plan to make real API calls.

If the dashboard UI changes, follow the current interface shown after logging in. Avoid relying on old screenshots from tutorials, especially if they use old model names or do not link to official documentation.

Step-by-step: how to get a DeepSeek API key

The exact dashboard labels may change, but the process follows the same practical flow:

  1. Open the official DeepSeek Platform.
  2. Sign in or create a DeepSeek account.
  3. Go to the API key management area shown in the platform dashboard.
  4. Create a new API key.
  5. Copy the key immediately and store it in a secure location.
  6. Set the key as an environment variable named DEEPSEEK_API_KEY.
  7. Check whether your account has enough topped-up balance or granted balance for API calls.
  8. Test the key with a minimal request before using it in production.

Use exact dashboard labels only as they appear in your current account. If you are using a team or company account, follow your internal access-control process before creating or sharing keys.

How to store your DeepSeek API key safely

A DeepSeek API key is a credential. Treat it like a password.

On macOS or Linux, set it as an environment variable:

export DEEPSEEK_API_KEY="your-deepseek-api-key"

On Windows PowerShell:

$env:DEEPSEEK_API_KEY="your-deepseek-api-key"

In production, use your platform’s secrets manager instead of hard-coding the key in source code.

  • Never commit the key to Git.
  • Never paste the key into public GitHub issues, Discord, Slack screenshots, notebooks, forums, or support tickets.
  • Never expose the key in frontend JavaScript, browser code, mobile app bundles, or client-side apps.
  • Use a backend route or proxy if a web or mobile app needs to call DeepSeek.
  • Rotate or delete the key immediately if it leaks.
  • Use separate keys for local, staging, and production if your workflow supports it.
  • Avoid logging full request headers because they may contain the key.
  • Avoid logging sensitive prompts and outputs unless you have a clear security and privacy reason.

How to test your DeepSeek API key with cURL

A cURL request is the fastest way to confirm that the key, base URL, and model name are working before adding SDK complexity.

curl https://api.deepseek.com/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${DEEPSEEK_API_KEY}" \
  -d '{
    "model": "deepseek-flash",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Say hello in one short sentence."}
    ],
    "thinking": {"type": "enabled"},
    "reasoning_effort": "high",
    "stream": false
  }'

This example follows DeepSeek’s current OpenAI-format API style: the OpenAI-format base URL is https://api.deepseek.com, the key is sent as Authorization: Bearer ${DEEPSEEK_API_KEY}, and the current example model is deepseek-flash. DeepSeek Your First API Call

How to test your DeepSeek API key in Python

DeepSeek’s official examples use the OpenAI Python SDK configured with DeepSeek’s base URL. First install the package:

pip install openai

Then call DeepSeek with your DeepSeek API key:

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["DEEPSEEK_API_KEY"],
    base_url="https://api.deepseek.com",
)

response = client.chat.completions.create(
    model="deepseek-flash",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Give me one API key safety tip."},
    ],
    stream=False,
    reasoning_effort="high",
    extra_body={
        "thinking": {
            "type": "enabled"
        }
    },
)

print(response.choices[0].message.content)

The three settings that matter most are:

  • api_key: use your DeepSeek API key, not an OpenAI key.
  • base_url: use https://api.deepseek.com for OpenAI-compatible requests.
  • model: use a current DeepSeek model ID, such as deepseek-flash.

How to test your DeepSeek API key in Node.js

For Node.js, install the OpenAI JavaScript SDK:

npm install openai

Then configure the client with DeepSeek’s base URL and your DeepSeek key:

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.DEEPSEEK_API_KEY,
  baseURL: "https://api.deepseek.com",
});

const completion = await client.chat.completions.create({
  model: "deepseek-flash",
  messages: [
    { role: "system", content: "You are a helpful assistant." },
    { role: "user", content: "Give me one short API key security rule." },
  ],
  thinking: { type: "enabled" },
  reasoning_effort: "high",
  stream: false,
});

console.log(completion.choices[0].message.content);

Use baseURL in the JavaScript SDK and base_url in the Python SDK. Mixing those spellings is a common setup mistake.

Which base URL and model name should you use?

DeepSeek’s current documentation lists two API formats:

API formatBase URLWhen to use it
OpenAI-compatible formathttps://api.deepseek.comUse this for OpenAI SDK-style examples in Python, Node.js, and cURL.
Anthropic-compatible formathttps://api.deepseek.com/anthropicUse this only when you are intentionally using Anthropic-format requests or compatible tooling.

At the time this article was verified, DeepSeek’s Models & Pricing page lists these current model IDs:

Model IDDocumented versionPractical note
deepseek-flashDeepSeek-V4.1-FlashBest starting point for most current examples and DeepSeek’s official first-call examples.
deepseek-v4-proDeepSeek-V4-Pro-0813Use only after checking current routing, pricing, and feature support for your workload.

DeepSeek’s docs say to use deepseek-flash as the model name. They also say legacy names such as deepseek-v4-flash and deepseek-v4-flash-vision-exp are still accepted, but the corresponding models have been retired and their requests are served by DeepSeek-V4.1-Flash and billed at the Flash price. DeepSeek Models & Pricing

Do you need billing or balance before using the key?

Creating an API key is not the same as getting unlimited free API usage. DeepSeek’s pricing page says API expenses are calculated by tokens and deducted from your topped-up balance or granted balance, with granted balance used first when both are available. DeepSeek Models & Pricing

For balance checks and top-ups before your first request, see our DeepSeek API billing guide.

DeepSeek’s Open Platform Terms say paid services may require prepayment, your balance will be consumed when you use paid services, and DeepSeek may suspend or terminate services if your balance is insufficient. The same terms say recharge methods, billing prices, consumption methods, and free quota are subject to information shown on product pages and the platform website. DeepSeek Open Platform Terms of Service

In practice, before production use, check:

  • Your current account balance.
  • Whether you have any granted balance.
  • The current pricing for the model you plan to use.
  • Whether your workload runs during peak or off-peak pricing hours.
  • Expected input, cached input, and output token volume.
  • Whether your app may retry failed requests and increase usage.

DeepSeek API pricing basics

DeepSeek’s current pricing page lists prices per 1M tokens and separates cache-hit input, cache-miss input, and output tokens. For example, deepseek-flash is priced differently for off-peak and peak usage. DeepSeek Models & Pricing

Cost itemWhat it means
Input tokens: cache hitInput tokens that hit DeepSeek’s cache and are billed at the cache-hit rate.
Input tokens: cache missInput tokens that do not hit the cache and are billed at the cache-miss rate.
Output tokensTokens generated by the model.
Peak pricingHigher rates during DeepSeek’s documented peak periods.
Off-peak pricingLower rates outside peak periods, according to DeepSeek’s current pricing page.

Do not rely on old screenshots, old R1 pricing, or old top-up tutorials. Always check the current pricing page before running production traffic.

Common errors and fixes

ProblemLikely causeFix
Authentication failsThe key is missing, copied incorrectly, expired, deleted, or not a DeepSeek API key.Confirm DEEPSEEK_API_KEY is set in the environment that runs the request.
The request goes to OpenAI instead of DeepSeekThe DeepSeek base URL was omitted.Set base_url="https://api.deepseek.com" in Python or baseURL: "https://api.deepseek.com" in Node.js.
The model is not recognizedThe request uses an OpenAI model name or an outdated DeepSeek alias.Use a current DeepSeek model ID from the Models & Pricing page.
The API key works in one terminal but not anotherThe environment variable is only set in one shell/session.Set the variable in the active shell, deployment environment, or secrets manager.
The app leaks the keyThe key was placed in frontend JavaScript, a mobile bundle, or public code.Delete or rotate the key and move calls to a backend service.
Requests fail after some usageThe account may have insufficient balance, or service/billing settings may need review.Check your DeepSeek Platform balance and current billing settings.
Third-party agent tool cannot connectThe tool may require the right base URL, model ID, and key field.Follow the tool’s DeepSeek integration guide and verify it uses the official DeepSeek endpoint.
Confusion between API formatsThe OpenAI-format and Anthropic-format base URLs are mixed.Use https://api.deepseek.com for OpenAI-format requests and https://api.deepseek.com/anthropic only for Anthropic-format requests.

What old R1 tutorials get wrong

Getting a DeepSeek API key is not a DeepSeek R1-specific task. The key is for the DeepSeek API platform. After creating the key, you should call current model IDs from DeepSeek’s current documentation.

Older tutorials may use R1-era model names such as deepseek-reasoner or older chat aliases. Do not hard-code those names in new apps unless the current DeepSeek docs explicitly support them for your use case. DeepSeek’s current first-call and pricing pages point developers toward current model IDs such as deepseek-flash and deepseek-v4-pro.

If you specifically need DeepSeek R1 open weights, that is a separate workflow from getting a hosted API key. For API onboarding, focus on the official platform, current authentication, current base URL, and current hosted model names.

Official vs third-party API key pages

Only create DeepSeek API keys through the official DeepSeek Platform. Do not enter DeepSeek credentials, API keys, or payment information into unknown websites that claim to generate keys.

  • Verify the domain before signing in.
  • Use official docs for authentication and model names.
  • Treat third-party tutorials as educational, not authoritative.
  • Evaluate any third-party tool before pasting a DeepSeek API key into it.
  • Delete or rotate a key if you entered it into a tool you no longer trust.

Security checklist for DeepSeek API keys

  • Create keys only from the official DeepSeek Platform.
  • Store keys in environment variables or a secrets manager.
  • Use DEEPSEEK_API_KEY instead of mixing it with OPENAI_API_KEY.
  • Never commit keys to Git.
  • Never expose keys in browser code, mobile app code, or frontend bundles.
  • Use backend routes for client-facing apps.
  • Rotate leaked keys immediately.
  • Use separate keys for local, staging, and production when possible.
  • Restrict team access to production keys.
  • Avoid logging full request headers.
  • Avoid logging sensitive prompts, outputs, or customer data unnecessarily.
  • Monitor usage and billing after deployment.

Frequently asked questions

Where do I get a DeepSeek API key?

Get it from the official DeepSeek Platform at platform.deepseek.com. DeepSeek’s API docs link to the platform when they instruct users to create or apply for an API key.

Is a DeepSeek API key free?

Creating a key is not the same as free unlimited API usage. DeepSeek API calls are billed according to current token pricing and deducted from topped-up or granted balance.

Do I need a DeepSeek account to create an API key?

Yes. DeepSeek’s Open Platform Terms say the Open Platform service and chat service use the same account, and the API key you create through your account is the credential used to call the Open Platform API.

Is the DeepSeek API key the same as my DeepSeek app login?

No. Your account lets you access the platform, but the API key is a separate credential used for API authentication. Do not paste your account password or app login into code.

What is the DeepSeek API base URL?

For OpenAI-compatible requests, use https://api.deepseek.com. For Anthropic-format requests, DeepSeek lists https://api.deepseek.com/anthropic.

How do I use a DeepSeek API key in Python?

Install the OpenAI Python SDK, initialize the client with api_key=os.environ["DEEPSEEK_API_KEY"] and base_url="https://api.deepseek.com", then call a current DeepSeek model such as deepseek-flash.

How do I use a DeepSeek API key in Node.js?

Install the OpenAI JavaScript SDK, initialize it with apiKey: process.env.DEEPSEEK_API_KEY and baseURL: "https://api.deepseek.com", then call a current DeepSeek model such as deepseek-flash.

What model should I use after getting the key?

Use a current model ID from DeepSeek’s Models & Pricing page. For most current examples, deepseek-flash is the safest starting point because DeepSeek uses it in current first-call examples.

Is deepseek-reasoner still the model to use?

Do not use deepseek-reasoner as the default in new tutorials unless current DeepSeek docs explicitly recommend it. Many older examples are R1-era examples and may not reflect current hosted API model names.

Why is my DeepSeek API key not working?

Common causes include a missing environment variable, copied key errors, insufficient balance, wrong base URL, using an OpenAI key instead of a DeepSeek key, or calling an outdated model name.

How do I fix a 401 authentication error?

Check that your request includes Authorization: Bearer ${DEEPSEEK_API_KEY}, that the key belongs to DeepSeek, and that your code is reading the environment variable in the same runtime that sends the request.

Can I put a DeepSeek API key in frontend JavaScript?

No. DeepSeek’s Open Platform Terms say developers should not expose API keys in browser or other client-side code. Use a backend service instead.

What should I do if my key leaks?

Delete or rotate the key immediately in the DeepSeek Platform, remove the leaked value from code or logs, check billing and usage, and review where the key was exposed so it does not happen again.

Can I use the key with Claude Code, Codex, OpenCode, or other agent tools?

DeepSeek’s first-call docs list agent integrations and mention popular agent and coding assistant tools. Use the tool’s official DeepSeek integration instructions and confirm the base URL, model name, and key field before saving your key in any third-party tool.

Do I need balance or payment before making requests?

For paid API usage, yes, you should verify balance or billing readiness. DeepSeek’s pricing page says fees are deducted from topped-up or granted balance, and the Open Platform Terms say service may be suspended or terminated if balance is insufficient.

Can I share my DeepSeek API key with my team?

Do not casually share a raw key in chat, email, or documents. Use a team-approved secrets manager, restrict access, and rotate keys when team members change roles or leave.

Bottom line

To get a DeepSeek API key, sign in to the official DeepSeek Platform, create a key in the API key management area, store it securely as DEEPSEEK_API_KEY, verify billing or balance, and test it against https://api.deepseek.com with a current model such as deepseek-flash.

The two most important rules are simple: create keys only from the official platform, and never expose the key in client-side code. After that, keep your examples current by checking DeepSeek’s Models & Pricing page instead of copying old R1 or deepseek-reasoner tutorials.

Official references