---
title: TypeScript SDK
description: pnpm add @agenko/sdk
---

# TypeScript SDK

Package: `@agenko/sdk` on npm. Use **pnpm**. Current series: `0.1.x`.

```typescript
import agenko from "@agenko/sdk";

agenko.init();

const handleTicket = agenko.check(async (ticket) => process(ticket));

const deleteAccount = agenko.approve({ when: "irreversible" }, async (userId) => {
  await db.deleteUser(userId);
});
```

Named imports work the same:

```typescript
import { init, check, approve } from "@agenko/sdk";
```

## Exports

| Name | Role |
|---|---|
| `init` / `instrument` | Bootstrap |
| `shutdown` | Flush OTEL |
| `isInitialized` | Guard |
| `getConfig` | Read resolved config |
| `check` | Receipt wrapper |
| `approve` | Gate wrapper |
| `getPrompt` / `clearPromptCache` | See [Prompts](/prompts) |
| `score` | See [Scores](/scores) |
| `getClient` / `agenkoClient` | Control-plane client |
| `ApprovalError` / `ApprovalTimeoutError` | Gate errors |

Types: `InitOptions`, `Receipt`, `ReceiptVerdict`, `ReceiptCheck`, `ToolCall`, `ScoreDataType`, `ScoreSource`, `Prompt`, `ApprovalConfig`.

## Lifecycle

`init()` is idempotent: call it once at startup. Use the lifecycle helpers when you need to tear down or inspect state:

```typescript
if (!agenko.isInitialized()) agenko.init();

// ...run your agent...

await agenko.shutdown(); // flush OTEL + close the HTTP client
```

`agenko.getConfig()` returns the resolved config (`apiKey`, `httpEndpoint`, `endpoint`, `serviceName`, `projectId`, `env`, `sessionId`, `userId`, `debug`) or `null` before `init()`.

## Auto-instrumentation

TypeScript detects `openai`, `@anthropic-ai/sdk`, and LangChain via OpenInference instrumentors (`@arizeai/openinference-instrumentation-*`). Python currently auto-detects a wider set (LiteLLM, LlamaIndex, CrewAI, Bedrock, …). Parity is the rule — gaps get filled on the TS side, not documented as features.

## Tests

`cd agenko/agenko-typescript && pnpm test --run`.

## Agent instructions

This page: https://docs.agenko.app/typescript.md

Fetch `/llms.txt` for the full index. Search: `GET /api/search-docs?query=...`
