From e1e800014a64987be114e11c91824412eb4fbab3 Mon Sep 17 00:00:00 2001 From: "jatin.go" Date: Wed, 13 May 2026 17:06:13 +0530 Subject: [PATCH] feat(ai-gateway): register FastRouter as a Kilo Gateway upstream MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds FastRouter (https://fastrouter.ai) as a known upstream provider in the Kilo Gateway. Registers 'fastrouter' in the ProviderId union and adds a FASTROUTER entry to provider-definitions.ts. No requests are rerouted by this change — the entry is symbolic so that future kilo-exclusive model definitions can declare gateway: 'fastrouter'. Companion to the kilocode-side built-in FastRouter provider PR. Closes maintainer checklist item #2 ("Kilo Gateway: please also submit a corresponding PR to add this provider to the Kilo Gateway") on the original kilocode PR review. Co-authored-by: Cursor --- .env.local.example | 2 ++ apps/web/.env.test | 1 + .../src/lib/ai-gateway/providers/kilo-exclusive-model.ts | 8 +++++++- .../src/lib/ai-gateway/providers/provider-definitions.ts | 7 +++++++ apps/web/src/lib/ai-gateway/providers/types.ts | 1 + 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.env.local.example b/.env.local.example index 4f15046328..c4ae4a89ce 100644 --- a/.env.local.example +++ b/.env.local.example @@ -29,6 +29,8 @@ R2_CLI_SESSIONS_BUCKET_NAME=test-bucket # ============================================================================ # OpenRouter (primary AI provider) - get from https://openrouter.ai/keys OPENROUTER_API_KEY=sk-or-v1-your-openrouter-key +# FastRouter (alternative OpenRouter-compatible LLM gateway) - get from https://fastrouter.ai +FASTROUTER_API_KEY= # Optional: Other AI providers OPENAI_API_KEY=sk-your-openai-key MISTRAL_API_KEY=your-mistral-key diff --git a/apps/web/.env.test b/apps/web/.env.test index 5df271d9c2..ee51df7f89 100644 --- a/apps/web/.env.test +++ b/apps/web/.env.test @@ -8,6 +8,7 @@ POSTGRES_URL="postgres://postgres:postgres@localhost:5432/postgres" POSTGRES_CONNECT_TIMEOUT=10000 POSTGRES_MAX_QUERY_TIME=5000 OPENROUTER_API_KEY=invalid-mock-api-key +FASTROUTER_API_KEY=invalid-mock-api-key STYTCH_PROJECT_ID=test-fake-project-id STYTCH_PROJECT_SECRET=test-fake-project-secret NEXT_PUBLIC_STYTCH_PROJECT_ENV=test diff --git a/apps/web/src/lib/ai-gateway/providers/kilo-exclusive-model.ts b/apps/web/src/lib/ai-gateway/providers/kilo-exclusive-model.ts index 288f65c1ff..4af17886c0 100644 --- a/apps/web/src/lib/ai-gateway/providers/kilo-exclusive-model.ts +++ b/apps/web/src/lib/ai-gateway/providers/kilo-exclusive-model.ts @@ -67,7 +67,13 @@ export function getInferenceProvider( model: KiloExclusiveModel ): OpenRouterInferenceProviderId | null { if (model.flags.includes('stealth')) return 'stealth'; - if (model.gateway === 'openrouter' || model.gateway === 'vercel') return null; + if ( + model.gateway === 'openrouter' || + model.gateway === 'vercel' || + model.gateway === 'fastrouter' + ) { + return null; + } return OpenRouterInferenceProviderIdSchema.parse(model.gateway); } diff --git a/apps/web/src/lib/ai-gateway/providers/provider-definitions.ts b/apps/web/src/lib/ai-gateway/providers/provider-definitions.ts index 01e803d0a7..cce2a135f0 100644 --- a/apps/web/src/lib/ai-gateway/providers/provider-definitions.ts +++ b/apps/web/src/lib/ai-gateway/providers/provider-definitions.ts @@ -14,6 +14,13 @@ export default { supportedChatApis: ['chat_completions', 'messages', 'responses'], transformRequest() {}, }, + FASTROUTER: { + id: 'fastrouter', + apiUrl: 'https://go.fastrouter.ai/api/v1', + apiKey: getEnvVariable('FASTROUTER_API_KEY'), + supportedChatApis: ['chat_completions'], + transformRequest() {}, + }, ALIBABA: { id: 'alibaba', apiUrl: 'https://dashscope-intl.aliyuncs.com/compatible-mode/v1', diff --git a/apps/web/src/lib/ai-gateway/providers/types.ts b/apps/web/src/lib/ai-gateway/providers/types.ts index ee7e75c028..8ac7cef1fc 100644 --- a/apps/web/src/lib/ai-gateway/providers/types.ts +++ b/apps/web/src/lib/ai-gateway/providers/types.ts @@ -4,6 +4,7 @@ import type { FraudDetectionHeaders } from '@/lib/utils'; export type ProviderId = | 'openrouter' + | 'fastrouter' | 'alibaba' | 'seed' | 'direct-byok'