feat(embeddings): add OpenRouter support - #6396
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview The Embeddings block gains an OpenRouter provider with a dynamic model combobox (live catalog API), a dedicated OpenRouter API key field (required on hosted and self-hosted; no Sim-hosted pool), and routing through Knowledge-base indexing/search now calls Embedding results add Reviewed by Cursor Bugbot for commit 05535d9. Bugbot is set up for automated code reviews on this repo. Configure here. |
Greptile SummaryThe PR adds OpenRouter support for explicit Embeddings block calls and as an opt-in self-hosted knowledge-embedding fallback.
Confidence Score: 5/5The PR appears safe to merge because both previously reported failures are fixed and no blocking related failure remains. No blocking failure remains; failover now advances only the failed batch while preserving ordered sibling results, and billing sums only tokens produced with platform-provided credentials.
|
| Filename | Overview |
|---|---|
| apps/sim/lib/embeddings/client.ts | Adds OpenRouter transports and per-batch knowledge fallback while retaining successful batches and computing provider-specific billable token totals. |
| apps/sim/lib/knowledge/documents/service.ts | Accumulates the new billable-token count across document embedding batches for usage recording. |
| apps/sim/lib/knowledge/embeddings.ts | Routes knowledge embedding generation through the deployment-aware fallback client and forwards billing metadata. |
| apps/sim/blocks/blocks/embeddings.ts | Adds the OpenRouter provider, dynamic model selection, explicit user key handling, and tool dispatch. |
| apps/sim/app/api/tools/embeddings/route.ts | Validates dynamic OpenRouter models and routes explicit OpenRouter requests through the dedicated embedding transport. |
| apps/sim/lib/core/config/env-capabilities.ts | Introduces the knowledge-embedding fallback capability and conditional fallback behavior. |
Sequence Diagram
sequenceDiagram
participant KB as Knowledge embedding caller
participant Batch as Batch orchestrator
participant Primary as OpenAI/Azure
participant OR as OpenRouter
participant Billing as Usage billing
KB->>Batch: Embed inputs
par Per precomputed batch
Batch->>Primary: Request batch
alt Primary succeeds
Primary-->>Batch: Embeddings and token usage
else Transient failure
Batch->>OR: Retry only failed batch
OR-->>Batch: Embeddings and token usage
end
end
Batch-->>KB: Ordered embeddings, totalTokens, billableTokens
KB->>Billing: Record platform-billable tokens only
Reviews (8): Last reviewed commit: "fix(embeddings): batch OpenRouter reques..." | 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 |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 05535d9. Configure here.

Summary
Type of Change
Testing
Checklist