# AnonGTO Solver API (v1)

Base URL: `https://api.anongto.com`. JSON in and out. Amounts in big blinds.
OpenAPI 3.1: https://anongto.com/api/openapi.json · Human docs: https://anongto.com/api/docs/ · Latency visualizer: https://anongto.com/api/latency/ · Free key: https://anongto.com/api/#get-key · Plans: https://anongto.com/api/pricing/

`POST /v1/solve` is stateless: send your game state at every decision and get back the GTO strategy, EV, per-seat `input_ranges` provenance, and `timing.warm_ids` for the player to act. There is no `mode` field — the request shape chooses the path automatically:

1. **Hand from preflop (`table` + `streets`)**: describe the table (shorthand or longhand) and every action since the deal.
2. **Custom postflop ranges (`board` + `pot_bb` + `players`)**: send two or three ranges, the pot, the stacks, and optional `sizing` for one postflop street.

Whenever the table state changes and it is not your turn yet (including closed streets during deal animations and 3-way pots), fire-and-forget `POST /v1/warm` with `{ table, streets }` (free of solve quota; returns `202 Accepted`). When action reaches you, `POST /v1/solve` hits the warm cache and returns `timing.solve_ms: 0` with the matching `slv_...` ID in `input_ranges[seat].warm_id` and `timing.warm_ids`.

Requests are strict: every action is a typed object (`{"type": "bet", "to_bb": 2.5}`, never `"bet 2.5"`), every preflop action is listed in order (folds included), unknown fields anywhere are refused (`400 unknown_field`), and every error names its field in `error.path` (a JSON Pointer).

The API is for study and analysis tools, not for use during play.

## Quick start

```bash
curl https://api.anongto.com/v1/solve \
  -H "Authorization: Bearer YOUR_KEY" \
  -H "content-type: application/json" \
  -d '{"table":{"seats":6,"stack_bb":100,"rake":{"pct":5,"cap_bb":0.6}},
       "streets":{"preflop":[{"seat":"UTG","type":"fold"},{"seat":"HJ","type":"fold"},{"seat":"CO","type":"fold"},
                            {"seat":"BTN","type":"raise","to_bb":2.5},{"seat":"SB","type":"fold"},{"seat":"BB","type":"call"}],
                  "flop":{"cards":["Jh","9s","4d"],"actions":[{"type":"check"}]}}}'
```

---

## Walkthrough: Common Spots

### Preflop (Regular vs With Ante)

Toggling `"ante_bb": 0.17` on `table` widens opening and defending frequencies automatically:

- **1. First to act (UTG open, `preflop: []`)**
  - Regular (`pot_bb: 1.5`): `fold` 82.5%, `raise 2.5` 17.5% (`ev_bb: 0.57`)
  - With Ante (`ante_bb: 0.17`, `pot_bb: 2.5`): `fold` 76.9%, `raise 2.5` 23.1% (`ev_bb: 0.87`)
- **2. Folded to us (BTN open after explicit folds)**
  - Regular: `fold` 56.5%, `raise 2.5` 43.5% (`ev_bb: 0.57`)
  - With Ante: `fold` 46.9%, `raise 2.5` 53.1% (`ev_bb: 0.85`)
- **3. Facing a 3-bet (BTN vs BB 3-bet to 13 bb, `include: { "hole_cards": ["Ah", "Qh"] }`)**
  ```json
{
  "table": {
    "seats": 6,
    "stack_bb": 100,
    "rake": {
      "pct": 5,
      "cap_bb": 0.6
    }
  },
  "streets": {
    "preflop": [
      {
        "seat": "UTG",
        "type": "fold"
      },
      {
        "seat": "HJ",
        "type": "fold"
      },
      {
        "seat": "CO",
        "type": "fold"
      },
      {
        "seat": "BTN",
        "type": "raise",
        "to_bb": 2.5
      },
      {
        "seat": "SB",
        "type": "fold"
      },
      {
        "seat": "BB",
        "type": "raise",
        "to_bb": 13
      }
    ]
  },
  "include": {
    "hole_cards": [
      "Ah",
      "Qh"
    ]
  }
}
```
  Live response (Regular):
  ```json
{
  "id": "slv_ef48e80206d84b03874a",
  "street": "preflop",
  "board": [],
  "to_act": "BTN",
  "pot_bb": 16,
  "to_call_bb": 10.5,
  "ev_bb": 1.47,
  "actions": [
    {
      "label": "fold",
      "type": "fold",
      "frequency": 0.6334,
      "ev_bb": 0
    },
    {
      "label": "call",
      "type": "call",
      "frequency": 0.2574,
      "ev_bb": 1.98
    },
    {
      "label": "raise 27",
      "type": "raise",
      "to_bb": 27,
      "frequency": 0.0812,
      "ev_bb": 9.92
    },
    {
      "label": "allin 100",
      "type": "all_in",
      "to_bb": 100,
      "frequency": 0.028,
      "ev_bb": 5.67
    }
  ],
  "hole_cards": {
    "cards": [
      "Ah",
      "Qh"
    ],
    "combo": "AhQh",
    "class": "AQs",
    "seat": "BTN",
    "granularity": "class",
    "in_range": true,
    "weight": 1,
    "ev_bb": 4.92,
    "actions": [
      {
        "label": "fold",
        "type": "fold",
        "frequency": 0,
        "ev_bb": 0
      },
      {
        "label": "call",
        "type": "call",
        "frequency": 0.845,
        "ev_bb": 4.92
      },
      {
        "label": "raise 27",
        "type": "raise",
        "to_bb": 27,
        "frequency": 0.155,
        "ev_bb": 4.92
      },
      {
        "label": "allin 100",
        "type": "all_in",
        "to_bb": 100,
        "frequency": 0,
        "ev_bb": 4.28
      }
    ]
  },
  "quota": {
    "used": 60,
    "limit": 1000
  },
  "timing": {
    "server_ms": 4,
    "solve_ms": 0,
    "warm_ids": [],
    "server": "finland"
  }
}
```

