# AnonGTO 扑克求解器 API（v1 中文参考）

基础地址：`https://api.anongto.com`。请求与响应均为 JSON，筹码金额统一以大盲（`bb`）为单位。
中文 OpenAPI 3.1：https://anongto.com/zh/api/openapi.json · 中文网页文档：https://anongto.com/zh/api/docs/ · 链路追踪器：https://anongto.com/zh/api/latency/ · 交互式演示：https://anongto.com/zh/api/demo/ · 免费密钥：https://anongto.com/zh/api/#get-key

`POST /v1/solve` 是完全无状态的：每次决策提交当前牌局状态，即可返回当前行动者的 GTO 策略、期望值（EV）、各位置 `input_ranges` 来源以及 `timing.warm_ids`。无需传递 `mode` 字段——请求体结构会自动决定求解路径：

1. **整手牌（`table` + `streets`）**：描述牌桌配置（简写或完整写法）及从发牌至今的每个行动。
2. **自定义翻后范围（`board` + `pot_bb` + `players`）**：传入 2 位或 3 位玩家的范围、底池、筹码及可选 `sizing`，直接求解单条翻后街。

只要牌桌状态发生变化且尚未轮到你（包括刚闭合的街道与 3 人底池），建议异步调用免费的 `POST /v1/warm`（返回 `202 Accepted`，**0 求解配额消耗**）。轮到你时调用 `POST /v1/solve` 将直接命中预热缓存，返回 `timing.solve_ms: 0` 并在 `input_ranges[seat].warm_id` 与 `timing.warm_ids` 中携带对应的 `slv_...`。

接口校验严格：所有行动均为类型化对象（例如 `{"type": "bet", "to_bb": 2.5}`，拒绝 `"bet 2.5"` 字符串），翻前行动需按顺序列出（含弃牌），任何未知字段返回 `400 unknown_field`，所有错误均在 `error.path` 中返回精确的 RFC 6901 JSON Pointer。

本 API 仅限学习与分析工具使用，不得用于实战。

## 快速开始

```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"}]}}}'
```

---

## 实战演练：常见局面

### 翻前（常规无前注 vs 有前注）

在 `table` 中添加 `"ante_bb": 0.17` 会自动放宽开池与防守频率：

- **1. 首位行动（UTG 开池，`preflop: []`）**
  - 常规（`pot_bb: 1.5`）：`fold` 82.5%，`raise 2.5` 17.5%（`ev_bb: 0.57`）
  - 有前注（`ante_bb: 0.17`，`pot_bb: 2.5`）：`fold` 76.9%，`raise 2.5` 23.1%（`ev_bb: 0.87`）
- **2. 前面全弃到 BTN 开池**
  - 常规：`fold` 56.5%，`raise 2.5` 43.5%（`ev_bb: 0.57`）
  - 有前注：`fold` 46.9%，`raise 2.5` 53.1%（`ev_bb: 0.85`）
- **3. 面对 3-bet（BTN 面对 BB 3-bet 至 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"
    ]
  }
}
```
  线上实测响应（常规）：
  ```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"
  }
}
```

### 翻后（无状态 `{ table, streets }`、`POST /v1/warm`、`sizing`、`include` 与自定义范围）

- **4. 发翻牌时预热 → 轮到 BTN 0 ms 命中缓存（公共牌 `Th 6s 2d`，BB 过牌到 BTN）**
  1) 异步发送 `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) BB 过牌后发送 `POST /v1/solve`（`actions: [{"type": "check"}]`）→ `200 OK`（`timing.solve_ms: 0`，`input_ranges[seat].warmed: 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": [
        "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"
  }
}
```
  交互式链路追踪器：https://anongto.com/zh/api/latency/
