Metadata-Version: 2.4
Name: tmam
Version: 1.6.1
Summary: OpenTelemetry-native Auto instrumentation library for monitoring LLM Applications and GPUs, facilitating the integration of observability into your GenAI-driven projects
License: Apache-2.0
License-File: LICENSE
Keywords: OpenTelemetry,otel,otlp,llm,tracing,openai,anthropic,claude,cohere,llm monitoring,observability,monitoring,gpt,Generative AI,chatGPT,gpu
Author: Tmam
Requires-Python: >=3.12.1,<4.0.0
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Dist: anthropic (>=0.49.0,<0.50.0)
Requires-Dist: boto3 (>=1.37.21,<2.0.0)
Requires-Dist: botocore (>=1.37.21,<2.0.0)
Requires-Dist: openai (>=1.68.2,<2.0.0)
Requires-Dist: opentelemetry-api (>=1.31.1,<2.0.0)
Requires-Dist: opentelemetry-exporter-otlp (>=1.31.1,<2.0.0)
Requires-Dist: opentelemetry-instrumentation (>=0.52b1,<0.53)
Requires-Dist: opentelemetry-sdk (>=1.31.1,<2.0.0)
Requires-Dist: pydantic (>=2.10.6,<3.0.0)
Requires-Dist: requests (>=2.32.3,<3.0.0)
Requires-Dist: schedule (>=1.2.2,<2.0.0)
Requires-Dist: xmltodict (>=0.14.2,<0.15.0)
Project-URL: Homepage, https://github.com/python
Project-URL: Repository, https://github.com/python
Description-Content-Type: text/markdown

# tmam

[![PyPI version](https://badge.fury.io/py/tmam.svg)](https://pypi.org/project/tmam/)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)

OpenTelemetry-native auto-instrumentation library for monitoring LLM applications, enabling cost tracking, tracing, and observability for your GenAI projects.

## Installation

```bash
pip install tmam
```

## Quick Start

```python
import tmam
from openai import OpenAI

# Initialize tmam — auto-instruments all supported LLM providers
tmam.init(
    environment="production",
    application_name="my-llm-app",
)

# Use OpenAI as normal — calls are automatically traced
client = OpenAI()
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello, world!"}],
)
print(response.choices[0].message.content)
# Traces with token counts, latency, and cost appear in your tmam dashboard
```

## Features

- **Auto-instrumentation** for 40+ LLM providers (OpenAI, Anthropic, Cohere, Mistral, Bedrock, VertexAI, and more)
- **Tracing** with `@tmam.trace()` decorator and `tmam.start_trace()` context manager
- **Metrics** collection for token usage, cost, latency, and request volume
- **Evaluations** with built-in evaluators for hallucination, bias, and toxicity detection
- **Experiments** for running dataset-driven evaluations with concurrency control
- **Vault** integration for secure secret retrieval
- **GPU monitoring** for GPU utilization and memory tracking

## Configuration

| Environment Variable | Description | Default |
|---------------------|-------------|---------|
| `OTEL_EXPORTER_OTLP_ENDPOINT` | tmam API endpoint | `https://api.tmam.ai` |
| `OTEL_EXPORTER_OTLP_HEADERS` | Headers including API key (`x-api-key=pk_xxx.sk_xxx`) | — |

| Init Parameter | Description | Default |
|---------------|-------------|---------|
| `environment` | Deployment environment name | `'default'` |
| `application_name` | Application name for grouping traces | `'default'` |
| `otlp_endpoint` | Override OTLP endpoint | env var |
| `otlp_headers` | Override OTLP headers dict | env var |

## Cost Allocation Tags

Track spending by team, department, or cost center using API key tags:

1. Go to **Settings > API Keys** in the platform
2. Add tags to your API key (e.g., `team: engineering`, `department: ML`)
3. View cost breakdowns by tag in **Cost Explorer**

## Guides

- [Error Handling & Troubleshooting](docs/error-handling.md)
- [FastAPI Integration](docs/fastapi-integration.md)
- [Changelog](docs/CHANGELOG.md)

## License

Apache 2.0 — see [LICENSE](LICENSE) for details.

