# Cyberhatak API

> OpenAI-compatible AI API for Timor-Leste. Base URL: `https://api.cyberhatak.arsana.cloud/v1`

## Quickstart

The Cyberhatak API is OpenAI-compatible. If your code already uses an OpenAI SDK, change the base URL and the key. Nothing else.

1. Log in to the dashboard → Top up → choose **AI balance**.
2. Create a key in the **AI keys** section.
3. Put the key in an env var and use the base URL below.

```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
```

## Authentication

Send the key in the `Authorization` header as a Bearer token. Keys start with `sk-`. Never put a key in frontend code or a public repo.

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

## Chat completions

`POST /v1/chat/completions`, same shape as OpenAI. Supports `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": "gpt-4o-mini",
    "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="gpt-4o-mini",
    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: "gpt-4o-mini",
  messages: [{ role: "user", content: "Bondia!" }],
  stream: true,
});
for await (const chunk of stream) process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
```

## Models and pricing

`GET /v1/models` returns the model list. Prices are USD per 1M tokens (sample; live prices are shown in the dashboard).

| Model | Provider | Input / 1M | Output / 1M | Context |
| --- | --- | --- | --- | --- |
| `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` for search and 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"}'
```

## AI balance

You have two balances. **AI balance** pays for /v1 requests only. **Account balance** pays for VPS, domains and other services. One never draws from the other.

1. Each request costs: (input tokens × input price + output tokens × output price) / 1,000,000.
2. When the AI balance hits $0 the API returns `403` with code `insufficient_user_quota` until you top up.
3. See usage per key in the dashboard.

## Errors

| Code | Meaning | What to do |
| --- | --- | --- |
| 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 |

## For AI agents

Paste this prompt into Claude Code, Cursor, Codex or any agent. It will fetch this document and wire up the project itself.

```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.
```

Raw markdown: https://cyberhatak.arsana.cloud/docs.md · LLM index: https://cyberhatak.arsana.cloud/llms.txt