- **5. 翻牌面对持续下注（无状态 `{ 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. 转牌面对过牌加注（无状态 `{ 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. 河牌过牌到底（自定义 `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. 自定义翻后范围（`board` + `pot_bb` + `players` + 自定义 `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 完整参考

### 身份验证

每次求解都需要 API 密钥（`agto_…`）：可在 https://anongto.com/zh/api/#get-key 免费领取，或在 https://anongto.com/api/pricing/ 升级套餐。
通过请求头 `Authorization: Bearer YOUR_KEY`（或 `X-API-Key: YOUR_KEY`）认证，请仅在服务端保管。
服务端仅存储密钥 SHA-256 指纹；`POST /v1/account/rotate` 可立即签发新密钥并保留旧密钥 24 小时。

### POST /v1/solve — 两种请求形态

#### 1. 整手牌（`table` + `streets`）

| 字段 | 类型 | 说明 |
|---|---|---|
| `table` | object | 必填。简写：`{"seats": 6, "stack_bb": 100, "stacks_bb"?: {"HJ": 60, "BTN": 25}, "rake": {"pct": 5, "cap_bb": 0.6} \| null, "ante_bb"?: 0, "straddle"?: false}`。完整写法：`{"max_seats": 6, "seats": [{"seat": "UTG", "stack_bb": 100}, ...], "rake": ..., "ante_bb"?: 0, "straddle"?: false}`。 |
| `streets.preflop` | array | 必填（`[]` = 首位行动）。按翻前顺序列出全部行动（含弃牌）：`{"seat": "BTN", "type": "fold" \| "check" \| "call" \| "raise" \| "all_in", "to_bb"?: number}`（仅 `raise` 必填 `to_bb`）。 |
| `streets.flop` | object | 可选：`{"cards": [3张牌], "actions": [...]}`。 |
| `streets.turn`、`streets.river` | object | 可选（需上一街已闭合）：`{"card": "2c", "actions": [...]}`。 |
| `sizing` | string 或 object | 可选（支持翻前与翻后）：`"auto_simplified"`（默认）、`"auto_mixed"`（2 人翻后），或自定义 `{"bet"?: [...], "raise"?: [...], "call"?: boolean, "all_in"?: boolean}`。 |
| `include` | object | 可选：`{"hand_classes"?: boolean, "combos"?: boolean, "hole_cards"?: ["Ah", "Kh"]}`。 |

请求示例：
```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": []}
  }
}
```

响应示例：
```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. 自定义翻后范围（`board` + `pot_bb` + `players`）

| 字段 | 类型 | 说明 |
|---|---|---|
| `board` | array | 3–5 张互不相同的公共牌，街道由长度自动推断。 |
| `pot_bb` | number | 本街开始时的底池大小（bb）。 |
| `players` | array | 按翻后行动顺序排列的 2 或 3 位玩家：`{"seat": "BB", "stack_bb": 94.5, "range": {"text": "…"} \| {"weights": [1326个 0..1 权重]}}`。 |
| `actions` | array | 可选，本街已发生行动（默认 `[]`，最多 12 个）。 |
| `sizing` | string 或 object | 可选：`"auto_simplified"`（默认）、`"auto_mixed"`（仅 2 人），或自定义 `{"bet"?, "raise"?, "call"?, "all_in"?}`。 |
| `rake` | object 或 null | 可选 `{"pct": 5, "cap_bb": 3}`（默认 `null`）。 |
| `include` | object | 可选 `{"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 }
}
```

3 人底池（原型）：在 `players` 中按翻后顺序传入 3 位玩家（`sizing: "auto_simplified"` 或自定义对象；单个行动 `ev_bb` 为 `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

在后台预热翻后街道与范围转换，使后续 `POST /v1/solve` 直接以 `timing.solve_ms: 0` 返回。

- **客户端规则：** 牌桌变化且未轮到你时（包括刚结束的街道与 3 人底池）直接异步发送 `POST /v1/warm`。
- **校验与配额：** 与 `POST /v1/solve` 共享请求格式与同步校验；**不消耗每日求解配额**（需剩余配额 `> 0`，未命中预热每日上限 `max(20, 4 × 今日已用求解数)`），独立 `2× per_min` 限流桶。
- **`202 Accepted` 响应：**
  - `{"status": "warming", "id": "slv_..."}` — 已进入低优先级后台预热通道。
  - `{"status": "ready"}` — 已在缓存中就绪，无需计算。
  - `{"status": "skipped", "reason": "quota" | "warm_cap" | "busy"}` — 静默跳过，不影响后续 `/v1/solve`。

```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

查看任意 `POST /v1/solve`（`slv_...`）的完整手牌轨迹（网页可视化：https://anongto.com/zh/api/latency/）。

- **24 小时 TTL & 密钥隔离：** 仅创建者密钥可读；未知/过期/跨密钥返回 `404 not_found`。
- **免费（0 求解配额）：** 限流 120 次/分钟。
- **响应字段：** `id`, `created_at`, `mode`, `street`, `board`, `positions`, `players`, `to_act`, `pot_bb`, `to_call_bb`, `ev_bb`, `request`, `actions[]`, `hole_cards?`, `nodes[]`, `input_ranges?`, `steps[]`, `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}