### Postflop (Stateless `{ table, streets }`, `POST /v1/warm`, `sizing`, `include` & Custom Ranges)

- **4. Pre-warm on flop deal, then instant cached solve (BTN after BB checks on `Th 6s 2d`)**
  1) Fire-and-forget `POST /v1/warm` (`actions: []`) → `202 Accepted`:
  ```json
{
  "table": {
    "seats": 6,
    "stack_bb": 100,
    "rake": {
      "pct": 5,
      "cap_bb": 0.6
    }
  },
  "streets": {
    "preflop": [
      {
        "seat": "UTG",
        "type": "fold"
      },
      {
        "seat": "HJ",
        "type": "fold"
      },
      {
        "seat": "CO",
        "type": "fold"
      },
      {
        "seat": "BTN",
        "type": "raise",
        "to_bb": 2.5
      },
      {
        "seat": "SB",
        "type": "fold"
      },
      {
        "seat": "BB",
        "type": "call"
      }
    ],
    "flop": {
      "cards": [
        "Th",
        "6s",
        "2d"
      ],
      "actions": []
    }
  }
}
```
  ```json
{
  "id": "slv_4c4370a55935439e80ce",
  "status": "warming"
}
```
  2) When BB checks, `POST /v1/solve` (`actions: [{"type": "check"}]`) → `200 OK` with `timing.solve_ms: 0`, `input_ranges[seat].warmed: true`, and the matching warm ID in `timing.warm_ids`:
  ```json
{
  "table": {
    "seats": 6,
    "stack_bb": 100,
    "rake": {
      "pct": 5,
      "cap_bb": 0.6
    }
  },
  "streets": {
    "preflop": [
      {
        "seat": "UTG",
        "type": "fold"
      },
      {
        "seat": "HJ",
        "type": "fold"
      },
      {
        "seat": "CO",
        "type": "fold"
      },
      {
        "seat": "BTN",
        "type": "raise",
        "to_bb": 2.5
      },
      {
        "seat": "SB",
        "type": "fold"
      },
      {
        "seat": "BB",
        "type": "call"
      }
    ],
    "flop": {
      "cards": [
        "Th",
        "6s",
        "2d"
      ],
      "actions": [
        {
          "type": "check"
        }
      ]
    }
  }
}
```
  ```json
{
  "id": "slv_e62229b79c744f1db5eb",
  "positions": {
    "oop": "BB",
    "ip": "BTN"
  },
  "street": "flop",
  "board": [
    "Th",
    "6s",
    "2d"
  ],
  "to_act": "BTN",
  "pot_bb": 5.5,
  "to_call_bb": 0,
  "ev_bb": 3.23,
  "actions": [
    {
      "label": "check",
      "type": "check",
      "frequency": 0.2607,
      "ev_bb": 2.45
    },
    {
      "label": "bet 1.64",
      "type": "bet",
      "to_bb": 1.64,
      "frequency": 0.0808,
      "ev_bb": 3.23
    },
    {
      "label": "bet 2.61",
      "type": "bet",
      "to_bb": 2.61,
      "frequency": 0.2611,
      "ev_bb": 3.36
    },
    {
      "label": "bet 5.13",
      "type": "bet",
      "to_bb": 5.13,
      "frequency": 0.3974,
      "ev_bb": 3.65
    },
    {
      "label": "allin 97.5",
      "type": "all_in",
      "to_bb": 97.5,
      "frequency": 0,
      "ev_bb": null
    }
  ],
  "input_ranges": {
    "BB": {
      "source": "preflop",
      "warmed": true,
      "warm_id": "slv_4c4370a55935439e80ce"
    },
    "BTN": {
      "source": "preflop",
      "warmed": true,
      "warm_id": "slv_4c4370a55935439e80ce"
    }
  },
  "quota": {
    "used": 85,
    "limit": 1000
  },
  "timing": {
    "server_ms": 10,
    "solve_ms": 0,
    "warm_ids": [
      "slv_4c4370a55935439e80ce"
    ],
    "server": "finland"
  }
}
```
  Interactive latency visualizer: https://anongto.com/api/latency/
