INTEGRATIONS

Works with every LLM you already use

One line of setup auto-instruments your existing API calls — no wrappers, no base URL changes, no refactors. Supports every major provider and framework.

Quick setup

Install the SDK, call tokenr.init(), and every LLM API call your application makes is automatically tracked — no changes to existing code.

# Install
pip install tokenr

# One line to instrument everything
import tokenr
tokenr.init("tk_live_...")  # auto-patches OpenAI, Anthropic, Google

# Your existing code — unchanged
from openai import OpenAI
client = OpenAI()
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello"}],
    # Optional attribution metadata
    tokenr_agent_id="support-bot",
    tokenr_team_id="customer-success",
    tokenr_feature="ticket-triage"
)
# Install
gem install tokenr

# Configure
require "tokenr"
Tokenr.configure { |c| c.api_key = ENV["TOKENR_TOKEN"] }

# Wrap your OpenAI client
client = OpenAI::Client.new
tracked = Tokenr::Integrations::OpenAI.wrap(
  client,
  agent_id: "support-bot",
  team_id: "customer-success"
)

# Use tracked client exactly like the original
response = tracked.chat(
  parameters: { model: "gpt-4o", messages: [...] }
)
# Track any LLM call via REST — works from any language
curl -X POST https://tokenr.co/api/v1/track \
  -H "Authorization: Bearer tk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "openai",
    "model": "gpt-4o",
    "input_tokens": 412,
    "output_tokens": 183,
    "agent_id": "support-bot",
    "team_id": "customer-success",
    "feature": "ticket-triage",
    "latency_ms": 834
  }'

Supported LLM providers

The Python SDK auto-patches the official client library for each provider. No code changes needed — Tokenr instruments the client at import time.

OpenAI Auto-patch

GPT-4o, GPT-4o-mini, GPT-4.1, o1, o3, o4-mini, text-embedding-3, DALL-E

import tokenr, openai
tokenr.init("tk_live_...")
client = openai.OpenAI()  # auto-tracked
OpenAI pricing →
Anthropic Auto-patch

Claude 3.5 Sonnet, Claude 3.5 Haiku, Claude 3 Opus, Claude 4 family

import tokenr, anthropic
tokenr.init("tk_live_...")
client = anthropic.Anthropic()  # auto-tracked
Anthropic pricing →
Google (Gemini) Auto-patch

Gemini 2.5 Pro, Gemini 2.0 Flash, Gemini 1.5 Pro, Gemini 1.5 Flash

import tokenr, google.generativeai as genai
tokenr.init("tk_live_...")
model = genai.GenerativeModel("gemini-2.0-flash")  # auto-tracked
Google pricing →
xAI (Grok) REST API

Grok-2, Grok-3, Grok-3 Mini, Grok Vision

# xAI uses OpenAI-compatible API
import tokenr, openai
tokenr.init("tk_live_...")
client = openai.OpenAI(
    api_key=XAI_KEY,
    base_url="https://api.x.ai/v1"
)
xAI pricing →
Mistral REST API

Mistral Large, Mistral Small, Mistral 7B, Codestral, Mixtral

# Mistral via OpenAI-compatible client
import tokenr, openai
tokenr.init("tk_live_...")
client = openai.OpenAI(
    api_key=MISTRAL_KEY,
    base_url="https://api.mistral.ai/v1"
)
Mistral pricing →
Cohere REST API

Command R+, Command R, Command Light, Embed models

# Track Cohere via REST
curl -X POST https://tokenr.co/api/v1/track \
  -H "Authorization: Bearer tk_live_..." \
  -d '{"provider":"cohere","model":"command-r-plus",
       "input_tokens":512,"output_tokens":210}'
Cohere pricing →
DeepSeek REST API

DeepSeek R1, DeepSeek V3, DeepSeek Chat

# DeepSeek via OpenAI-compatible client
import tokenr, openai
tokenr.init("tk_live_...")
client = openai.OpenAI(
    api_key=DEEPSEEK_KEY,
    base_url="https://api.deepseek.com"
)
DeepSeek pricing →
MiniMax REST API

MiniMax M2, MiniMax Text, MiniMax Speech

# Track MiniMax via REST
curl -X POST https://tokenr.co/api/v1/track \
  -H "Authorization: Bearer tk_live_..." \
  -d '{"provider":"minimax","model":"minimax-m2",
       "input_tokens":380,"output_tokens":145}'
MiniMax pricing →
Azure OpenAI Auto-patch

All OpenAI models deployed via Azure OpenAI Service

import tokenr
from openai import AzureOpenAI
tokenr.init("tk_live_...")
client = AzureOpenAI(
    azure_endpoint=AZURE_ENDPOINT,
    api_key=AZURE_KEY
)  # auto-tracked via OpenAI patch
See pricing hub →

Framework compatibility

Tokenr patches the underlying client libraries, not the framework. This means it works automatically with any framework that calls the official SDKs — no framework-specific integration needed.

LangChain
Works automatically

LangChain calls the OpenAI/Anthropic SDK under the hood. Tokenr's patch intercepts those calls transparently.

LlamaIndex
Works automatically

LlamaIndex uses official provider SDKs. Auto-patched by Tokenr at init time.

AutoGen
Works automatically

Microsoft AutoGen agents call the OpenAI SDK. Tokenr tracks all calls made by agents and sub-agents.

CrewAI
Works automatically

CrewAI routes through the OpenAI SDK. Each agent's cost appears separately in Tokenr when tagged with an agent ID.

Direct API calls
Works automatically

No framework at all — just openai.OpenAI() or anthropic.Anthropic(). Tokenr patches these directly.

LiteLLM (library mode)
Works automatically

When LiteLLM is used as a library (not a proxy server), it calls the provider SDKs. Tokenr patches apply.

Portkey / Helicone (proxy mode)
Use REST API

When requests go through a proxy, the SDK patch has no effect. Use the Tokenr REST API to track from the proxy layer, or run Tokenr alongside via the SDK.

Any language (Go, Java, Rust, etc.)
Use REST API

The Python and Ruby SDKs cover those runtimes. For any other language, use the POST /api/v1/track endpoint directly — see the API docs.

Attribution metadata

Tag every API call with the dimensions that matter to your organization. These tags ride alongside your existing API calls as extra kwargs — no wrapper functions, no changed return values.

tokenr_agent_id

Which agent or service made the call. Use this to see cost broken down by agent in the dashboard. Example: "support-bot", "code-reviewer".

tokenr_team_id

Which team owns this agent or feature. Enables team-level cost rollups and role-based access. Example: "platform", "customer-success".

tokenr_feature

Which product feature triggered this call. Use this to break down cost by feature within an agent. Example: "ticket-summarization", "rag-retrieval".

tokenr_tags

Arbitrary key-value metadata for custom segmentation. Example: {"env": "production", "customer_tier": "enterprise"}.

START IN 60 SECONDS

One line. Every provider. Full attribution.

Free tier. No credit card. No infra to maintain.

Also see: AI FinOps guide · LLM Pricing Hub · Blog