Running it

Going to production

What a client needs before it runs without you: time-outs, retry rules, safe repeats, the numbers to watch and a checklist.

In short

  • Set the time-out of your client to at least 35 seconds when you send Prefer: wait=30.
  • Retry only 429, 503 and lost answers. Do not send a 500 or another 4xx again unchanged.
  • Send an Idempotency-Key with every POST /v1/solves. A repeat is then not charged.
  • Keep keys on your server, and log the Request-Id of every answer.

Time-outs

  • Set the time-out of your HTTP client to at least 35 seconds when you send Prefer: wait=30. Many clients stop at 30 seconds by default.
  • Allow about 90 seconds in total for a first solve after a quiet period: the solver must start.
  • A large request can run for hours. Put a limit of your own on how long you wait, and cancel what you no longer need.

Retry rules

AnswerWhat to do
429Wait the seconds in Retry-After, then send the same request.
503, or no answer (a network error or a time-out)Send it again after 1, 2, 4 and 8 seconds: at most 5 tries. Use Retry-After when the answer has it; a 503 also has the seconds as retry_after in its body.
409 request_in_progressWait the seconds in Retry-After, then send the same request.
500Do not send it again unchanged. Contact us with the request id.
Any other 4xxDo not send it again unchanged. Change the request, the key or the account first.

What is safe to repeat

  • Every GET is safe to repeat. So are POST /v1/estimates, POST /v1/trees, POST /v1/warmup and POST /v1/solves/{id}/cancel.
  • POST /v1/solves is safe to repeat only with an Idempotency-Key. Without one, each send is a new request and is charged.
How an Idempotency-Key works, and what it remembers

An Idempotency-Key is 8 to 128 characters that you choose, such as a UUID. It is remembered for 24 hours, for one account and one mode (test and live are apart). A repeat with the same body gets the first answer again and charges nothing more.

A repeat with another body is 409 idempotency_conflict. A repeat that arrives while the first is still being created is 409 request_in_progress.

A refusal is remembered only when it made a solve record: such a refusal has a solve_id in its body, and a repeat gets the same refusal again. A request that a check refused made nothing: a 422 for a field or a limit, or a 402 for an estimate above your balance.

Its key is free, and the same key with a corrected body is accepted. See refusals that leave a record.

# the second send gets the first solve again and is not charged
IDEM=$(uuidgen)
for attempt in 1 2; do
  curl -sS -X POST "$GECKO_API/v1/solves" \
    -H "Authorization: Bearer $GECKO_KEY" -H "Content-Type: application/json" \
    -H "Idempotency-Key: $IDEM" -H "Prefer: wait=30" \
    -d @spot.json | jq -r .id
done

Look it up

Go-live checklist

eleven points to check
  1. Your flow runs from start to end with a test key, with your own spots.
  2. Your account has calls or a plan (see Go live).
  3. The live key is in a secret store on your server. It has a daily limit.
  4. The client time-out is at least 35 seconds. The first solve after a quiet period is allowed about 90 seconds.
  5. You retry only 429, 503 and lost answers, with the waits above.
  6. POST /v1/solves carries an Idempotency-Key wherever your code can send it two times.
  7. Large requests carry max_credits, and you ask for an estimate first.
  8. Your reading code accepts a missing hand, a missing node and a missing exit.
  9. You store the results you need within 6 days, with the solve id and the model_id.
  10. You log the Request-Id of every answer.
  11. Your use fits the fair use rules: no help to a player during a hand.

Rate limits

120 requests a minute for a key

Each key may send 120 requests a minute. Every answer to a call that reached the check of the key has RateLimit-Limit (the limit) and RateLimit-Remaining (what is left now). The headers are not on the open routes (/v1/health, /v1/hands, /v1/pricing), on a 401, on a 404 for a route that does not exist, on a 405, on a 413, or on a body that is not JSON.

The count fills again evenly: two a second at 120 a minute. Above the limit the answer is 429 rate_limited with Retry-After. A wait with Prefer: wait=30 is one request, so waiting this way stays far below the limit.

curl -sS -D - -o /dev/null "$GECKO_API/v1/account" -H "Authorization: Bearer $GECKO_KEY" \
  | grep -i -E "ratelimit|request-id"

Request ids

Every answer has a Request-Id header, and every error has the same id as request_id in its body. Write it to your log with the solve id. When you ask us about a request, send the request id.

No webhooks

The API does not call you back. To know when a solve or a request is finished, wait with Prefer: wait or ask again: see Waiting for a result. There is no client library: the API is plain HTTP with JSON.

Throughput

one solve at a time

By default an account has one solve at the solver at a time, and capacity is shared between accounts. A request of N solves takes about N times the typical seconds in GET /v1/health, and longer when others wait too.

Sending more requests at the same time does not make it faster: they wait in the same line. Ask us for more solves at one time.

Keys

Keep keys on your server, use one key for each service, and rotate a key without a gap: see keep and rotate keys.