feat(provider): add Nexforce Router - #192
Open
fernandovitti wants to merge 1 commit into
Open
Conversation
Add nexforce as a recognized model provider across core and CLI so its NEXFORCE_API_KEY can be stored and validated from the Admin page, listed in deployment secrets, and probed by the CLI doctor. The provider has no servable base model yet (the pinned pi-ai runtime has no nexforce provider), so MODEL_PROVIDER=nexforce is refused at config load and the CLI refuses --model-provider nexforce; key validation probes a 1-token chat completion because the /v1/models catalog is public and ignores auth.
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.
feat(provider): add Nexforce Router
The value proposition
This PR adds Nexforce Router — Latin America's largest AI inference router — so QM
deployments get one API key that reaches Anthropic, OpenAI, Google, DeepSeek, Moonshot,
Zhipu, and Cloudflare Workers AI, with automatic fallback and per-key cost control.
One OpenAI-compatible endpoint (
https://router.nexforce.ai/v1), oneNEXFORCE_API_KEY,and your team can swap between the frontier labs and the best open models without touching a
line of infra. Response headers (
X-Nexforce-Requested-Model/X-Nexforce-Served-Model)make it transparent which model answered each request, and per-key spend caps and fallback
chains keep every conversation predictable.
Why it matters for Latin America
Local billing and compliance are the real unlock. Nexforce handles invoicing, taxes, and
payment infrastructure locally for each country in the region, so teams get compliant,
locally-issued invoices without the FX and foreign-procurement friction of paying an
overseas provider. You keep full visibility into which model served each request and what it
cost — per API key, per conversation.
What changed
src/model/pi-models.ts— registernexforceinMODEL_PROVIDERS, availability, and serviceabilitysrc/config.ts— readNEXFORCE_API_KEYinto the core configsrc/model/model-credential-store.ts— track nexforce availability alongside the other providerssrc/wiring.ts— surface an environment-provided nexforce key to the credential storesrc/api/routes/admin/model-providers.ts— validate nexforce keys against the router (a 1-token chat probe, since/v1/modelsis public)src/deployment/secret-schema.ts—NEXFORCE_API_KEYsecret gatesrc/model/model-catalog.ts,src/api/routes/admin/scope-config.ts— carry the nexforce provider through the model catalog typescli/src/config.ts— CLI provider registry, key name, and harness rulescli/src/backends/doctor.ts— live nexforce key probe forqm doctorcli/src/secrets.ts,cli/src/commands/setup.ts— nexforce key in deployment secrets and the setup wizardplugins/admin/public/index.html— nexforce appears in the Admin model-provider onboardingcli/templates/deployment/deployment.md— operator-facing provider docsHow to configure
Environment: set
NEXFORCE_API_KEY(or store it write-only from the Admin page →Model provider), and it becomes a recognized, validated provider key.
Endpoint:
https://router.nexforce.ai/v1— an OpenAI-compatible Chat Completions APIwith streaming, tool calling, and multimodal input. Key validation probes a minimal
chat completion against
deepseek/deepseek-v4-flash(the cheapest catalog model).The nexforce catalog — spanning Anthropic, OpenAI, Google, DeepSeek, Moonshot, Zhipu, and
Cloudflare Workers AI — is discoverable at
https://router.nexforce.ai/v1/models(public),including
nexforce/smart-route, which lets the router pick an equivalent model per request.Verification done
https://router.nexforce.ai/v1/models— 139 models acrossAnthropic, OpenAI, Google, DeepSeek, Moonshot, Zhipu, Meta, Mistral, MiniMax, Qwen, xAI,
NVIDIA, and the
nexforce/smart-routerouter model./v1/chat/completionsrejects a bad key with401 invalid_api_key, while the catalog stays public — which is why key validation uses achat probe rather than the models listing.
tests pass; CLI typecheck clean. (A live chat roundtrip with a real
nfc_key is pending atest key from the reviewer.)
A note on scope
This is the declarative registration: the provider is recognized end-to-end for key
management, secrets, and validation. The QM runtime streams through the pinned
@earendil-works/pi-aiengine, which does not yet know nexforce, so it intentionally has noservable base model and
MODEL_PROVIDER=nexforcefails fast at config load rather thansilently serving broken turns. Wiring nexforce into the streaming layer is the natural
follow-up once the runtime gains the provider.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.