- **5. Flop, facing a c-bet (stateless `{ table, streets }` + `include: { "hand_classes": true }`)**:
  ```json
{
  "table": {
    "seats": 6,
    "stack_bb": 100,
    "rake": {
      "pct": 5,
      "cap_bb": 0.6
    }
  },
  "streets": {
    "preflop": [
      {
        "seat": "UTG",
        "type": "fold"
      },
      {
        "seat": "HJ",
        "type": "fold"
      },
      {
        "seat": "CO",
        "type": "fold"
      },
      {
        "seat": "BTN",
        "type": "raise",
        "to_bb": 2.5
      },
      {
        "seat": "SB",
        "type": "fold"
      },
      {
        "seat": "BB",
        "type": "call"
      }
    ],
    "flop": {
      "cards": [
        "Jh",
        "9s",
        "4d"
      ],
      "actions": [
        {
          "type": "check"
        },
        {
          "type": "bet",
          "to_bb": 1.82
        }
      ]
    }
  },
  "include": {
    "hand_classes": true
  }
}
```
- **6. Turn, facing a check-raise (stateless `{ table, streets }` + `include: { "hole_cards": ["Ah", "Jc"] }`)**:
  ```json
{
  "table": {
    "seats": 6,
    "stack_bb": 100,
    "rake": {
      "pct": 5,
      "cap_bb": 0.6
    }
  },
  "streets": {
    "preflop": [
      {
        "seat": "UTG",
        "type": "fold"
      },
      {
        "seat": "HJ",
        "type": "fold"
      },
      {
        "seat": "CO",
        "type": "fold"
      },
      {
        "seat": "BTN",
        "type": "raise",
        "to_bb": 2.5
      },
      {
        "seat": "SB",
        "type": "fold"
      },
      {
        "seat": "BB",
        "type": "call"
      }
    ],
    "flop": {
      "cards": [
        "Jh",
        "9s",
        "4d"
      ],
      "actions": [
        {
          "type": "check"
        },
        {
          "type": "bet",
          "to_bb": 1.82
        },
        {
          "type": "call"
        }
      ]
    },
    "turn": {
      "card": "2c",
      "actions": [
        {
          "type": "check"
        },
        {
          "type": "bet",
          "to_bb": 6.86
        },
        {
          "type": "raise",
          "to_bb": 20.5
        }
      ]
    }
  },
  "sizing": "auto_simplified",
  "include": {
    "hole_cards": [
      "Ah",
      "Jc"
    ]
  }
}
```
- **7. River, checked down as OOP (stateless `{ table, streets }` + custom `sizing` + `include: { "combos": true }`)**:
  ```json
{
  "table": {
    "seats": 6,
    "stack_bb": 100,
    "rake": {
      "pct": 5,
      "cap_bb": 0.6
    }
  },
  "streets": {
    "preflop": [
      {
        "seat": "UTG",
        "type": "fold"
      },
      {
        "seat": "HJ",
        "type": "fold"
      },
      {
        "seat": "CO",
        "type": "fold"
      },
      {
        "seat": "BTN",
        "type": "raise",
        "to_bb": 2.5
      },
      {
        "seat": "SB",
        "type": "fold"
      },
      {
        "seat": "BB",
        "type": "call"
      }
    ],
    "flop": {
      "cards": [
        "Jh",
        "9s",
        "4d"
      ],
      "actions": [
        {
          "type": "check"
        },
        {
          "type": "check"
        }
      ]
    },
    "turn": {
      "card": "2c",
      "actions": [
        {
          "type": "check"
        },
        {
          "type": "check"
        }
      ]
    },
    "river": {
      "card": "7h",
      "actions": []
    }
  },
  "sizing": {
    "bet": [
      {
        "pct": 33
      },
      {
        "pct": 75
      }
    ],
    "raise": [
      {
        "pct": 60
      }
    ]
  },
  "include": {
    "combos": true
  }
}
```
- **8. Custom postflop ranges (`board` + `pot_bb` + `players` + custom `sizing` + `include.hole_cards`)**:
  ```json
{
  "board": [
    "Jh",
    "9s",
    "4d",
    "2c"
  ],
  "pot_bb": 10.5,
  "players": [
    {
      "seat": "BB",
      "stack_bb": 94.5,
      "range": {
        "text": "22-TT, A2s-AJs, K8s+, Q9s+, J9s+, T8s+, 98s, 87s, ATo-AQo, KJo+, QJo"
      }
    },
    {
      "seat": "BTN",
      "stack_bb": 94.5,
      "range": {
        "text": "22+, A2s+, K5s+, Q8s+, J8s+, T8s+, 97s+, 87s, 76s, A8o+, KTo+, QTo+, JTo"
      }
    }
  ],
  "actions": [
    {
      "type": "check"
    },
    {
      "type": "bet",
      "to_bb": 5.25
    }
  ],
  "sizing": {
    "bet": [
      {
        "pct": 50
      },
      {
        "pct": 100
      }
    ],
    "raise": [
      {
        "pct": 60
      }
    ]
  },
  "rake": {
    "pct": 5,
    "cap_bb": 0.6
  },
  "include": {
    "hole_cards": [
      "Qd",
      "Td"
    ]
  }
}
```

---

## API Reference

### Authentication

Every solve needs an API key (`agto_…`): get a free key at https://anongto.com/api/#get-key or pick a plan at https://anongto.com/api/pricing/.
Send `Authorization: Bearer YOUR_KEY` (or `X-API-Key: YOUR_KEY`). Keep the key on your server.
We store only a SHA-256 fingerprint of each key; `POST /v1/account/rotate` issues a replacement immediately while keeping the previous key valid for 24 hours.

### POST /v1/solve — Two Request Shapes

#### 1. Hand from preflop (`table` + `streets`)

