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

# Getting Started

> Install @dzapio/ai and run it through SDK, CLI, HTTP, or MCP.

This page gets you from install to first real request with the current `@dzapio/ai` runtime.

## 1) Install

```bash theme={null}
npm install @dzapio/ai
```

If your environment maps `@dzapio` to a private registry, use:

```bash theme={null}
npm install @dzapio/ai --@dzapio:registry=https://registry.npmjs.org
```

## 2) Set required environment variables

```bash theme={null}
export OPENAI_API_KEY=sk-...
```

`OPENAI_API_KEY` is the only variable required to run the model. Optional
provider keys (Tavily, CoinStats, Moralis, etc.) enable individual tools.

## 3) SDK example (`DZapSDK`)

```ts theme={null}
import { DZapSDK } from "@dzapio/ai";

const sdk = new DZapSDK();

await sdk.initialize({
  initializeRetrieval: true,
  syncProviders: false,
});

const result = await sdk.ask({
  userQuery: "Show my balances",
  metadata: {
    accountInfo: [{ blockchain: "evm", chain: "1", user_account: "0xabc..." }],
  },
  transactionConfirmationMode: "on",
});

console.log(result.sessionId);
console.log(result.finalText);
```

## 4) CLI example

```bash theme={null}
dzap
```

Aliases also supported: `dzapai`, `DzapAI`.

The interactive flow prompts for:

1. Wallet profile (wallet, chain, blockchain, private key)
2. Chat input and slash commands

## 5) HTTP streaming example

The server exposes a single Server-Sent Events endpoint, `POST /ask_stream`:

```bash theme={null}
curl -N -X POST "https://nlp-ai-439689868940.europe-north1.run.app/ask_stream" -H "Content-Type: application/json" -d "{\"user_query\":\"Price of USDC on Ethereum\",\"session_id\":\"demo-session\",\"metadata\":{\"accountInfo\":[{\"blockchain\":\"evm\",\"chain\":\"1\",\"user_account\":\"0xabc...\"}]}}"
```

The stream emits one `step` event per tool call, a final `finalText` event, then `[DONE]`:

```text theme={null}
data: {"chatId":"demo-session","response":{"type":"step","tool_name":"PriceTool","data":"...","session_id":"demo-session"}}
data: {"chatId":"demo-session","response":{"type":"finalText","data":"USDC is ...","session_id":"demo-session","chain_id":"1"}}
data: [DONE]
```

## 6) MCP endpoint example

```json theme={null}
{
  "mcpServers": {
    "DZapAI": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "https://nlp-ai-439689868940.europe-north1.run.app/mcp"]
    }
  }
}
```

## Next

<CardGroup cols={2}>
  <Card title="SDK-AI" icon="code" href="/ai/sdk-ai">
    Full SDK API reference with more examples.
  </Card>

  <Card title="MCP Server" icon="plug" href="/ai/mcp/overview">
    Stdio + streamable HTTP details.
  </Card>

  <Card title="Tool Categories" icon="wrench" href="/ai/tools/overview">
    All 21 exposed tools.
  </Card>

  <Card title="CLI" icon="terminal" href="/ai/cli/overview">
    Interactive shell command reference.
  </Card>
</CardGroup>
