How to use DeepSeek API?

Updated 2026-07-15Asked across Reddit, Quora & Google· DeepSeek
Short answer

To use the DeepSeek API, create an account at platform.deepseek.com, generate an API key, then point any OpenAI-compatible library at base URL https://api.deepseek.com. Use model 'deepseek-chat' (now deepseek-v4-flash) for fast chat or 'deepseek-reasoner' (deepseek-v4-pro) for step-by-step reasoning. It's pay-as-you-go, from about $0.14 per million input tokens.

Why — the first-principles explanation

An API (Application Programming Interface) is a way for your own code to talk to DeepSeek's model directly, without the website. Instead of typing into a chat box, your program sends a small packet of text — your prompt — over the internet, and DeepSeek sends back the model's answer as text. You are renting the model by the word.

DeepSeek deliberately made its API compatible with OpenAI's format. That matters because thousands of tools and code libraries were already written for OpenAI. By copying that format, DeepSeek lets you reuse all of them: you keep the same code and just change two things — the web address (base URL) it points to, and the secret key that proves who's paying. This is why tutorials say you can switch from OpenAI to DeepSeek in about two lines.

You pay per token, which is roughly three-quarters of a word. DeepSeek meters your input tokens (what you send) and output tokens (what it writes back) separately, because generating text costs far more compute than reading it. A clever trick called context caching stores repeated parts of your prompts so that reused text costs a tiny fraction — this is why the same request can be dramatically cheaper the second time.

An example that makes it click

Think of the API like ordering from a restaurant by phone instead of dining in. The website chat is dining in — you sit down and talk to a waiter. The API is the phone line: your app 'calls' a specific number (the base URL), gives a password so they know your account (the API key), states exactly what you want (the prompt), and a meal comes back through the window (the response).

Because DeepSeek uses the same 'phone menu' as OpenAI, any app already built to call OpenAI can dial DeepSeek instead by changing just the number and the password. If you send the same opening line every call — 'You are a helpful tutor' — the kitchen remembers it (caching) and charges you almost nothing for that repeated part.

How to do it

  1. Go to platform.deepseek.com and sign up for an account.
  2. Add a small amount of credit (billing is prepaid, pay-as-you-go).
  3. Open the 'API Keys' section and click 'Create new API key', then copy and store it securely.
  4. Install an OpenAI-compatible library, e.g. `pip install openai`.
  5. In your code, set base_url to https://api.deepseek.com and api_key to your key.
  6. Choose a model: 'deepseek-chat' (fast, general) or 'deepseek-reasoner' (shows reasoning).
  7. Send a chat completion request with your messages and read the 'content' field from the response.
  8. Monitor spending on the platform dashboard and set usage limits if needed.

Key facts

Infographic: How to use DeepSeek API — short answer and key facts
Visual summary — How to use DeepSeek API?
D
Try DeepSeek

An open-weight Chinese model family that matched frontier quality at low cost.

Affiliate link — we may earn a commission at no cost to you.
Visit DeepSeek ↗
▶ The 60-second explainer (script)

Here's how to use the DeepSeek API in five minutes. First, go to platform.deepseek.com, sign up, and create an API key — that's your password for billing. Then, because DeepSeek copies OpenAI's format, you just install the OpenAI library and change two lines: set the base URL to api.deepseek.com and paste your key. Pick a model — 'deepseek-chat' for fast answers or 'deepseek-reasoner' when you want it to show its work. Send your messages, and read the reply from the response. You pay per token, starting around fourteen cents per million input tokens, so it's very cheap. Add a little credit up front, watch your dashboard, and you're running. That's it — an OpenAI app becomes a DeepSeek app in about two lines of code.

What authoritative sources say

DeepSeek API Documentationofficial — DeepSeek's API uses base URL https://api.deepseek.com, is OpenAI-compatible, and API keys are created at platform.deepseek.com. source ↗
DeepSeek API Docs — Models & Pricingofficial — Model names and per-token pricing for deepseek-chat and deepseek-reasoner. source ↗
DataCampmedia — Step-by-step walkthrough of authenticating and making DeepSeek API calls. source ↗

People also ask

Do I need to know how to code to use the API?

Basic Python or JavaScript helps, but because it's OpenAI-compatible, you can also plug it into no-code tools that accept a custom base URL and key.

Which model should I pick?

Use deepseek-chat (deepseek-v4-flash) for fast, everyday tasks and deepseek-reasoner (deepseek-v4-pro) for hard math, coding, or logic where you want visible reasoning.

Is there a free tier?

The API is paid pay-as-you-go, but it's inexpensive; new accounts sometimes receive trial credit, and free access is available via third-party hosts or by running the open weights locally.

Can I reuse my existing OpenAI code?

Yes. Change the base URL to api.deepseek.com and swap the API key and model name; most other code stays the same.

Related questions