| Field | Type | Meaning |
|---|---|---|
| `table` | object | Required. Shorthand: `{"seats": 6, "stack_bb": 100, "stacks_bb"?: {"BTN": 80}, "rake": {"pct": 5, "cap_bb": 0.6} \| null, "ante_bb"?: 0, "straddle"?: false}`. Longhand: `{"max_seats": 6, "seats": [{"seat": "UTG", "stack_bb": 100}, ...], "rake": ..., "ante_bb"?: 0, "straddle"?: false}`. |
| `streets.preflop` | array | Required (`[]` = first decision). Every action in preflop order, folds included: `{"seat": "BTN", "type": "fold" \| "check" \| "call" \| "raise" \| "all_in", "to_bb"?: number}` (`to_bb` required on `raise` only). |
| `streets.flop` | object | Optional: `{"cards": [3 cards], "actions": [...]}`. |
| `streets.turn`, `streets.river` | object | Optional (each needs the prior street closed): `{"card": "2c", "actions": [...]}`. |
| `sizing` | string or object | Optional (preflop & postflop): `"auto_simplified"` (default), `"auto_mixed"` (2-player postflop), or custom `{"bet"?: [...], "raise"?: [...], "call"?: boolean, "all_in"?: boolean}`. |
| `include` | object | Optional: `{"hand_classes"?: boolean, "combos"?: boolean, "hole_cards"?: ["Ah", "Kh"]}`. |

Request:
```json
{
  "table": {
    "seats": 6,
    "stack_bb": 100,
    "rake": {"pct": 5, "cap_bb": 0.6}
  },
  "streets": {
    "preflop": [{"seat": "UTG", "type": "fold"}, {"seat": "HJ", "type": "fold"}, {"seat": "CO", "type": "fold"},
                {"seat": "BTN", "type": "raise", "to_bb": 2.5}, {"seat": "SB", "type": "fold"}, {"seat": "BB", "type": "call"}],
    "flop": {"cards": ["Jh", "9s", "4d"], "actions": []}
  }
}
```

Response:
```json
{
  "id": "slv_7a70b32058654aafbf92",
  "positions": { "oop": "BB", "ip": "BTN" },
  "street": "flop",
  "board": ["Jh", "9s", "4d"],
  "to_act": "BB",
  "pot_bb": 5.5,
  "to_call_bb": 0,
  "ev_bb": 1.85,
  "actions": [
    { "label": "check",      "type": "check",                  "frequency": 0.9466, "ev_bb": 1.82 },
    { "label": "bet 1.83",   "type": "bet",    "to_bb": 1.83,  "frequency": 0.0534, "ev_bb": 2.47 },
    { "label": "allin 97.5", "type": "all_in", "to_bb": 97.5,  "frequency": 0,      "ev_bb": null }
  ],
  "input_ranges": {
    "BB":  { "source": "preflop", "warmed": false, "warm_id": null },
    "BTN": { "source": "preflop", "warmed": false, "warm_id": null }
  },
  "quota": { "used": 74, "limit": 1000 },
  "timing": { "server_ms": 7, "solve_ms": 0, "warm_ids": [], "server": "finland" }
}
```

#### 2. Custom postflop ranges (`board` + `pot_bb` + `players`)

| Field | Type | Meaning |
|---|---|---|
| `board` | array | 3–5 distinct cards; street is inferred from length. |
| `pot_bb` | number | Pot at the start of this street, in bb. |
| `players` | array | 2 or 3 players in postflop acting order: `{"seat": "BB", "stack_bb": 94.5, "range": {"text": "…"} \| {"weights": [1326 numbers 0..1]}}`. |
| `actions` | array | Optional actions on this street so far (default `[]`, up to 12). |
| `sizing` | string or object | Optional: `"auto_simplified"` (default), `"auto_mixed"` (2 players only), or custom `{"bet", "raise"}`. |
| `rake` | object or null | Optional `{"pct": 5, "cap_bb": 3}` (default `null`). |
| `include` | object | Optional `{"hand_classes"?: boolean, "combos"?: boolean, "hole_cards"?: ["Ah", "Kh"]}`. |

```json
{
  "board": ["Jh", "9s", "4d", "2c"],
  "pot_bb": 10.5,
  "players": [
    {"seat": "BB",  "stack_bb": 94.5, "range": {"text": "AA,KK,AKs:0.5"}},
    {"seat": "BTN", "stack_bb": 94.5, "range": {"weights": [0, 0, 0.5, 1, …]}}
  ],
  "actions": [{"type": "check"}, {"type": "bet", "to_bb": 3.5}],
  "sizing": {"bet": [{"pct": 33}, {"pct": 75}], "raise": [{"pct": 60}]},
  "rake": {"pct": 5, "cap_bb": 3},
  "include": { "combos": true }
}
```

Three players (prototype): send 3 entries in `players` in postflop order (`sizing: "auto_simplified"` or custom `{"bet", "raise"}`; per-action `ev_bb` is `null`).
```bash
curl https://api.anongto.com/v1/solve \
  -H "Authorization: Bearer YOUR_KEY" \
  -H "content-type: application/json" \
  -d '{"board":["Jh","9s","4d"],"pot_bb":9,
       "players":[{"seat":"SB","stack_bb":97,"range":{"text":"22+, A2s+, K9s+, ATo+"}},
                  {"seat":"BB","stack_bb":97,"range":{"text":"22+, A2s+, K2s+, A2o+, K9o+"}},
                  {"seat":"BTN","stack_bb":97,"range":{"text":"22+, A2s+, K5s+, A7o+, KTo+"}}],
       "actions":[{"type":"check"}]}'
```

### POST /v1/warm

Pre-warm postflop streets and range transitions in the background so your next `POST /v1/solve` returns immediately with `timing.solve_ms: 0` and the matching warm ID in `input_ranges[seat].warm_id` and `timing.warm_ids`.

