# AgentMetrics SDK

Real-time cost tracking for AI agents. One decorator. Full visibility.

## Install

```bash
pip install agentmetrics
```

## Quick Start

```python
from agentmetrics import sentinel

# Configure once at startup
sentinel.configure(api_key="am_your_key_here")

# Decorate any agent function
@sentinel.track(agent_id="customer_support")
def my_agent(task: str) -> str:
    # Your agent logic here
    return result
```

## Async Support

```python
@sentinel.track(agent_id="async_agent")
async def my_async_agent(task: str) -> str:
    result = await some_llm_call(task)
    return result
```

## With LangGraph

```python
from agentmetrics import sentinel
sentinel.configure(api_key="am_your_key_here")

@sentinel.track(agent_id="langgraph_agent")
def run_graph(state: dict) -> dict:
    return graph.invoke(state)
```

## With CrewAI

```python
from agentmetrics import sentinel
sentinel.configure(api_key="am_your_key_here")

@sentinel.track(agent_id="research_crew")
def run_crew(topic: str) -> str:
    return crew.kickoff(inputs={"topic": topic})
```

## Self-Hosted

Point the SDK at your own server:

```python
sentinel.configure(
    api_key="am_your_key_here",
    base_url="https://your-server.com/v1",
)
```

## Graceful Degradation

If the AgentMetrics server is unreachable, your agent keeps running normally.
The SDK never raises exceptions or blocks execution.

## License

Apache 2.0
