> ## Documentation Index
> Fetch the complete documentation index at: https://docs.circuit.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Kalshi agent SDK

> Trade Kalshi prediction market contracts from a connected Kalshi account.

`agent.kalshi` trades Kalshi outcome contracts from the Kalshi account the session was started with. A contract pays 1 USD when its outcome happens and nothing otherwise, and Kalshi settles held contracts into the account's USD itself. Orders and order reads require a hosted target or a paper session; local `circuit run` rejects them. Kalshi accounts are funded on kalshi.com; Circuit neither deposits nor withdraws.

`events.search({ query })` returns up to 20 series whose title, category or tag match the query, `events.search({ seriesTicker })` a series' open events, and `events.search({ eventTicker })` one event with its markets. Each market has a `ticker`, `title`, `yesSubTitle`, `noSubTitle`, `closeTime`, `volume24h`, `trading`, and `yes` and `no` quotes with the contract's pair id `asset` (`KALSHI:<ticker>.YES/USD`) and its best `bid` and `ask` in USD per contract, null when the book has none. `agent.exchanges.markets.list({ exchange: "kalshi", base: "<ticker>.YES" })` returns one contract's order rules; Kalshi markets are listed one contract at a time.

`orders.create(order, options?)` takes the [order shape every venue shares](https://docs.circuit.org/agent-developers/sdk-reference/hyperliquid.md): `{ kind: "spotBuy" | "spotSell", asset, amount: { size }, execution }`, with `size` in contracts at 0.01 steps and `execution` `{ kind: "limit", price, timeInForce }` priced in USD per contract of the pair's outcome ("gtc" rests, "ioc" fills what crosses now, "alo" is post-only). Buying No is buying the `NO` pair; Circuit translates it to Kalshi's single YES book. Kalshi nets the two outcomes of a market, so preparation refuses a sell of more contracts than are free to sell and a buy while the account holds the other outcome; sell that one instead. `agent.orders.listOpen({ venue: "kalshi" })` returns the session's resting orders, and `orders.cancel({ orderId, asset }, options?)` cancels one the session placed.

## Connect a credential

`circuit exchange connect --venue kalshi --api-key <key-id> --private-key-file <path>` connects an account with the private key file Kalshi downloads; Ed25519 and RSA keys both work. Keys locked to a numbered subaccount are refused, since Circuit trades the primary account. A key with the Write scope gets trade access, a Read key read access. Declare the venue under [`exchangeCredentials`](../getting-started/circuit-toml-reference#exchangecredentials-section), then pass the account ID from `circuit exchange list` as `--exchange-credential <id>` with a hosted target.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.