Cost
How searchSDK reports what each call cost, where the figure comes from, and how retries and fallback stay visible.
Every response has a cost: usd, estimated, source and, for credit pricing, credits.
source | Meaning |
|---|---|
reported | The provider's response states the cost in USD |
reported-credits | The provider reports credits, converted at the list price per credit |
computed | Computed from the list price in the registry |
unknown | No public price; usd is null, never 0 |
none | Nothing was billed |
estimated is false only for an exact figure from the provider, or when nothing was sent. Provider options that change the price pick a price tier, or make a computed cost unknown when the registry cannot price them.
Every attempt
Each entry in attempts has its own cost and billed: yes when the provider answered with success, possible when the request may have reached it without an answer, no when nothing was sent or the provider answered with an error. Retries and fallback never hide spend.
import { search } from "@searchsdk/sdk";
const res = await search("sqlite wal mode", { provider: "exa" });
const billed = res.attempts.filter((a) => a.billed !== "no");
const known = billed.every((a) => a.cost.usd !== null);
const usd = billed.reduce((sum, a) => sum + (a.cost.usd ?? 0), 0);
console.log(known ? usd : "unknown");A failed call carries the same attempts on its SearchError.
Before a call
costBound gives the most one request can cost at the highest documented rate, such as overage or the top of a price range. Use it to hold a spend cap without guessing a margin. listPrice gives the computed price for a result count.
import { costBound, listPrice, registry } from "@searchsdk/sdk";
const bound = costBound(registry.exa, "search", { maxResults: 10, depth: "deep" });
console.log(bound.usd); // null when it cannot be bounded; see bound.unknownBecause
console.log(listPrice(registry.exa, "search", { count: 10 }).usd);A free allowance gives a bound with requiresOverageOff: true: it holds while paid use past the allowance stays off.
Prices come from each provider's page, with the date they were read.