← All guides
On this page
Tutorial GTO strategy · 02/06 Trainer 18 min Intermediate

Part 1: Your first strategy call

Build the core of a GTO poker trainer from a controlled training scenario or a completed hand — the same kind of strategy layer that powers Counterplay. This part makes a real preflop strategy call, reads its verifiable mixed frequencies, and grades a decision after review.

Updated Maintained by Pokerai API

1 · First call 2 · The range grid 3 · Postflop tree 4 · Turn/river solving

What you'll need

A free API key (grab one here) and curl or Python 3. Set your key as an env var:

export POKERAI_API_KEY="gto_your_key_here"

Step 1 · Your first call

Ask for the GTO strategy when Hero holds A♥K♥ in MP and UTG has raised:

curl https://pokerai.bet/v1/gto/preflop \
  -H "authorization: Bearer $POKERAI_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "hole_cards": "AhKh",
    "positions": { "hero": "MP" },
    "preflop_actions": [
      { "position": "SB", "action": "small blind", "amount": 0.5 },
      { "position": "BB", "action": "big blind", "amount": 1 },
      { "position": "UTG", "action": "raise", "amount": 3 }
    ]
  }'

Response:

{
  "hole_cards": "AhKh",
  "situation": "Raise",
  "strategy": [
    { "action": "raise", "frequency": 1, "amount_bb": 9, "sizing_pot": 0.8 }
  ]
}

AKs facing a UTG open is a pure 3-bet: raise 100% of the time, to 9bb. situation is derived from the actions you sent (here, facing one raise = "Raise").

Step 2 · Read the frequencies

The key idea: the API returns a mixed strategy — the GTO frequency of each action — not a single "recommended" move. Most hands are pure (one action at 100%), but many are mixed. For example, UTG opening A2s:

{ "action": "raise", "frequency": 0.296 }   # raise 29.6% of the time
{ "action": "fold",  "frequency": 0.704 }   # fold 70.4% of the time
Both raising and folding A2s here are GTO-correct. A player who always folds it, or always raises it, isn't "wrong" on any single hand — but over many hands they deviate from the equilibrium mix. That's exactly what a trainer measures.

Step 3 · In code

A tiny typed client — the same shape Counterplay uses (app/gto/client.py):

import os, httpx

class Pokerai:
    def __init__(self):
        self.h = {"Authorization": f"Bearer {os.environ['POKERAI_API_KEY']}"}
        self.c = httpx.Client(base_url="https://pokerai.bet", timeout=15)

    def preflop(self, hole_cards, hero, actions):
        r = self.c.post("/v1/gto/preflop", headers=self.h, json={
            "hole_cards": hole_cards,
            "positions": {"hero": hero},
            "preflop_actions": actions,
        })
        r.raise_for_status()
        return {s["action"]: s["frequency"] for s in r.json()["strategy"]}

gto = Pokerai()
strat = gto.preflop("AhKh", "MP", [{"position":"UTG","action":"raise","amount":3}])
print(strat)   # {'raise': 1.0}

Step 4 · Grade a decision

This is the trainer's heart. Grade Hero's action by the GTO frequency of the action they chose — not by how far it is from the most-frequent action. A 14%-frequency raise is a fine mixed play, not a mistake:

def grade(chosen_action, strategy):
    freq = strategy.get(chosen_action, 0.0)
    if freq >= 0.10: return "ok"        # a real part of the GTO mix
    if freq >= 0.005: return "minor"    # rare, but not a blunder
    return "major"                       # ~never played → a real leak

grade("raise", {"raise": 0.296, "fold": 0.704})   # "ok"  (A2s raise)
grade("raise", {"fold": 1.0})                     # "major" (raising 32o UTG)
This is exactly how Counterplay grades — severity comes from the chosen action's own frequency, so low-frequency mixed actions aren't punished. (See the case study.)

What you built

A working strategy layer: fetch GTO frequencies for a documented training spot, and grade a player's completed decision against the equilibrium. Pokerai API supplies the deterministic strategy facts; any coach or LLM can explain those returned frequencies, but does not replace the solver. That loop — spot → strategy → grade — is the whole trainer, one street at a time.

Acceptable use

Accept inputs only from controlled training scenarios or hands that have already ended. Keep high-impact grading, coaching, or product output reviewable by a human. Pokerai API is for training, coaching, hand review, study, and research. Real-time assistance at real-money tables is prohibited.

Next — Part 2: the 13×13 range grid

Fetch a whole range in one call and render it, like the range pages. Coming soon.

Related resources