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

# TypeScript SDK

> The official TypeScript client for the Gatelit gateway.

`@gatelit/sdk` is a zero-dependency TypeScript client that works in Node.js, Deno, Bun, and the browser.

## Installation

```bash theme={null}
npm install @gatelit/sdk
# or
pnpm add @gatelit/sdk
# or
yarn add @gatelit/sdk
```

## Create a client

```ts theme={null}
import { GatelitClient } from "@gatelit/sdk"

const client = new GatelitClient({
  gatewayUrl: "https://your-gateway.workers.dev",
  getToken: async () => ({
    token: process.env.GATELIT_SERVICE_KEY!,
    scheme: "GatelitKey",
  }),
})
```

`getToken` is called before every request. For browser apps, fetch a short-lived token from your backend:

```ts theme={null}
const client = new GatelitClient({
  gatewayUrl: "https://your-gateway.workers.dev",
  getToken: async () => {
    const res = await fetch("/api/ai-token")
    const { token } = await res.json()
    return { token, scheme: "GatelitSigned" }
  },
})
```

## Models

Models are specified as `provider/model-id`:

| String                                 | Provider  | Model             |
| -------------------------------------- | --------- | ----------------- |
| `openai/gpt-4o`                        | OpenAI    | GPT-4o            |
| `openai/o3-mini`                       | OpenAI    | o3 mini           |
| `anthropic/claude-3-5-sonnet-20241022` | Anthropic | Claude 3.5 Sonnet |
| `google/gemini-2.5-flash`              | Google    | Gemini 2.5 Flash  |
| `mistral/mistral-large-latest`         | Mistral   | Mistral Large     |

## Explore the SDK

<CardGroup cols={2}>
  <Card title="Chat" href="/sdk/typescript/chat">
    Non-streaming requests with full response and usage
  </Card>

  <Card title="Streaming" href="/sdk/typescript/streaming">
    Token-by-token streaming with async iteration
  </Card>

  <Card title="JSON output" href="/sdk/typescript/json-output">
    Type-safe structured output with schema enforcement
  </Card>

  <Card title="Conversations" href="/sdk/typescript/conversations">
    Multi-turn chat with automatic message history management
  </Card>
</CardGroup>
