# Configuration and environment variables

> Where okibi keeps its settings, and every environment variable it reads.

## The config file

okibi keeps its settings in `~/.config/okibi/config.json`, or in `$XDG_CONFIG_HOME/okibi/config.json` when that variable is set. It holds:

| Field | Meaning |
| --- | --- |
| `api_url` | The Okibi API this machine talks to, when it isn't `https://okibi.ai` |
| `default_workspace` | The workspace `okibi workspaces` and `okibi auth status` show as your default |
| `api_key` | Only present when no OS keyring is available |

To run a command in another workspace, pass `--workspace <slug>` or set `OKIBI_WORKSPACE`. See [What wins](#what-wins).

## Environment variables

| Variable | Effect |
| --- | --- |
| `OKIBI_API_KEY` | API key to use instead of the stored login |
| `OKIBI_API_URL` | API base URL, for example a local development server |
| `OKIBI_WORKSPACE` | Workspace slug, the same as `--workspace` |
| `OKIBI_NO_KEYRING` | Set to `1` to store the key in the config file instead of the OS keyring |
| `OKIBI_NO_AUTO_UPDATE` | Set to `1` to stop background updates |
| `OKIBI_NO_ANALYTICS` | Set to `1` to turn off usage analytics; `DO_NOT_TRACK=1` works too |
| `XDG_CONFIG_HOME` | Moves the config directory |

## What wins

| Setting | Order |
| --- | --- |
| API key | `OKIBI_API_KEY`, then the OS keyring, then the config file |
| API URL | The `--api-url` flag, then `OKIBI_API_URL`, then `api_url` in the config file, then `https://okibi.ai` |
| Workspace | `--workspace`, then `OKIBI_WORKSPACE`, then the workspace your API key belongs to |

A key locked to one workspace always uses that workspace. A flag can't move it.
