How do I make my first request with the Pokerai JavaScript SDK?
Install @pokerai/client, create createPokeraiClient with an API key, then call its typed POST method for /v1/gto/preflop.
npm install @pokerai/client, keep POKERAI_API_KEY in a server-side environment variable, create createPokeraiClient({ apiKey }), and call client.POST("/v1/gto/preflop", { body }). The result separates parsed data from the typed error; it is not a live-play recommendation.Quick facts
| Official package entry | npm install @pokerai/client; import createPokeraiClient from @pokerai/client |
|---|---|
| First SDK call | client.POST("/v1/gto/preflop", { body }) calls the documented presolved preflop operation |
| Authentication | createPokeraiClient({ apiKey }) sends the key as a Bearer token; create the key from dashboard sign-in |
| Response | The client returns parsed data on success or a typed error; the documented success fields include situation, strategy, and quota |
| Free tier | 1,000 presolved lookups + 25 real-time solves / month; this request charges one presolved lookup |
| Use boundary | Training, coaching, hand review, study, and research only; no real-money RTA |
Install and authenticate
Install the official package, then expose the API key only to trusted server-side code. Do not commit a real key, bundle it into browser JavaScript, or print it in logs.
npm install @pokerai/client
export POKERAI_API_KEY="gto_your_key_here"
Minimal JavaScript SDK request
This official SDK pattern calls the public preflop strategy operation. The request shape, endpoint, and non-success status codes are defined by the current OpenAPI snapshot.
import { createPokeraiClient } from "@pokerai/client";
const client = createPokeraiClient({
apiKey: process.env.POKERAI_API_KEY,
});
const { data, error } = await client.POST("/v1/gto/preflop", {
body: {
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 },
],
},
});
if (error) throw new Error(JSON.stringify(error));
console.log(data.situation, data.strategy);
Interpret the response
On success, read data.situation as the derived preflop state and iterate data.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 frequencies as a mixed distribution for study or sampling, not as a promise of profit or one recommended move.
The response can include data.quota. Record account usage from the returned result or dashboard rather than inferring it from application counters. The current public contract—not a hard-coded SDK assumption—remains the source for response fields.
Errors and quota handling
The public contract for this operation declares 400, 401, and 429. Check error before reading data. Correct invalid input instead of retrying it unchanged; for missing or invalid credentials, check the server-side Bearer key; for 429, check account quota and the current quota documentation.
When to use it
Use this client pattern in a server-side trainer, coaching product, completed-hand review tool, study workflow, research project, or AI-agent integration with human review. It is a concise path when you want an OpenAPI-typed JavaScript surface 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 locales/product-facts.json. The import name and client call pattern were read from the official JavaScript 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 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.
| Endpoint | SDK call | Use it for |
|---|---|---|
POST /v1/gto/preflop | client.POST("/v1/gto/preflop", { body }) | One authenticated, presolved preflop strategy lookup |
SDK, API, and provenance links
- Developer docs — authentication, quotas, SDK, MCP, and error handling
- API Reference — current preflop request and response schema
- OpenAPI snapshot — machine-readable English public contract
- JavaScript SDK source — official repository; inspect its current typed client surface
- JavaScript package entry — official package URL; this Guide makes no release-status claim
- Python SDK — official package entry point
- MCP server — official package entry point
- GTO API quickstart — the equivalent minimal HTTP request and mixed-strategy explanation
- llms.txt — concise LLM entry point