📊 We use cookies & analytics to improve your experience. Learn more
Latest

DeepSeek Mastery — Reasoning Models Without the Bill Module 3 · Lesson 10 of 15

0% Exit to course

Module 3 · Files, tools and your own data Lesson 10 of 15

The DeepSeek API and the open weights and your first script

Learning objective

DeepSeek serves its models over an API that is compatible with the OpenAI request shape and priced far below the frontier labs, and publishes the weights of its core models. You do not need this to finish the course, and you do not need it for a fresher job either — but an afternoon here is what turns "I have used DeepSeek" into "I have built with it", which is a different sentence in an interview.

The concept

DeepSeek serves its models over an API that is compatible with the OpenAI request shape and priced far below the frontier labs, and publishes the weights of its core models. The idea is simple: the same model you have been chatting with also answers a web request, so you can put it inside a script, a spreadsheet or a page. A key identifies you; a request sends the text; a response comes back as data.

The reason to try it once, even if you never build anything: it makes the chat version less mysterious. You see that the whole conversation is text in and text out, that your instructions are literally lines of a request, and that "the model" is one parameter among several.

A first call looks like this:

Python
from openai import OpenAI

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

r = client.chat.completions.create(
    model="deepseek-reasoner",
    messages=[{"role": "user", "content": "A train covers 240 km in 3h20m. What is its speed in m/s? Show every step."}],
)

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

Common mistakes

The mistake is building a user-facing product on a smaller provider's capacity without handling the busy periods. Retry with a delay, and show the user that the job is queued rather than failed.

Worked example

A batch job that solves a folder of problems and records the working is cheap enough to actually run — which is the reason people build on this rather than on a premium model.

Your practice task

Get a key, run one request that works, and change one word in it to see the answer change. That is the whole of the first afternoon.

Do this before moving on. Reading a solution teaches the shape of it; typing it teaches you.

Key takeaway

DeepSeek serves its models over an API that is compatible with the OpenAI request shape and priced far below the frontier labs, and publishes the weights of its core models.

Create free account or sign in

Almost there

15 lessons left of 15

Finish every lesson to unlock the certificate. Each one ends in a practice task — do them and the final project brief writes itself.