Skip to main content

Installation

Run the following command to install Netra in your environment
pip install 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:
pip install 'netra-sdk[presidio]'
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:
pip install 'netra-sdk[llm_guard]'
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

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. Api Key Pn

Environment Variable Configuration

Add the following environment variables to your application to enable Netra SDK tracing.
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.
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 section in our documentation.
I