> ## Documentation Index
> Fetch the complete documentation index at: https://tracevell.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# TypeScript Instrumentation

## Laminar.initialize(options?)

Initialize Tracevell tracing and auto-instrumentation.

**Parameters:**

| Name | Type | Default | Description |
| - | - | - | - |
| `projectApiKey` | `string` | `LMNR_PROJECT_API_KEY` env | Project API key |
| `baseUrl` | `string` | `https://api.lmnr.ai` | Base URL |
| `baseHttpUrl` | `string` | `baseUrl` | OTLP HTTP base URL |
| `httpPort` | `number` | `443` | OTLP HTTP port |
| `grpcPort` | `number` | `8443` | OTLP gRPC port |
| `instrumentModules` | `Record<string, unknown>` | `undefined` | Libraries to auto-instrument |
| `disableBatch` | `boolean` | `false` | Disable batching span processor |
| `traceExportTimeoutMillis` | `number` | `30000` | Export timeout |
| `maxExportBatchSize` | `number` | `512` | Max spans per export batch |
| `flushBySize` | `boolean` | `false` | Also flush a batch when its payload would exceed `maxExportBatchSizeBytes`. See [Batching](https://tracevell.com/docs/sdk/batching.md) |
| `maxExportBatchSizeBytes` | `number` | `33554432` | Approximate max bytes per export batch. Only used when `flushBySize` is true |
| `forceHttp` | `boolean` | `false` | Force OTLP HTTP exporter |
| `logLevel` | `'error'` \| `'warn'` \| `'info'` \| `'debug'` | `'error'` | SDK log level |
| `sessionRecordingOptions` | `SessionRecordingOptions` | — | Browser session recording options |
| `metadata` | `Record<string, any>` | — | Global metadata merged with per-span metadata |
| `inheritGlobalContext` | `boolean` | `false` | Inherit existing OTEL context instead of forcing Tracevell context |
| `spanProcessor` | `SpanProcessor` | — | Provide a custom OTEL span processor |
| `release` | `string` | — | Release stamped on every span, usually the git commit SHA. When unset, read from `LMNR_RELEASE`, then deploy platform variables, then `.git`. See [Agent versions](https://tracevell.com/docs/tracing/agent-versions.md#attach-a-release) |

**Returns:** `void`

## instrumentModules

Pass modules to auto-instrument in `initialize()`.

```typescript theme={null}
import { Tracevell } from '@lmnr-ai/lmnr';
import OpenAI from 'openai';
import Anthropic from '@anthropic-ai/sdk';

Laminar.initialize({
  projectApiKey: process.env.LMNR_PROJECT_API_KEY,
  instrumentModules: {
    OpenAI: OpenAI,
    anthropic: Anthropic,
  },
});
```

**Supported module keys:**

| Key | Package |
| - | - |
| `OpenAI` | `openai` |
| `anthropic` | `@anthropic-ai/sdk` |
| `azureOpenAI` | Azure OpenAI |
| `cohere` | `cohere-ai` |
| `bedrock` | AWS Bedrock |
| `google_vertexai` | Vertex AI |
| `google_aiplatform` | AI Platform |
| `pinecone` | `@pinecone-database/pinecone` |
| `langchain` | An object of `@langchain/core` and `@langchain/langgraph` modules: `callbackManagerModule`, `singletonsModule`, `chatModelsModule`, `llmsModule`, `langgraphModule`. See [LangChain and LangGraph](https://tracevell.com/docs/integrations/langchain.md#getting-started) |
| `llamaIndex` | `llamaindex` |
| `chromadb` | `chromadb` |
| `qdrant` | `@qdrant/js-client-rest` |
| `together` | `together-ai` |
| `playwright` | `playwright` |
| `puppeteer` | `puppeteer` |
| `stagehand` | `@browserbasehq/stagehand` |
| `kernel` | Microsoft Kernel |
| `claudeAgentSDK` | `@anthropic-ai/claude-agent-sdk` |

**Special cases:**

* Pass `undefined` → auto-instrument all supported
* Pass `{}` → disable all auto-instrumentation
* `openAI` (lowercase) is deprecated. Use `OpenAI` to avoid initialization errors.

***

## Laminar.patch(modules)

Manually instrument modules after initialization.

```typescript theme={null}
import { Tracevell } from '@lmnr-ai/lmnr';
import OpenAI from 'openai';

Laminar.initialize({ projectApiKey: '...' });

// Later (e.g., in Next.js server components)
Laminar.patch({ OpenAI: OpenAI });
```

**Parameters:**

| Name | Type | Default | Description |
| - | - | - | - |
| `modules` | `InitializeOptions['instrumentModules']` | — | Modules to instrument |

**Returns:** `void`

**Note:** Throws if `modules` empty. Warns if Tracevell not initialized.

***

## Laminar.wrapClaudeAgentQuery(originalQuery)

Instrument Claude Agent SDK query function.

```typescript theme={null}
import { Tracevell } from '@lmnr-ai/lmnr';
import { query } from '@anthropic-ai/claude-agent-sdk';

const instrumentedQuery = Laminar.wrapClaudeAgentQuery(query);
```

**Use when:** Claude Agent SDK imported before `Laminar.initialize()` or in ESM environments.

**Parameters:**

| Name | Type | Default | Description |
| - | - | - | - |
| `originalQuery` | `Function` | — | The original Claude Agent SDK query function |

**Returns:** `Function` (same type as `originalQuery`)

**Alternative:** Use the top-level export `instrumentClaudeAgentQuery(originalQuery)`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.