- **Simple client rule:** whenever the table state changes and it is not your turn yet — including closed streets during deal animations and 3-way spots (warmed via `MW3_MEMO`) — fire-and-forget `POST /v1/warm` with `{ table, streets }` (do not wait for it).
- **Same request body & validation as `POST /v1/solve`:** accepts `table + streets` or `board + pot_bb + players` and validates synchronously (`400` / `422` on invalid bodies).
- **Free of solve quota:** requires remaining daily solve quota `> 0`, capped at `max(20, 4 × solves_used_today)` uncached warms per day (cache hits and dedup joins are unlimited). Uses a separate `2× per_min` rate limit so warms never rate-limit `POST /v1/solve`.
- **`202 Accepted` responses:**
  - `{"status": "warming", "id": "slv_..."}` — background solve queued on the lowest-priority warm lane (2-way or 3-way).
  - `{"status": "ready"}` — already cached (including closed-street range transitions or instant on-chart preflop), zero work needed.
  - `{"status": "skipped", "reason": "quota" | "warm_cap" | "busy"}` — skipped without error (daily solve quota empty, uncached warm cap reached, or warm lane busy).

```bash
curl https://api.anongto.com/v1/warm \
  -H "Authorization: Bearer YOUR_KEY" \
  -H "content-type: application/json" \
  -d '{"table":{"seats":6,"stack_bb":100,"rake":{"pct":5,"cap_bb":0.6}},
       "streets":{"preflop":[{"seat":"UTG","type":"fold"},{"seat":"HJ","type":"fold"},{"seat":"CO","type":"fold"},
                            {"seat":"BTN","type":"raise","to_bb":2.5},{"seat":"SB","type":"fold"},{"seat":"BB","type":"call"}],
                  "flop":{"cards":["Th","6s","2d"],"actions":[]}}}'

# HTTP/1.1 202 Accepted
# {"id":"slv_4c4370a55935439e80ce","status":"warming"}
```

### GET /v1/solves/{id}/trace

Inspect the full hand trace for any `POST /v1/solve` response ID (`slv_...`). You can also paste any `slv_...` ID into the interactive Table-First Hand Trace Inspector at https://anongto.com/api/latency/ to step through every node on a poker table.

- **24-hour TTL & caller-scoped:** traces are retained for 24 hours and only readable by the API key that created the solve. Unknown, expired, or other-key IDs return `404 not_found` at `/id`.
- **Free of solve quota:** never consumes daily solve quota (rate-limited at 120 req/min).
- **Response shape:** `id`, `created_at`, `mode` (`"hand" | "ranges"`), `street`, `board`, `positions`, `players`, `to_act`, `pot_bb`, `to_call_bb`, `ev_bb`, `request` (the solved `HandSolve` or `RangesSolve` payload), `actions[]` (`{ label, type, to_bb?, frequency, ev_bb }`), optional `hole_cards`, `nodes[]` (chronological transitions `{ index, street, board, pot_bb, to_act, closed_street, trigger, is_target, our_solve?, warm: { sent, id, status, reason?, request?, response? }, solve?: { step_status, ms, warm_id } }`), optional postflop `input_ranges`, `steps[]` (each `{ street, board?, status: "instant" | "warmed" | "cached" | "solved", ms, warm_id, actions_count }`), and `timing`.

```bash
curl https://api.anongto.com/v1/solves/slv_dced614b1e934b91ba00/trace \
  -H "Authorization: Bearer YOUR_KEY"

# HTTP/1.1 200 OK
{
  "id": "slv_dced614b1e934b91ba00",
  "created_at": "2026-11-28T12:04:19.104Z",
  "mode": "hand",
  "street": "flop",
  "board": ["Th", "6s", "2d"],
  "positions": { "oop": "BB", "ip": "BTN" },
  "players": 2,
  "to_act": "BTN",
  "pot_bb": 5.5,
  "to_call_bb": 0,
  "ev_bb": 3.23,
  "request": {
    "table": { "seats": 6, "stack_bb": 100, "rake": { "pct": 5, "cap_bb": 0.6 } },
    "streets": {
      "preflop": [
        { "seat": "UTG", "type": "fold" }, { "seat": "HJ", "type": "fold" }, { "seat": "CO", "type": "fold" },
        { "seat": "BTN", "type": "raise", "to_bb": 2.5 }, { "seat": "SB", "type": "fold" }, { "seat": "BB", "type": "call" }
      ],
      "flop": { "cards": ["Th", "6s", "2d"], "actions": [{ "type": "check" }] }
    }
  },
  "actions": [
    { "label": "check",      "type": "check",                  "frequency": 0.2607, "ev_bb": 2.45 },
    { "label": "bet 1.64",   "type": "bet",    "to_bb": 1.64,  "frequency": 0.0808, "ev_bb": 3.23 },
    { "label": "bet 2.61",   "type": "bet",    "to_bb": 2.61,  "frequency": 0.2611, "ev_bb": 3.36 },
    { "label": "bet 5.13",   "type": "bet",    "to_bb": 5.13,  "frequency": 0.3974, "ev_bb": 3.65 },
    { "label": "allin 97.5", "type": "all_in", "to_bb": 97.5,  "frequency": 0,      "ev_bb": null }
  ],
  "nodes": [
    { "index": 0, "street": "preflop", "board": [], "pot_bb": 1.5, "to_act": "UTG", "closed_street": false, "trigger": "Hand dealt", "is_target": false, "warm": { "sent": false, "id": null, "status": null } },
    { "index": 7, "street": "flop", "board": ["Th", "6s", "2d"], "pot_bb": 5.5, "to_act": "BB", "closed_street": false, "trigger": "Deal flop Th 6s 2d", "is_target": false, "warm": { "sent": true, "id": "slv_4c4370a55935439e80ce", "status": "warming" } },
    { "index": 8, "street": "flop", "board": ["Th", "6s", "2d"], "pot_bb": 5.5, "to_act": "BTN", "closed_street": false, "trigger": "BB check", "is_target": true, "warm": { "sent": false, "id": null, "status": null }, "solve": { "step_status": "warmed", "ms": 0, "warm_id": "slv_4c4370a55935439e80ce" } }
  ],
  "input_ranges": {
    "BB":  { "source": "preflop", "warmed": true, "warm_id": "slv_4c4370a55935439e80ce" },
    "BTN": { "source": "preflop", "warmed": true, "warm_id": "slv_4c4370a55935439e80ce" }
  },
  "steps": [
    { "street": "preflop", "status": "instant", "ms": 0, "warm_id": null, "actions_count": 6 },
    { "street": "flop", "board": ["Th", "6s", "2d"], "status": "warmed", "ms": 0, "warm_id": "slv_4c4370a55935439e80ce", "actions_count": 1 }
  ],
  "timing": {
    "server_ms": 6,
    "solve_ms": 0,
    "warm_ids": ["slv_4c4370a55935439e80ce"],
    "server": "finland"
  }
}
```

