Running it

Waiting for a result

A solve takes seconds, and the first one after a quiet period takes longer. This page shows the states of a solve and the two ways to wait for its end.

In short

  • POST /v1/solves answers 202 with a solve. It does not wait for the solver.
  • Send Prefer: wait=30 to hold the answer up to 30 seconds. Ask again while the status is pending, queued or running.
  • A solve is finished when its status is complete, failed, skipped or cancelled.
  • After a quiet period the first solve waits about 45 seconds for a solver to start. There are no webhooks: you wait in the request, or you ask again.

Life of a solve

A solve moves forward through these states and never back. The last four are final.

Every status: what it means, and whether it is final and charged
statusMeaningFinalCharged
pendingIt waits for a free solver, or for the solve of the street before it.NoNo
queuedIt is sent to the solver and waits for it to start.NoYes, when it is sent
runningThe solver works on it.NoYes
completeThe result is ready at result.YesYes
failedIt has no result. error says why.YesNo: the call is returned
skippedIt never started: the request reached its budget, a limit or the end of your calls first.YesNo
cancelledIt never started: you cancelled the request first.YesNo

The root of a request with many solves also has a tree block for the state of the whole request: see Requests with many solves.

Hold the answer: Prefer: wait=N

Send Prefer: wait=N on POST /v1/solves or on GET /v1/solves/{id}. The answer comes when the solve is finished, or about N seconds after the request arrived.

The most is 30. For a request with then, expand or boards, the root waits while tree.status is running.

When the wait ends first, you get the solve as it is then, with the status pending, queued or running. That is not an error: ask again. Set the time-out of your HTTP client above the wait: at least 35 seconds for wait=30.

Ask again

Call GET /v1/solves/{id} until the status is final. With Prefer: wait=30 on each call you need no pause between calls.

Without it, ask every 0.5 to 1 second: a plain GET /v1/solves/{id} answers within about 2 seconds, also for a request with hundreds of solves. The helpers wait_for and waitFor in the quick start do this, for one solve and for a whole request.

curl -sS "$GECKO_API/v1/solves/$FLOP" \
  -H "Authorization: Bearer $GECKO_KEY" -H "Prefer: wait=30" | jq '{status, queue, tree}'

Look it up

The queue

the place in line of a live solve

While a live solve waits or runs, GET /v1/solves/{id} shows where it stands.

{
  "id": "slv_00VcT0iMuhDqPySfwtq2K",
  "status": "pending",
  "queue": {"position": 3, "estimated_start_seconds": 8, "solver": "warm"}
}

position is the place in line: 1 is next, and 0 means the solve is at the solver. estimated_start_seconds is the expected time until the solver starts on it. solver is "warm" or "cold": a cold solver must start first.

Warm and cold solver

the first solve after a quiet period

Solver capacity starts on demand. A solver stays warm for 4 minutes after its last solve. After a quiet period, the first solve waits for a solver to start: typically about 45 seconds.

cold_start_seconds in GET /v1/health has the measured value. After that, solves start within seconds.

A cold start is not an error, and it is not charged extra. Allow about 90 seconds for a first solve after a quiet period.

GET /v1/health needs no key. Its pool block shows the state now and the typical time of a solve on each street.

curl -sS "$GECKO_API/v1/health"
The answer of GET /v1/health
{
  "status": "ok",
  // solver: its version, and what it supports (rake, tree options, locks, iterations, accuracy, ICM)
  "solver": {"model_id": "2bf1217b..."},
  "pool": {
    "state": "warm",
    "typical_seconds": {"flop": 4.0, "turn": 2.0, "river": 1.5},
    "cold_start_seconds": 45,
    "waiting": 0
  }
}

state is "warm" or "cold". typical_seconds is measured on recent solves. cold_start_seconds is the typical extra wait of a first solve.

waiting is the number of solves in line. When the solver cannot be reached, the status is "degraded" and the HTTP status is 503. We give no guarantee of speed or uptime: see the Terms.

Warm-up

POST /v1/warmup

POST /v1/warmup starts a solver before your first solve. Call it when you know that solves will follow, for example at the start of a batch job.

It is free. It starts a solver at most one time in 5 minutes for each account.

curl -sS -X POST "$GECKO_API/v1/warmup" -H "Authorization: Bearer $GECKO_KEY"
{"state": "warm"}
{"state": "warming", "ready_in_seconds": 45}

You do not have to wait for the warm-up: a solve sent while the solver starts waits in line and runs when it is ready. With a test key the answer is always {"state": "warm"}.

Fair order and throughput

how long many solves take

Capacity is shared between all accounts. Solves run in turn between accounts: two accounts with long lists take turns, and an account that arrives later does not wait behind the whole list of another.

Single solves and single lines run before large requests of other accounts. A large request is one with more than 10 solves, such as most expand requests.

An account runs one solve at a time unless we raised its limit. The other solves of a request wait as pending and are not charged while they wait.

So a request of N solves takes about N times the typical seconds in GET /v1/health: at 3 seconds a solve, 181 solves take about 9 minutes and 18,758 solves about 16 hours. Ask us for more solves at one time.

When a solve does not finish

  • A solve that fails is failed, with the reason in error. It is not charged: the call is returned.
  • When the solver cannot be reached, the solve is tried again a few times before it fails.
  • A solve that the solver does not finish in 30 minutes is given up: solver_timeout, the call is returned.