← All guides
On this page
Quickstart Start here · 03/06 Python 10 min Beginner

How do I make my first request with the Pokerai Python SDK?

Install pokerai-bet, import pokerai, create an AuthenticatedClient with an API key, then call the SDK's documented wrapper for POST /v1/gto/preflop.

Updated Maintained by Pokerai API

Direct answer: use pip install pokerai-bet, keep POKERAI_API_KEY in your environment, and call preflop_strategy.sync(client=client, body=req). The typed result represents either the documented response or a documented API error; it is not a live-play recommendation.

Quick facts

Official package entrypip install pokerai-bet; the import package is pokerai
First SDK callpreflop_strategy.sync wraps POST /v1/gto/preflop
AuthenticationAuthenticatedClient sends the API key as a Bearer token; create the key from dashboard sign-in
ResponseA typed preflop response with situation, strategy, and quota, or the documented error model
Free tier1,000 presolved lookups + 25 real-time solves / month; this request is one presolved lookup
Use boundaryTraining, coaching, hand review, study, and research only; no real-money RTA

Install and authenticate

Install the package named in the approved product facts, then export an API key locally. Do not commit a real key, place it in browser code, or print it in logs.

python -m pip install pokerai-bet
export POKERAI_API_KEY="gto_your_key_here"

Minimal Python SDK request

This is the official SDK client pattern for the public preflop strategy operation. The request shape, endpoint, and non-success status codes are defined by the current OpenAPI snapshot.

import os

from pokerai import AuthenticatedClient
from pokerai.api.lookup import preflop_strategy
from pokerai.models import (
    PreflopRequest,
    PreflopRequestPositions,
    PreflopRequestPreflopActionsItem,
    PreflopRequestPreflopActionsItemAction as Act,
)
from pokerai.models.position import Position

client = AuthenticatedClient(
    base_url="https://pokerai.bet",
    token=os.environ["POKERAI_API_KEY"],
)

req = PreflopRequest(
    hole_cards="AhKh",
    positions=PreflopRequestPositions(hero=Position.MP),
    preflop_actions=[
        PreflopRequestPreflopActionsItem(position=Position.SB, action=Act.SMALL_BLIND, amount=0.5),
        PreflopRequestPreflopActionsItem(position=Position.BB, action=Act.BIG_BLIND, amount=1),
        PreflopRequestPreflopActionsItem(position=Position.UTG, action=Act.RAISE, amount=3),
    ],
)

result = preflop_strategy.sync(client=client, body=req)
print(result)

Interpret the response

For a successful response, read situation as the derived preflop state and iterate strategy. Each strategy item has an action and a frequency from 0 to 1; bet or raise items can also expose sizing_pot, amount_bb, and allin. Treat the set of frequencies as a mixed distribution to study or sample from, not as a promise of profit or a single recommended move.

The response can also include quota. Record account usage from the returned result or dashboard rather than inferring it from client-side counters. The public contract—not a hard-coded SDK assumption—remains the source for the current response shape.

Errors and quota handling

The public contract for this operation declares 400, 401, and 429. The generated SDK's sync call parses documented error responses into its error model; use sync_detailed when your application also needs the HTTP status and headers. Correct invalid input instead of retrying it unchanged; for missing or invalid credentials, check the Bearer key; for 429, check account quota and the current quota documentation.

When to use it

Use this SDK pattern in a server-side trainer, coaching product, completed-hand review tool, study workflow, research project, or an AI agent integration with human review. It is a concise path when you want typed request and response models while still validating against the public API contract.

When not to use it

Do not use this example in browser code that exposes an API key, a live-table feed, or an action-automation loop. Do not infer support for endpoints, SDK methods, versions, registry publication, or performance claims that are absent from the current public source and OpenAPI snapshot.

Provenance and current contract

The package name, install entry, repository, Docs, Reference, and OpenAPI links come from this repository's locales/product-facts.json. The import names and call pattern above were read from the official Python SDK source revision; this Guide deliberately does not claim a package version or registry publication state. Check the current API Reference and OpenAPI snapshot before updating generated-client code.

No real-money RTA

Pokerai API is for training, coaching, hand review, study, and research only. Real-time assistance at real-money tables is prohibited. Keep SDK output out of live-table automation and do not present mixed frequencies as a real-time action instruction.

Relevant public operation

Start with the documented presolved preflop lookup; use the current Reference and OpenAPI snapshot before selecting another operation.

EndpointSDK wrapperUse it for
POST /v1/gto/prefloppreflop_strategy.syncOne authenticated, presolved preflop strategy lookup

SDK, API, and provenance links