Conversation
Perplexity bills Sonar a per-request fee that depends on the request's search context size (low $5, medium $8, high $12 per 1000 requests, https://docs.perplexity.ai/docs/getting-started/pricing). The catalog marked Sonar uncaptured_fees, so every Sonar call was a lower bound. - CatalogSnapshot.cost and price_deployment accept search_context_size. - New price rule search_context_fee_per_request adds the tier's fee when a valid size (low/medium/high) is supplied. A missing or invalid size is never inferred: the call stays partial with reason search_context_size_unknown. A tier absent from the table is partial with search_context_fee_unavailable. - The loader validates the rule's shape and values. - The OSS server forwards the row's search_context_size to pricing. - metergraph-core 0.2.24, catalog 2026-09-16. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
- LoadedCatalog.price accepts and forwards search_context_size, so the public wrapper can price the Sonar fee. - metergraph-server requires metergraph-core>=0.2.24: older core rejects the new keyword and would fail every ingest row. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Related PRs (MET-13)
Shared contract: native row field Linear: https://linear.app/metergraph/issue/MET-13/capture-sonar-search-context-fees-for-exact-pricing |
Codex review
Confirmed and fixed
Also fixed before the review (self-review, commit 5f68ddc): a tier missing from a fee table silently added no fee and still reported After the fixes: Rejected: none. |
Prove-it reportVerdictProven. With a size, a Sonar call is priced exactly (tokens plus the tier fee) through the real OSS server ingest into PostgreSQL. Without a valid size it stays partial and no tier is inferred. The same checks against
Evidence§1-3 E2E: OSS server ingest into PostgresCommand: Negative control: the same script with §4-7 Test suites
Negative control: head's Tests used
Not covered
|
|
[P2] The declared version is behind main. This PR bumps Three releases landed since this branch was cut — 0.2.26 (Gemini cache-read correction), 0.2.27 ( Two consequences:
Worth knowing while rebasing: 0.2.28 added an |
Summary
Part of MET-13 (exact Sonar pricing). Perplexity bills Sonar a per-request fee that depends on the search context size. Until now the catalog marked Sonar
uncaptured_fees, so every Sonar call was a partial, lower-bound price.CatalogSnapshot.cost(...)andprice_deployment(...)takesearch_context_size(low/medium/high, trimmed and case-folded).search_context_fee_per_request: {low, medium, high}(USD per request). With a valid size, the fee is added on top of token charges and the call ispriced.low). No fee is added and the call stayspartialwith reasonsearch_context_size_unknown. If the size is valid but that tier has no fee in the table, the call ispartialwithsearch_context_fee_unavailable.perplexity/sonaronperplexity-api:uncaptured_feesis replaced by{low: 0.005, medium: 0.008, high: 0.012}.project_rowpasses the row'ssearch_context_sizethrough to pricing. The schema is unchanged.metergraph-core0.2.24, catalog version 2026-09-16.docs/prices.mddocuments the rule and both reasons.Price source
https://docs.perplexity.ai/docs/getting-started/pricing, checked 2026-09-16. Under "Request Pricing by Search Context Size", per 1000 requests: Sonar $5 / $8 / $12 (Sonar Pro and Sonar Reasoning Pro $6 / $10 / $14, which are not in the catalog yet). The page lists Low as the default. Response
usage.search_context_sizereports the size that was applied, per https://docs.perplexity.ai/api-reference/chat-completions-post.The effective window of the existing Sonar entry is kept. Only its rule changes, because the token rates are the same.
How it was tested
New tests: one per tier (tokens plus fee,
priced, no reasons); missing or invalid size ispartial+search_context_size_unknown; case and whitespace normalization; fee is independent ofbatch; a model without the rule ignores the size;price_deploymentapplies the fee; a tier missing from the table ispartial, never free; loader rejects invalid rule shapes; server projection ispricedwith a size andpartialwithout.Acceptance criteria
partial/ lower bound, and no tier is inferredmetergraph-core0.2.24 (needed before the metergraph-internal PR can take the pin)Not done
web_search_options.search_type = pro) fees for Sonar Pro are not modelled.Related PRs (MET-13)
Listed on the Linear issue; see the cross-link comment below.
Linear: https://linear.app/metergraph/issue/MET-13/capture-sonar-search-context-fees-for-exact-pricing
🤖 Generated with Claude Code