Solving
Estimates and budgets
Count the solves and the calls of a request before you send it, give a request a budget, and look at a betting tree without a solve. All three are free.
In short
POST /v1/estimatescounts the solves and the calls of a request. It is free and solves nothing.max_creditsis the most calls a request may use. A request above it is refused before anything runs.POST /v1/treesshows the betting tree and the exits of a spot, without a solve.
Ask for an estimate
POST /v1/estimates takes the same body as POST /v1/solves for a spot and answers with the number of solves it needs and the calls they cost (credits). It solves nothing and costs nothing. It runs the checks of a solve: the field names, the limits, the size of the request, metadata, and ICM with a test key.
jq '. + {expand: [{lines: "all", cards: "distinct"}, {lines: "all", cards: "distinct"}]}' spot.json > big.json
curl -sS -X POST "$GECKO_API/v1/estimates" \
-H "Authorization: Bearer $GECKO_KEY" -H "Content-Type: application/json" \
-d @big.json
big = {**spot, "expand": [{"lines": "all", "cards": "distinct"}, {"lines": "all", "cards": "distinct"}]}
estimate = call("POST", "/v1/estimates", json=big, headers=AUTH) # an estimate: nothing is solved
print(estimate["solves"], estimate["credits"], estimate["credits_available"])
const big = { ...spot, expand: [{ lines: "all", cards: "distinct" }, { lines: "all", cards: "distinct" }] };
const estimate = await call("POST", "/v1/estimates", { body: big }); // an estimate: nothing is solved
console.log(estimate.solves, estimate.credits, estimate.credits_available);
The answer
{
"streets": {
"flop": {"solves": 1, "credits": 1},
"turn": {"solves": 180, "credits": 180},
"river": {"solves": 18577, "credits": 18577}
},
"solves": 18758,
"credits": 18758,
"exact": true,
"credits_available": 14547,
"price_at_lowest_pack_rate": 1875.8,
"currency": "usd"
}
How to read the numbers
- The numbers are an upper limit.
exactistruewhen the count follows from the betting tree alone, andfalsewithnode_actionsor ICM. A real solve leaves out lines that no hand reaches, so a request can need fewer solves than the estimate, never more. credits_availableis the calls you have left.price_at_lowest_pack_rateis the price of that many calls bought with pay per call, without a plan.- With
boardsthe answer adds"boards", the number of boards, and counts all of them. - An estimate takes a spot, with
boardorboards. It does not take aparentbody: the answer is422 invalid_request. - An estimate gives no time. See throughput.
Budgets: max_credits and allow_partial
The server makes the same estimate when you send a request, and checks it against two limits before anything runs.
max_creditswhole number, optional- The most calls this request may use. Without it, and above it, the account's limit for one request applies: 20,000 calls unless we changed it for you. A request whose estimate is above the budget is refused:
422 max_credits_exceeded, with the estimate in the answer. allow_partialboolean, optionaltrueorfalse; another value is refused.truestarts the request even when the estimate is above the budget or above your balance. It runs until the budget or your calls end. Thentree.statusis"stopped", the solves that did not start areskipped, and what is finished stays readable.
With a live key, a request whose estimate is above your balance is refused: 402 insufficient_credits, with the estimate and your balance (credits) in the answer. Nothing is charged for a refused request.
The refusal: 422 max_credits_exceeded
{
"type": "https://api.gtogecko.com/docs/errors#error-max_credits_exceeded",
"title": "Max credits exceeded",
"status": 422,
"code": "max_credits_exceeded",
"detail": "This request needs about 181 credits, above the limit of 100. Raise max_credits, name fewer lines or cards, or send allow_partial.",
"request_id": "req_c0dfe7b07251e03318f9",
"estimate": {"streets": {"flop": {"solves": 1, "credits": 1}, "turn": {"solves": 180, "credits": 180}}, "solves": 181, "credits": 181, "exact": true},
"max_credits": 100
}
See the betting tree before you solve
POST /v1/trees takes board, pot, stack and the betting fields, and answers with the betting tree of the street and its exits. No ranges, no solve, no charge.
Use it to find the lines for then and expand. It applies the same request checks as a solve.
curl -sS -X POST "$GECKO_API/v1/trees" \
-H "Authorization: Bearer $GECKO_KEY" -H "Content-Type: application/json" \
-d '{"board": ["As", "Ks", "7h"], "pot": 100, "stack": 300, "bet_sizes": [0.33], "raise_sizes": [1.0]}' \
| jq '{nodes: (.nodes | length), exits}'
The answer (part)
{
"nodes": [
{"node": "n0", "line": [], "kind": "decision", "pot": 100, "player": "oop", "to_call": 0,
"actions": [{"token": "c", "action": "check", "next": "n1"},
{"token": "b33", "action": "bet:33", "next": "n15"},
{"token": "b300", "action": "bet:300", "next": "n24"}]},
{"node": "n2", "line": ["c", "c"], "kind": "exit", "pot": 100, "stack": 300}
],
"exits": [
{"exit_id": "n2", "line": ["c", "c"], "pot": 100, "stack": 300}
],
"note": "Built by the same rules as the solver. Decisions with stated actions (node_actions) are not shown."
}
What the preview does not show
A node's kind is decision, fold, showdown or exit. The preview shows the whole tree of your sizes.
It does not show decisions changed with node_actions, and a real solve leaves out the lines that no hand reaches. What a request runs always follows the exits of the solved street.