Skip to content

feat(ocr): Add environment variable support for OCR configuration#1712

Open
ErixWong wants to merge 1 commit intomicrosoft:mainfrom
ErixWong:feat/ocr-env-config
Open

feat(ocr): Add environment variable support for OCR configuration#1712
ErixWong wants to merge 1 commit intomicrosoft:mainfrom
ErixWong:feat/ocr-env-config

Conversation

@ErixWong
Copy link
Copy Markdown

@ErixWong ErixWong commented Apr 11, 2026

This PR adds the ability to configure OCR services via environment variables, following the 12-factor app principles.

Changes

  • Add from_env() class method to LLMVisionOCRService for creating instances from environment variables (MARKITDOWN_OCR_API_KEY, MARKITDOWN_OCR_API_BASE, MARKITDOWN_OCR_MODEL)
  • Update plugin registration to support three-tier configuration priority:
    1. Explicit kwargs (llm_client, llm_model, llm_prompt)
    2. Environment variables
    3. No OCR service (text-only extraction)

Benefits

  • No need to hardcode API keys in code
  • Easier deployment in containerized environments
  • Backward compatible - existing code continues to work

Testing

  • Tested with local environment variables
  • Verified backward compatibility with existing code

Fixes: N/A (feature enhancement)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant