Watch any eight-person engineering squad work for a week and you will notice an unspoken reality: nobody wants to be forced into someone else's editor. Your backend engineers live inside tmux, Neovim, and tight Git workflows; your product engineers want VS Code's visual diff gutter and integrated debugger; someone on the platform team swears by terminal-first patch generation; and two frontend leads like Windsurf's unified Cascade workspace. Friction starts the moment each of those tools demands its own vendor account, separate international credit card, and siloed usage dashboard.
We previously walked through wiring the first wave of coding harnesses in our guide on how to connect Claude Code, Cursor, and Cline with one API key. This tutorial tackles the second half of the modern agentic stack—how to setup OpenCode, Roo Code, Windsurf, and Aider on TOP AI using scoped tp- keys issued per developer laptop.
Rather than stopping at basic connection screenshots, we are going to build production-ready configurations that hold up under real sprint pressure: separating TOP AI's OpenAI-compatible endpoint (https://topai.id/v1) from its native Anthropic caching endpoint (https://topai.id), pairing expensive reasoning models with fast patch writers, enforcing repository context hygiene via .aiignore and .rooignore, and auditing real TP spend across an identical four-file TypeScript feature benchmark.
15-Minute Quick Path: Sign up free at /daftar for 5,000 non-expiring TP (
1 TP = Rp 1, zero credit card), mint a per-laptoptp-key with a daily spend cap at /dashboard/kunci, and configure OpenCode CLI (opencode.json), Roo Code (Architect / Code / Debug / Ask profiles), Aider (.aider.conf.ymlArchitect + Editor), and Windsurf (custom OpenAI endpoint +.aiignore). On our 4-file TypeScript feature + tests benchmark, proper split-model and caching setups cut feature cost from 1,120 TP (uncached single-model Opus loop) down to 185–365 TP—up to a 6x reduction.
Why Agentic Tool-Calling Loops Dictate Your Endpoint Strategy
Before pasting JSON or YAML into config directories, it helps to be completely clear on how agentic harnesses burn tokens. As documented in the TOP AI developer reference at /en/docs, tool calling is not executed inside the gateway. TOP AI forwards your tool schemas (tools, tool_choice, or Anthropic's input_schema and tool_result blocks) to the upstream model and streams back the model's structured decision. Your local harness—OpenCode, Roo Code, Aider, or Windsurf—actually reads files from disk, runs vitest or pytest, inspects git diff, and posts the output back into the next turn.
That architecture has one immediate billing consequence: every iteration in an agent loop is a separate billed request carrying the growing conversation transcript. Ask an agent to "add idempotency-key validation to the payout webhook and cover edge cases with unit tests," and a typical run looks like this:
- Turn 1: list directory layout and read route definitions.
- Turn 2: inspect shared database transaction helpers and Zod validators.
- Turn 3: formulate a multi-file change plan.
- Turn 4–5: write edits across four files.
- Turn 6: run the test command and capture a TypeScript mismatch.
- Turn 7–8: patch the type error and re-run tests until green.
By turn 7, you are resending tens of thousands of input tokens from turns 1 through 6. If you run an uncached frontier model across all eight turns with zero step limits, a single medium-sized ticket easily blows past 1,000 TP. That is why TOP AI exposes two native protocol lanes under the exact same tp- key and wallet:

- OpenAI-Compatible Lane (
https://topai.id/v1): Standard/v1/chat/completionsand/v1/modelsinterface used by Aider, Roo Code's OpenAI-Compatible profiles, Windsurf's custom endpoint, and OpenCode's OpenAI adapter. Ideal for routing cleanly acrossdeepseek-v4-pro,deepseek-v4-1-flash,gpt-6-astra, and cross-vendor fallbacks. - Native Anthropic Lane (
https://topai.id— NO/v1suffix): Used by native Anthropic adapters in OpenCode and Roo Code. Anthropic's official SDK automatically appends/v1/messagesand/v1/messages/count_tokens. Putting/v1in this base URL causes requests to hit/v1/v1/messagesand return404. Using the native lane unlocks full Anthropic prompt caching onclaude-opus-5andclaude-sonnet-5-5, dropping repeated context read costs by roughly 90%—we broke down the exact break-even math in Anthropic prompt caching math explained.
Here is how the four tools map onto TOP AI's dual-protocol gateway:
| Agentic Tool | Primary Protocol to TOP AI | Exact Base URL | Native Anthropic Prompt Caching | Built-in Multi-Model Split | Primary Config Surface |
|---|---|---|---|---|---|
| OpenCode CLI | Anthropic Native + OpenAI Compatible | https://topai.id (Anthropic) & https://topai.id/v1 (OpenAI) | Full support via @ai-sdk/anthropic | Fast per-session switching + small_model | ~/.config/opencode/opencode.json |
| Roo Code (VS Code) | Anthropic Native + OpenAI Compatible | https://topai.id (Anthropic) & https://topai.id/v1 (OpenAI) | Full support on Anthropic profiles | First-class (Architect, Code, Debug, Ask) | VS Code profiles + .rooignore |
| Aider (Terminal) | OpenAI Compatible (LiteLLM) | https://topai.id/v1 | Optional cache headers | First-class (architect + editor-model + weak-model) | ~/.aider.conf.yml + .aiderignore |
| Windsurf IDE | Custom OpenAI Compatible | https://topai.id/v1 | Provider-dependent routing | Per-thread model picker in Cascade | Custom Provider UI + .aiignore |
If this is your very first time hitting TOP AI endpoints and you want a quick primer on the response topai billing telemetry block (charged_gp, balance_after, upstream, latency_ms), bookmark our TOP AI quickstart tutorial alongside live model rates at /en/pricing.
Step 0: Account Setup, Per-Laptop tp- Keys & Zero-Cost Shell Preflight
Resist the shortcut of copying one founder-level API key into Slack for the whole engineering team. The first time someone's local agent enters an infinite lint-fix loop during lunch, you will have zero attribution and no way to shut down that single workstation without breaking everyone else's editor.
1. Claim Your 5,000 TP Starter Balance
Register at /daftar using an active email address and a password of at least 8 characters—no credit card required. TOP AI credits 5,000 TP (1 TP = Rp 1) immediately with no expiration timer. That starter wallet is large enough to run 15 to 25 full multi-file features across all four tools so you can benchmark ergonomics and speed on your own codebase before spending real budget. Once you move to daily team usage, follow our TOP AI balance top-up and token cost monitoring tutorial to track spend per key.
2. Mint a Scoped tp- Key for Your Machine
Open /dashboard/kunci and create one dedicated key per developer laptop using a predictable naming convention:
dev-dimas-macbook-agenticdev-sarah-linux-aiderdev-kevin-win11-windsurf
Copy the tp- plaintext string right away—TOP AI stores only a one-way hash and never displays the raw key again. Before saving the key configuration, lock in two safeguards:
- Daily TP Cap: Set 15,000–30,000 TP/day for an active full-time developer laptop (or 2,000 TP/day while testing on your initial 5,000 TP bonus). Even a buggy auto-approved shell loop cannot burn past that daily ceiling.
- Model Allowlist: Restrict the key strictly to the models your team actually uses—for example
claude-opus-5,claude-sonnet-5-5,gpt-6-astra,deepseek-v4-pro, anddeepseek-v4-1-flash.
3. Export TOPAI_API_KEY and Run Zero-Cost Preflight Checks
Keep credentials out of Git repositories and tool config files by exporting TOPAI_API_KEY in your shell environment.
macOS / Linux (~/.zshrc or ~/.bashrc):
export TOPAI_API_KEY="tp-replace-with-your-laptop-key"
export TOPAI_OPENAI_BASE="https://topai.id/v1"
export TOPAI_ANTHROPIC_BASE="https://topai.id"Reload your shell and run two 0 TP preflight checks to confirm the gateway sees your key and active balance:
source ~/.zshrc
# 1. Verify live model catalog (0 TP, no auth required)
curl -sS "$TOPAI_OPENAI_BASE/models" | jq '.data[0:6] | map(.id)'
# 2. Verify tp- key validity and TP balance (0 TP)
curl -sS "$TOPAI_OPENAI_BASE/balance" \
-H "Authorization: Bearer $TOPAI_API_KEY" | jq .Windows PowerShell (7+ or Windows PowerShell 5.1):
# Persist for the current Windows user profile
[Environment]::SetEnvironmentVariable("TOPAI_API_KEY", "tp-replace-with-your-laptop-key", "User")
[Environment]::SetEnvironmentVariable("TOPAI_OPENAI_BASE", "https://topai.id/v1", "User")
[Environment]::SetEnvironmentVariable("TOPAI_ANTHROPIC_BASE", "https://topai.id", "User")
# Load into the active terminal session immediately
$env:TOPAI_API_KEY = "tp-replace-with-your-laptop-key"
$env:TOPAI_OPENAI_BASE = "https://topai.id/v1"
$env:TOPAI_ANTHROPIC_BASE = "https://topai.id"
# Zero-cost balance check (0 TP)
Invoke-RestMethod -Uri "$env:TOPAI_OPENAI_BASE/balance" `
-Headers @{ Authorization = "Bearer $env:TOPAI_API_KEY" } | ConvertTo-Json -Depth 4Once /v1/balance returns HTTP 200 with your live TP balance, authentication is verified end-to-end. Now let's wire all four agentic tools cleanly.
Tool 1: OpenCode CLI (opencode.json + Dual-Protocol Caching)
OpenCode CLI hits a sweet spot for developers who want an open-source, keyboard-driven Terminal UI (TUI) that runs identically on a local MacBook, WSL2, or a remote Linux box over SSH. What makes OpenCode unusually strong with TOP AI is its ability to register multiple provider blocks inside a single opencode.json file.
Instead of forcing every model through one adapter, we configure two TOP AI provider entries: topai-anthropic pointing at https://topai.id so claude-sonnet-5-5 and claude-opus-5 get native Anthropic prompt caching, and topai-openai pointing at https://topai.id/v1 for deepseek-v4-pro, deepseek-v4-1-flash, and gpt-6-astra.
1. Install OpenCode CLI
# macOS / Linux via Homebrew
brew install opencode-ai/tap/opencode
# Cross-platform (macOS, Linux, Windows) via npm
npm install -g opencode-ai
# Confirm installation
opencode --version2. Configure ~/.config/opencode/opencode.json
OpenCode loads global defaults from ~/.config/opencode/opencode.json (on Windows: %USERPROFILE%\.config\opencode\opencode.json) and merges project-level overrides if an opencode.json exists in your repo root. Reference {env:TOPAI_API_KEY} so no secret ever sits in plaintext on disk:
{
"$schema": "https://opencode.ai/config.json",
"model": "topai-anthropic/claude-sonnet-5-5",
"small_model": "topai-openai/deepseek-v4-1-flash",
"autoupdate": false,
"provider": {
"topai-anthropic": {
"npm": "@ai-sdk/anthropic",
"name": "TOP AI (Anthropic Native + Cache)",
"options": {
"baseURL": "https://topai.id",
"apiKey": "{env:TOPAI_API_KEY}"
},
"models": {
"claude-sonnet-5-5": {
"name": "Claude Sonnet 5.5 (TOP AI)",
"limit": { "context": 200000, "output": 16384 }
},
"claude-opus-5": {
"name": "Claude Opus 5 (TOP AI)",
"limit": { "context": 200000, "output": 16384 }
}
}
},
"topai-openai": {
"npm": "@ai-sdk/openai-compatible",
"name": "TOP AI (OpenAI Compatible)",
"options": {
"baseURL": "https://topai.id/v1",
"apiKey": "{env:TOPAI_API_KEY}"
},
"models": {
"deepseek-v4-pro": {
"name": "DeepSeek V4 Pro (TOP AI)",
"limit": { "context": 128000, "output": 8192 }
},
"deepseek-v4.1-flash": {
"name": "DeepSeek V4.1 Flash (TOP AI)",
"limit": { "context": 128000, "output": 8192 }
},
"gpt-6-astra": {
"name": "GPT-6 Astra (TOP AI)",
"limit": { "context": 256000, "output": 16384 }
}
}
}
},
"permission": {
"edit": "ask",
"bash": {
"*": "ask",
"git status": "allow",
"git diff *": "allow",
"npm test*": "allow",
"pnpm test*": "allow",
"npx vitest*": "allow"
}
}
}Three design choices in that config immediately save money and prevent accidents:
- Offloading housekeeping to
small_model: OpenCode fires background calls for session title generation, history compaction, and lightweight summaries. Routingsmall_modeltotopai-openai/deepseek-v4-1-flashkeeps those background calls at pennies per thousand invocations instead of burning Claude Sonnet tokens. - Protocol-accurate
baseURL: Noticetopai-anthropicuseshttps://topai.idwith zero/v1suffix, preserving Anthropic'scache_controlbreakpoints end-to-end. On multi-turn coding sessions, cache hits kick in from turn 2 onward, bringing our 4-file TypeScript feature benchmark down to 240 TP. - Scoped bash allowlist: Read-only Git checks and targeted unit test commands run smoothly without interrupting your flow, while package installs, migrations, or destructive shell commands still pause for confirmation.
3. Smoke-Test Inside a Real Repo
cd ~/code/billing-api
opencodeInside the TUI, run /models to verify all five models appear under TOP AI (Anthropic Native + Cache) and TOP AI (OpenAI Compatible). Start with a read-only prompt—*"Inspect src/webhooks/ and summarize how HMAC signature verification handles replay windows without editing any files"*—then ask a follow-up question in the same thread to confirm prompt caching kicks in cleanly.
Tool 2: Roo Code Multi-Mode VS Code Extension (Architect / Code / Debug / Ask)
For engineers who spend eight hours a day inside VS Code, Roo Code stands out because of one architectural feature: Mode-bound API Configuration Profiles. Instead of treating every action—reading a file, planning a database migration, writing boilerplate tests, or debugging a race condition—with the same expensive frontier model, Roo Code lets you bind a dedicated TOP AI model profile to each mode.
1. Create Three Scoped TOP AI Profiles in Roo Code
Install Roo Code (RooVeterinaryInc.roo-cline) from the VS Code Marketplace. Open the Roo Code sidebar, click the Settings gear, and create three profiles under API Configuration Profiles:
Profile 1 — TOPAI-Architect (Planning & System Design):
- API Provider:
OpenAI Compatible(forgpt-6-astra) orAnthropic(if you preferclaude-opus-5with native prompt caching). - Base URL:
https://topai.id/v1(OpenAI Compatible) orhttps://topai.id(Anthropic with Use custom base URL checked). - API Key: Your workstation's
tp-key (stored securely in VS Code SecretStorage, never written to Git). - Model ID:
gpt-6-astra(orclaude-opus-5). - Context Window / Max Output:
200000/8192.
Profile 2 — TOPAI-Code-Worker (Fast Patch & Test Implementation):
- API Provider:
OpenAI Compatible - Base URL:
https://topai.id/v1 - API Key: Same laptop
tp-key. - Model ID:
deepseek-v4-pro - Image Support: Off (code and text only).
Profile 3 — TOPAI-Ask-Flash (Quick Q&A & Log Triage):
Live TOP AI API Pricing for Models Mentioned
Frequently Asked Questions
Why should every developer laptop get its own tp- API key instead of sharing a single company key?+
A shared key destroys visibility the moment an agent loop gets stuck retrying a failing test suite overnight. Minting one scoped tp- key per laptop at /dashboard/kunci gives you per-engineer daily TP caps, role-specific model allowlists, clear spend attribution, and instant single-device revocation when someone loses a machine or leaves the team.
When do I use https://topai.id/v1 versus https://topai.id without the /v1 suffix?+
Use https://topai.id/v1 for every OpenAI-compatible tool: Aider, Roo Code's OpenAI Compatible profiles, Windsurf's custom provider, and OpenCode's OpenAI adapter. Use https://topai.id with no trailing /v1 exclusively for native Anthropic adapters in OpenCode and Roo Code because Anthropic SDKs append /v1/messages automatically; adding /v1 yourself creates /v1/v1/messages and triggers a 404.
How far does the 5,000 TP signup bonus at /daftar actually go when testing all four tools?+
Quite far. At 1 TP = Rp 1, our 4-file TypeScript feature plus unit tests benchmark consumed 185 TP in Aider Architect+Editor, 240 TP in OpenCode with Anthropic caching, 290 TP in Roo Code split-mode, and 365 TP in Windsurf. That means 5,000 TP comfortably pays for 15 to 25 real multi-file feature runs across all four harnesses before you need a top-up.









