๐จ๐๐ฒ ๐๐ฒ๐ฒ๐ฝ๐ฆ๐ฒ๐ฒ๐ธ ๐๐ฃ๐ ๐๐ถ๐๐ต ๐ฃ๐๐๐ต๐ผ๐ป
DeepSeek is cheap. Most tutorials skip the basics. This is the simple version.
Why use it?
- Low cost.
- Works like OpenAI.
Setup steps:
- Go to platform.deepseek.com.
- Create an API key.
- Save it as an environment variable.
Install the tool: pip install openai
Use this code:
import os from openai import OpenAI
client = OpenAI( api_key=os.environ.get("DEEPSEEK_API_KEY"), base_url="https://api.deepseek.com", )
response = client.chat.completions.create( model="deepseek-v4-flash", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Explain what an API is in one sentence."}, ], )
print(response.choices[0].message.content)
Only the base_url and model name change.
Pricing:
- Input: $0.14 per million tokens.
- Output: $0.28 per million tokens.
- GPT and Claude models cost 10x more on output.
Warnings:
- Add credits first.
- Keep keys out of GitHub.
- Old model names expire July 24, 2026.
You have a cheap AI API. This code works with other models.
What are you building? Was signup easy outside the US? Is this common?
Source: https://dev.to/jieming_liang/how-to-use-the-deepseek-api-in-python-a-beginners-guide-2026-fne Optional learning community: https://t.me/GyaanSetuAi