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

# Project Configuration

> Configure the Python and TypeScript SDKs programmatically

While environment variables are the recommended way to configure PandaProbe, you can also configure either SDK programmatically.

### Basic programmatic configuration

<Tabs>
  <Tab title="Python">
    ```python title="Python" theme={null}
    import pandaprobe

    pandaprobe.init(
        api_key="your-api-key",
        project_name="my-project",
        endpoint="https://api.pandaprobe.com",
        environment="production",
        release="v1.2.3",
    )
    ```
  </Tab>

  <Tab title="TypeScript">
    ```ts title="TypeScript" theme={null}
    import { init } from "pandaprobe";

    init({
      apiKey: "your-api-key",
      projectName: "my-project",
      endpoint: "https://api.pandaprobe.com",
      environment: "production",
      release: "v1.2.3",
    });
    ```
  </Tab>
</Tabs>

### Precedence rules

Parameters passed to `init` always take precedence over environment variables:

```python title="Python" theme={null}
# Even if PANDAPROBE_ENDPOINT is set in the environment,
# this will use the explicitly provided endpoint:
pandaprobe.init(
    endpoint="https://custom-endpoint.com",
)
```

Precedence order (highest to lowest):

1. Explicit keyword arguments to `pandaprobe.init()`
2. `PANDAPROBE_*` environment variables
3. SDK defaults

TypeScript uses camelCase option names. Python uses snake\_case.

### SdkConfig fields

The resolved configuration is stored as a frozen `SdkConfig` dataclass. You can inspect it via the client:

```python title="Python" theme={null}
client = pandaprobe.init(api_key="...", project_name="...")
print(client.config.endpoint)       # "https://api.pandaprobe.com"
print(client.config.batch_size)     # 10
print(client.config.flush_interval) # 5.0
```

| Field | Type | Default |
| - | - | - |
| `api_key` | `str \| None` | `None` |
| `project_name` | `str \| None` | `None` |
| `endpoint` | `str` | `"https://api.pandaprobe.com"` |
| `environment` | `str \| None` | `None` |
| `release` | `str \| None` | `None` |
| `enabled` | `bool` | `True` |
| `batch_size` | `int` | `10` |
| `flush_interval` | `float` | `5.0` |
| `max_queue_size` | `int` | `1000` |
| `debug` | `bool` | `False` |

The equivalent TypeScript `SdkConfig` fields are `apiKey`, `projectName`, `endpoint`, `environment`, `release`, `enabled`, `batchSize`, `flushInterval`, `maxQueueSize`, and `debug`.

<Warning>
  When tracing is enabled, both the API key and project name are required. Python raises `ValueError`; TypeScript throws `Error` if either value is missing.
</Warning>

### Re-initialization

Calling `pandaprobe.init()` when a client already exists shuts down the previous client and creates a new one:

```python title="Python" theme={null}
pandaprobe.init(project_name="project-a")
# ... traces go to project-a ...

pandaprobe.init(project_name="project-b")
# ... traces now go to project-b ...
```

TypeScript behaves the same way:

```ts title="TypeScript" theme={null}
import { init } from "pandaprobe";

init({ projectName: "project-a" });
// Traces go to project-a.

init({ projectName: "project-b" });
// Traces now go to project-b.
```

### Auto-initialization

If you don't call `pandaprobe.init()`, the SDK auto-initializes from environment variables on first use:

```python title="Python" theme={null}
# No init() call needed if env vars are set:
with pandaprobe.start_trace("my-trace") as t:
    ...
```

Auto-initialization is attempted once. If it fails (for example, missing API key), subsequent calls to `get_client()` return `None` and convenience functions like `flush()` and `shutdown()` silently no-op.

TypeScript also auto-initializes once on first use. If initialization fails, `getClient()` returns `null`; `flush()`, `shutdown()`, and `score()` safely no-op until `init()` is called.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.