Skip to content

Add OpenRouter provider support#188

Open
kenrogers wants to merge 2 commits intohuggingface:mainfrom
kenrogers:codex/openrouter-provider-support
Open

Add OpenRouter provider support#188
kenrogers wants to merge 2 commits intohuggingface:mainfrom
kenrogers:codex/openrouter-provider-support

Conversation

@kenrogers
Copy link
Copy Markdown

@kenrogers kenrogers commented Apr 29, 2026

Summary

Adds explicit OpenRouter model support to ML Intern's LiteLLM parameter resolver.

ML Intern already treats bare model ids as Hugging Face Router ids, and this PR
keeps that behavior unchanged. The fix here is narrower: when a user passes an
explicit provider-prefixed model id like openrouter/..., route it through
LiteLLM's OpenRouter provider instead of letting it fall through to the Hugging
Face Router fallback.

That avoids surprising endpoint/auth behavior for an explicit third-party
provider namespace while preserving the existing Hugging Face Router default for
bare model ids.

Example:

ml-intern --model openrouter/anthropic/claude-sonnet-4-5 "your prompt"

Details

  • routes openrouter/... model ids through LiteLLM's OpenRouter provider before the Hugging Face Router fallback
  • keeps the existing Hugging Face Router fallback for bare and unrecognized model ids
  • reads OPENROUTER_API_KEY and optional OPENROUTER_API_BASE
  • supports optional OpenRouter attribution headers via OR_SITE_URL and OR_APP_NAME
  • forwards supported reasoning_effort values consistently with the existing OpenAI-style resolver behavior
  • documents the env var and CLI usage in the README

Tests

uv run --extra dev pytest tests/unit/test_llm_params.py

Result: 13 passed.

@kenrogers kenrogers marked this pull request as ready for review April 30, 2026 14:43
@fglogan
Copy link
Copy Markdown

fglogan commented May 3, 2026

closed per maintainer request

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.

2 participants