Quickstart

Server running, first agent tracked, data in the dashboard — in under five minutes.

1. Start the AgentMetrics server

AgentMetrics runs as a local server. Your SDK sends data to it. Start the server before doing anything else.

Installs as an OS service (systemd on Linux, launchd on macOS, Task Scheduler on Windows). Starts on boot, runs in the background.

Shell
pip install agentmetrics-server
agentmetrics install

Requires Python 3.11+.

Dashboard: http://localhost:3099 API: http://localhost:8099

2. Get an API key

Open http://localhost:3099 and go to Settings to generate a key.

Note

Running locally for development? Any non-empty string works as the key.

3. Install the SDK

Shell
pip install agentmetrics

Requires Python 3.9+.

4. Configure

Call configure() once at startup, before any tracking calls.

Python
import os
import agentmetrics

agentmetrics.configure(
    api_key=os.environ["AGENTMETRICS_API_KEY"],
    base_url="http://localhost:8099",
)

5. Enable token and cost tracking

Call instrument() once after configure(). It patches LLM client libraries to capture token counts and cost on every call.

Python
agentmetrics.instrument()

Supports: OpenAI, Anthropic, LiteLLM, Google Gemini, Cohere, Mistral, LangChain, LlamaIndex.

6. Wrap your agent

Python
@agentmetrics.track(agent_id="my-agent")
def my_agent(task: str) -> str:
    answer = call_llm(task)
    return answer

7. Run it and check the dashboard

Python
result = my_agent("summarize this document")

Open http://localhost:3099 — your run appears within a few seconds.

What gets tracked automatically

Every invocation captures:

  • Duration (wall-clock, from call to return)
  • Success or failure status
  • Error message if the function raises or throws
  • Cost and token usage across all LLM calls (when instrument() is called)

Next steps

Using a framework instead of the raw SDK?

Full SDK reference: Python SDK · JavaScript SDK

Deploying for a team or to the cloud? See Deploy.