Repository navigation
feat(ai-gateway): use TENCENT_FREE_API_KEY for free Tencent model in Vercel settings - #5128
chrarnoldus wants to merge 2 commits into
Conversation
| }; | ||
|
|
||
| export function isTencentFreeModel(model: string): boolean { | ||
| return model === tencent_hy3_free_model.public_id || model === tencent_hy3_free_model.internal_id; |
There was a problem hiding this comment.
WARNING: isTencentFreeModel('tencent/hy3') also matches the internal (non-:free) id, which the rest of the gateway treats as a paid model
isFreeModel('tencent/hy3') returns false (no :free suffix, not a kilo-exclusive public_id, not auto-free), so a direct client request for tencent/hy3 is balance-gated and billed as a paid model (route.ts rejects zero-balance users for non-free models) — yet when such a request routes to Vercel it now carries the free TENCENT_FREE_API_KEY in providerOptions.gateway.byok. If tencent/hy3 is requestable as a paid catalog model, paying users would be served (and potentially rate-limited) by the free key while being billed paid rates. If only the :free public id should ever receive this key, drop the internal_id match here; otherwise please confirm the paid-id billing semantics are intended.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
| const request: GatewayRequest = { | ||
| kind: 'chat_completions', | ||
| body: { | ||
| model: 'anthropic/claude-sonnet-4.5', |
There was a problem hiding this comment.
SUGGESTION: This test uses anthropic/claude-sonnet-4.5, so it cannot catch the regression its title describes
Since isTencentFreeModel('anthropic/claude-sonnet-4.5') is always false, this test would still pass even if the Tencent byok block were later moved so it also runs in the userByok branch. Using tencent/hy3:free as the requested model together with a user BYOK entry would actually exercise the "does not override userByok" guard this test is named for.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
| - `OPENAI_API_KEY` - OpenAI API key; used in `apps/web/src/lib/ai-gateway/embeddings/embedding-providers.ts` for the `text-embedding-3-small` embedding model, and as a provider config in `apps/web/src/lib/config.server.ts`. `[SECRET]` | ||
| - `MISTRAL_API_KEY` - Mistral API key; used in `apps/web/src/lib/ai-gateway/embeddings/embedding-providers.ts` for `codestral-embed-2505` and `mistral-embed` embeddings, in the FIM completions proxy at `apps/web/src/app/api/fim/completions/route.ts` (routes Mistral Codestral vs. La Plateforme keys), and as a provider config in `apps/web/src/lib/config.server.ts`. `[SECRET]` | ||
| - `STREAMLAKE_API_KEY` - StreamLake API key for model inference through the AI gateway; provider definition in `apps/web/src/lib/ai-gateway/providers/provider-definitions.ts`. `[SECRET]` | ||
| - `TENCENT_FREE_API_KEY` - API key for the free Tencent model when routed through Vercel AI Gateway. `[SECRET]` |
There was a problem hiding this comment.
SUGGESTION: Consider also adding TENCENT_FREE_API_KEY to .env.local.example
The other optional AI provider keys documented in this section (OPENAI_API_KEY, MISTRAL_API_KEY, STREAMLAKE_API_KEY, XAI_API_KEY) are also listed in .env.local.example, which dev/local/setup-env.ts parses during local setup. Adding the new key there keeps local-dev discoverability consistent.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
Code Review SummaryStatus: 1 Issue Found | Recommendation: Address before merge Executive SummaryThe follow-up commit correctly restricts Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (4 files)
Fix these issues in Kilo Cloud Previous Review Summary (commit 48125e3)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 48125e3)Status: 3 Issues Found | Recommendation: Address before merge Executive SummaryThe Vercel BYOK wiring for the free Tencent model is well-tested, but Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (7 files)
Reviewed by kimi-k3 · Input: 28.7K · Output: 8.1K · Cached: 498.7K Review guidance: REVIEW.md from base branch |
Configure
applyVercelSettingsso that in the non-user-BYOK case, when routing the free Tencent model (tencent/hy3:free/tencent/hy3) andTENCENT_FREE_API_KEYis set, the API key is passed inproviderOptions.gateway.byok.