Skip to content

fix(billing): reserve Sim's hosted model and tool keys for paid plans - #10313

Merged
waleedlatif1 merged 3 commits into
stagingfrom
fix/hosted-keys-paid-only
Nov 22, 2026
Merged

waleedlatif1 merged 3 commits into
stagingfrom
fix/hosted-keys-paid-only

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Sim's hosted provider keys are now paid-only. A free-plan payer without prepaid credits never runs on them, for models or tools.
  • One gate, mayUseHostedKey (lib/billing/core/hosted-key-access.ts), guards both:
    • Hosted model keys in getApiKeyWithBYOK, which covers agent, router, evaluator, Pi and the Fireworks pool.
    • Hosted tool keys in executeTool.
  • The per-tool requiresPaidPlan opt-in is removed, so the tool check now applies to every hosted tool. Image and video already had it.
  • Free payers keep running on their own keys: a workspace BYOK key, or a key passed on the block. Without one, the run fails with a 402 upgrade message.
  • A caller's own key on a hosted model now reports as isBYOK, so it is never billed as Sim's key. This also applies to the existing fallback when no hosted key is configured.
  • The two duplicated hosted-model key branches collapse into one resolveHostedModelKey helper.
  • The pricing comparison table, pricing FAQ and the costs docs now state that Sim-hosted models and tools come with paid plans.

Type of Change

  • Bug fix

Testing

  • byok.test.ts: new cases for a payer without paid access.
    • Refused with a 402 when the caller has no key.
    • The caller's own key is served as BYOK.
    • A workspace BYOK key is used without consulting the plan.
    • The Fireworks pool is refused the same way.
  • tools/index.test.ts: the paid-access suite now covers hosted tools without a per-tool flag.
  • Ran biome on the changed files. CI runs the full gate: type-check, audits and tests.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Free-plan payers without prepaid credits no longer run on Sim's hosted
provider keys. One gate, mayUseHostedKey, now guards both hosted model
keys (getApiKeyWithBYOK) and hosted tool keys (executeTool), replacing
the per-tool requiresPaidPlan opt-in. BYOK keys and keys passed on the
block keep working; a caller's own key on a hosted model is reported as
BYOK so its usage is not billed.
@vercel

vercel Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Nov 22, 2026 8:21pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The reviewed changes appear safe to merge.

Summary

The PR reserves Sim-hosted model and tool keys for payers with paid access, while keeping customer-owned keys usable.

  • Free-plan runs need their own key for Sim-hosted models and tools.
  • Pricing pages show that Sim-hosted keys come with paid plans.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Model or tool needs a key] --> B{Customer key available?}
  B -->|Yes| C[Use customer key]
  B -->|No| D[Check admitted payer or workspace payer]
  D --> E{Paid access?}
  E -->|Yes| F[Use Sim-hosted key]
  E -->|No| G[Return upgrade error]
Loading

Reviews (2) · Last reviewed commit: "fix(billing): judge the run's admitted p..." · Reviewed by Greptile

@cubic-dev-ai cubic-dev-ai Bot left a comment •

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.

All reported issues were addressed across 13 files

This PR changes payment, billing, or quota logic. Ultrareviews find 2.4x more serious bugs than standard reviews. Comment @cubic-dev-ai ultrareview to run one.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/tools/index.ts Resolved
Comment thread apps/sim/lib/api-key/byok.ts Resolved
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

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.

No issues found across 18 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 6419048 into staging Nov 22, 2026
85 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/hosted-keys-paid-only branch November 23, 2026 00:04

This branch was previously deployed

1 inactive deployment
Preview — b3f24842 Deployed Nov 22, 2026 by vercel[bot]
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.

1 participant