Replace Qwen provider with LiteLLM and OpenRouter aggregators

Adding one bespoke provider package per vendor doesn't scale. LiteLLM
proxy and OpenRouter both speak the OpenAI chat-completions wire
format and each front dozens-to-hundreds of underlying models, so
supporting them once gets that whole catalog instead of one more
one-off integration — providers/qwen turns out to have been exactly
that pattern hand-rolled a second time (its own copy of the
OpenAI-compatible translation, just pointed at DashScope's base URL).

providers/litellm and providers/openrouter are both thin constructors
over the OpenAI provider's existing NewOpenAIProviderWithKind(apiKey,
baseURL, "openai-compatible") — no new request/stream-translation code.
OpenRouter defaults to its public endpoint when baseURL is empty;
LiteLLM has none (self-hosted), so callers must supply one.

Context-window detection (tokens.ContextWindow) already keys off the
model ID's family rather than the provider prefix, specifically so a
model exposed under a custom/proxy provider name still gets the right
window — so litellm/openrouter models need zero changes there.
This commit is contained in:
sausheong committed 2026-09-06 16:13:30 +08:00
1 parent 0ba1b4dbcc
commit f624e4c7bd
11 files changed
+143 -431

No files matched your search

+2 -2
View File
@@ -34,8 +34,8 @@ const stripCacheMax = 256
// ApplyStripList runs StripFields over each tool's Parameters with the
// given field-strip list, preserving input order and accumulating
// diagnostics across all tools. The per-provider NormalizeToolSchema
// methods (OpenAI, Qwen, Gemini) are thin wrappers over this helper —
// only the strip list differs. Anthropic doesn't use this (identity).
// methods (OpenAI, Gemini) are thin wrappers over this helper — only the
// strip list differs. Anthropic doesn't use this (identity).
//
// Memoized: identical inputs return cached output without re-walking
// the JSON Schema. Cache key is a SHA-256 over (sorted fields, tool