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.
- Question
Estimate - 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.
- Thread
- What a conversation has cost, as opposed to what one call costs.
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 inusageonce 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.
Nonewhen the API reported no counts, because a made-up number is worse than none. - rates_
from_ env - Rates from
JEV_PRICE;Nonewhen it is unset or malformed. - rates_
from_ str - Rates from a stored string;
Nonewhen it is empty or malformed. - rates_
value - The same pair as
JEV_PRICEtakes:0.20/1.00. - thread
- Estimate a call per turn, or
Nonewhen the state is not a conversation. - usd
- Dollars, with enough decimals to be readable at the size a single call costs.