Skip to content

Require a paid plan with usage remaining for embeddings - #1542

Merged
AnthonyRonning merged 1 commit into
masterfrom
embeddings-paid-gate
Nov 10, 2026
Merged

AnthonyRonning merged 1 commit into
masterfrom
embeddings-paid-gate

Conversation

@AnthonyRonning

@AnthonyRonning AnthonyRonning commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Problem

POST /v1/embeddings only checked guest accounts. A free registered account, or a paid account with no usage left, passed straight through to the provider. Usage was published after the call, but nothing read the balance before it, so the only bound was the shared request rate limiter. The request model was also forwarded as sent.

No Maple client calls this route for its own features. It is reachable through the SDKs, the proxy and the Maple Work local API.

Change

  • Embeddings now use the same billing snapshot as Chat Completions (chat_billing_access), for JWT and API-key callers alike: a paid plan with usage remaining in the pool the call is billed to.
  • A missing billing client, a billing error or a timeout returns a retryable 503 instead of access.
  • Only nomic-embed-text is accepted; any other model is a 400.
  • Model and input validation run before billing or the provider is contacted, so invalid requests still get their 400.
Caller Before After
Paid, usage remaining allowed allowed
Paid, usage exhausted allowed 403 usage_limit_reached
Free registered allowed 403 model_not_available_on_plan
Free guest 401 401
Billing unavailable allowed (guests 401) 503

Client impact

Paid callers using the default or nomic-embed-text model see no change. Callers that sent another model name now get a 400.

Validation

  • cargo fmt --check, cargo clippy --all-targets -- -D warnings in the pinned #ci shell
  • New unit tests for the access decision and request validation; the backend pre-commit gate (1136 tests) passed
  • Not run: a live encrypted-client request against a local stack with billing linked

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

/v1/embeddings only checked guests. A free registered account, or a paid
one with no usage left, could call it without limit beyond the shared
request rate limiter, and usage was only published after the provider
call. The request model was also forwarded as sent.

Embeddings now use the same billing snapshot as Chat Completions, for
JWT and API-key callers alike: a paid plan with usage remaining in the
pool the call is billed to. A missing or failed billing answer is a
retryable 503 instead of access. Only nomic-embed-text is accepted, and
validation runs before billing or the provider is contacted.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@AnthonyRonning
AnthonyRonning merged commit 4b91700 into master Nov 10, 2026
23 checks passed
@AnthonyRonning
AnthonyRonning deleted the embeddings-paid-gate branch November 10, 2026 05:13
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