Published at

How to use DeepSeek API: πŸš€ Getting Started with the DeepSeek API

How to use DeepSeek API:  πŸš€ Getting Started with the DeepSeek API

The DeepSeek API provides access to Deepseek R1 and Zero, cutting-edge language models designed for reasoning, coding, and general chat tasks. Whether you're a developer, researcher, or business user, this guide walks you through how to generate an API key, authenticate requests, select the appropriate model, and make your first API call. With clear examples and links to resources, you'll be up and running with DeepSeek in minutes.

Table of Contents

πŸ“₯ Model Downloads

DeepSeek models are freely available for download. You can host and run them on your own infrastructure. Below are the available versions and their resources:


πŸ”Ή DeepSeek-R1 Models

ModelTotal ParamsActivated ParamsContext LengthDownload
DeepSeek-R1-Zero671B37B128KπŸ€— HuggingFace
DeepSeek-R1671B37B128KπŸ€— HuggingFace

Note: Both DeepSeek-R1-Zero and DeepSeek-R1 are trained on the DeepSeek-V3-Base.
For detailed architecture information, please refer to the DeepSeek-V3 repository.


πŸ”Ή DeepSeek-R1-Distill Models

ModelBase ModelDownload
DeepSeek-R1-Distill-Qwen-1.5BQwen2.5-Math-1.5BπŸ€— HuggingFace
DeepSeek-R1-Distill-Qwen-7BQwen2.5-Math-7BπŸ€— HuggingFace
DeepSeek-R1-Distill-Llama-8BLlama-3.1-8BπŸ€— HuggingFace
DeepSeek-R1-Distill-Qwen-14BQwen2.5-14BπŸ€— HuggingFace
DeepSeek-R1-Distill-Qwen-32BQwen2.5-32BπŸ€— HuggingFace
DeepSeek-R1-Distill-Llama-70BLlama-3.3-70B-InstructπŸ€— HuggingFace

Note: The DeepSeek-R1-Distill models are fine-tuned versions of open-source models using output samples from DeepSeek-R1.
Some configurations and tokenizers have been modifiedβ€”please use DeepSeek’s provided settings for proper deployment.

Deepseek Open Platform

At same time you can access deepseek through Deepseek open platform.

πŸ” Step 1: Get an API Key

  1. Go to the DeepSeek Open Platform.
  2. Sign up or log in.
  3. Navigate to β€œAPI Keys” from the sidebar.
  4. Click β€œCreate API Key”, name it if desired, and copy the key securely.

    ⚠️ You’ll only see the key once, so make sure to store it safely.


πŸ”§ Step 2: Set Up Authentication

Use Bearer Token authentication in your HTTP headers:

  • HTTP Header:

     Authorization: Bearer YOUR_API_KEY
  • API Endpoint:

    https://api.deepseek.com/v1/chat/completions

Ensure you include the Authorization header in all your API requests

🧠Step 3: Choose a Model

DeepSeek offers two primary models:​

  • deepseek-chat (V3): A general-purpose model trained on extensive text data, suitable for a wide range of tasks.

  • deepseek-reasoner (R1): Optimized for advanced reasoning, mathematics, and coding tasks. ​ Learn R, Python & Data Science Online

Specify your chosen model in the model parameter of your API request.​

πŸ’» Step 4: Make an API Call (Python Example)

Here’s how to make a basic API call using Python:


url = "https://api.deepseek.com/v1/chat/completions"
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
}
data = {
    "model": "deepseek-chat",
    "messages": [{"role": "user", "content": "Hello, DeepSeek!"}]
}

response = requests.post(url, headers=headers, json=data)
print(response.json())

Replace YOUR_API_KEY with your actual API key.

πŸ§ͺ Step 5: Test with Tools like Apidog

For testing and debugging, you can use tools like Apidog:​

  1. Install Apidog and create a new API request.

  2. Set the HTTP method to POST.

  3. Enter the API endpoint: https://api.deepseek.com/v1/chat/completions.

  4. Configure headers:

    1. Authorization: Bearer YOUR_API_KEY

    2. Content-Type: application/json

  5. Add the request body in JSON format:

{
  "model": "deepseek-chat",
  "messages": [{"role": "user", "content": "Hello, DeepSeek!"}]
}
  1. Send the request and observe the response.

πŸ“š Additional Resources

Here are some useful links to learn more about DeepSeek and its ecosystem: