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

# 你好，世界

> 在 5 分钟内构建一个可运行的示例。

## Node.js / TypeScript

```typescript theme={null}
import { Theo } from "@hitheo/sdk";

const theo = new Theo({ apiKey: process.env.THEO_API_KEY! });

async function main() {
  // Simple completion
  const response = await theo.complete({
    prompt: "Write a haiku about debugging code",
    mode: "auto",
  });

  console.log(response.content);
  console.log(`Model: ${response.model.label} | Cost: ${response.usage.cost_cents}¢`);
}

main();
```

**运行方式：**

```bash theme={null}
export THEO_API_KEY=theo_sk_...
npx tsx hello.ts
```

## 流式输出

```typescript theme={null}
const stream = theo.stream({
  prompt: "Explain how DNS works step by step",
});

for await (const event of stream) {
  if (event.type === "token") {
    process.stdout.write(event.token!);
  }
  if (event.type === "done") {
    const done = event.data as { usage: { cost_cents: number } };
    console.log(`\n\nCost: ${done.usage.cost_cents}¢`);
  }
}
```

## Python（REST API）

无需 SDK — REST API 可与任何 HTTP 客户端配合使用：

```python theme={null}
import requests
import os

response = requests.post(
    "https://www.hitheo.ai/api/v1/completions",
    headers={
        "Authorization": f"Bearer {os.environ['THEO_API_KEY']}",
        "Content-Type": "application/json",
    },
    json={
        "prompt": "Write a Python function to flatten nested lists",
        "mode": "code",
    },
)

data = response.json()
print(data["content"])
print(f"Model: {data['model']['label']} | Cost: {data['usage']['cost_cents']}¢")
```

## 使用 E.V.I.

通过自定义角色，将 Theo 嵌入到你的产品中：

```typescript theme={null}
const evi = theo.evi({
  persona: "You are Kai, a friendly coding assistant for DevHub. Help developers debug issues and write tests.",
  skills: ["deep-research"],
});

const res = await evi.complete({
  prompt: "Why is my useEffect running twice in dev mode?",
});

console.log(res.content);
// → Kai explains React strict mode with code examples
```

你的用户对话的对象是 "Kai" — 他们永远看不到 Theo。完整教程请参阅 [E.V.I. 指南](/guides/build-an-evi)。


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