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

# SDK Config

> Configuration precedence for the Nullspace SDK and CLI.

The Python SDK accepts explicit `api_key=` and `base_url=` arguments. If those
are omitted, the SDK and CLI use the same file and environment lookup order:

1. Environment variables: `NULLSPACE_API_KEY`, `NULLSPACE_API_URL`, then
   `NULLSPACE_BASE_URL`
2. Project `.env` in the current working directory
3. `~/.config/nullspace/config.json`
4. Legacy `~/.nullspace/config.json`
5. Built-in API URL default: `http://localhost:3000`

Example `.env`:

```bash theme={"theme":{"light":"one-light","dark":"one-dark-pro"}}
NULLSPACE_API_KEY=ns_live_...
NULLSPACE_API_URL=https://api.your-nullspace-domain
```

See [Hosted endpoints](./hosted-endpoints) for current private-beta
endpoint values.

Self-hosted single-host localhost/no-domain clients normally use Caddy on the
same host:

```bash theme={"theme":{"light":"one-light","dark":"one-dark-pro"}}
NULLSPACE_API_KEY=ns_live_...
NULLSPACE_API_URL=http://localhost
```

Owned-domain self-host clients use the configured Caddy/API origin:

```bash theme={"theme":{"light":"one-light","dark":"one-dark-pro"}}
NULLSPACE_API_URL=https://nullspace.example
```

Example config file:

```json theme={"theme":{"light":"one-light","dark":"one-dark-pro"}}
{
  "api_key": "ns_live_...",
  "base_url": "https://api.your-nullspace-domain"
}
```

The SDK also accepts legacy config key `api_url` as an alias for `base_url`.
`nullspace auth login --api-url https://api.13-215-85-171.sslip.io` writes the
legacy config path for backward compatibility and saves `base_url` with the API
key. New automation can prefer environment variables or
`~/.config/nullspace/config.json`.

Run `nullspace auth status` to see the resolved API URL, which source won the
lookup, and a `sha256:` key fingerprint (the key itself is never printed).

Use `NULLSPACE_API_URL` for SDK and CLI clients. `VITE_NULLSPACE_API_BASE` is
only read by the Vite console at build time.
