Every time an engineering team wires up a new AI-backed feature, the actual model integration usually takes ten lines of code—and the surrounding plumbing steals half a day. You open one billing portal for Anthropic, a second for OpenAI, a third for DeepSeek, fight international card verification on two of them, copy three incompatible SDK wrappers into your service layer, and still have no single place telling you what a request cost in real money until the monthly invoice lands.
This TOP AI quickstart tutorial strips that friction down to a five-minute terminal walkthrough. Starting from a blank machine, you will register at /daftar and claim an instant 5,000 TP trial balance, mint a tp- prefixed API key at /dashboard/kunci, run zero-cost preflight checks on GET /v1/models and GET /v1/balance, and fire working completions across cURL, PowerShell, the Python OpenAI SDK, the Node/TypeScript OpenAI SDK, the native Anthropic SDK, and Server-Sent Events (SSE) streaming. Rather than stopping at a toy "hello world," we will also unpack the topai billing telemetry block, decode all six gateway error codes, and harden your first key before it ever touches a production container.
Five-Minute TL;DR: Register at
/daftar(email + 8+ char password, no credit card) for 5,000 TP (1 TP = Rp 1, never expires). Create atp-key in/dashboard/kunci, export it asTOPAI_API_KEY, and point OpenAI-compatible SDKs tohttps://topai.id/v1or native Anthropic SDKs tohttps://topai.id(no/v1). Every completion returns standard SDK payloads plus atopaiobject exposing exactcharged_gp,balance_after,upstream,failover, andlatency_ms.
If you want the broader architectural view of how unified gateways replace multi-vendor sprawl across Southeast Asian and global engineering teams, bookmark our unified AI gateway field guide and the official reference at /en/docs. Let's get your first verified response on screen.
Local Prerequisites Check
No custom CLI binary, vendor-locked SDK, or local GPU is required. All inference runs server-side behind TOP AI's dual-protocol gateway. Make sure your workstation has the following basics ready so every snippet below runs verbatim:
- A terminal with
curl: Preinstalled on macOS, Linux, and Windows 10/11 (PowerShell snippets are included alongside Bash so Windows engineers do not have to wrestle with quote escaping). - Python 3.10+ or Node.js 20+: Use whichever runtime powers your backend, or test both side by side.
- An active email address: Used for
/daftarsignup and dashboard login. No credit card, business verification, or upfront deposit is asked during onboarding. - Optional
jqbinary: Handy for filtering the JSON output ofGET /v1/models, though every example works cleanly without it.
Step 1: Register at /daftar and See What 5,000 TP Actually Buys
Navigate to /daftar and create your account using an email address and a password of at least 8 characters. The moment registration completes, TOP AI's ledger inserts a bonus_daftar credit of +5,000 TP into your balance.
Three billing mechanics distinguish this starter wallet from typical trial tiers and are worth understanding before you run your first benchmark:
- Fixed 1:1 Rupiah parity (
1 TP = Rp 1). There are no opaque "compute units," fluctuating FX markups, or surprise platform surcharges. Your 5,000 TP balance equals Rp 5,000 of real API spending power. For a full financial comparison against flat-rate plans, see our breakdown of prepaid pay-as-you-go TOP Points vs $200 monthly AI subscriptions. - Zero expiration clock. Unused TOP Points stay in your ledger indefinitely. If you prototype this weekend and come back three months later to ship production traffic, every remaining TP is still sitting there.
- Atomic balance deduction with zero negative drift. Every billable call runs inside a database transaction (
SELECT ... FOR UPDATE) that verifies balance before deducting and writing an immutable ledger row. Concurrent workers cannot double-spend your wallet into overdraft, and requests that fail upstream are not billed.
If a teammate invited you via an affiliate link, your own starter credit remains the full 5,000 TP—nothing is skimmed off your trial, and the referrer earns commission only when you top up later.
Developers often ask whether 5,000 TP is only enough for a handful of smoke tests or enough to run a genuine technical evaluation. Because TOP AI exposes models across radically different cost tiers through the exact same API key, 5,000 TP stretches remarkably far when matched to the right workload:
| Model ID on TOP AI | Estimated Capacity on 5,000 TP | Cost & Speed Profile | Ideal Quickstart Evaluation Workload |
|---|---|---|---|
deepseek-v4-1-flash | ~4,200 requests | Ultra-low cost, sub-second turnaround for high-volume jobs | Strict JSON extraction, ticket routing, intent classification, lightweight chat |
gemini-4-flash | ~3,100 requests | Fast multimodal generalist with high throughput | Long-document summarization, image analysis, rapid RAG synthesis |
deepseek-v4-pro | ~950 requests | High reasoning-per-rupiah sweet spot for engineering tasks | Backend code generation, automated PR diff reviews, structured refactors |
claude-sonnet-5-5 | ~310 requests | Sharp instruction adherence, reliable tool calling and prose | Production coding assistants, multi-step agents, technical architecture review |
claude-opus-5 | ~110 requests | Frontier reasoning depth for highest-stakes problem solving | Hard cross-file debugging, security design audits, complex specification synthesis |
That headroom is large enough to run an automated regression suite of hundreds of structured-output cases on deepseek-v4-1-flash—whose real-world latency and JSON adherence we measured in our DeepSeek V4.1 Flash latency and JSON extraction audit—while comparing side-by-side quality against claude-sonnet-5-5 and gpt-6-1 before you ever look at /en/pricing.

