# Cyberhatak API

> API AI kompatível ho OpenAI ba Timor-Leste. Base URL: `https://api.cyberhatak.arsana.cloud/v1`

## Hahú lalais

Cyberhatak nia API kompatível ho OpenAI. Se kódigu Ita uza ona OpenAI SDK, troka base URL no xave deit.

1. Tama iha dashboard → Tau saldu → hili **Saldu AI**.
2. Kria xave foun iha seksaun **Xave AI**.
3. Tau xave iha env var no uza base URL iha kraik.

```bash
CYBERHATAK_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
CYBERHATAK_BASE_URL=https://api.cyberhatak.arsana.cloud/v1

# Many tools read these standard names too:
OPENAI_API_KEY=$CYBERHATAK_API_KEY
OPENAI_BASE_URL=$CYBERHATAK_BASE_URL
```

## Autentikasaun

Haruka xave iha header `Authorization` ho formatu Bearer. Xave hahú ho `sk-`. Keta hatama xave iha kódigu frontend ka repo públiku.

```http
Authorization: Bearer sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
```

## Chat completions

`POST /v1/chat/completions`, hanesan ho OpenAI. Suporta `stream: true`.

```bash
curl https://api.cyberhatak.arsana.cloud/v1/chat/completions \
  -H "Authorization: Bearer $CYBERHATAK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-haiku-4-5",
    "messages": [{"role": "user", "content": "Bondia! Explika AI iha liafuan tolu."}]
  }'
```

```python
# pip install openai
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.cyberhatak.arsana.cloud/v1",
    api_key=os.environ["CYBERHATAK_API_KEY"],
)

res = client.chat.completions.create(
    model="claude-haiku-4-5",
    messages=[{"role": "user", "content": "Bondia!"}],
)
print(res.choices[0].message.content)
```

```js
// npm install openai
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.cyberhatak.arsana.cloud/v1",
  apiKey: process.env.CYBERHATAK_API_KEY,
});

const stream = await client.chat.completions.create({
  model: "claude-haiku-4-5",
  messages: [{ role: "user", content: "Bondia!" }],
  stream: true,
});
for await (const chunk of stream) process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
```

## Modelu no folin

`GET /v1/models` fó lista modelu. Folin iha USD kada 1M token (ezemplu; folin loos hatudu iha dashboard).

| Modelu | Fornesedór | Input / 1M | Output / 1M | Kontekstu |
| --- | --- | --- | --- | --- |
| `claude-opus-5-5` | Anthropic | $5.20 | $26.00 | 1M |
| `claude-fable-5-1` | Anthropic | $13.00 | $65.00 | 1M |
| `claude-sonnet-5` | Anthropic | $2.60 | $13.00 | 1M |
| `gpt-6-astra` | OpenAI | $13.00 | $65.00 |  |
| `gpt-6-sol` | OpenAI | $2.60 | $13.00 |  |
| `gemini-3.1-pro-preview` | Google | $2.60 | $15.60 |  |
| `deepseek-v4-pro` | DeepSeek | $1.72 | $5.15 | 1M |
| `claude-haiku-4-5` | Anthropic | $1.30 | $6.50 | 200K |
| `gemini-3.8-flash` | Google | $0.98 | $4.88 |  |
| `glm-5.3` | Z.ai | $1.82 | $5.72 |  |
| `glm-5.3-flash` | Z.ai | $0.20 | $0.65 |  |
| `text-embedding-3-small` | OpenAI | $0.03 | - | 8K |

```bash
curl https://api.cyberhatak.arsana.cloud/v1/models -H "Authorization: Bearer $CYBERHATAK_API_KEY"
```

## Embeddings

`POST /v1/embeddings` ba buka no RAG.

```bash
curl https://api.cyberhatak.arsana.cloud/v1/embeddings \
  -H "Authorization: Bearer $CYBERHATAK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "text-embedding-3-small", "input": "Dili, Timor-Leste"}'
```

## Saldu AI

Ita iha saldu rua. **Saldu AI** ba pedidu /v1 deit. **Saldu konta** ba VPS, domíniu no servisu seluk. Saldu ida la tun husi seluk.

1. Kada pedidu kobra: (token input × folin input + token output × folin output) / 1,000,000.
2. Bainhira Saldu AI $0, API fó erru `403` ho kódigu `insufficient_user_quota` too Ita tau saldu.
3. Haree uzu kada xave iha dashboard.

## Erru

| Kódigu | Signifika | Halo saida |
| --- | --- | --- |
| 401 | Invalid or deleted key | Check `CYBERHATAK_API_KEY` |
| 403 `insufficient_user_quota` | AI balance is $0 | Top up the AI balance |
| 503 / `model_not_found` | Unknown model | Use an id from `GET /v1/models` |
| 429 | Too many requests | Retry with backoff |
| 5xx | Upstream provider error | Retry; switch model if it persists |

## Ba AI agent

Kopia prompt ne'e ba Claude Code, Cursor, Codex ka agent seluk. Agent sei lee dokumentu ne'e rasik no konfigura projetu.

```text
Read https://cyberhatak.arsana.cloud/docs.md and integrate Cyberhatak AI into this project.
Use the OpenAI-compatible SDK with base URL https://api.cyberhatak.arsana.cloud/v1 and read the key from the env var CYBERHATAK_API_KEY. Do not hard-code the key.
```

Markdown mentah: https://cyberhatak.arsana.cloud/docs.md · Indise ba LLM: https://cyberhatak.arsana.cloud/llms.txt
