# API keys

Use an organization API key for REST, automation, or a machine without a browser.

Use account sign-in for interactive clients. Claude Code, Claude.ai, Cursor and Codex ask you to sign in with your Dyno account when you add Phi. The CLI and Python client use `phi auth login`. The [quickstarts](/docs/quickstart/claude) show sign-in first.

Create an API key for REST, automation, or a machine without a browser.

## Create a key

1. Sign in to Phi and open your account from the button at the top right of any page.
2. Open **API keys**, name the key for the machine or tool that will use it, and choose **Create key**.
3. Copy the key when it appears. Phi does not show it again.
4. Under **Connect your agent**, choose a client and copy its command.

**Test the connection** calls Phi's MCP endpoint with the new key. It reports whether the key connected, the available credits, or why Phi refused it.

_Interactive: KeysLink. See https://phi.dynotx.com/docs/guides/api-keys._

The key acts as you in the organization where you created it, with your permissions. Phi records every run it starts under your name. A key does not expire unless you set an expiry. Revoke it from the same tab when the machine or tool no longer needs it. Revoke and replace a key that is lost.

The examples below use `YOUR_API_KEY` and Phi's production address. On staging, copy the command from the API keys tab so it uses the correct address.

## Connect your agent

Phi serves MCP at `/mcp`. Without a browser, Claude Code, Cursor and GitHub Copilot take the key in a bearer header. Codex reads it from a named environment variable. Claude.ai does not accept a key and uses account sign-in.

**Claude Code**

```bash
claude mcp add --transport http phi https://phi.dynotx.com/mcp \
  --header "Authorization: Bearer YOUR_API_KEY"
```

**Cursor**

```json
// .cursor/mcp.json
{
  "mcpServers": {
    "phi": {
      "url": "https://phi.dynotx.com/mcp",
      "headers": { "Authorization": "Bearer YOUR_API_KEY" }
    }
  }
}
```

**Codex**

```bash
export PHI_KEY=YOUR_API_KEY
codex mcp add phi --url https://phi.dynotx.com/mcp --bearer-token-env-var PHI_KEY
```

Codex reads `PHI_KEY` from its environment each time it starts, so keep the export in the shell profile you run it from.

**GitHub Copilot**

```json
// .vscode/mcp.json
{
  "servers": {
    "phi": {
      "type": "http",
      "url": "https://phi.dynotx.com/mcp",
      "headers": { "Authorization": "Bearer YOUR_API_KEY" }
    }
  }
}
```

**ChatGPT:** Phi's ChatGPT connector is not available yet. Use Claude Code meanwhile.

Continue with the [Claude Code](/docs/quickstart/claude?app=code), [Claude.ai](/docs/quickstart/claude?app=web), [Cursor](/docs/quickstart/cursor), [Codex](/docs/quickstart/codex), or [GitHub Copilot](/docs/quickstart/copilot) quickstart to run a first fold.

## Python

Install the client, then put the key in the environment the client reads, or pass it directly.

```bash
pip install dyno-phi
export PHI_API=https://phi.dynotx.com
export PHI_KEY=YOUR_API_KEY
```

```python
from phi import PhiClient

with PhiClient() as phi:                       # reads PHI_API and PHI_KEY
    print(phi.quota())

with PhiClient(base_url="https://phi.dynotx.com", api_key="YOUR_API_KEY") as phi:
    print(phi.quota())
```

The client also reads `~/.config/phi/config.toml`. The package is `dyno-phi` on PyPI, but the import is `phi`. Versions 0.2.x belonged to an earlier, unrelated client and are retired.

Continue with the [Python quickstart](/docs/quickstart/python).

## HTTP

Every request carries the key in the `x-api-key` header.

```bash
export PHI_API=https://phi.dynotx.com
export PHI_KEY=YOUR_API_KEY
curl -s "$PHI_API/v1/quota" -H "x-api-key: $PHI_KEY"
```

```bash
curl -s -X POST "$PHI_API/v1/jobs" \
  -H "x-api-key: $PHI_KEY" -H "content-type: application/json" \
  -d '{ "job_type": "ESMFOLD", "inputs": { "sequences": ["NLYIQWLKDGGPSSGRPPPS"] } }'
```

The [REST quickstart](/docs/quickstart/rest) submits, waits and downloads with the same two variables.

## CLI

The same package carries the CLI; `uv tool install` puts `phi` on your path.

```bash
uv tool install dyno-phi
export PHI_API=https://phi.dynotx.com
export PHI_KEY=YOUR_API_KEY
phi auth whoami
```

`phi auth whoami` says who the key acts as and in which organization. On a machine with no browser, `phi auth login` with `--key` saves the key as a profile instead of the two variables. The [CLI quickstart](/docs/quickstart/cli) continues from here.

## Keep it safe

- Do not put a key in a repository, chat, or shared notebook.
- Use a separate key for each machine or tool so you can revoke one without disrupting the others.
- Use an organization key beginning with `ak_`. Phi refuses personal keys because it needs an organization to bill.

---
Source: https://phi.dynotx.com/docs/guides/api-keys
