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

# Client Configuration

> Configure the Mynth JavaScript and TypeScript client for production use.

The SDK exposes a single client class: `Mynth`.

## Basic setup

```ts theme={"theme":"kanagawa-dragon"}
import Mynth from "@mynthio/sdk";

const client = new Mynth();
```

If you omit `apiKey`, the SDK reads `MYNTH_API_KEY` from the environment.

## Explicit configuration

```ts theme={"theme":"kanagawa-dragon"}
import Mynth from "@mynthio/sdk";

const client = new Mynth({
  apiKey: process.env.MYNTH_API_KEY,
  baseUrl: "https://api.mynth.io",
  destination: "my-store",
});
```

## Options

| Option        | Type     | Description                                                                                                                                                        |
| ------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `apiKey`      | `string` | Your Mynth API key. Optional only when `MYNTH_API_KEY` is already set.                                                                                             |
| `baseUrl`     | `string` | Override the default API base URL. Useful for proxies, tests, or custom deployments.                                                                               |
| `destination` | `string` | Default destination slug to deliver generated images to. Optional only when `MYNTH_DESTINATION` is already set. Overridable per request via `request.destination`. |

## Authentication behavior

The client always sends Bearer authentication:

```http theme={"theme":"kanagawa-dragon"}
Authorization: Bearer mak_...
```

The SDK uses your API key for server-to-server requests. For browser-safe task polling, use the task's `publicAccessToken` instead of your API key.

The same client exposes image generation, rating, and alt text methods:

```ts theme={"theme":"kanagawa-dragon"}
await client.image.generate({ prompt: "A product photo" });
await client.image.rate({ urls: ["https://example.com/image.webp"], mode: "nsfw_sfw" });
await client.image.alt({ urls: ["https://example.com/image.webp"] });
```

## When to override `baseUrl`

Override `baseUrl` only when you have a clear reason:

* an internal proxy
* a staging API
* tests that run against a mocked or isolated host

For standard production usage, keep the default `https://api.mynth.io`.
