Archived
This project has been archived by its maintainers, and is no longer receiving any updates.
EcoTrace AI SDK
Production-oriented AI Workload Observability & Optimization SDK
EcoTrace is a lightweight, provider-agnostic Python SDK for observing, analyzing, and optimizing AI/LLM workloads.
Core Pipeline
OBSERVE ──> DETECT ──> ANALYZE ──> OPTIMIZE ──> MEASURE
- Observe: Capture AI requests and responses across multiple LLM providers.
- Detect: Identify exact duplicate and semantically similar AI requests.
- Analyze: Measure token consumption, latency distribution, and workload efficiency.
- Optimize: Recommend strategies such as caching and model right-sizing.
- Measure: Quantify cost, energy, carbon impact, and calculate composite EcoScore.
Architecture
EcoTrace is built around clean architecture principles and a provider-agnostic data model:
Public API (EcoTrace, @track)
│
▼
Tracking (Tracker, Session, EventEmitter)
│
▼
Capture (RequestCapture, ResponseCapture)
│
▼
Providers (OpenAI, Gemini, Groq, Generic) ──> Storage (MemoryStorage, SQLiteStorage)
│
▼
Analysis / Optimization / Impact (Consume normalized RequestEvent data)
- Provider Agnostic: Normalized
RequestEventabstraction decoupled from specific vendor SDKs. - Zero API Keys Required for Import: The SDK imports and initializes cleanly without requiring live provider credentials.
- Minimal Dependencies: Core SDK depends strictly on the Python Standard Library.
Installation
pip install -e .
Basic Usage
Manual Tracking
from ecotrace import EcoTrace
eco = EcoTrace(project="my-ai-app")
result = eco.track(
provider="openai",
model="gpt-4o-mini",
prompt="Explain quantum computing in simple terms.",
response="Quantum computing uses qubits...",
latency_ms=120.5
)
print(f"Tracked Event ID: {result.event.request_id}")
print(f"Total Tokens: {result.event.total_tokens}")
Decorator Usage
from ecotrace import EcoTrace, track
eco = EcoTrace()
@track(provider="openai", model="gpt-4o-mini")
def ask_ai(prompt: str) -> str:
return "AI response"
response = ask_ai("What is Python?")
SDK Project Structure
ecotrace/
├── __init__.py
├── client.py
├── config.py
├── exceptions.py
│
├── capture/
│ ├── __init__.py
│ ├── request.py
│ └── response.py
│
├── providers/
│ ├── __init__.py
│ ├── base.py
│ ├── openai.py
│ ├── gemini.py
│ ├── groq.py
│ └── generic.py
│
├── tracking/
│ ├── __init__.py
│ ├── tracker.py
│ ├── session.py
│ └── events.py
│
├── analysis/
│ ├── __init__.py
│ ├── duplicates.py
│ ├── similarity.py
│ ├── tokens.py
│ ├── latency.py
│ └── efficiency.py
│
├── optimization/
│ ├── __init__.py
│ ├── optimizer.py
│ ├── recommendations.py
│ └── strategies.py
│
├── impact/
│ ├── __init__.py
│ ├── cost.py
│ ├── energy.py
│ ├── carbon.py
│ └── ecoscore.py
│
├── storage/
│ ├── __init__.py
│ ├── base.py
│ ├── memory.py
│ ├── sqlite.py
│ └── models.py
│
├── integrations/
│ ├── __init__.py
│ └── decorators.py
│
└── utils/
├── __init__.py
├── hashing.py
├── timestamps.py
└── validation.py
Current Status & Next Steps
| Component | Status | Details |
|---|---|---|
| SDK Foundation | ✅ Complete | Package structure, EcoTrace client, RequestEvent data model |
| Provider Abstractions | ✅ Complete | BaseProvider, OpenAIProvider, GeminiProvider, GroqProvider, GenericProvider |
| Storage Layer | ✅ Complete | MemoryStorage and SQLiteStorage |
| Capture & Tracking | ✅ Complete | RequestCapture, ResponseCapture, Tracker, Session, EventEmitter |
| Decorators | ✅ Complete | @track function decorator |
| Duplicate Detection | ✅ Complete | DuplicateDetector using deterministic request hashing |
| Intelligence Modules | 🚧 Planned (Phase 2) | Advanced semantic similarity embeddings, ML optimization strategies |
| Carbon/Energy Models | 🚧 Planned (Phase 2) | Hardware-specific energy calibration and grid-aware intensity models |
| Dashboard & Backend API | 🚧 Planned (Phase 3) | Visual dashboard & FastAPI database endpoints |
License
MIT License #\x00 \x00E\x00c\x00o\x00T\x00r\x00a\x00c\x00e\x00-\x00A\x00I\x00 \x00 \x00
Release files for ecotrace-ai 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ecotrace_ai-0.1.0.tar.gz | 61.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ecotrace_ai-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 130.5 kB
Release files / ecotrace_ai-0.1.0.tar.gz
| Download URL | ecotrace_ai-0.1.0.tar.gz |
|---|---|
| Size | 61.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a31c2e8bad8359b37c1205f48bf4343125d9882866771afbfe06d7bb3291f8a4
|
|
BLAKE2b-256 checksum How to use checksums |
39a04ad38226dd3aac41654ed1315647e52a75840a26171feabb4ed586f4fb48
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Release files / ecotrace_ai-0.1.0-py3-none-any.whl
| Download URL | ecotrace_ai-0.1.0-py3-none-any.whl |
|---|---|
| Size | 68.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
180c627c50862710751996bc594752d514bb6e5937a237800834be177c5d8367
|
|
BLAKE2b-256 checksum How to use checksums |
5dd36888a4ae13e548a68a0ef5bc3ada9b535d3f22132138cec896fd7b6e94e8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|