feat(provider): add built-in LLMTR gateway provider - #10
Open
knowhycodata wants to merge 3 commits into
Open
Conversation
LLMTR (https://llmtr.com) is a Turkey-hosted, OpenAI-compatible AI gateway fronting 200+ models (global providers + Turkey-hosted models with a data-residency guarantee) behind a single endpoint. - New `llmtr` provider plugin injects an `@ai-sdk/openai-compatible` provider into the catalog (url https://llmtr.com/v1), mirroring the openrouter/nvidia/ zenmux gateway pattern. Bearer key resolves from the `llmtr` integration. - Registers an `llmtr` integration with API-key + env (`LLMTR_API_KEY`) auth. - Discovers the model catalog live from the public `/v1/models` endpoint (OpenRouter-style schema), converting per-token pricing to per-1M cost and mapping modalities/tool support/limits. Curated offline seed of Turkey-hosted flagships keeps the provider usable without network. `LLMTR_BASE_URL` overrides the endpoint; `LLMTR_SKIP_REMOTE_MODELS=1` disables the live fetch. - Adds hermetic test coverage and a README section. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
LLMTR models (gemma-4, qwen3, muse-glimmer) expose thinking as an on/off toggle (`reasoning: true`, or a `:think` model-id suffix), not OpenAI-style graded reasoning_effort. An active effort variant — or one carried over from another model — sent `reasoning_effort` and LLMTR rejected the whole request. Rewrite the outgoing request body for the LLMTR provider so any graded reasoning_effort becomes `reasoning: true` (an explicit off/none/minimal/ disabled keeps thinking off, and an existing reasoning flag is preserved), matching what LLMTR accepts. Add rewriteLLMTRReasoningBody plus unit tests.
Seed the GLM 5.x family (5.3, 5.2, 5.1, 5) and the DeepSeek family (V4 Pro,
V4 Flash, Chat, R1) — strong tool-use / reasoning models better suited to
security work than the existing Turkey-hosted seeds. Metadata comes from the
live LLMTR catalog; the forked live fetch still wins on id collisions so
pricing stays current.
These upstreams expose different thinking controls, so make the reasoning
normalization per-model instead of blanket: classify each model as
effort/boolean/none from its advertised parameters (in a dependency-free
module to avoid a plugin-registry import cycle), and only rewrite an outgoing
reasoning_effort for on/off ("boolean") or no-reasoning ("none") models.
Graded-effort models (GLM 5.2/5.3, proxied OpenAI, ...) keep their native
reasoning_effort untouched. Add classifier and seed-catalog tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #9
What
Adds LLMTR — a Turkey-hosted, OpenAI-compatible AI gateway (200+ models, global + Turkey-hosted with data-residency guarantee) — as a built-in provider. It plugs in like the other gateway providers (openrouter/nvidia/zenmux): an
@ai-sdk/openai-compatibleprovider athttps://llmtr.com/v1whose bearer key is resolved from a newllmtrintegration.Changes
packages/core/src/plugin/provider/llmtr.ts— new provider plugin:llmtrprovider into the catalog (@ai-sdk/openai-compatible, urlhttps://llmtr.com/v1, branding headers).llmtrintegration with API-key + env (LLMTR_API_KEY) auth methods./v1/modelsendpoint (OpenRouter-style schema): converts per-token pricing → per-1M cost, maps modalities, tool support (supported_parameters), and context/output limits.LLMTR_BASE_URLoverrides the endpoint;LLMTR_SKIP_REMOTE_MODELS=1disables the live fetch (used by the test).packages/core/src/plugin/provider.ts— registerLLMTRPlugininProviderPlugins.packages/core/test/plugin/provider-llmtr.test.ts— hermetic tests: registration, provider api/headers, integration key+env methods, seed model pricing conversion & tool detection.README.md— LLMTR configuration section.Usage
pentestcode auth login # pick "LLMTR", paste API key (or export LLMTR_API_KEY=...){ "provider": { "llmtr": { "model": "openai/gpt-5.5" } } }Verification
tsgo --noEmit(core) — clean.bun test test/plugin/— 217 pass / 0 fail (incl. 4 new).