Skip to content

New: Claude apikey added#14

Merged
RishiGoswami-code merged 1 commit into
OzymorLab:mainfrom
RishiGoswami-code:new/llm
Jun 7, 2026
Merged

New: Claude apikey added#14
RishiGoswami-code merged 1 commit into
OzymorLab:mainfrom
RishiGoswami-code:new/llm

Conversation

@RishiGoswami-code

Copy link
Copy Markdown
Collaborator

Add Claude API Fallback for OCR and Parsing Reliability

Summary

This PR introduces Anthropic Claude as a fallback LLM provider when Gemini requests fail due to quota limits, billing issues, rate limits, or service unavailability.

Changes

  • Added Claude API configuration support through environment variables.

  • Implemented fallback logic for OCR and document parsing workflows.

  • Added automatic provider switching when Gemini returns errors such as:

    • RESOURCE_EXHAUSTED
    • 429 Too Many Requests
    • Service unavailability errors
  • Improved logging to indicate the active provider and fallback events.

  • Preserved existing Gemini-first behavior to minimize changes to current workflows.

Motivation

During document parsing, Gemini requests can fail when API credits are exhausted or quota limits are reached. This causes OCR extraction to fail completely, resulting in empty question papers and interrupted grading workflows.

By introducing Claude as a secondary provider, the system can continue processing documents without requiring manual intervention, improving platform reliability and reducing service disruptions.

Impact

  • Increased OCR and parsing availability.
  • Reduced failures caused by provider-specific outages or quota exhaustion.
  • Improved resilience for production and demo environments.
  • No breaking changes to existing APIs.

Configuration

Required environment variable:

CLAUDE_API_KEY=<your_claude_api_key>

Optional fallback behavior:

# ── LLM Provider Strategy ──
 # claude_primary  → Claude first, Gemini fallback  (default)
 # gemini_primary  → Gemini first, Claude fallback
 # claude_only / gemini_only  → single provider, no fallback
LLM_PROVIDER_STRATEGY=claude_primary

Testing

  • Verified normal processing using Gemini.
  • Verified automatic fallback when Gemini returns RESOURCE_EXHAUSTED.
  • Verified successful parsing through Claude after provider switch.
  • Verified existing parsing pipeline remains unchanged when Gemini is available.

@RishiGoswami-code RishiGoswami-code merged commit fce4447 into OzymorLab:main Jun 7, 2026
1 check failed
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