DeepSeek V4 API Tutorial: Get Started in 5 Minutes
Introduction
The DeepSeek V4 API provides programmatic access to one of the most powerful AI models - completely free. This tutorial covers everything from setup to advanced usage.
Getting Your API Key
Step 1: Sign Up
Visit NoteLM.ai/free-deepseek-v4/api and create a free account.
Step 2: Generate API Key
Navigate to API Keys section and generate a new key.
Step 3: Store Securely
Save your API key securely. Never commit it to version control.
Python Setup
Install SDK
Basic Usage
from openai import OpenAI
client = OpenAI(
api_key="your-api-key",
base_url="https://api.notelm.ai/v1"
)
response = client.chat.completions.create(
model="deepseek-v4",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Explain quantum computing in simple terms."}
]
)
print(response.choices[0].message.content)
Streaming Responses
stream = client.chat.completions.create(
model="deepseek-v4",
messages=[{"role": "user", "content": "Write a poem about coding."}],
stream=True
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")
JavaScript/TypeScript Setup
Install SDK
Basic Usage
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env.DEEPSEEK_API_KEY,
baseURL: 'https://api.notelm.ai/v1',
});
async function chat() {
const response = await client.chat.completions.create({
model: 'deepseek-v4',
messages: [{ role: 'user', content: 'Hello!' }],
});
console.log(response.choices[0].message.content);
}
chat();
API Parameters
| Parameter | Type | Description |
|---|
| model | string | "deepseek-v4" |
| messages | array | Conversation messages |
| temperature | float | 0-2, creativity level |
| max_tokens | int | Maximum response length |
| stream | bool | Enable streaming |
Rate Limits (Free Tier)
- Requests: 1,000/day
- Tokens: 100,000/day
- Concurrent: 5 requests
Error Handling
from openai import APIError, RateLimitError
try:
response = client.chat.completions.create(...)
except RateLimitError:
print("Rate limit exceeded. Wait and retry.")
except APIError as e:
print(f"API error: {e}")
Best Practices
- 1.Use environment variables for API keys
- 2.Implement retry logic for rate limits
- 3.Stream long responses for better UX
- 4.Cache common responses to save quota
The DeepSeek V4 API provides powerful AI capabilities for free. The OpenAI-compatible interface makes migration easy.
Get your free API key → API Dashboard