open-codesign icon indicating copy to clipboard operation
open-codesign copied to clipboard

[Feature]: Add LLMTR as a built-in provider

Open knowhycodata opened this issue 4 weeks ago • 1 comments

Problem / pain point

Users of LLMTR, an OpenAI-compatible gateway (https://llmtr.com/v1, Bearer keys starting with llmtr-), currently have to set it up as a custom endpoint: pick the wire protocol, type the base URL, and enter a model id by hand. Onboarding doesn't recognise an llmtr- key either. I work on LLMTR.

Proposed solution

Add LLMTR as a built-in provider the same way Atlas Cloud was added in #404:

  • openai-chat wire, base URL https://llmtr.com/v1, LLMTR_API_KEY, default model qwen/qwen3.8-27b-free (free tier), with llmtr/qwen3-8-27b in the shortlist
  • detect llmtr- keys in onboarding
  • model discovery from GET /v1/models; the onboarding key check uses a one-token chat request, since /v1/models is public and returns 200 for any key
  • key help link to https://llmtr.com/docs/en/api-keys/

No new dependencies, BYOK only, nothing bundled.

Alternatives considered

The custom OpenAI-compatible provider form already works with the same base URL; this only makes it a one-step setup and keeps the shortlist and key link in one place.

Scope

Provider / model

Hard-constraints check

  • [x] I have read the hard constraints in CLAUDE.md and this proposal does not conflict with any of them.

knowhycodata avatar Nov 04 '26 12:11 knowhycodata

Thanks for the detailed write-up — and for shipping LLMTR. The proposal is well-scoped: a single openai-chat provider entry, a key prefix in onboarding, /v1/models discovery, and a key help link. Nothing bundled, no new deps, BYOK-only.

Verdict on the hard constraints: this sits cleanly inside them. CLAUDE.md constraint 2 requires BYOK-only with no proxied calls, and AGENTS.md constraint 2 repeats it — a built-in provider entry (config + shortlist + onboarding hint) doesn't add a proxy or a bundled runtime, so it doesn't touch constraints 1 or 2. It also doesn't need a shipped dependency, so constraint 4 in CLAUDE.md is unaffected.

Where it lands in the codebase (verified from this checkout):

  • packages/providers/ is the provider layer — CLAUDE.md describes it as "pi-ai adapter + custom provider extensions", and .github/labeler.yml:11 maps area:providers to packages/providers/**.
  • Provider registration should go through pi rather than a parallel SDK layer: AGENTS.md states custom providers are registered via pi.registerProvider(), and CLAUDE.md says all LLM calls go through @mariozechner/pi-ai with pi-ai gaps handled as thin extensions in packages/providers.
  • pi-ai is currently ^0.72.1 in apps/desktop/package.json and is locally patched (patches/@[email protected], declared under pnpm.patchedDependencies in the root package.json). Worth knowing before you assume a catalog entry exists upstream — if LLMTR needs to be a first-class entry rather than a config-only provider, the extension belongs in packages/providers, not as a new pi-ai patch.
  • Onboarding key-prefix detection and the connection probe live in the Electron main/provider-config path under apps/desktop/ (the repo layout in CLAUDE.md puts the shell there; I can't point at the exact detection module from this pass).
  • CLAUDE.md requires at least one Vitest test for a new feature, so the PR should carry provider-level tests, not just a catalog entry.

Two things in the spec to tighten before a PR:

  1. The model IDs don't line up: the default is qwen/qwen3.8-27b-free but the shortlist entry is llmtr/qwen3-8-27b. Those look like the same model written two ways — the exact id strings returned by GET /v1/models are what matter, since that's what gets stored in config and sent on the wire. Please paste the raw /v1/models ids for both.
  2. Making a free-tier model the default for the provider is fine, but it silently becomes what new users hit first. If the free tier is rate-limited or queue-backed, a shortlist-only entry with a paid model as default avoids a confusing first run. Your call — just flagging the UX consequence.

Implementation notes that would make review easy:

  • Detect llmtr- with an anchored prefix (^llmtr-) so it can't collide with other custom-endpoint keys, and place it alongside the existing provider probes rather than special-casing the onboarding flow.
  • Your reasoning on the key check is right: since /v1/models is public and returns 200 for any key, the probe must be a chat request. Suggest max_tokens: 1 and treating only 401/403 as "invalid key" — map network failures, 429, and 5xx to an "unverified" state so a flaky network doesn't tell users their key is wrong.
  • For discovery, keep a static fallback shortlist when /v1/models fails or times out, and cache results per session so onboarding isn't blocked on a slow gateway.
  • If /v1/models doesn't use the standard {"data":[{"id":...}]} shape, the parsing needs to be explicit — that's the most likely place for a silent empty shortlist.

Related history: the issue cites #404 (Atlas Cloud) as the pattern to copy. As you note, the generic custom OpenAI-compatible provider already works with https://llmtr.com/v1, so this is purely setup ergonomics — a shortlist, a key link, and prefix detection — not new protocol support. That framing should keep the review small.

Need more info:

  • Raw model id strings from GET /v1/models (and whether the response is OpenAI-standard data[].id).
  • Which model should be the provider default vs. shortlist-only.^1
  • Does /v1/chat/completions support SSE streaming, and does it accept max_tokens (vs max_completion_tokens)?
  • Is the auth header exactly Authorization: Bearer llmtr-..., with no extra required header?

^1 If you'd rather not decide up front, shortlist-only is the lower-risk default for a first PR.


Open-CoDesign Bot

github-actions[bot] avatar Nov 04 '26 12:11 github-actions[bot]