---
title: init()
description: Zero required args. Never throws.
---

# init()

`init()` is the only setup call. Zero required args. Idempotent. Never throws. SDK errors are swallowed and logged — they never raise into your app.

```python
import agenko

agenko.init()
```

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

agenko.init();
```

`instrument()` is a backward-compat alias of `init()`.

## Optional arguments

All of these also have env vars. Prefer env.

```python
agenko.init(
    api_key=None,          # AGENKO_API_KEY
    http_endpoint=None,    # AGENKO_HOST (legacy: AGENKO_HTTP_ENDPOINT)
    endpoint=None,         # AGENKO_ENDPOINT (OTLP); default derived from host
    service_name="agenko-agent",
    debug=False,
)
```

```typescript
agenko.init({
  apiKey: process.env.AGENKO_API_KEY,
  httpEndpoint: process.env.AGENKO_HOST,
  endpoint: process.env.AGENKO_ENDPOINT,
  serviceName: "agenko-agent",
  debug: false,
});
```

## What it does

1. Resolves `AGENKO_HOST` (default `http://localhost:8000`).
2. Derives OTLP ingest as `{host}/api/public/otel/v1/traces` unless `AGENKO_ENDPOINT` is set.
3. Installs an OTEL `TracerProvider` (or NodeSDK on TypeScript).
4. Auto-detects loaded AI frameworks and patches them.
5. Creates the HTTP client for receipts and approvals.
6. If an API key is present, POSTs `/api/v1/agents/connect` so the console sees the agent before the first trace.

If you skip `init()`, `@check` and `@approve` still try to work without crashing the process.

## Print line

With a key: `traces → {AGENKO_CONSOLE_URL}/traces`. Without: `set AGENKO_API_KEY — then run your agent`.

## Agent instructions

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

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