Metadata-Version: 2.4
Name: cetra-sdk
Version: 0.1.0rc3
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-agno>=1.2.0 ; extra == 'agno'
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-groq>=0.1.40 ; extra == 'all'
Requires-Dist: openinference-instrumentation-mistralai>=2.3.5 ; extra == 'all'
Requires-Dist: openinference-instrumentation-cohere>=0.1.22 ; extra == 'all'
Requires-Dist: openinference-instrumentation-ollama>=0.1.20 ; extra == 'all'
Requires-Dist: openinference-instrumentation-together>=0.1.20 ; extra == 'all'
Requires-Dist: openinference-instrumentation-instructor>=0.1.35 ; python_full_version < '3.14' and extra == 'all'
Requires-Dist: openinference-instrumentation-agno>=1.2.0 ; extra == 'all'
Requires-Dist: openinference-instrumentation-smolagents>=0.1.50 ; extra == 'all'
Requires-Dist: openinference-instrumentation-haystack>=0.1.53 ; extra == 'all'
Requires-Dist: openinference-instrumentation-beeai>=0.1.36 ; python_full_version < '3.15' and extra == 'all'
Requires-Dist: openinference-instrumentation-mcp>=2.1.5 ; 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-beeai>=0.1.36 ; python_full_version < '3.15' and extra == 'beeai'
Requires-Dist: openinference-instrumentation-cohere>=0.1.22 ; extra == 'cohere'
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-groq>=0.1.40 ; extra == 'groq'
Requires-Dist: openinference-instrumentation-haystack>=0.1.53 ; extra == 'haystack'
Requires-Dist: openinference-instrumentation-instructor>=0.1.35 ; python_full_version < '3.14' and extra == 'instructor'
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-mcp>=2.1.5 ; extra == 'mcp'
Requires-Dist: openinference-instrumentation-mistralai>=2.3.5 ; extra == 'mistralai'
Requires-Dist: openinference-instrumentation-ollama>=0.1.20 ; extra == 'ollama'
Requires-Dist: openinference-instrumentation-openai>=0.1.69 ; extra == 'openai'
Requires-Dist: openinference-instrumentation-openai-agents>=2.7.1 ; extra == 'openai-agents'
Requires-Dist: openinference-instrumentation-smolagents>=0.1.50 ; extra == 'smolagents'
Requires-Dist: openinference-instrumentation-together>=0.1.20 ; extra == 'together'
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: agno
Provides-Extra: all
Provides-Extra: anthropic
Provides-Extra: bedrock
Provides-Extra: beeai
Provides-Extra: cohere
Provides-Extra: crewai
Provides-Extra: dspy
Provides-Extra: google-genai
Provides-Extra: groq
Provides-Extra: haystack
Provides-Extra: instructor
Provides-Extra: langchain
Provides-Extra: litellm
Provides-Extra: llama-index
Provides-Extra: mcp
Provides-Extra: mistralai
Provides-Extra: ollama
Provides-Extra: openai
Provides-Extra: openai-agents
Provides-Extra: smolagents
Provides-Extra: together
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]` |
| `groq` | `cetra-sdk[groq]` |
| `mistralai` | `cetra-sdk[mistralai]` |
| `cohere` | `cetra-sdk[cohere]` |
| `ollama` | `cetra-sdk[ollama]` |
| `together` | `cetra-sdk[together]` |
| `instructor` | `cetra-sdk[instructor]` |
| `agno` | `cetra-sdk[agno]` |
| `smolagents` | `cetra-sdk[smolagents]` |
| `haystack` | `cetra-sdk[haystack]` |
| `beeai` | `cetra-sdk[beeai]` |
| `mcp` | `cetra-sdk[mcp]` |
| `autogen-agentchat` | `pip install openinference-instrumentation-autogen-agentchat` |

The `instructor` and `beeai` distributions do not support every Python
version: the `instructor` extra installs on Python 3.13 or earlier, and `beeai`
on Python 3.14 or earlier.

`cetra-sdk[all]` installs every instrumentor that has an extra. 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).
