Skip to content

API Documentation ​

Welcome to the DeepSeek API documentation. Our API provides powerful AI capabilities through simple HTTP requests, enabling you to integrate advanced language model features into your applications.

Quick Start ​

Get started with the DeepSeek API in just a few steps:

1. Get Your API Key ​

First, you'll need to obtain an API key:

  • Sign up for a DeepSeek account
  • Navigate to the API Keys section in your dashboard
  • Generate a new API key for your project

2. Make Your First Request ​

Here's a simple example using curl:

bash
curl -X POST "https://api.deepseek.com/v1/chat/completions" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "deepseek-chat",
    "messages": [
      {
        "role": "user",
        "content": "Hello, how are you?"
      }
    ]
  }'

3. Handle the Response ​

The API will return a JSON response with the model's output:

json
{
  "id": "chatcmpl-123",
  "object": "chat.completion",
  "created": 1677652288,
  "model": "deepseek-chat",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! I'm doing well, thank you for asking. How can I assist you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 9,
    "completion_tokens": 12,
    "total_tokens": 21
  }
}

API Features ​

Chat Completions ​

  • Text Generation: Generate human-like responses for conversations
  • System Messages: Set context and behavior for the AI assistant
  • Streaming: Real-time response streaming for better user experience
  • Function Calling: Enable the model to call external functions

Multimodal Support ​

  • Image Understanding: Process and analyze images alongside text
  • Vision-Language Tasks: Combine visual and textual information
  • Document Analysis: Extract information from documents and images

Advanced Features ​

  • JSON Mode: Force structured JSON output for data extraction
  • Long Context: Handle extended conversations and documents
  • Batch Processing: Process multiple requests efficiently
  • Custom Models: Fine-tuned models for specific use cases

Authentication ​

All API requests require authentication using an API key. Include your API key in the Authorization header:

Authorization: Bearer YOUR_API_KEY

Rate Limits ​

To ensure fair usage and optimal performance:

  • Free Tier: 100 requests per minute
  • Pro Tier: 1,000 requests per minute
  • Enterprise: Custom limits based on your needs

Error Handling ​

The API uses standard HTTP status codes and returns detailed error messages:

json
{
  "error": {
    "message": "Invalid API key provided",
    "type": "invalid_request_error",
    "code": "invalid_api_key"
  }
}

SDKs and Libraries ​

We provide official SDKs for popular programming languages:

  • Python: pip install deepseek-python
  • Node.js: npm install deepseek-node
  • Java: Maven and Gradle support
  • Go: Go modules support
  • PHP: Composer package available

Next Steps ​

Support ​

Need help? We're here to assist:

  • Documentation: Comprehensive guides and examples
  • Community: Join our developer community
  • Support: Contact our technical support team
  • Status: Check our API status and uptime

Ready to build something amazing? Start with our Quick Start Guide or explore our Use Cases for inspiration.

基于 DeepSeek AI 大模型技术