Metadata-Version: 2.4
Name: bryel
Version: 0.1.0
Summary: OpenTelemetry-native tracing for LLM apps and agents — ships OpenInference/OTLP traces to bryel.
Project-URL: Homepage, https://docs.bryel.ai
Project-URL: Documentation, https://docs.bryel.ai
Author: bryel
License-Expression: MIT
Keywords: bryel,genai,llm,observability,openinference,opentelemetry,tracing
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Requires-Dist: opentelemetry-api>=1.20.0
Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.20.0
Requires-Dist: opentelemetry-sdk>=1.20.0
Provides-Extra: anthropic
Requires-Dist: openinference-instrumentation-anthropic; extra == 'anthropic'
Provides-Extra: bedrock
Requires-Dist: openinference-instrumentation-bedrock; extra == 'bedrock'
Provides-Extra: langchain
Requires-Dist: openinference-instrumentation-langchain; extra == 'langchain'
Provides-Extra: llama-index
Requires-Dist: openinference-instrumentation-llama-index; extra == 'llama-index'
Provides-Extra: openai
Requires-Dist: openinference-instrumentation-openai; extra == 'openai'
Description-Content-Type: text/markdown

# bryel (Python)

OpenTelemetry-native tracing for LLM apps and agents. One call ships your model
calls, tool calls, tokens, and cost to [bryel](https://docs.bryel.ai) as
OpenInference traces — from any framework.

```bash
uv add bryel            # or: pip install bryel
```

## Quickstart

```python
import bryel
bryel.init(api_key="bk_…", service_name="my-app")

# Trace OpenAI (any OpenInference instrumentor works the same way):
from openinference.instrumentation.openai import OpenAIInstrumentor
OpenAIInstrumentor().instrument()

from openai import OpenAI
OpenAI().chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "hello"}],
)
```

Prefer bryel to wire up everything it can find? Let it instrument every installed
OpenInference library for you:

```python
import bryel
bryel.init(api_key="bk_…", instrument=True)   # instruments openai, anthropic, langchain, …
```

## How it works

bryel is just the exporter. It configures an OpenTelemetry `TracerProvider` with
an OTLP/HTTP exporter pointed at the bryel ingest, authenticated with your API
key. The [OpenInference instrumentors](https://github.com/Arize-ai/openinference)
emit the spans; bryel's ingest normalizes both the OpenInference (`llm.*`) and
OpenTelemetry GenAI (`gen_ai.*`) conventions — so there's nothing to map.

## API

### `bryel.init(api_key=None, *, service_name=None, endpoint=None, headers=None, set_global=True, instrument=False)`

Configures the exporter and returns the `TracerProvider`.

- `api_key` — your project API key (`bk_…`). Falls back to `$BRYEL_KEY`.
- `service_name` — OpenTelemetry `service.name`.
- `endpoint` — OTLP/HTTP traces URL. Defaults to the bryel ingest, or
  `$BRYEL_INGEST_URL` for self-hosting.
- `headers` — extra headers, merged after auth.
- `set_global` — register as the global OTel provider (default `True`).
- `instrument` — also auto-instrument installed OpenInference libraries.

### `bryel.auto_instrument(tracer_provider=None) -> list[str]`

Best-effort instrument every installed OpenInference library. Returns the ones it
wired up. Safe to call with none installed.

### `bryel.shutdown()`

Flush pending spans and shut down. Call on process exit.

## Feedback and grouping

Group turns into a conversation and attach 👍/👎 by stamping metadata on your
spans — set `session.id`, `user.id`, and a `bryel.interaction.id` you mint. See
the [docs](https://docs.bryel.ai).

MIT © bryel