读取轨迹第 `index` 个节点的 169 牌型策略（`hand_classes`）与各座位到达范围（`player_ranges`）。同样免费、密钥隔离、保留 24 小时。

### `sizing`（行动与尺度菜单 CRUD）

- `"auto_simplified"`（默认）：翻牌在单尺度足够时自动简化为 1 个下注尺度（否则多尺度），转牌 75%，河牌 33/75/125%，加注 60%。
- `"auto_mixed"`：翻牌完整多尺度 GTO 混合菜单（仅 2 人翻后）。
- **翻后自定义菜单** `{"bet"?: [{"pct": 33}, {"bb": 2.5}], "raise"?: [{"pct": 60}], "call"?: boolean, "all_in"?: boolean}`：1–3 个下注尺度（`all_in: true` 时可 0–3 个）、可选 0–2 个加注尺度（`pct` 或 `bb`），以及 `call` / `all_in` 开关。
- **翻前自定义菜单** `{"raise"?: [{"bb": 2.5}], "call"?: boolean, "all_in"?: boolean}`：0–3 个加注尺度（`bb` 或整数 `pct`），以及 `call`（跛入 / 补盲 / 冷跟）与 `all_in` 开关，由自定义翻前求解器实时求解。

### `include` 与底牌跟随

省略 `include` 仅返回汇总 `actions[]`（约 1.5 KB）：
- `"hand_classes": true` — 169 牌型类别表。
- `"combos": true` — 翻后 1,326 组合 / 翻前 169 类别表。
- `"hole_cards": ["Ah", "Kh"]` — 当前行动者指定底牌策略（与公共牌冲突返回 `400`）。

请求：
```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"] }
}
```

响应：
```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" }
}
```

0% 到达权重组合（仍返回 `200`，`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"
}
```

### 范围语法

- **文本（`{"text": "…"}`）：** `QQ`, `AKs`, `AKo`, `AK`, `22+`, `ATs+`, `77-99`, `K9o-KQo`, `AhKh`，可附 `:weight`（`AQs:0.5`），后者覆盖前者。
- **权重数组（`{"weights": [1326 个数值]}`）：** 牌号 = `rank * 4 + suit`（`2..A` = 0..12，`c d h s` = 0..3；`2c` = 0，`As` = 51），组合 `a < b` 索引为 `b * (b - 1) / 2 + a`。

### 响应示例

```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" }
}
```

### 错误码

统一结构 `{ "error": { "code", "message", "path" } }`（`path` 为 RFC 6901 JSON Pointer）：

```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"
  }
}
```

| 状态码 | 错误码 | 说明 |
|---|---|---|
| 400 | `invalid_request`, `invalid_range`, `unknown_field`, `invalid_json` | 字段格式错误、重复牌、形态冲突或未知字段 |
| 400 | `invalid_poker_state` | 非当前行动者或非法扑克行动 |
| 401 | `unauthorized` | 密钥缺失、无效、过期或已吊销 |
| 404 | `not_found` | 追踪 ID 不存在、已过期（>24h）或不属于当前密钥 |
| 413 | `body_too_large` | 请求体超过 256 KB |
| 422 | `line_not_in_tree`, `line_over`, `unsolvable`, `preflop_open`, `street_open`, `unsupported_table`, `multiway` | 上一街未闭合、手牌已结束或局面不可解 |
| 429 | `rate_limited`, `quota_exceeded` | 超出每分钟频率、并发或每日/终身配额（见 `Retry-After`） |
| 503 / 504 | `busy`, `timeout` | 求解通道满载或超时，约 1 秒后重试 |

### 套餐与限额

| 套餐 | 价格 | 每日求解 | 每分钟 | 并发 |
|---|---|---|---|---|
| Free | $0 | 100 | 10 | 1 |
| Builder | $49/月 | 2,000 | 30 | 2 |
| Pro | $199/月 | 10,000 | 120 | 3 |
| Business | $799/月 | 50,000 | 600 | 4 |
| Trial（人工试用） | — | 1,000 | 30 | 1 |

### GET /v1/account 与 GET /v1/status

- `GET /v1/account`：返回密钥套餐、限额与 30 天用量；`POST /v1/account/rotate` 轮换密钥（旧密钥保留 24 小时）。
- `GET /v1/status`（无需认证）：返回服务健康状态与 90 天可用率（https://anongto.com/api/status/）。

### 代码示例

#### Python（无状态 `{ 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+（自定义翻后范围）
```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));
```