### GET /v1/solves/{id}/nodes/{index}

Fetch the 169-class GTO strategy (`hand_classes`) and per-seat reaching ranges (`player_ranges`) at chronological node `index` (`0 .. nodes.length - 1`) of a solve trace.

- **Free of solve quota, caller-scoped & 24-hour TTL:** same auth, 24-hour retention, and 120 req/min rate limit as `GET /v1/solves/{id}/trace` (`404 not_found` at `/id` or `/index` if missing or out of bounds).
- **Response shape:** `id`, `index`, `street`, `board`, `pot_bb`, `to_act` (`null` on closed streets), `ev_bb`, `actions[]`, 169-class `hand_classes` (when `to_act` is present), and per-seat `player_ranges` keyed by active seat name (mapping each of the 169 hand classes to its reaching weight `0..1` and live `combos`).

### `sizing`

- `"auto_simplified"` (default): automatic size policy preferring **one flop bet size** when the size-picker network says a single size captures the spot cleanly (falling back to a wider menu when needed), 75% on the turn, 33/75/125% on the river, and 60% raises. Facing a bet always solves at the exact bet size.
- `"auto_mixed"`: full multi-size GTO flop mix from the size-picker network (2-player postflop only).
- **Postflop custom menu** `{"bet"?: [{"pct": 33}, {"bb": 2.5}], "raise"?: [{"pct": 60}], "call"?: boolean, "all_in"?: boolean}`: 1–3 bet sizes (or 0–3 when `all_in: true`), optional 0–2 raise sizes (`pct` of pot after calling or `bb`), and optional `call` / `all_in` booleans to include or remove Call or All-in.
- **Preflop custom menu** `{"raise"?: [{"bb": 2.5}], "call"?: boolean, "all_in"?: boolean}`: 0–3 raise sizes (`bb` or integer `pct`), plus optional `call` (open-limp / SB complete / cold-call CRUD) and `all_in` booleans, solved live by our custom preflop solver.

### `include` & Follow a combo

Omitting `include` returns aggregate `actions[]` only (~1.5 KB):
- `"hand_classes": true` — top-level `hand_classes` (169-class map).
- `"combos": true` — top-level `combos` (1,326-combo map postflop; 169-class map preflop). Both `hand_classes` and `combos` may be requested together.
- `"hole_cards": ["Ah", "Kh"]` — top-level `hole_cards` for `to_act`. Card duplicates against the board return `400` at `/include/hole_cards/0` or `/1`.

Request:
```json
{
  "table": {
    "seats": 6,
    "stack_bb": 100,
    "rake": {"pct": 5, "cap_bb": 0.6}
  },
  "streets": {
    "preflop": [{"seat": "UTG", "type": "fold"}, {"seat": "HJ", "type": "fold"}, {"seat": "CO", "type": "fold"},
                {"seat": "BTN", "type": "raise", "to_bb": 2.5}, {"seat": "SB", "type": "fold"}, {"seat": "BB", "type": "call"}],
    "flop": {"cards": ["Jh", "9s", "4d"], "actions": [{"type": "check"}]}
  },
  "include": { "hole_cards": ["Kh", "Ah"] }
}
```

