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

# Authentication

> Configure API credentials for the Chamber Python SDK

The Chamber SDK supports multiple authentication methods. Choose the one that best fits your workflow.

## Authentication Methods

<Tabs>
  <Tab title="Environment Variable">
    Set the `CHAMBER_TOKEN` environment variable:

    ```bash theme={null}
    export CHAMBER_TOKEN="ch.your-api-token"
    ```

    Then initialize the client without arguments:

    ```python theme={null}
    from chamber_sdk import ChamberClient

    client = ChamberClient()
    ```
  </Tab>

  <Tab title="CLI Config">
    If you have the [Chamber CLI](/cli/installation) installed and authenticated, the SDK can use its credentials:

    ```python theme={null}
    from chamber_sdk import ChamberClient

    client = ChamberClient.from_config()
    ```

    This reads from `~/.chamber/token.json`.
  </Tab>

  <Tab title="Direct Token">
    Pass the token directly to the client:

    ```python theme={null}
    from chamber_sdk import ChamberClient

    client = ChamberClient(token="ch.your-api-token")
    ```

    <Warning>
      Avoid hardcoding tokens in source code. Use environment variables or secret management for production.
    </Warning>
  </Tab>
</Tabs>

## Getting an API Token

1. Log in to the [Chamber Dashboard](https://app.usechamber.io)
2. Navigate to **Settings** > **API Tokens**
3. Click **Create Token** and copy the generated token

<Info>
  API tokens start with the prefix `ch.` followed by a unique identifier.
</Info>

## Multi-Organization Users

If you belong to multiple organizations, specify which one to use:

```python theme={null}
client = ChamberClient(
    token="ch.your-api-token",
    organization_id="org-123456"
)
```

## Configuration Options

| Parameter         | Description                         | Default                        |
| ----------------- | ----------------------------------- | ------------------------------ |
| `token`           | API token                           | From env or config             |
| `organization_id` | Organization ID for multi-org users | None                           |
| `api_url`         | Override API endpoint               | `https://api.usechamber.io/v1` |
| `timeout`         | Request timeout in seconds          | 30                             |

## Custom API Endpoint

For testing or custom deployments, you can override the default API URL:

```python theme={null}
client = ChamberClient(
    token="ch.your-api-token",
    api_url="https://custom.api.example.com/v1"
)
```

The default API endpoint is `https://api.usechamber.io/v1`.

## Verifying Authentication

Test your credentials by checking the API health:

```python theme={null}
client = ChamberClient()
health = client.health()
print(f"API Status: {health.status}")
print(f"API Version: {health.version}")
```

## Token Precedence

The SDK looks for authentication tokens in this order:

1. **Direct token parameter** - `ChamberClient(token="...")`
2. **Environment variable** - `CHAMBER_TOKEN`
3. **Config file** - `~/.chamber/token.json`

If no token is found, an `AuthenticationError` is raised.

## Next Steps

With authentication configured, follow the [Quickstart guide](/sdk/python/quickstart) to submit your first workload.
