# Tanso — Agent Integration Guide

## Installation

Install Observe AI cost tracking in your codebase:

```bash
# Using the install prompt (recommended)
# 1. Sign up at https://observe.tansohq.com/signup
# 2. Copy the install prompt from your dashboard
# 3. Paste into Claude Code, Cursor, or Copilot

# Or install the TypeScript SDK directly
npm install @tansohq/sdk
```

## Configuration

### MCP Server (for AI agents)

Add the Tanso MCP server to your agent's configuration:

```json
{
  "mcpServers": {
    "tanso-platform": {
      "url": "https://api.tansohq.com/mcp",
      "headers": {
        "X-API-Key": "sk_test_your_key"
      }
    },
    "tanso-data-lab": {
      "url": "https://data.tansohq.com/api/mcp"
    }
  }
}
```

### API Keys

Generate API keys at https://dashboard.tansohq.com under Settings > API Keys.

- `sk_test_*` — Sandbox keys for development
- `sk_live_*` — Production keys

### Authentication

See the full authentication guide: [Agent Auth](https://tansohq.com/agent-auth.md)

## Usage

### Check Entitlements

```typescript
import { TansoClient } from '@tansohq/sdk';

const tanso = new TansoClient({ apiKey: 'sk_test_...' });
const result = await tanso.checkEntitlement({
  customerReferenceId: 'customer-123',
  featureKey: 'ai-summarization'
});
```

### Ingest Usage Events

```typescript
await tanso.ingestEvent({
  eventName: 'ai_call',
  customerReferenceId: 'customer-123',
  featureKey: 'ai-summarization',
  properties: { model: 'gpt-4o', tokens: 1500 }
});
```

### Query Pricing Data (Data Lab — no auth required)

```typescript
const response = await fetch('https://data.tansohq.com/api/mcp', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    method: 'tools/call',
    params: { name: 'query_companies', arguments: { pricing_model: 'usage-based' } }
  })
});
```

## Resources

- [OpenAPI Spec (Platform)](https://tansohq.com/openapi.json)
- [OpenAPI Spec (Observe)](https://tansohq.com/observe-openapi.json)
- [OpenAPI Spec (Data Lab)](https://tansohq.com/data-openapi.json)
- [LLM Context](https://tansohq.com/llms.txt)
- [MCP Tool Reference](https://tansohq.com/llms-mcp.txt)
- [Source Code](https://github.com/katrinalaszlo/observe)
