feat(embeddings): add OpenRouter support - #6396
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Embeddings block & tools: Users can pick OpenRouter alongside OpenAI, Gemini, Cohere, and Mistral. Models load dynamically from OpenRouter’s embedding catalog via a new API route and combobox; a dedicated OpenRouter API key is always required (no hosted pool). The embeddings tool route validates model ids against the live catalog and calls Knowledge bases: Document/query embedding now goes through Supporting work includes an OpenRouter wire adapter, model id normalization, Reviewed by Cursor Bugbot for commit e75c0ba. Bugbot is set up for automated code reviews on this repo. Configure here. |
Greptile SummaryThe PR adds OpenRouter embeddings for explicit block usage and as an opt-in self-hosted knowledge-embedding fallback.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the previously reported duplicate failover work and mixed-BYOK overbilling paths are both corrected at the current head.
|
| Filename | Overview |
|---|---|
| apps/sim/lib/embeddings/client.ts | Adds OpenRouter transports and per-batch knowledge fallback while preserving output order and separating total from billable token usage. |
| apps/sim/lib/knowledge/documents/service.ts | Accumulates billable embedding tokens across every outer document batch and uses that total for usage recording. |
| apps/sim/lib/knowledge/embeddings.ts | Routes knowledge document and search embeddings through the deployment-aware embedding client. |
| apps/sim/blocks/blocks/embeddings.ts | Adds explicit OpenRouter block selection, dynamic model loading, and a required user-provided OpenRouter key. |
| apps/sim/app/api/tools/embeddings/route.ts | Validates dynamic OpenRouter models and dispatches them through the dedicated OpenRouter embedding transport. |
Sequence Diagram
sequenceDiagram
participant KB as Knowledge pipeline
participant Client as Embedding client
participant OpenAI as OpenAI / workspace BYOK
participant OR as OpenRouter fallback
participant Billing as Usage billing
KB->>Client: Embed precomputed batches
loop Each batch
Client->>OpenAI: Retry embedding request
alt OpenAI succeeds
OpenAI-->>Client: Embeddings and token usage
else Transient retries exhausted
Client->>OR: Retry only failed batch
OR-->>Client: Embeddings and token usage
end
end
Client-->>KB: Ordered embeddings, totalTokens, billableTokens
KB->>Billing: Record only billableTokens
Reviews (10): Last reviewed commit: "fix(embeddings): reset stale OpenRouter ..." | Re-trigger Greptile
|
@cursor review |
…-fallback # Conflicts: # apps/sim/tools/generated/tool-ids.ts # apps/sim/tools/generated/tool-metadata.ts # apps/sim/tools/generated/tool-outputs.ts
|
@cursor review |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit e4124c8. Configure here.
…-fallback # Conflicts: # apps/sim/tools/generated/tool-ids.ts # apps/sim/tools/generated/tool-metadata.ts # apps/sim/tools/generated/tool-outputs.ts
|
@cursor review |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit ca35ea0. Configure here.
|
@cursor review |
…-fallback # Conflicts: # apps/sim/tools/generated/tool-ids.ts # apps/sim/tools/generated/tool-metadata.ts # apps/sim/tools/generated/tool-outputs.ts
|
@cursor review |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit e75c0ba. Configure here.
Summary
Type of Change
Testing
Checklist