Obtaining DeepSeek API Key

Overview

This guide walks through the process of obtaining and configuring your DeepSeek API key for integration with third-party applications.

Prerequisites

Step 1: Access API Key Section

  1. Navigate to the DeepSeek portal: https://www.deepseek.com/en

  2. Click API Platform

  3. Login to your account

../_images/deepseek_api_platform.png

Step 2: Generate New API Key

  1. In the left sidebar, click “API Keys”

  2. Select “Create new API Key”

  3. In the dialog: - Enter a name - Click “Create API key”

../_images/deepseek_api_create.png

Fig. 14 API key generation interface

Verification

To verify successful integration:

curl https://api.deepseek.com/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <DeepSeek API Key>" \
  -d '{
        "model": "deepseek-chat",
        "messages": [
          {"role": "system", "content": "You are a helpful assistant."},
          {"role": "user", "content": "Hello!"}
        ],
        "stream": false
      }'
# Please install OpenAI SDK first: `pip3 install openai`

from openai import OpenAI

client = OpenAI(api_key="sk-api here", base_url="https://api.deepseek.com")

# DeepseekV3: deepseek-chat  DeepseekR1: deepseek-reasoner
response = client.chat.completions.create(
    model="deepseek-reasoner",
    messages=[
        {"role": "system", "content": "You are a helpful assistant"},
        {"role": "user", "content": "Hello"},
    ],
    stream=False
)

print(response.choices[0].message)

Troubleshooting

Table 14 Common Issues

Symptom

Solution

“Invalid API Key”

Regenerate key and re-configure

Rate limiting

Check quota at DeepSeek portal

Connection timeout

Verify network restrictions

Security Notes

  • Store keys in secure password managers

  • Never commit keys to version control

  • Rotate keys quarterly

  • Restrict keys by IP when possible

Additional Resources