Skip to content

feat(gateway): serve embedding models from OpenRouter#3109

Merged
chrarnoldus merged 2 commits intomainfrom
feat/embedding-models-from-openrouter
May 8, 2026
Merged

feat(gateway): serve embedding models from OpenRouter#3109
chrarnoldus merged 2 commits intomainfrom
feat/embedding-models-from-openrouter

Conversation

@kilo-code-bot
Copy link
Copy Markdown
Contributor

@kilo-code-bot kilo-code-bot Bot commented May 7, 2026

Summary

Follow-up to #3099. The /api/gateway/embedding-models endpoint now proxies the live OpenRouter catalog (output_modalities=embeddings) instead of returning a hardcoded list, mirroring the existing /api/gateway/models endpoint for language models. Clients now see every embedding model OpenRouter exposes (Gemini, Perplexity, Qwen, BAAI, Sentence Transformers, etc.) without us shipping a new release each time the catalog changes.

  • Added getOpenRouterEmbeddingModels() in apps/web/src/lib/ai-gateway/providers/openrouter/index.ts that fetches ${OPENROUTER}/models?output_modalities=embeddings, validates with OpenRouterModelsResponseSchema, and reuses the existing attribution headers and Sentry plumbing.
  • Rewrote apps/web/src/app/api/gateway/embedding-models/route.ts to call that helper and return the OpenRouter response shape ({ data: [...] }), with a 500 + Sentry capture on failure.

Verification

  • curl http://localhost:3000/api/gateway/embedding-models returns the live OpenRouter embeddings catalog.

Visual Changes

N/A

Reviewer Notes

  • The response shape changes from the static { defaultModel, models, aliases } catalog to the standard OpenRouterModelsResponse ({ data: OpenRouterModel[] }) used by /api/gateway/models. Any client still relying on the old shape (e.g. the bundled fallback in the kilocode indexing PR) should be updated in lockstep.
  • The catalog can be sizeable (~25+ models). The fetch reuses the 60s next.revalidate caching that the language-models endpoint uses.
  • apps/web/src/lib/ai-gateway/embeddings/kilo-embedding-models.ts is untouched; it is still consumed by apps/web/src/app/(app)/claw/components/embeddingModels.ts and other internal call sites and can be retired in a separate change once those move to the live endpoint.

Make /api/gateway/embedding-models proxy the live OpenRouter
catalog (output_modalities=embeddings) so clients see all supported
embedding models, mirroring the existing /api/gateway/models endpoint
for language models.
@kilo-code-bot
Copy link
Copy Markdown
Contributor Author

kilo-code-bot Bot commented May 7, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (3 files)
  • apps/web/src/app/api/gateway/embedding-models/route.test.ts
  • apps/web/src/app/api/gateway/embedding-models/route.ts
  • apps/web/src/lib/ai-gateway/providers/openrouter/index.ts

Reviewed by gpt-5.5-2026-04-23 · 159,355 tokens

Importing jest from @jest/globals interferes with module auto-mocking
under SWC, leaving the mocked function as the real implementation.
* Test using:
* curl -vvv 'http://localhost:3000/api/gateway/embedding-models'
*/
export async function GET(): Promise<
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this affect the new semantic search feature in the extnesion?

Copy link
Copy Markdown
Contributor

@chrarnoldus chrarnoldus May 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it call this endpoint? api/gateway/embedding-models then yes

@chrarnoldus chrarnoldus merged commit 2dafbae into main May 8, 2026
13 checks passed
@chrarnoldus chrarnoldus deleted the feat/embedding-models-from-openrouter branch May 8, 2026 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants