Skip to main content

Module cost

Module cost 

Source
Expand description

What a session costs: the tokens a request carries, the tokens its answers bring back, and the money that is at rates you supply.

Nothing here calls the API. Token counts are an estimate — roughly four characters to a token, JSON punctuation in pairs — so treat them as an order of magnitude, not an invoice. The answer side is not guesswork about length: a System One answer has the shape the question asks for, so the estimate prices the real shape, which is why a choice over eight labels costs more to answer than a noul.

Rates are yours to set, in dollars per million tokens, because the price of a model is not something an SDK should hardcode: :cost 0.20/1.00 in the REPL, or JEV_PRICE=0.20/1.00 in the environment.

Structs§

Cost
Dollars, split the way the rates are.
Estimate
The token side of a call: where they go, and how many there are.
QuestionEstimate
What one question adds to a request and to the answers.
Rates
Dollars per million tokens, one rate for what goes up and one for what comes back.

Constants§

PRICE_ENV
Environment variable holding <input>/<output> dollars per million tokens.

Functions§

estimate
Estimate one call: what the session sends, and what its answers come back as.
estimate_json_tokens
Tokens in a JSON value, as it goes on the wire.
estimate_tokens
Tokens in a piece of text, estimated: a run of letters is a token per four characters, digits run denser, a run of punctuation pairs up the way ":" and "}, do in a real vocabulary, and a CJK character is a token on its own. Whitespace rides along with the token beside it. No tokenizer is shipped or downloaded to do this; the API reports the real counts in usage once a call has been made.
format_rates
$0.20/$1.00 per Mtok.
parse_rates
0.20/1.00, 0.20 1.00, $0.20, $1.00 — input first, output second, per million tokens.
price
Price a pair of token counts.
price_estimate
Price an estimate.
price_usage
Price what a call actually used. None when the API reported no counts, because a made-up number is worse than none.
rates_from_env
Rates from JEV_PRICE; None when it is unset or malformed.
rates_from_str
Rates from a stored string; None when it is empty or malformed.
rates_value
The same pair as JEV_PRICE takes: 0.20/1.00.
usd
Dollars, with enough decimals to be readable at the size a single call costs.