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

# Client

> Initialize and configure the Docent client

The `Docent` class is the main entry point for the SDK. All API operations are methods on this client.

## Initialization

```python theme={null}
from docent import Docent

# Minimal — reads API key from environment or docent.env
client = Docent()

# With explicit configuration
client = Docent(
    api_key="your-api-key",
    collection_id="my-default-collection",
)
```

## Constructor Parameters

<ParamField body="api_key" type="str | None">
  API key for authentication. Falls back to config file (`docent.env`), then
  `DOCENT_API_KEY` environment variable. **Required** — if no key is found,
  raises `ValueError`.
</ParamField>

<ParamField body="collection_id" type="str | None">
  Stored as `default_collection_id` for your convenience, but SDK methods
  do **not** fall back to it automatically — you must pass `collection_id`
  explicitly to each method call. Falls back to `DOCENT_COLLECTION_ID` from
  the config file.
</ParamField>

<ParamField body="api_url" type="str | None">
  Direct URL of the Docent API server. Overrides URL derived from `domain`.
  Falls back to `DOCENT_API_URL` environment variable.
</ParamField>

<ParamField body="frontend_url" type="str | None">
  Direct URL of the Docent frontend UI. Overrides URL derived from `domain`.
  Falls back to `DOCENT_FRONTEND_URL` environment variable.
</ParamField>

<ParamField body="domain" type="str | None" default="docent.transluce.org">
  Domain of the Docent instance. API and frontend URLs are derived as
  `https://api.{domain}` and `https://{domain}` unless overridden.
</ParamField>

<ParamField body="use_https" type="bool" default="True">
  Whether to use HTTPS when constructing URLs from the domain.
</ParamField>

<ParamField body="config_file" type="str | Path | None">
  Explicit path to a dotenv config file. If not provided, the SDK searches
  for `docent.env` starting from the current directory and traversing upward.
</ParamField>

<ParamField body="log_stream" type="IO[str] | None">
  Output stream for SDK log messages. Defaults to `sys.stdout`.
</ParamField>

## Properties

<ResponseField name="frontend_url" type="str">
  The resolved Docent frontend base URL.
</ResponseField>

<ResponseField name="backend_url" type="str">
  The resolved Docent API base URL.
</ResponseField>

<ResponseField name="default_collection_id" type="str | None">
  The default collection ID, if configured.
</ResponseField>

## Example: Full Configuration

```python theme={null}
from docent import Docent

client = Docent(
    api_key="your-api-key",
    collection_id="my-collection",
    api_url="https://api.my-docent.example.com",
    frontend_url="https://my-docent.example.com",
)

print(client.frontend_url)  # https://my-docent.example.com
print(client.backend_url)   # https://api.my-docent.example.com/rest
```
