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

# Configuration

> Set the Gotenberg endpoint or hosted API key via environment variables or code.

Chromiumly needs either a **hosted API key** or a **self-hosted endpoint**. Environment variables work in all runtimes (Node, Deno, Bun). On Node.js you can also use the `config` library or `Chromiumly.configure()`.

## Hosted API

When using the hosted API at `https://api.chromiumly.dev`, set your API key. You do **not** set `GOTENBERG_ENDPOINT`; the library uses the hosted URL automatically.

### Environment variable

```bash theme={null}
CHROMIUMLY_API_KEY=your-api-key
```

### Code

```typescript theme={null}
import { Chromiumly } from "chromiumly";

Chromiumly.configure({
  apiKey: "your-api-key",
});
```

## Self-hosted endpoint

When running Gotenberg yourself (e.g. via Docker), set the base URL of the Gotenberg API.

### dotenv (environment)

```bash theme={null}
GOTENBERG_ENDPOINT=http://localhost:3000
```

### config library

```json theme={null}
{
  "gotenberg": {
    "endpoint": "http://localhost:3000"
  }
}
```

### Code

```typescript theme={null}
import { Chromiumly } from "chromiumly";

Chromiumly.configure({ endpoint: "http://localhost:3000" });
```

## Resolution order

The library resolves the endpoint as follows:

1. If you called `Chromiumly.configure()` with `endpoint` or `apiKey`, that is used.
2. Otherwise it reads from the environment (e.g. `GOTENBERG_ENDPOINT`, `CHROMIUMLY_API_KEY`) or from the `config` library.
3. If an API key is set (and no endpoint), the endpoint becomes `https://api.chromiumly.dev`.

<Warning>
  If neither an endpoint nor an API key is configured, conversion calls will
  throw when they try to resolve the endpoint.
</Warning>

For authentication (basic auth, custom headers), see [Authentication](/authentication).
