Metadata-Version: 2.4
Name: respan-sdk
Version: 2.6.26
Summary: Respan SDK allows you to interact with the Respan API smoothly
License: MIT
Author: Respan
Author-email: team@respan.ai
Requires-Python: >3.9,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Provides-Extra: dev
Requires-Dist: dateparser (>=1.2.0,<2.0.0)
Requires-Dist: pydantic (>=2.10.3,<3.0.0)
Requires-Dist: requests (>=2.31.0,<3.0.0)
Requires-Dist: typing-extensions (>=4.12.2,<5.0.0)
Project-URL: Documentation, https://docs.respan.ai
Project-URL: Homepage, https://respan.ai
Project-URL: Repository, https://github.com/respan-ai/respan-sdks.git
Description-Content-Type: text/markdown

## Respan SDK

**[respan.ai](https://respan.ai)** | **[Documentation](https://docs.respan.ai)** | **[PyPI](https://pypi.org/project/respan-sdk/)**

Light weight library for Respan type definitions and API payload preprocessing

Features:
- Definition of types, what data structure Respan expects to receive in API calls.
- Preprocessing, separating Respan-specific parameters from LLM-specific parameters
- Conversion, converting input types from Anthropic API format into OpenAI API format.
- **Filter types** — typed vocabulary for the Respan filter system, shared across BE and SDKs.

For **tracing**, please go to [Respan Tracing](https://github.com/respan-ai/respan-sdks/tree/main/python-sdks/respan-tracing) instead.

### Filter Types

The SDK exports the full Respan filter vocabulary so every package (backend, tracing, exporters) uses the same typed definitions instead of raw dicts.

```python
from respan_sdk import (
    # TypedDict versions (lightweight, no validation)
    FilterParamDict,      # Dict[str, MetricFilterParam | List[MetricFilterParam] | FilterBundle]
    MetricFilterParam,    # Single filter condition (operator + value)
    FilterBundle,         # Nested group with connector (AND/OR)

    # Pydantic versions (with validation)
    FilterParamDictPydantic,
    MetricFilterParamPydantic,
    FilterBundlePydantic,

    # Value type
    MetricFilterValueType,  # Union[str, int, float, bool, List[...]]
)
```

**Operators** — the full operator vocabulary available in `operator` field:

| Category | Operators |
|----------|-----------|
| Equality | `""`, `"="`, `"=="`, `"eq"`, `"equals"` |
| Negation | `"not"` |
| Numeric | `"gt"`, `"gte"`, `"lt"`, `"lte"` |
| String | `"contains"`, `"icontains"`, `"startswith"`, `"endswith"`, `"ilike"`, `"regex"` |
| Membership | `"in"` |
| Null/Empty | `"isnull"`, `"empty"`, `"notEmpty"`, `"not_empty"` |
| Search | `"trigram_word_similar"`, `"full_text_search"` |

**Example — filter spans by status:**
```python
export_filter: FilterParamDict = {
    "status_code": {"operator": "", "value": "ERROR"},
}
```

**Example — numeric range:**
```python
export_filter: FilterParamDict = {
    "latency": {"operator": "gte", "value": 1000},
}
```

**Example — nested bundle with OR:**
```python
export_filter: FilterParamDict = {
    "model": {"operator": "in", "value": ["gpt-4", "claude-3"]},
    "filter_bundle": {
        "connector": "OR",
        "filter_params": {
            "status_code": {"operator": "", "value": "ERROR"},
            "latency": {"operator": "gte", "value": 5000},
        },
    },
}
```

