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

# SDK API

> Curated reference for the main Captar SDK entrypoints used in v1.

# SDK API

These are the core v1 entrypoints you should know.

## `createCaptar(options)`

Creates a project-scoped runtime with pricing, exporter, and optional control-plane
policy sync configuration.

Use this once near app startup. It is the root object that everything else hangs
off, so the configuration should stay small and obvious.

```ts theme={null}
const captar = createCaptar({
  project: "support-bot",
  exporter: { url: process.env.CAPTAR_INGEST_URL! },
  controlPlane: {
    hookId: "hook_123",
    syncPolicy: true,
    baseUrl: "http://localhost:3000",
  },
});
```

## `startSession(options)`

Starts a session with merged budget, metadata, and policy.

This is where you set the rules for one request, job, or task. Put the metadata
you will want to see again in the trace here.

## `wrapOpenAI(client, options)`

Wraps an existing OpenAI client so requests inherit the active session context.

It should preserve the API shape you already use, which keeps adoption low-risk.

## `trackTool(name, options)`

Runs a tool inside the same runtime trace and applies tool policy before execution.

Use this for any external action that should show up alongside the model request
that caused it.

## `flush()`

Flushes exporter buffers when the request or job is done.

You usually want it in scripts, short-lived workers, and serverless handlers.
