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

# Python

> Get started with Netra SDK in Python and begin monitoring your AI applications in just a few minutes

## Installation

Run the following command to install Netra in your environment

```shellscript pip theme={null}
pip install netra-sdk
```

```shellscript poetry theme={null}
poetry add netra-sdk
```

## Optional Dependencies

Netra SDK supports optional dependencies for enhanced functionality:

### Presidio for PII Detetcion

To use the PII detection features provided by Netra SDK:

```shellscript pip theme={null}
pip install 'netra-sdk[presidio]'
```

```shellscript poetry theme={null}
poetry add netra-sdk --extras "presidio"
```

> [!WARNING]
>
> If you try to use the PII detection utility in Netra SDK without installing this dependency, you will receive an exception. So, always make sure to install the package if you plan to use this utility.

### LLM-Guard for Prompt Injection Protection

To use the full functionality of prompt injection scanning provided by llm-guard:

```shellscript pip theme={null}
pip install 'netra-sdk[llm_guard]'
```

```shellscript poetry theme={null}
poetry add netra-sdk --extras "llm_guard"
```

> [!NOTE]
>
> The `llm-guard` package has a dependency on PyTorch, which may cause installation issues on Intel Mac machines. The base SDK will install and function correctly without llm-guard, with limited prompt injection scanning capabilities. When `llm-guard` is not available, Netra will log appropriate warnings and continue to operate with fallback behavior.
>
> ![Hero Light](https://mintlify.s3.us-west-1.amazonaws.com/keyvalue/images/hero-light.png)

## Initialization

### API Key Configuration

To enable Netra SDK tracing, you need to provide an API key. You can obtain your API key from the Netra [dashboard](https://getnetra.ai/).

![Api Key Pn](https://mintcdn.com/keyvalue/gdbAh1XvajZIg5B4/images/api-key.png?fit=max\&auto=format\&n=gdbAh1XvajZIg5B4\&q=85\&s=8bea0fde2942234e9db3195ba014f144)

### Environment Variable Configuration

Add the following environment variables to your application to enable Netra SDK tracing.

```bash theme={null}
export NETRA_OTLP_ENDPOINT="https://api.eu.getnetra.ai/telemetry"
export NETRA_API_KEY="your-api-key-here"
```

### Code Snippet

Follow the code below to initialize Netra in you application. By default, Netra will instrument all the installed packages.

```python Python theme={null}
from netra import Netra
from netra.instrumentation.instruments import InstrumentSet

# Initialize with default settings
Netra.init(app_name="Your application name")

# Or with custom configuration
api_key = "Your API key"
headers = f"x-api-key={api_key}"
Netra.init(
    app_name="Your application name",
    headers=headers,
    trace_content=True,
    environment="Your Application environment"
)
```

## Decorators for Easy Instrumentation

Netra SDK provides decorators like `@workflow`, `@agent`, and `@task` for easy instrumentation of your code. For more details and usage examples, please refer to the [Decorators](https://keyvalue.mintlify.site/tracing/decorators.md) section in our documentation.


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