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

# Kalshi

> Authenticate to Kalshi.

## Setup

Generate an API key id + RSA private key at [kalshi.com/account/profile](https://kalshi.com/account/profile) → API Keys.

Put them in `.env`:

```env theme={null}
KALSHI_API_KEY_ID=...
KALSHI_PRIVATE_KEY_PATH=./kalshi-private-key.pem
```

Then pass them to the constructor:

<CodeGroup>
  ```python Python theme={null}
  import os
  from openpx import Exchange

  exchange = Exchange("kalshi", {
      "api_key_id":       os.environ["KALSHI_API_KEY_ID"],
      "private_key_path": os.environ["KALSHI_PRIVATE_KEY_PATH"],
  })
  ```

  ```javascript Node theme={null}
  import { Exchange } from "@openpx/sdk";

  const exchange = new Exchange("kalshi", {
      api_key_id:       process.env.KALSHI_API_KEY_ID,
      private_key_path: process.env.KALSHI_PRIVATE_KEY_PATH,
  });
  ```

  ```rust Rust theme={null}
  use openpx::ExchangeInner;
  use serde_json::json;

  let exchange = ExchangeInner::new("kalshi", json!({
      "api_key_id": std::env::var("KALSHI_API_KEY_ID").unwrap(),
      "private_key_path": std::env::var("KALSHI_PRIVATE_KEY_PATH").unwrap(),
  }))?;
  ```
</CodeGroup>
