Skip to content

"API returned unexpected status code: 413" on OpenAI compatbile OCR LLM endpoint #791

Description

@CyWS

Hey there,
been using paperless-gpt now for hundreds of documents with an OpenAI compatbile API from Ionos Germany. Since a few days (can't point it to any update or date unfortunately, last time it worked was 2nd Nov 2025), OCR has stopped working with that error: API returned unexpected status code: 413

My understanding is that HTTP 413 points to "Content Too Large", so the generated image might be too large for Ionos API? Their documentation https://docs.ionos.com/cloud/ai/ai-model-hub does not really say anything on that. I am heavily below the rate limits and I chose a model capable of image input: https://docs.ionos.com/cloud/ai/ai-model-hub/models/llms/mistral-small-24b

Alll the LLM activities Title, Tags and Date work totally fine.

Any chance to further debug this?

Please see the log:

time="2025-11-24T11:33:54Z" level=info msg="Using token limit: 5000"
time="2025-11-24T11:33:54Z" level=info msg="OCR provider: llm"
time="2025-11-24T11:33:54Z" level=info msg="Settings file not found at config/settings.json, creating with default values."
Using paperless-gpt as manual tag
Using paperless-gpt-auto as auto tag
    ╔═══════════════════════════════════════╗
    ║             Paperless GPT             ║
    ╚═══════════════════════════════════════╝
Version: v0.23.0
Commit: fecd76a5bf14f8183b53d874b31b0121981a9779
Build Date: 1758104151
Platform: linux/amd64
Go Version: go1.25.0
Started: Mon, 24 Nov 2025 11:33:54 UTC
time="2025-11-24T11:33:54Z" level=info msg="Initializing OCR provider: llm"
time="2025-11-24T11:33:54Z" level=info msg="Using LLM OCR provider" model=mistralai/Mistral-Small-24B-Instruct provider=openai
time="2025-11-24T11:33:54Z" level=info msg="Creating new LLM OCR provider" model=mistralai/Mistral-Small-24B-Instruct provider=openai
time="2025-11-24T11:33:54Z" level=info msg="Successfully initialized LLM OCR provider" model=mistralai/Mistral-Small-24B-Instruct provider=openai
time="2025-11-24T11:33:54Z" level=info msg="Validating OCR provider 'llm' with processing mode 'image'"
time="2025-11-24T11:33:54Z" level=info msg="✅ OCR provider and processing mode configuration is valid"
time="2025-11-24T11:33:54Z" level=info msg="Serving frontend files from embedded assets"
time="2025-11-24T11:33:54Z" level=info msg="Server started on interface :8080"
Using paperless-gpt-ocr as manual OCR tag
Using paperless-gpt-ocr-auto as auto OCR tag
time="2025-11-24T11:35:25Z" level=debug msg="Making HTTP request" method=GET url="http://webserver:8000/api/documents/?tags__name__iexact=paperless-gpt-ocr-auto&page_size=25"
time="2025-11-24T11:35:25Z" level=debug msg="Making HTTP request" method=GET url="http://webserver:8000/api/tags/"
time="2025-11-24T11:35:26Z" level=debug msg="Making HTTP request" method=GET url="http://webserver:8000/api/correspondents/?page_size=9999"
time="2025-11-24T11:35:26Z" level=debug msg="Found 1 documents with tag paperless-gpt-ocr-auto"
time="2025-11-24T11:35:26Z" level=info msg="Processing document for OCR" document_id=484
time="2025-11-24T11:35:26Z" level=info msg="Starting OCR processing" document_id=484
time="2025-11-24T11:35:26Z" level=debug msg="OCR provider does not support hOCR" document_id=484
time="2025-11-24T11:35:26Z" level=debug msg="Making HTTP request" method=GET url="http://webserver:8000/api/documents/484/download/"
time="2025-11-24T11:35:27Z" level=debug msg="Downloaded document images" document_id=484 limit_pages=0 processed_page_count=1 total_page_count=1
time="2025-11-24T11:35:27Z" level=debug msg="Processing page" document_id=484 page=1
time="2025-11-24T11:35:28Z" level=info msg="Using OpenAI image format" model=mistralai/Mistral-Small-24B-Instruct page=1 provider=openai
time="2025-11-24T11:35:28Z" level=error msg="Failed to get response from vision model" error="API returned unexpected status code: 413" model=mistralai/Mistral-Small-24B-Instruct page=1 provider=openai
time="2025-11-24T11:35:28Z" level=error msg="OCR processing failed: error performing OCR for document 484, page 1: error getting response from LLM: API returned unexpected status code: 413" document_id=484
time="2025-11-24T11:35:28Z" level=error msg="Error in background tagging: error in processAutoOcrTagDocuments: one or more errors occurred: document 484 OCR error: error performing OCR for document 484, page 1: error getting response from LLM: API returned unexpected status code: 413"
time="2025-11-24T11:35:48Z" level=debug msg="Making HTTP request" method=GET url="http://webserver:8000/api/documents/?tags__name__iexact=paperless-gpt-ocr-auto&page_size=25"
time="2025-11-24T11:35:48Z" level=debug msg="Making HTTP request" method=GET url="http://webserver:8000/api/tags/"
time="2025-11-24T11:35:48Z" level=debug msg="Making HTTP request" method=GET url="http://webserver:8000/api/correspondents/?page_size=9999"
time="2025-11-24T11:35:49Z" level=debug msg="Found 1 documents with tag paperless-gpt-ocr-auto"
time="2025-11-24T11:35:49Z" level=info msg="Processing document for OCR" document_id=484
time="2025-11-24T11:35:49Z" level=info msg="Starting OCR processing" document_id=484
time="2025-11-24T11:35:49Z" level=debug msg="OCR provider does not support hOCR" document_id=484
time="2025-11-24T11:35:49Z" level=debug msg="Making HTTP request" method=GET url="http://webserver:8000/api/documents/484/download/"
time="2025-11-24T11:35:50Z" level=debug msg="Downloaded document images" document_id=484 limit_pages=0 processed_page_count=1 total_page_count=1
time="2025-11-24T11:35:50Z" level=debug msg="Processing page" document_id=484 page=1
time="2025-11-24T11:35:51Z" level=info msg="Using OpenAI image format" model=mistralai/Mistral-Small-24B-Instruct page=1 provider=openai
time="2025-11-24T11:35:51Z" level=error msg="Failed to get response from vision model" error="API returned unexpected status code: 413" model=mistralai/Mistral-Small-24B-Instruct page=1 provider=openai
time="2025-11-24T11:35:51Z" level=error msg="OCR processing failed: error performing OCR for document 484, page 1: error getting response from LLM: API returned unexpected status code: 413" document_id=484
time="2025-11-24T11:35:51Z" level=error msg="Error in background tagging: error in processAutoOcrTagDocuments: one or more errors occurred: document 484 OCR error: error performing OCR for document 484, page 1: error getting response from LLM: API returned unexpected status code: 413"

Extract of my config:

  paperless-gpt:
    image: icereed/paperless-gpt:latest
    restart: unless-stopped
    environment:
      LLM_PROVIDER: "openai"
      OPENAI_BASE_URL: "https://openai.inference.de-txl.ionos.com/v1"
      OPENAI_API_KEY: "${OPENAI_IONOS_API_TOKEN}"
      LLM_MODEL: "openai/gpt-oss-120b"
      TOKEN_LIMIT: "5000"
      LLM_REQUESTS_PER_MINUTE: "1" # 120 Default
      OCR_PROVIDER: "llm"
      VISION_LLM_PROVIDER: "openai"
      VISION_LLM_MODEL: "mistralai/Mistral-Small-24B-Instruct"
      VISION_LLM_REQUESTS_PER_MINUTE: "1" # 120 Default
      OCR_PROCESS_MODE: "image"
      PDF_SKIP_EXISTING_OCR: "true"
      OCR_LIMIT_PAGES: "0" # Optional, default: 5. Set to 0 for no limit.
      CREATE_LOCAL_PDF: "false"
      CREATE_LOCAL_HOCR: "false"
      LOG_LEVEL: "debug"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions