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

# TypeScript Installation

> Install @brew.new/sdk with npm, pnpm, yarn, or bun. Covers Node 20+ requirements, client options like timeout and retries, and a first request.

## Install

```bash npm theme={null}
npm install @brew.new/sdk
```

```bash pnpm theme={null}
pnpm add @brew.new/sdk
```

```bash yarn theme={null}
yarn add @brew.new/sdk
```

```bash bun theme={null}
bun add @brew.new/sdk
```

## Package

| Property | Value |
| - | - |
| Package | [`@brew.new/sdk`](https://www.npmjs.com/package/@brew.new/sdk) |
| Runtime | Node 20 or newer |
| Repo | [github.com/GetBrew/typescript-sdk](https://github.com/GetBrew/typescript-sdk) |

> [!WARNING]
>
> The SDK is server-first. Do not use it directly in browser code with a
> real API key.

## Create a Client

Create an API key at
[brew.new/settings/api](https://brew.new/settings/api). A brand key resolves its brand automatically. An organization key needs a client `brandId` or `withBrand(brandId)`.

See [API
authentication](https://docs.brew.new/api-reference/api/authentication.md) for the complete
scoping and permission contract.

```ts theme={null}
import { createBrewClient } from '@brew.new/sdk'

const brew = createBrewClient({
  apiKey: process.env.BREW_API_KEY!,
})
```

## Configuration

The client accepts these options:

```ts theme={null}
import { createBrewClient } from '@brew.new/sdk'

const brew = createBrewClient({
  apiKey: process.env.BREW_API_KEY!,
  baseUrl: 'https://brew.new/api',
  timeoutMs: 30_000, // per attempt, response body included
  maxRetries: 2,
  retryOnTimeout: true, // false: a timeout is final, never retried
  // signal: controller.signal, // optional: cancels every request on this client
  userAgent: 'my-app/1.0.0',
  fetch: globalThis.fetch,
})
```

### Common `baseUrl` Values

* `https://brew.new/api`
* `http://localhost:3000/api`

> [!NOTE]
>
> Long-running methods raise the default timeout: generation and editing use 240 seconds, imports and GIFs 300, image generation 180. A longer client `timeoutMs` is kept, and a
> per-request `timeoutMs` always wins. On Node, the built-in `fetch` stops
> waiting after 300 seconds whatever `timeoutMs` says.

## First Request

```ts theme={null}
const { data: domains } = await brew.domains.list()
console.log(domains)
```

## What to Read Next

> [card] [Quickstart](https://docs.brew.new/sdks/typescript/quickstart.md)
>
> Generate a design and send yourself a test.

> [card] [Error Handling](https://docs.brew.new/sdks/typescript/error-handling.md)
>
> See how `BrewApiError` works.

## Need Help?

Our team is ready to support you at every step of your journey with Brew. Choose the option that works best for you:

> [tab] Self-Service Tools
>
> > [card] Search Documentation
> >
> > Type in the "Ask any question" search bar at the top left to instantly find relevant documentation pages.
>
> > [card] [Ask ChatGPT or Claude](#top)
> >
> > Click here to open the **Copy page** menu at the top of this page, then send the page to ChatGPT, Claude, or your editor.

> [tab] Talk to Our Team
>
> > [card] [Schedule a Call](https://cal.com/team/brewdotnew/brew-demo)
> >
> > Book time with our founders for personalized guidance on strategy, best practices, or complex implementation questions.
>
> > [card] Call Us Directly
> >
> > Need immediate assistance? Reach us at **+1-(332)-203-2145** for urgent issues or time-sensitive questions.
>
> > [card] Slack Channel
> >
> > Our preferred support channel. You'll receive an invite after signup for direct founder support and fast responses.
>
> > [card] [Email Support](mailto:support@brew.new)
> >
> > Contact us at **[support@brew.new](mailto:support@brew.new)** for detailed inquiries or if you prefer not to use Slack.


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