Metadata-Version: 2.4
Name: observio
Version: 0.1.0
Summary: Observio Python SDK
Requires-Python: >=3.8
Requires-Dist: httpx>=0.24.0
Requires-Dist: opentelemetry-api>=1.20.0
Requires-Dist: opentelemetry-exporter-otlp>=1.20.0
Requires-Dist: opentelemetry-sdk>=1.20.0
Requires-Dist: pydantic>=2.0
Description-Content-Type: text/markdown

# Observio Python SDK

Observio is an open-source, full-stack LLM observability and evaluation platform. It helps you trace agentic workflows, capture nested tool invocations, log input/output tokens, and attribute costs across multiple AI models seamlessly.

## Features

- **Full-Stack Tracing**: Capture backend, tool, and LLM layers with zero friction.
- **Dynamic Auto-Decorators**: Decorate functions using `@observe()` to automatically start and stop tracing spans.
- **OpenTelemetry Standard**: Built on standard OpenTelemetry semantic conventions for AI.
- **Cost & Token Attribution**: Track precise model pricing and token counts on spans.

## Installation

Install the SDK via `pip`:

```bash
pip install observio
```

## Quick Start

### 1. Initialization

Initialize the SDK at the start of your application:

```python
from observio import Observio

Observio.initialize(
    project_api_key="your-observio-project-api-key",
    base_url="http://localhost:8000",        # Base URL of your local or hosted Observio instance
    force_http=True                          # Set to True for local development
)
```

### 2. Tracing Functions

Use the `@observe()` decorator to trace any function or RAG component:

```python
from observio import observe

@observe()
def call_llm(prompt: str):
    # Traced under a single span
    return "This response is traced"

@observe()
def process_rag_pipeline(query: str):
    context = retrieve_context(query)
    response = call_llm(query)
    return response
```

### 3. Adding Span Attributes

Enhance your spans with rich context metadata:

```python
from opentelemetry import trace
from observio import observe

@observe()
def embed_text(text: str):
    span = trace.get_current_span()
    # Categorize the layer
    span.set_attribute("observio.layer", "ai")
    # Log usage metrics
    span.set_attribute("gen_ai.usage.input_tokens", len(text) // 4)
    span.set_attribute("lmnr.span.total_cost", 0.0001)
    return [0.1, 0.2, 0.3]
```
