POST
/
v1
/
chat
/
completions
DeepSeek OCR
curl --request POST \
  --url https://api.example.com/v1/chat/completions \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "<string>",
  "messages": [
    {}
  ],
  "max_tokens": 123,
  "temperature": 123
}
'
Extract text from images using DeepSeek’s vision capabilities.

Overview

DeepSeek OCR allows you to extract text from images, documents, and screenshots. The model can recognize text in multiple languages and handle various document formats.

Authentication

All requests require a Bearer token in the Authorization header:
Authorization: Bearer YOUR_API_KEY

Request Parameters

model
string
required
ID of the model to use. Use deepseek-chat with vision capabilities.
messages
array
required
A list of messages with image content for OCR processing.
max_tokens
integer
Maximum number of tokens to generate.
temperature
number
default:"0"
Sampling temperature. Lower values recommended for OCR accuracy.

Request Example

curl -X POST https://api.example.com/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-chat",
    "messages": [
      {
        "role": "user",
        "content": [
          {"type": "text", "text": "Please extract all text from this image."},
          {"type": "image_url", "image_url": {"url": "https://example.com/document.png"}}
        ]
      }
    ],
    "temperature": 0,
    "max_tokens": 4096
  }'

Response Example

{
  "id": "chatcmpl-123",
  "object": "chat.completion",
  "created": 1677652288,
  "model": "deepseek-chat",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Here is the extracted text from the image:\n\nINVOICE\nInvoice Number: INV-2024-001\nDate: January 15, 2024\n\nBill To:\nJohn Smith\n123 Main Street\nNew York, NY 10001\n\nItems:\n1. Product A - $50.00\n2. Product B - $75.00\n\nTotal: $125.00"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 1150,
    "completion_tokens": 95,
    "total_tokens": 1245
  }
}

Supported Image Formats

  • PNG
  • JPEG
  • WebP
  • GIF

Use Cases

  • Document digitization
  • Receipt and invoice processing
  • Screenshot text extraction
  • Handwritten text recognition
  • Multi-language text extraction

Available Models

  • deepseek-chat