API Documentation

Complete guide to integrating with the DeepSeek V4 OpenAI-compatible API

Quick Start

Get Started in 3 Steps

1Get your API key

Navigate to the developer dashboard and create a new API key. Save it securely - you won't be able to see it again.

2Install the OpenAI client

pip install openai

3Make your first request

from openai import OpenAI

client = OpenAI(
    base_url="https://deepseek-v4.io/api/v1",
    api_key="your-api-key"
)

response = client.chat.completions.create(
    model="deepseek/deepseek-v4-flash",
    messages=[
        {"role": "user", "content": "Hello!"}
    ]
)

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

Authentication

API Key Authentication
Include your API key in the Authorization header

All API requests require your API key to be included in the Authorization header:

Authorization: Bearer sk-your-api-key-here

⚠️ Security Best Practices

  • • Never expose your API key in client-side code
  • • Use environment variables to store keys
  • • Rotate your keys regularly
  • • Monitor usage in the developer dashboard

Available Endpoints

POST/v1/chat/completions
Create chat completions with AI models

Main endpoint for creating conversational AI responses. Compatible with OpenAI's Chat Completions API.

Request Body

{
  "model": "deepseek/deepseek-v4-flash",
  "messages": [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Hello!"}
  ],
  "temperature": 0.7,
  "max_tokens": 1000
}
GET/v1/models
List available AI models

Returns a list of available models that can be used with the API.

Available Models

Supported AI Models

deepseek/deepseek-v4-flash

Fast

Optimized for speed and efficiency. Best for simple queries and real-time applications.

deepseek-ai/DeepSeek-V3

Powerful

Full-featured model for complex reasoning and detailed responses.

Error Handling

Standard Error Responses

API errors return standard HTTP status codes and JSON error objects:

{
  "error": {
    "message": "Invalid API key",
    "type": "invalid_request_error",
    "code": "invalid_api_key",
    "param": null,
    "details": []
  }
}

Common HTTP Status Codes

  • 400 - Bad Request (invalid parameters)
  • 401 - Unauthorized (invalid API key)
  • 403 - Forbidden (insufficient permissions)
  • 429 - Rate Limit Exceeded
  • 500 - Internal Server Error

Rate Limits

API Rate Limiting
API keys have rate limits to prevent abuse and ensure fair usage

API keys have rate limits to prevent abuse and ensure fair usage. Default limits vary by plan:

Starter60 requests/minute
Pro120 requests/minute
Scale300 requests/minute

Rate limit status is returned in response headers: X-RateLimit-Remaining

Need Help?

Documentation

Explore detailed guides and examples

Community

Join our developer community

Support

Get help from our support team