# Documentation — AuCore

> How to get an AuCore API key and use it: authentication, models, chat completions, streaming, token optimization and error handling.

Source: https://ai.aunuhost.bond/docs

Documentation

# Getting started

AuCore exposes one OpenAI-compatible API for every model in the catalog.
 If your code already talks to OpenAI, you only need to change two values.

AI API — Base URL

This is the value you set as `base_url` in the OpenAI SDK (or any
 compatible client). Both and resolve.

## 1. Get a key

1. Choose a plan on the [pricing page](https://ai.aunuhost.bond/plan).
2. Request access on the [support page](https://ai.aunuhost.bond/support), naming your plan.
3. AuCore issues your key and sends it to you.
4. Redeem it at [/login](https://ai.aunuhost.bond/login). Your [dashboard](https://ai.aunuhost.bond/client) then shows the key, base URL and analytics.

Keys look like `auc_live_a1b2c3d4e5f6g7h8`. They are account-scoped, rotatable and revocable at any time.

## 2. Two APIs — which one do I use?

AuCore runs **two independent API planes**, each with its own key type, base URL and quota system. Pick the one that matches what you're building:

|  | 🤖 AI API (this page) | 🧰 REST API Toolkit ([catalog](https://ai.aunuhost.bond/restapi)) |
| --- |--- |--- |
| **What it does** | Chat completions, embeddings, moderations, media generation — the OpenAI-compatible inference surface | 580+ utility endpoints: Islamic tools, web scraping, anime, finance, crypto, QR codes, weather, security, and more |
| **Key prefix** | `auc_live_…` / `auc_premier_…` / `auc_platinum_…` / `auc_free_…` | `auc_rest_…` |
| **Base URL** | (same origin — this page's domain) | https://api.fallsad.biz.id/api |
| **Auth** | Bearer token in `Authorization` header | `?key=…` query param, `x-api-key` header, or Bearer |
| **Quota** | RPM + daily requests by plan (Free → Platinum) | 5 calls/day free (admin-adjustable per key) |
| **Key source** | Issued by AuCore after plan purchase, or Google sign-in (free) | Issued from the admin dashboard (API keys tab) |
| **Use it for** | Chatbots, RAG, agents, code generation, summarization, image/video generation | Utility microservices: prayer times, weather, currency, QR, short links, anime search… |

**Rule of thumb:** if you're calling a model (GPT, Claude, Gemini, Llama…), use the **AI API** with your `auc_live_` key. If you're calling a utility endpoint (weather, QR, prayer times…), use the **REST API Toolkit** with your `auc_rest_` key. They never mix — a `auc_rest_` key cannot call chat completions, and a `auc_live_` key cannot call toolkit features.

## 3. Authenticate

Send your key as a bearer token on every request.

```
Authorization: Bearer auc_live_a1b2c3d4e5f6g7h8
Content-Type: application/json
```

| Status | Meaning |
| --- |--- |
| `401` | Key missing or unknown |
| `403` | Key revoked or expired, or model above your plan |
| `429` | Rate or daily budget exceeded |

## 4. List models

```
curl <span class="s" data-base></span>/models \
  -H "Authorization: Bearer $AUCORE_KEY"
```

```
{
  <span class="s">"object"</span>: <span class="s">"list"</span>,
  <span class="s">"data"</span>: [
    {
      <span class="s">"id"</span>: <span class="s">"aucore-router-auto"</span>,
      <span class="s">"owned_by"</span>: <span class="s">"Anthropic"</span>,
      <span class="s">"context_window"</span>: <span class="n">1000000</span>,
      <span class="s">"modalities"</span>: [<span class="s">"text"</span>, <span class="s">"vision"</span>, <span class="s">"tools"</span>],
      <span class="s">"min_plan"</span>: <span class="s">"premier"</span>,
      <span class="s">"available"</span>: <span class="k">true</span>
    }
  ]
}
```

`available` reflects your own plan, so you can filter the catalog client-side.

## 5. Chat completions

```
curl <span class="s" data-base></span>/chat/completions \
  -H "Authorization: Bearer $AUCORE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "aucore-router-auto",
    "messages": [
      {"role": "system", "content": "You are concise."},
      {"role": "user", "content": "What is retrieval augmented generation?"}
    ],
    "temperature": 0.7,
    "max_tokens": 1024
  }'
```

**Response**

```
{
  <span class="s">"id"</span>: <span class="s">"chatcmpl_aucore_8f2a…"</span>,
  <span class="s">"object"</span>: <span class="s">"chat.completion"</span>,
  <span class="s">"model"</span>: <span class="s">"aucore-router-auto"</span>,
  <span class="s">"choices"</span>: [{
    <span class="s">"index"</span>: <span class="n">0</span>,
    <span class="s">"message"</span>: {<span class="s">"role"</span>: <span class="s">"assistant"</span>, <span class="s">"content"</span>: <span class="s">"RAG is…"</span>},
    <span class="s">"finish_reason"</span>: <span class="s">"stop"</span>
  }],
  <span class="s">"usage"</span>: {<span class="s">"prompt_tokens"</span>: <span class="n">24</span>, <span class="s">"completion_tokens"</span>: <span class="n">148</span>, <span class="s">"total_tokens"</span>: <span class="n">172</span>}
}
```

### Parameters

| Field | Type | Notes |
| --- |--- |--- |
| `model` | string | Required. Any ID from the catalog. |
| `messages` | array | Required. Roles: system, user, assistant. |
| `temperature` | number | 0–2. Default 1. |
| `max_tokens` | integer | Capped at 32,000. |
| `top_p` | number | Nucleus sampling. |
| `stream` | boolean | Server-sent events when true. |
| `tools` | array | Premier and Platinum only. |

## 6. Streaming

Set `"stream": true` and read server-sent events. Each chunk is a `data:` line, ending with `data: [DONE]`.

```
data: {"choices":[{"delta":{"content":"RAG"}}]}
data: {"choices":[{"delta":{"content":" combines"}}]}
data: [DONE]
```

```
<span class="c">// Node.js — stream with the OpenAI SDK</span>
<span class="k">const</span> stream = <span class="k">await</span> client.chat.completions.create({
  model: <span class="s">"aucore-router-auto"</span>,
  messages: [{ role: <span class="s">"user"</span>, content: <span class="s">"Write a haiku"</span> }],
  stream: <span class="k">true</span>,
});

<span class="k">for await</span> (<span class="k">const</span> chunk <span class="k">of</span> stream) {
  process.stdout.write(chunk.choices[<span class="n">0</span>]?.delta?.content ?? <span class="s">""</span>);
}
```

## 7. Automatic model selection

Send `aucore-router-auto` as the model and AuCore chooses the cheapest model capable of handling the prompt: short prompts go to a fast small model, code-heavy or long prompts escalate automatically.

```
{
  <span class="s">"model"</span>: <span class="s">"aucore-router-auto"</span>,
  <span class="s">"messages"</span>: [{<span class="s">"role"</span>: <span class="s">"user"</span>, <span class="s">"content"</span>: <span class="s">"Summarise this in one line: …"</span>}]
}
```

## 8. Use an existing SDK

```
<span class="c"># Python</span>
<span class="k">from</span> openai <span class="k">import</span> OpenAI

client = OpenAI(base_url=<span class="s" data-base-q></span>, api_key=os.environ[<span class="s">"AUCORE_KEY"</span>])
r = client.chat.completions.create(
    model=<span class="s">"aucore-router-auto"</span>,
    messages=[{<span class="s">"role"</span>: <span class="s">"user"</span>, <span class="s">"content"</span>: <span class="s">"Hello"</span>}],
)
<span class="k">print</span>(r.choices[<span class="n">0</span>].message.content)
```

LangChain, LlamaIndex, the AI SDK and anything else that accepts a custom base URL work the same way. `/v1` is accepted as an alias, so `…/api/v1` and `…/api` both resolve.

## 9. Token optimization

Every request passes through the AuCore token minimizer before it reaches a model provider. Whitespace is normalized, oversized histories are windowed to fit your plan's context budget, and bloated tool results are capped — typically saving 15–40% of input tokens on long conversations, which makes free-tier quotas last dramatically longer.

- Automatic by default; nothing to configure.
- Add `"optimize": "aggressive"` to the request body for deeper compression (strips filler phrases).
- Check the savings in every response: headers `X-AuCore-Tokens-In` / `X-AuCore-Tokens-Saved`, or the `aucore.tokens_minimized` field.

## 10. Rate limits

| Plan | Per minute | Per day | Context | Weight |
| --- |--- |--- |--- |--- |
| Basic | 20 | 1,500 | 64K | 1× |
| Premier | 60 | 6,000 | 200K | 3× |
| Platinum | 180 | 25,000 | 1M | 9× |

Every response includes limit headers:

```
X-AuCore-Plan: platinum
X-RateLimit-Limit: 180
X-RateLimit-Remaining: 174
X-RateLimit-Reset: 1786000060
X-RateLimit-Daily-Remaining: 24985
```

## 11. Errors

```
{
  <span class="s">"error"</span>: {
    <span class="s">"type"</span>: <span class="s">"rate_limit_exceeded"</span>,
    <span class="s">"message"</span>: <span class="s">"Daily request budget reached for plan basic."</span>,
    <span class="s">"code"</span>: <span class="n">429</span>,
    <span class="s">"retry_after"</span>: <span class="n">41</span>,
    <span class="s">"reset_at"</span>: <span class="s">"2026-08-17T00:00:00.000Z"</span>
  }
}
```

Retry `429` and `502` with exponential backoff plus jitter. Never retry `400` or `403` without changing the request.

## 12. Account management & support

Beyond chat, the gateway exposes account endpoints for everything the dashboard does — all with the same Bearer key.

### Profile & usage

```
PATCH <span class="s" data-base></span>/account/profile      <span class="c"># update your name / email</span>
GET  <span class="s" data-base></span>/account/history?days=30  <span class="c"># daily request series (max 90 days)</span>
GET  <span class="s" data-base></span>/account/requests?limit=50 <span class="c"># recent request log (metadata only)</span>
```

### Secondary keys

Mint up to five named keys for separate projects. They authenticate as your account with the same plan limits and can be revoked independently — no need to share the master key.

```
POST <span class="s" data-base></span>/account/keys          <span class="c"># { "name": "chatbot-prod" } → key shown once</span>
GET  <span class="s" data-base></span>/account/keys          <span class="c"># list every secondary key</span>
DELETE <span class="s" data-base></span>/account/keys/:id    <span class="c"># revoke one key instantly</span>
```

### Webhooks

Register up to three HTTPS endpoints and AuCore POSTs events to them: `usage.daily`, `quota.warn` (≥80% of the daily budget) and `key.rotate`.

```
POST <span class="s" data-base></span>/account/webhooks     <span class="c"># { "url": "https://your.app/hook", "events": ["usage.daily"] }</span>
GET  <span class="s" data-base></span>/account/webhooks     <span class="c"># list registered webhooks</span>
DELETE <span class="s" data-base></span>/account/webhooks/:id
```

### Support & subscribe

```
POST <span class="s" data-base></span>/support   <span class="c"># { name, email, topic, message, consent: true }</span>
POST <span class="s" data-base></span>/subscribe <span class="c"># { email } → product updates by email</span>
```

Support requests **require** `consent: true` (the checkbox on the [support form](https://ai.aunuhost.bond/support)) and a valid email — replies are sent there by our email plane. Subscribers receive feature updates and promos; unsubscribe by contacting support.

## 13. Good practice

- Keep keys on your server; have your own backend call AuCore.
- Rotate immediately if a key may have leaked — old keys stop working at once.
- Set `max_tokens` deliberately; it is the simplest cost control you have.
- Use `aucore-router-auto` when quality requirements vary per request.
- Log the `id` from responses so support can trace a specific call.

## 14. Official SDK

The AuCore SDK is a zero-dependency JavaScript client that works everywhere — Node.js 18+, browsers, Deno, Bun, and edge runtimes. No npm install needed — download it directly:

**Download the SDK**

Single file, ~8 KB, zero dependencies

[Download .mjs](https://ai.aunuhost.bond/assets/sdk/aucore-sdk.mjs)

### Quick start

```
<span class="c">// Node.js / Deno / Bun / edge — import the downloaded file</span>
<span class="k">import</span> AuCore <span class="k">from</span> <span class="s">"./aucore-sdk.mjs"</span>;

<span class="k">const</span> ai = <span class="k">new</span> AuCore({ apiKey: <span class="s">"auc_live_…"</span> });

<span class="c">// Chat completion</span>
<span class="k">const</span> res = <span class="k">await</span> ai.chat.create({
  model: <span class="s">"aucore-router-auto"</span>,
  messages: [{ role: <span class="s">"user"</span>, content: <span class="s">"Hello!"</span> }]
});
console.log(res.choices[<span class="n">0</span>].message.content);

<span class="c">// Streaming</span>
<span class="k">const</span> stream = <span class="k">await</span> ai.chat.create({ messages: […], stream: <span class="k">true</span> });
<span class="k">for await</span> (<span class="k">const</span> chunk <span class="k">of</span> stream) {
  process.stdout.write(chunk.choices[<span class="n">0</span>]?.delta?.content ?? <span class="s">""</span>);
}

<span class="c">// REST toolkit (separate key)</span>
<span class="k">const</span> rest = <span class="k">new</span> AuCore({ restKey: <span class="s">"auc_rest_…"</span> });
<span class="k">const</span> weather = <span class="k">await</span> rest.rest.call(<span class="s">"info/weather"</span>, { city: <span class="s">"Jakarta"</span> });
```

### Browser usage (no build step)

In a browser, add a `type="module"` script tag that imports the SDK from this site's CDN at
 `/assets/sdk/aucore-sdk.mjs`, then instantiate `new AuCore({ apiKey: "auc_live_…" })`
 and call `ai.chat.create()` — the same API as the Node.js example above.

**How it works:** the SDK is a single ES module that wraps the same REST API you'd call with `fetch`. It adds automatic retry on 429/5xx, request timeouts, typed errors, and a clean API surface (`ai.chat.create()`, `ai.rest.call()`). Since it's zero-dependency, you can copy the file into any project — no package manager needed. If you prefer npm, run `npm publish` from the `sdk/` folder after setting up an npm account.

## 15. REST API Toolkit — quick reference

The toolkit is a separate plane with its own base URL and key. Full interactive catalog at [/restapi](https://ai.aunuhost.bond/restapi).

```
<span class="c"># call any toolkit feature with your auc_rest_ key</span>
curl <span class="s">"https://api.fallsad.biz.id/api/islamic/prayer-times?lat=-6.2&lon=106.8&key=auc_rest_…"</span>

curl <span class="s">"https://api.fallsad.biz.id/api/info/weather?city=Jakarta&key=auc_rest_…"</span>

curl <span class="s">"https://api.fallsad.biz.id/api/tools/qr-code?text=hello&key=auc_rest_…"</span>
```

Every response carries rate-limit headers (`X-RateLimit-Limit`, `-Remaining`, `-Reset`) so you can track your quota client-side. Check `GET /me` for a full usage report.

---

Need something not covered here? See the [full API reference](https://ai.aunuhost.bond/reference),
 the [FAQ](https://ai.aunuhost.bond/faq), or [contact support](https://ai.aunuhost.bond/support).
