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

# Installation

> Add the Sinker SDK to your TypeScript project.

## Requirements

* Node.js 18 or later
* The Sinker Rust sidecar running on `localhost:7777` (see the [repo README](https://github.com/ubadineke/sinker))
* An API key for your chosen model provider (`OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `GROQ_API_KEY`, or `XAI_API_KEY`)

***

## Install

<Tabs>
  <Tab title="npm">
    ```bash theme={null}
    npm install sinker-sdk
    ```
  </Tab>

  <Tab title="pnpm">
    ```bash theme={null}
    pnpm add sinker-sdk
    ```
  </Tab>

  <Tab title="yarn">
    ```bash theme={null}
    yarn add sinker-sdk
    ```
  </Tab>
</Tabs>

***

## ESM

The SDK is published as native ESM (`"type": "module"`). If you're using CommonJS, import it with a dynamic `import()`:

```ts theme={null}
// ESM (recommended)
import { Sinker } from 'sinker-sdk';

// CommonJS
const { Sinker } = await import('sinker-sdk');
```

***

## TypeScript

Full `.d.ts` declarations are included. No `@types/` package needed. Requires `"moduleResolution": "NodeNext"` (or `"Bundler"`) in your `tsconfig.json`:

```json theme={null}
{
  "compilerOptions": {
    "module": "NodeNext",
    "moduleResolution": "NodeNext"
  }
}
```

***

## Verify the connection

```ts theme={null}
import { Sinker } from 'sinker-sdk';

const sinker = new Sinker({
  model: {
    provider: 'anthropic',
    apiKey: process.env.ANTHROPIC_API_KEY!,
  },
});

const tip = await sinker.getTip();
console.log('p50 tip:', tip.p50_lamports, 'lamports');

const state = await sinker.getSlot();
console.log('current slot:', state.slot, 'leader:', state.leader);

sinker.destroy();
```

If the sidecar isn't running you'll get a `SinkerError: Request failed: fetch failed` — start the sidecar first with `sinker start` from the `sinker/` directory.
