The POST /v1/estimate route prices a request on every model before it is sent, with no key needed, so a client can show the cost of a prompt up front; this page shows the request shape at https://api.uplinkswitch.com/v1, how input tokens are estimated when you do not pass a count, and how a key makes the estimate use your own locked prices. Nothing is sent to a model and nothing is charged, which is why the route is safe to call on every keystroke in a cost preview.
The smallest call
Give the route the text you plan to send and it returns the cost on every metered model, ordered cheapest first. You can describe the input three ways, in any combination: a prompt string, a system string, and a messages array shaped like the one you would send to the chat route.
curl https://api.uplinkswitch.com/v1/estimate \
-H "Content-Type: application/json" \
-d '{
"system": "You summarize support tickets in one line.",
"prompt": "Customer cannot reset their password after the latest release.",
"output_tokens": 200
}'output_tokens is how long you expect the answer to be; leave it off and the route assumes a default length of 1000. The response is an object whose data array holds one entry per model with its display_name, developer, the counted input_tokens and output_tokens, the cost_usd at this gateway's rate, the list_cost_usd at the developer's own price, and the saved_usd and saved_pct between them. A prices field says whether those are public rates or your organization's, and a basis field says how the input count was reached.
How input tokens are counted
If you do not already know your token count, the route estimates one for you: it treats roughly four characters as one token and adds a small per-message allowance for chat structure. That heuristic tends to run high on ordinary prose but is not a model-exact tokenizer, so dense text such as code or non-Latin scripts can count higher than it guesses; treat the quote as an estimate, not a to-the-token promise. The basis field in the response tells you which path was used.
When you do have an exact count, pass input_tokens and the route takes it as given instead of estimating from text. This is the accurate mode: run your real tokenizer once, send the number, and the input side of the quote uses exactly that number. Tokenizers differ between model families, so for a multi-model quote count with each family's tokenizer when precision matters; the output side still depends on how long the real answer runs.
curl https://api.uplinkswitch.com/v1/estimate \
-H "Content-Type: application/json" \
-d '{"input_tokens": 1800, "output_tokens": 400,
"models": ["gpt-6.1-sol", "claude-sonnet-5-5", "deepseek-v4.1-flash"]}'Narrowing to the models you care about
By default the answer covers every metered model, which is useful for a picker but noisy for a preview. Pass a models array of catalog ids and the route prices only those, keeping them in cheapest-first order. The ids in the call above, gpt-6.1-sol, claude-sonnet-5-5 and deepseek-v4.1-flash, give you one mid-range and two low-cost options to compare for the same prompt. On the 2026-11-24 catalog their availability reads ok, ok and ok, in that order. Use the exact ids from the catalog; unknown ids are simply left out of the answer.
Keyless in the browser, keyed for your rates
The route accepts a request from any origin with no key, so a web client can call it directly and show a live price as the user types, with no server in between and nothing billable happening. That is the public-price mode.
Send the request with your key instead and two things change: the quote uses your organization's own prices rather than the public ones, and it reflects any active price lock, so the number you preview is the number your account will actually pay. A cost preview inside your own app should run keyed for that reason, with the call made from your backend so the key never reaches a browser; a public pricing widget on a marketing page can stay keyless.
// Keyless preview from a browser; quote your own rates from your backend, never with a key in page code
const res = await fetch("https://api.uplinkswitch.com/v1/estimate", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
prompt: userText,
output_tokens: 300,
models: ["gpt-6.1-sol", "deepseek-v4.1-flash"],
}),
});
const { data } = await res.json();
const cheapest = data[0]; // already sorted cheapest firstPreview versus the real charge
The estimate is a forecast and the request record is the fact. Two gaps are worth knowing. First, output length: you tell the route how long you think the answer will be, but the real answer settles on the tokens the model actually produced, so a verbose reply costs more than a short-output estimate and a terse one costs less. Second, features that add tokens or fees, such as server-tool calls, are not part of a plain text estimate. For the settled truth after a call, read usage.cost in the response body or look the request up afterwards. The estimate's job is to get you the right model and a safe budget before you commit.
If you would rather not write code, the LLM cost calculator is the no-code sibling of this route: paste a prompt and an expected output length and it shows the same per-model comparison in the page. For the full current rate card, the price index lists every model, and the route itself is in the docs.