All Posts

DeepSeek API Beginner Tutorial

DeepSeek API Beginner Tutorial

In this tutorial, you will learn the DeepSeek API to interact with the AI model programmatically. An API (Application Programming Interface) is like a messenger that lets your code communicate with external services like DeepSeek. You send requests and the API returns responses.

DeepSeek Normal Workflow

The user opens a web browser and goes to the DeepSeek website. The user types a prompt into a text box and hits enter or a send button. The browser then sends that prompt to a server. The server processes the request, checks authentication, and then sends the prompt to the DeepSeek AI model. The model generates a response, which goes back to the server, and then the server sends the response back to the user’s browser, which displays it to the user.

 

DeepSeek Normal Workflow

DeepSeek API

The DeepSeek API provides access to DeepSeek’s Large Language Models (LLMs), which are AI systems designed to understand and generate human-like text. The API is the interface used to interact with DeepSeek AI models.

An API is an interface to a service. It provides programmatic access to the LLMs without any interface like a web browser client. The DeepSeek API acts as a gateway to access and interact with DeepSeek’s Large Language Models (LLMs), like DeepSeek R1/ V3, allowing developers to utilize their capabilities for tasks like text generation, translation, and question answering through a simple interface.

 

 

DeepSeek API Beginner Tutorial

What You’ll Need

To get started with the API, you need the following pre-requisites:

  • Sign up for the DeepSeek Account (  https://deepseek.com/signup ) 
  • API Key (from account dashboard)
  • Basic programming knowledge

DeepSeek API Platform

The DeepSeek API Platform is a comprehensive AI service platform that provides advanced artificial intelligence capabilities through APIs (Application Programming Interfaces). It enables developers and businesses to integrate AI technologies into their application workflows without requiring extensive expertise in Machine Learning.

 

 

DeepSeek API Platform

The DeepSeek API uses an API format compatible with OpenAI. You can use the OpenAI SDK to access the DeepSeek API. You can change the parameters like base_url and api_key and start using DeepSeek APIs.

To get the DeepSeek API key, follow the instructions outlined below:

 

The two configuration paramters are:

base_url ->  https://api.deepseek.com
api_key ->   DeepSeek API key

For example, OpenAI API

Steps to install OpenAI Python SDK are outlined here:

Basic API Request (Python)


import requests
import os

API_KEY = os.getenv("DEEPSEEK_API_KEY")
ENDPOINT = "https://api.deepseek.com/v1/chat/completions"

response = requests.post(
    ENDPOINT,
    headers={"Authorization": f"Bearer {API_KEY}"},
    json={
        "model": "deepseek-chat",
        "messages": [{"role": "user", "content": "Hello DeepSeek!"}]
    }
)
print(response.json())
    

DeepSeek API Parameters

Authentication: Use your API key in the Authorization header

Endpoints: Different URLs for different tasks (e.g., /chat, /models)

 

Parameter Description
model AI model version (e.g., deepseek-chat)
temperature Creativity control (0=factual, 2=creative)
max_tokens Maximum response length

Example

import requests

# Replace with your DeepSeek API key
api_key = “<your api key goes here>”