Skip to main content
The Kindred tracer automatically intercepts HTTP requests from your AI agent, classifies them as LLM or tool calls, and exports logs to Kindred. Call it once at startup; no per-request wrapping is required.

Node.js

Installation

npm install kindred-tracer-node
# or
pnpm add kindred-tracer-node

Basic usage

Call kindredTracer() once at startup. All HTTP requests from your process will be intercepted and logged.
import { kindredTracer } from 'kindred-tracer-node';

// At startup — initialize the tracer
kindredTracer();

// Your agent code — no wrapping needed
const response = await fetch('https://api.openai.com/v1/chat/completions', {
  method: 'POST',
  body: JSON.stringify({ /* ... */ })
});

Configuration

Set these environment variables:
VariableRequiredDescription
KINDRED_API_KEYYesYour Kindred API key (from the web dashboard)
KINDRED_API_URLNoKindred API base URL; defaults to https://api.usekindred.dev
KINDRED_SESSION_IDNoSession identifier; auto-generated UUID if not set
KINDRED_AGENT_IDNoAgent identifier
KINDRED_RUN_IDNoRun identifier
You can also pass values directly:
import { kindredTracer } from 'kindred-tracer-node';

kindredTracer('session-123', 'agent-456', 'run-789');

Flushing logs

Before shutdown, flush any pending logs:
import { flushLogs } from 'kindred-tracer-node';

await flushLogs();

Full Node example

import { kindredTracer, flushLogs } from 'kindred-tracer-node';

process.env.KINDRED_API_KEY = 'your-api-key-here';

kindredTracer();

const response = await fetch('https://api.openai.com/v1/chat/completions', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    model: 'gpt-4',
    messages: [{ role: 'user', content: 'Hello!' }]
  })
});

await flushLogs();

Python

Installation

pip install kindred-tracer
With optional dependencies:
pip install kindred-tracer[all]   # Includes requests support

Basic usage

Call kindred_tracer() once at startup. All HTTP requests (including those from the OpenAI SDK) will be intercepted and logged.
from kindred_tracer import kindred_tracer
import openai

kindred_tracer()

client = openai.OpenAI()
response = client.chat.completions.create(
    model="gpt-4",
    messages=[{"role": "user", "content": "Hello!"}]
)

Async usage

Same pattern with async:
import asyncio
from kindred_tracer import kindred_tracer
from openai import AsyncOpenAI

kindred_tracer()

async def main():
    client = AsyncOpenAI()
    response = await client.chat.completions.create(
        model="gpt-4",
        messages=[{"role": "user", "content": "Hello!"}]
    )

asyncio.run(main())

Configuration

Same environment variables as Node:
VariableRequiredDescription
KINDRED_API_KEYYesYour Kindred API key (from the web dashboard)
KINDRED_API_URLNoKindred API base URL; defaults to https://api.usekindred.dev
KINDRED_SESSION_IDNoSession identifier; auto-generated if not set
KINDRED_AGENT_IDNoAgent identifier
KINDRED_RUN_IDNoRun identifier
Or pass explicitly:
from kindred_tracer import kindred_tracer

kindred_tracer(session_id='session-123', agent_id='agent-456', run_id='run-789')

Flushing logs

Before shutdown:
from kindred_tracer import flush

flush()

Full Python example

from kindred_tracer import kindred_tracer, flush
import openai
import os

os.environ['KINDRED_API_KEY'] = 'your-api-key-here'

kindred_tracer()

client = openai.OpenAI()
response = client.chat.completions.create(
    model="gpt-4",
    messages=[{"role": "user", "content": "Hello!"}]
)

flush()

How it works

  1. One-time init — Calling kindredTracer() / kindred_tracer() sets global context and enables interception.
  2. Auto-instrumentation — Node patches https.request / http.request; Python patches httpx (used by OpenAI SDK v1+).
  3. Request detection — Requests to known LLM hostnames are logged as agent (LLM); others as tool.
  4. Non-blocking export — Logs are batched and sent asynchronously so your agent is not slowed down.

Supported LLM providers

The tracer detects requests to:
  • OpenAI (api.openai.com)
  • Anthropic (api.anthropic.com)
  • Google Gemini (generativelanguage.googleapis.com)
  • Cohere (api.cohere.com)
  • Mistral (api.mistral.ai)
Other hosts are logged as tool executions.

Security

Sensitive headers are sanitized before logging:
  • Authorization
  • x-api-key
  • api-key
  • x-auth-token
  • cookie

Next steps