Metadata-Version: 2.4
Name: cetra-sdk
Version: 0.1.0rc2
Summary: Python SDK for the cetra observability server.
Keywords: llm,observability,opentelemetry,tracing,evaluation
License-Expression: MIT
License-File: LICENSE
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Typing :: Typed
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Topic :: System :: Monitoring
Requires-Dist: opentelemetry-api>=1.45.2,<2
Requires-Dist: opentelemetry-sdk>=1.45.2,<2
Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.45.2,<2
Requires-Dist: requests>=2.32
Requires-Dist: openinference-instrumentation-openai>=0.1.69 ; extra == 'all'
Requires-Dist: openinference-instrumentation-anthropic>=3.3.0 ; extra == 'all'
Requires-Dist: openinference-instrumentation-langchain>=0.1.82 ; extra == 'all'
Requires-Dist: openinference-instrumentation-llama-index>=4.7.1 ; extra == 'all'
Requires-Dist: openinference-instrumentation-litellm>=0.1.53 ; extra == 'all'
Requires-Dist: openinference-instrumentation-google-genai>=1.5.1 ; extra == 'all'
Requires-Dist: openinference-instrumentation-bedrock>=0.1.63 ; extra == 'all'
Requires-Dist: openinference-instrumentation-openai-agents>=2.7.1 ; extra == 'all'
Requires-Dist: openinference-instrumentation-crewai>=1.1.23 ; extra == 'all'
Requires-Dist: openinference-instrumentation-dspy>=0.1.50 ; extra == 'all'
Requires-Dist: openinference-instrumentation-anthropic>=3.3.0 ; extra == 'anthropic'
Requires-Dist: openinference-instrumentation-bedrock>=0.1.63 ; extra == 'bedrock'
Requires-Dist: openinference-instrumentation-crewai>=1.1.23 ; extra == 'crewai'
Requires-Dist: openinference-instrumentation-dspy>=0.1.50 ; extra == 'dspy'
Requires-Dist: openinference-instrumentation-google-genai>=1.5.1 ; extra == 'google-genai'
Requires-Dist: openinference-instrumentation-langchain>=0.1.82 ; extra == 'langchain'
Requires-Dist: openinference-instrumentation-litellm>=0.1.53 ; extra == 'litellm'
Requires-Dist: openinference-instrumentation-llama-index>=4.7.1 ; extra == 'llama-index'
Requires-Dist: openinference-instrumentation-openai>=0.1.69 ; extra == 'openai'
Requires-Dist: openinference-instrumentation-openai-agents>=2.7.1 ; extra == 'openai-agents'
Requires-Python: >=3.11
Project-URL: Homepage, https://cetra.sh
Project-URL: Documentation, https://cetra.sh/docs/reference/python/
Project-URL: Repository, https://github.com/cetra-ai/cetra
Project-URL: Issues, https://github.com/cetra-ai/cetra/issues
Project-URL: Changelog, https://github.com/cetra-ai/cetra/blob/main/CHANGELOG.md
Provides-Extra: all
Provides-Extra: anthropic
Provides-Extra: bedrock
Provides-Extra: crewai
Provides-Extra: dspy
Provides-Extra: google-genai
Provides-Extra: langchain
Provides-Extra: litellm
Provides-Extra: llama-index
Provides-Extra: openai
Provides-Extra: openai-agents
Description-Content-Type: text/markdown

# Python SDK

`cetra` is the Python SDK for cetra, the single-binary LLM observability
server. It is a thin layer over OpenTelemetry: spans go out as OTLP/HTTP
protobuf to `<base_url>/v1/traces`, and scores go to
`<base_url>/api/v1/scores`. Python >= 3.11. MIT.

The server stores traces only. If another OpenTelemetry GenAI instrumentation sends prompts
and completions as log events, they reach `/v1/logs` and are dropped; the project shows a hint
in the UI. Set that instrumentation to capture message content on spans.

## Install

```bash
pip install cetra-sdk
```

Auto-instrumentation is optional, one extra per library:

| `instrument` name | Extra |
|---|---|
| `openai` | `cetra-sdk[openai]` |
| `anthropic` | `cetra-sdk[anthropic]` |
| `langchain` | `cetra-sdk[langchain]` |
| `llama-index` | `cetra-sdk[llama-index]` |
| `litellm` | `cetra-sdk[litellm]` |
| `google-genai` | `cetra-sdk[google-genai]` |
| `bedrock` | `cetra-sdk[bedrock]` |
| `openai-agents` | `cetra-sdk[openai-agents]` |
| `crewai` | `cetra-sdk[crewai]` |
| `dspy` | `cetra-sdk[dspy]` |

`cetra-sdk[all]` installs every instrumentor. The core package pulls in only
`opentelemetry-api`, `opentelemetry-sdk`, `opentelemetry-exporter-otlp-proto-http`
and `requests`.

## Quick start

<!-- test -->
```python
import cetra

cetra.init(api_key="sk-cetra-test")


@cetra.observe(kind="tool", name="search_docs")
def search_docs(query: str, limit: int = 2) -> list[str]:
    return ["doc-1", "doc-2"]


@cetra.observe(name="answer")
def answer(question: str) -> str:
    docs = search_docs(question)
    return f"It is in {docs[0]}."


answer("why?")

cetra.flush()  # blocks until spans (and scores) are exported
```

`init()` is called once per process; it also registers an `atexit` hook that
calls `shutdown()` (flush, then stop). `flush()` is the manual lever when you
need the data out now — see [Serverless](https://cetra.sh/docs/reference/python/opentelemetry/#serverless).

Without an API key (argument and `CETRA_API_KEY` both unset), `init()` logs
one warning — `cetra: no API key; set CETRA_API_KEY, or CETRA_ENABLED=false
to silence this; tracing is disabled` — and the SDK runs as a no-op: nothing
raises, nothing is sent. Set `CETRA_ENABLED=false` to silence the warning.

## Documentation

The full guide and reference are at https://cetra.sh/docs/reference/python/ (configuration,
tracing, context, scores, datasets and experiments, OpenTelemetry, the API).