Response:
```json
{
  "id": "slv_08602e0b9ade40259ff5",
  "positions": { "oop": "BB", "ip": "BTN" },
  "street": "flop",
  "board": ["Jh", "9s", "4d"],
  "to_act": "BTN",
  "pot_bb": 5.5,
  "to_call_bb": 0,
  "ev_bb": 3.28,
  "actions": [
    { "label": "check",      "type": "check",                  "frequency": 0.4293, "ev_bb": 2.54 },
    { "label": "bet 1.3",    "type": "bet",    "to_bb": 1.3,   "frequency": 0.1271, "ev_bb": 3.31 },
    { "label": "bet 2.61",   "type": "bet",    "to_bb": 2.61,  "frequency": 0.0597, "ev_bb": 3.57 },
    { "label": "bet 6.87",   "type": "bet",    "to_bb": 6.87,  "frequency": 0.3839, "ev_bb": 4.06 },
    { "label": "allin 97.5", "type": "all_in", "to_bb": 97.5,  "frequency": 0,      "ev_bb": null }
  ],
  "hole_cards": {
    "cards": ["Ah", "Kh"],
    "combo": "AhKh",
    "class": "AKs",
    "seat": "BTN",
    "granularity": "combo",
    "in_range": true,
    "weight": 1,
    "ev_bb": 2.36,
    "actions": [
      { "label": "check",      "type": "check",                  "frequency": 0.4244, "ev_bb": 2.37 },
      { "label": "bet 1.3",    "type": "bet",    "to_bb": 1.3,   "frequency": 0.2524, "ev_bb": 2.36 },
      { "label": "bet 2.61",   "type": "bet",    "to_bb": 2.61,  "frequency": 0.0156, "ev_bb": 2.34 },
      { "label": "bet 6.87",   "type": "bet",    "to_bb": 6.87,  "frequency": 0.3076, "ev_bb": 2.36 },
      { "label": "allin 97.5", "type": "all_in", "to_bb": 97.5,  "frequency": 0,      "ev_bb": -0.55 }
    ]
  },
  "input_ranges": {
    "BB":  { "source": "preflop", "warmed": false, "warm_id": null },
    "BTN": { "source": "preflop", "warmed": false, "warm_id": null }
  },
  "quota": { "used": 75, "limit": 1000 },
  "timing": { "server_ms": 8, "solve_ms": 0, "warm_ids": [], "server": "finland" }
}
```

Out-of-range combo (`200` with `in_range: false`):
```json
"hole_cards": {
  "cards": ["7h", "2c"], "combo": "7h2c", "class": "72o", "seat": "BTN", "granularity": "combo",
  "in_range": false, "weight": 0, "ev_bb": null, "actions": null, "reason": "not_in_range"
}
```

### Ranges

- **Text** (`{"text": "…"}`): `QQ`, `AKs`, `AKo`, `AK`, `22+`, `ATs+`, `77-99`, `K9o-KQo`, `AhKh`, with optional `:weight` in `0..1` (`AQs:0.5`); later items override earlier ones.
- **Weights** (`{"weights": [1326 numbers]}`): card id = `rank * 4 + suit` (`2..A` = 0..12, `c d h s` = 0..3; `2c` = 0, `As` = 51); combo `a < b` sits at `b * (b - 1) / 2 + a`.

### Response

```json
{
  "id": "slv_4752bf4a76624a66a258",
  "street": "flop",
  "board": ["Jh", "9s", "4d"],
  "positions": { "oop": "BB", "ip": "BTN" },
  "players": 2,
  "to_act": "BTN",
  "pot_bb": 5.5,
  "to_call_bb": 0,
  "ev_bb": 3.24,
  "actions": [
    { "label": "check",      "type": "check",                  "frequency": 0.3507, "ev_bb": 2.54 },
    { "label": "bet 1.82",   "type": "bet",    "to_bb": 1.82,  "frequency": 0.4192, "ev_bb": 3.44 },
    { "label": "bet 4.13",   "type": "bet",    "to_bb": 4.13,  "frequency": 0.23,   "ev_bb": 3.95 },
    { "label": "allin 97.5", "type": "all_in", "to_bb": 97.5,  "frequency": 0,      "ev_bb": null }
  ],
  "hand_classes": {
    "AA":  { "combos": 6, "weight": 1, "ev_bb": 6.86,
             "strategy": { "check": 0.0371, "bet 1.82": 0.7872, "bet 4.13": 0.1757, "allin 97.5": 0 } },
    "AKs": { … }
  },
  "input_ranges": {
    "BB":  { "source": "custom", "warmed": false, "warm_id": null },
    "BTN": { "source": "custom", "warmed": false, "warm_id": null }
  },
  "quota": { "used": 12, "limit": 1000 },
  "timing": { "server_ms": 391, "solve_ms": 386, "warm_ids": [], "server": "finland" }
}
```

Fields: `id`, `street`, `board`, `to_act`, `positions`, `players`, `folded`, `pot_bb`, `to_call_bb`, `ev_bb`, `actions[]` (`label`, `type`, `to_bb?`, `frequency`, `ev_bb`), optional `hand_classes`, `combos`, `hole_cards`, postflop `input_ranges` (per-seat `{ source: "preflop" | "flop" | "turn" | "custom", warmed: boolean, warm_id: string | null }` for 2-way and 3-way), `quota`, `timing: { server_ms, solve_ms, warm_ids, server }`.

### Errors

Every error returns `{ "error": { "code", "message", "path" } }` where `path` is a RFC 6901 JSON Pointer (`""` for whole body):

```http
HTTP/1.1 400 Bad Request
{
  "error": {
    "code": "invalid_poker_state",
    "message": "HJ acts before CO: list every preflop action in order, folds included",
    "path": "/streets/preflop/2"
  }
}
```

| Status | Code | When |
|---|---|---|
| 400 | `invalid_request`, `invalid_range`, `unknown_field`, `invalid_json` | Malformed body, card duplicate, conflicting shapes, or unknown field |
| 400 | `invalid_poker_state` | Out-of-turn or illegal poker action |
| 401 | `unauthorized` | Missing, unknown, expired, or revoked key |
| 404 | `not_found` | Solve trace ID not found, expired (>24h), or belongs to a different API key |
| 413 | `body_too_large` | Body exceeds 256 KB |
| 422 | `line_not_in_tree`, `line_over`, `unsolvable`, `preflop_open`, `street_open`, `unsupported_table`, `multiway` | Street not closed, hand already ended, or spot cannot be solved |
| 429 | `rate_limited`, `quota_exceeded` | Per-minute, concurrency, or daily/lifetime quota limit reached (see `Retry-After`) |
| 503 / 504 | `busy`, `timeout` | Solver slots full or timed out; retry after a second |