Notice how both protocol lanes converge inside a single gateway plane before hitting upstream providers. Whether your code speaks OpenAI JSON or native Anthropic Messages, authentication, rate limiting, automatic provider failover, and ledger accounting operate identically.
Step 2: Mint a tp- API Key and Wire Environment Variables Safely
Once logged in, open /dashboard/kunci (Dashboard -> API Key). Before clicking the creation button, lock in five operational properties of TOP AI keys:
- Predictable prefix and length: Every user API key starts with
tp-and is 43 characters long. - One-time plaintext display: TOP AI hashes keys with SHA-256 and never stores plaintext on disk. Copy the key the moment the dialog opens; if you dismiss it without saving, you cannot retrieve it—revoke it and mint a new one.
- 20 active keys per account: Keep separate keys for local development, CI pipelines, staging servers, and individual production microservices rather than sharing one master credential everywhere.
- Sub-second revocation: Clicking revoke invalidates the key within seconds. The very next request using that token gets an immediate
401 authentication_errorwith zero grace window. - Strict boundary between dashboard sessions and API keys: The web dashboard, playground, and image studio authenticate via an
httpOnlycookie namedtopai_sesi(30-day TTL, purged on logout). Yourtp-API key works exclusively on/v1/*API endpoints, keeping programmatic tokens isolated from browser cookies.
Click Create new key()never prefix the variable with NEXT_PUBLIC_. Anything prefixed with NEXT_PUBLIC_ is inlined directly into client-side JavaScript bundles where any visitor can scrape it in seconds.
Step 3: Zero-Cost Preflight Checks With GET /v1/models and GET /v1/balance
Before spending a single TP on inference, verify two things at zero cost (0 TP): that you have exact, live model IDs from the gateway catalog, and that your TOPAI_API_KEY authenticates cleanly against your 5,000 TP ledger. Running these two calls first eliminates almost every typo-driven 404 or missing-header 401 right at the gate.
Keep this complete endpoint map handy as you build out your integration:
| Method & Path | Protocol Surface & Base URL | Auth Header | Billing Rule | Operational Limits & Notes |
|---|---|---|---|---|
GET /v1/models | OpenAI (https://topai.id/v1) | Public (none required) | 0 TP (Free) | Cached 60s browser / 300s CDN; returns live IDs, context windows, and pricing |
GET /v1/balance | OpenAI (https://topai.id/v1) | Authorization: Bearer tp-... | 0 TP (Free) | Returns live balance, key quota, daily/monthly spend, and bisa_dipakai flag |
POST /v1/chat/completions | OpenAI (https://topai.id/v1) | Authorization: Bearer tp-... | Token-based + min_charge_gp | 8 MB body cap, 120s timeout, supports stream: true, tools, tool_choice |
POST /v1/messages | Anthropic (https://topai.id) | x-api-key: tp-... or Bearer | Token-based + min_charge_gp | Requires anthropic-version: 2023-06-01, top-level system, full prompt caching |
POST /v1/messages/count_tokens | Anthropic (https://topai.id) | x-api-key: tp-... or Bearer | 0 TP (Free) | Exact preflight input token count before committing to expensive prompts |
POST /v1/images/generations | OpenAI (https://topai.id/v1) | Authorization: Bearer tp-... | Fixed per image (min_charge_gp) | Defaults to flux-2-pro at 1024x1024; 180s timeout |
3.1 Query Live Models and Pricing (GET /v1/models)
Because GET /v1/models is public and CDN-cached for 300 seconds, you can safely fetch it at application startup to populate model selectors or compute internal cost guardrails dynamically:
curl -s https://topai.id/v1/models | jq '.data[0:2]'Each entry exposes capabilities alongside full per-million-token pricing in TOP Points:
{
"object": "list",
"data": [
{
"id": "claude-sonnet-5-5",
"object": "model",
"created": 1735689600,
"owned_by": "anthropic",
"context_window": 1000000,
"capabilities": {
"vision": true,
"tools": true,
"kind": "chat"
},
"pricing": {
"input_per_1m_gp": 2300,
"output_per_1m_gp": 11600,
"cache_read_per_1m_gp": 230,
"cache_write_per_1m_gp": 2875,
"min_charge_gp": 50
}
}
]
}Notice the spread between input_per_1m_gp (2300) and cache_read_per_1m_gp (230)—a 10x discount for repeated system prompts and repository context. We break down exact breakeven points and cache breakpoint sizing in Anthropic prompt caching math explained.
3.2 Verify Authentication and Balance (GET /v1/balance)
Next, test your TOPAI_API_KEY against GET /v1/balance. This costs 0 TP and confirms end-to-end TLS connectivity, key validity, and active credit in a single round-trip:
curl -s https://topai.id/v1/balance \
-H "Authorization: Bearer $TOPAI_API_KEY"Expect a JSON body matching this schema:
{
"object": "balance",
"saldo_gp": 5000,
"kuota_gp": 5000,
"sisa_kuota_gp": 5000,
"terpakai_total_gp": 0,
"terpakai_hari_ini_gp": 0,
"terpakai_bulan_ini_gp": 0,
"request_total": 0,
"jenis_kunci": "user",
"bisa_dipakai": true
}Once bisa_dipakai returns true and saldo_gp shows 5000, your credentials are live. In multi-tenant SaaS products or internal tooling dashboards, polling GET /v1/balance periodically is also the cleanest way to render live remaining quota meters without maintaining a parallel billing mirror.
Step 4: Fire Your First cURL Completion and Decode the topai Telemetry Block
Now send your first real completion to POST https://topai.id/v1/chat/completions. Passing -i prints the HTTP response headers right above the JSON payload so you can inspect both observability surfaces at once.
Bash / Zsh (curl)
curl -i https://topai.id/v1/chat/completions \
-H "Authorization: Bearer $TOPAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-5-5",
"messages": [
{ "role": "user", "content": "Name the three primary colors in one short line." }
],
"max_tokens": 256
}'Windows PowerShell (Invoke-RestMethod)
PowerShell's native serializer avoids JSON double-quote escaping headaches completely:
$headers = @{
"Authorization" = "Bearer $env:TOPAI_API_KEY"
"Content-Type" = "application/json"
}
$payload = @{
model = "claude-sonnet-5-5"
max_tokens = 256
messages = @(
@{ role = "user"; content = "Name the three primary colors in one short line." }
)
} | ConvertTo-Json -Depth 4
$result = Invoke-RestMethod `
-Uri "https://topai.id/v1/chat/completions" `
-Method Post `
-Headers $headers `
-Body $payload
$result | ConvertTo-Json -Depth 6Anatomy of the Response and the topai Telemetry Object
On HTTP 200 OK, TOP AI returns a standard OpenAI completion body that drops seamlessly into existing parsers, augmented with a top-level topai object:
{
"id": "chatcmpl-9x2k1",
"object": "chat.completion",
"created": 1770000000,
"model": "claude-sonnet-5-5",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Red, blue, and yellow."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 24,
"completion_tokens": 9,
"total_tokens": 33,
"cache_read_input_tokens": 0,
"cache_creation_input_tokens": 0
},
"topai": {
"charged_gp": 45,
"balance_after": 4955,
"upstream": "anthropic",
"failover": false,
"latency_ms": 812
}
}Do not ignore the topai block once your code starts parsing choices[0].message.content. Most AI backends fly blind on unit economics because upstream SDKs return token counts without finalized pricing, forcing teams to maintain brittle price lookup tables that go stale every time a provider adjusts rates. TOP AI attaches exact post-transaction accounting and routing metadata to every response—and mirrors key metrics in HTTP headers for reverse-proxy logging.
Live TOP AI API Pricing for Models Mentioned
Frequently Asked Questions
Does the 5,000 TP signup balance expire or require a credit card?+
No. Registering at /daftar with an email and a password of at least 8 characters credits 5,000 TP immediately with zero credit card entry. Because 1 TP always equals Rp 1 and prepaid balances never expire, you can spend those 5,000 TP today or months from now.
How many real API calls can I run on the 5,000 TP starter balance?+
On standard prompt-and-response sizes, 5,000 TP covers roughly 4,200 requests on deepseek-v4-1-flash, around 3,100 requests on gemini-4-flash, about 950 requests on deepseek-v4-pro, roughly 310 requests on claude-sonnet-5-5, or around 110 requests on claude-opus-5.
Why does OpenAI SDK require https://topai.id/v1 while Anthropic SDK requires https://topai.id?+
OpenAI SDKs append /chat/completions and /models to whatever baseURL you provide, so /v1 must be part of the base URL. Anthropic's official SDK automatically appends /v1/messages and /v1/messages/count_tokens itself; putting /v1 into Anthropic's baseURL sends traffic to /v1/v1/messages and triggers a 404 error.
Do GET /v1/models, GET /v1/balance, or POST /v1/messages/count_tokens deduct any TP?+
No. All three utility endpoints are completely free (0 TP). GET /v1/models does not even require an API key and is cached for 60 seconds in browsers and 300 seconds at the CDN layer, making it safe to query on service boot.







