How to Install Deepseek using NPM

Hi there! If you're looking to install Deepseek in your project, you're in the right place. In this guide, I'll walk you through the process of installing Deepseek using NPM in just a few simple steps. Additionally, I'll cover how to use CURL and integrate Deepseek with Python.

Deepseek is an open-source large language model (LLM) developed by Hangzhou DeepSeek Artificial Intelligence Co., Ltd., a Chinese AI company.

Despite being created at a significantly lower cost (just $6 million compared to OpenAI's $100 million for GPT-4), Deepseek performs tasks at the same level as ChatGPT.

The model was developed during U.S. sanctions on Nvidia chips, which aimed to limit China's AI development. On January 10, 2025, the company launched its first free chatbot app for iOS and Android.

By January 27, it had become the most-downloaded free app on the iOS App Store in the U.S. also you can download from Play Store, even impacting Nvidia's stock price with an 18% drop.

How to Install Deepseek using NPM

 

The DeepSeek API uses a format that is fully compatible with the OpenAI API. By adjusting the configuration settings, you can seamlessly use the OpenAI SDK or any software compatible with the OpenAI API to access the DeepSeek API.

PARAM VALUE
base_url *        https://api.deepseek.com
api_key API KEY

To ensure compatibility with OpenAI, you can use https://api.deepseek.com/v1 as the base_url. However, please note that the v1 in the URL does not correspond to the model's version in any way.

The prices listed below are in unites of per 1M tokens. A token, the smallest unit of text that the model recognizes, can be a word, a number, or even a punctuation mark.

Pricing Details:

MODEL CONTEXT LENGTH MAX COT TOKENS MAX OUTPUT TOKENS 1M TOKENS
INPUT PRICE
(CACHE HIT)
1M TOKENS
INPUT PRICE
(CACHE MISS)
1M TOKENS
OUTPUT PRICE
deepseek-chat 64K - 8K $0.014 $0.14 $0.28
deepseek-reasoner 64K 32K 8K $0.14 $0.55 $2.19

 

After obtaining an API key, you can access the DeepSeek API using the example scripts provided below:

Install using NodeJS NPM:

We'll install openai using the following npm command. And we'll use deepseek API using the following example.

npm install openai

Example:

import OpenAI from "openai";

const openai = new OpenAI({
        baseURL: 'https://api.deepseek.com',
        apiKey: '<DeepSeek API Key>'
});

async function main() {
  const completion = await openai.chat.completions.create({
    messages: [{ role: "system", content: "Install deepseek using npm" }],
    model: "deepseek-chat",
  });

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

main();

 

CURL:

Next, we'll see how to use deepseek using the CURL method:

Example:

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": "Install deepseek using CURL"},
          {"role": "user", "content": "Hello!"}
        ],
        "stream": false
      }'

 

Install using Python pip3

Then, we'll install using the pip3 command in Python:

pip3 install openai

Example:

from openai import OpenAI

client = OpenAI(api_key="<DeepSeek API Key>", base_url="https://api.deepseek.com")

response = client.chat.completions.create(
    model="deepseek-chat",
    messages=[
        {"role": "system", "content": "Install deepseek using python"},
        {"role": "user", "content": "Hello"},
    ],
    stream=False
)

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

 


You might also like:

techsolutionstuff

Techsolutionstuff | The Complete Guide

I'm a software engineer and the founder of techsolutionstuff.com. Hailing from India, I craft articles, tutorials, tricks, and tips to aid developers. Explore Laravel, PHP, MySQL, jQuery, Bootstrap, Node.js, Vue.js, and AngularJS in our tech stack.

RECOMMENDED POSTS

FEATURE POSTS