### Plans and limits

| Plan | Price | Solves a day | A minute | At once |
|---|---|---|---|---|
| Free | $0 | 100 | 10 | 1 |
| Builder | $49/mo | 2,000 | 30 | 2 |
| Pro | $199/mo | 10,000 | 120 | 3 |
| Business | $799/mo | 50,000 | 600 | 4 |
| Trial (by hand) | — | 1,000 | 30 | 1 |

### GET /v1/account

Returns `{ key, limits, usage, billing }` for your key and 30 days of usage. `POST /v1/account/rotate` issues a new key and keeps the old key active for 24 hours.

### GET /v1/status (no key)

Returns `{ ok, status, parts, checked_at, uptime_90d_pct, days }`. Status page: https://anongto.com/api/status/

### Speed

- **Pre-warm with `POST /v1/warm`:** whenever the table state changes and it is not your turn yet (including closed streets and 3-way spots), fire-and-forget `POST /v1/warm` with `{ table, streets }`. Track `timing.warm_ids` (and `input_ranges[seat].warmed`) alongside `timing.solve_ms: 0` on subsequent `POST /v1/solve` calls to measure your warm hit rate. Interactive Trace Inspector: https://anongto.com/api/latency/
- **Reuse one HTTP connection:** `requests.Session()` in Python or `fetch` keep-alive in Node.
- **Accept `gzip`:** (`--compressed` in curl) shrinks large combo/class payloads 5–10×.
- **Request only the `include` keys you need:** omit `include` (~1.5 KB) or pass `include: {"hole_cards": ["Ah", "Kh"]}`.

### Examples

#### Python (stateless `{ table, streets }` + `POST /v1/warm`)
```python
import requests

# Reuse one Session: keeps TLS open and negotiates gzip automatically
api = requests.Session()
headers = {"Authorization": "Bearer YOUR_KEY"}

table = {"seats": 6, "stack_bb": 100, "rake": {"pct": 5, "cap_bb": 0.6}}
preflop = [
    {"seat": "UTG", "type": "fold"}, {"seat": "HJ", "type": "fold"}, {"seat": "CO", "type": "fold"},
    {"seat": "BTN", "type": "raise", "to_bb": 2.5}, {"seat": "SB", "type": "fold"}, {"seat": "BB", "type": "call"},
]

# 1. Flop lands and villain acts first: fire-and-forget POST /v1/warm (free of solve quota)
api.post(
    "https://api.anongto.com/v1/warm",
    headers=headers,
    json={"table": table, "streets": {"preflop": preflop, "flop": {"cards": ["Jh", "9s", "4d"], "actions": []}}},
    timeout=3,
)

# 2. When BB checks to BTN, send the full stateless hand history to POST /v1/solve
r = api.post(
    "https://api.anongto.com/v1/solve",
    headers=headers,
    json={
        "table": table,
        "streets": {
            "preflop": preflop,
            "flop": {"cards": ["Jh", "9s", "4d"], "actions": [{"type": "check"}]},
        },
        "include": {"hole_cards": ["Ah", "Kh"]},
    },
    timeout=15,
)
ans = r.json()
if not r.ok:
    raise SystemExit(f'{ans["error"]["code"]} at {ans["error"]["path"]}: {ans["error"]["message"]}')

print(ans["to_act"], "warm_ids:", ans["timing"]["warm_ids"], "solve_ms:", ans["timing"]["solve_ms"])
for a in ans["hole_cards"]["actions"]:
    print(a["label"], a["frequency"], a["ev_bb"])
```

#### JavaScript, Node 18+ (custom postflop ranges)
```javascript
// Custom postflop ranges: your own ranges and bet sizes on any board
const r = await fetch("https://api.anongto.com/v1/solve", {
  method: "POST",
  headers: { Authorization: "Bearer " + process.env.ANONGTO_KEY, "content-type": "application/json" },
  body: JSON.stringify({
    board: ["Jh", "9s", "4d", "2c"],
    pot_bb: 10.5,
    players: [
      { seat: "BB", stack_bb: 94.5, range: { text: "22-TT, A2s-AJs, K8s+, Q9s+, J9s+, T8s+, 98s, 87s, ATo-AQo, KJo+, QJo" } },
      { seat: "BTN", stack_bb: 94.5, range: { text: "22+, A2s+, K5s+, Q8s+, J8s+, T8s+, 97s+, 87s, 76s, A8o+, KTo+, QTo+, JTo" } },
    ],
    actions: [{ type: "check" }, { type: "bet", to_bb: 5.25 }],
    sizing: { bet: [{ pct: 50 }, { pct: 100 }], raise: [{ pct: 60 }] },
    rake: { pct: 5, cap_bb: 0.6 },
    include: { hole_cards: ["Qd", "Td"] },
  }),
});
const answer = await r.json();
if (!r.ok) throw new Error(answer.error.code + " at " + answer.error.path + ": " + answer.error.message);
console.log(answer.to_act, "warm_ids:", answer.timing.warm_ids, answer.actions.map((a) => a.label + " " + a.frequency));
```
