Tool setup
OpenCode
OpenCode talks to any OpenAI-compatible endpoint, so you add AdvancedMind AI as a provider and point it at the gateway.
Before you start
You need an active API key and credits on the org. Create a key under API keys and copy the secret; it is shown once. A standard-scoped key can use either Klara preview whenever that route is available.
1. Set your API key
OpenCode reads AMAI_API_KEY from the environment, so the secret never lands in a config file. Export it in the shell you launch OpenCode from:
export AMAI_API_KEY="amai_sk_..." # paste the secret shown once at key creation2. Add AdvancedMind AI as a provider
OpenCode uses an OpenAI-compatible client. Point its baseURL at https://api.advancedmind.ai/v1 and declare the models you want. Add this to your OpenCode config: global at ~/.config/opencode/opencode.json, or a project-local opencode.json at the repo root.
{
"provider": {
"advancedmind": {
"npm": "@ai-sdk/openai-compatible",
"name": "AdvancedMind AI",
"options": {
"baseURL": "https://api.advancedmind.ai/v1",
"apiKey": "{env:AMAI_API_KEY}"
},
"models": {
"Klara-base-preview-v1": {
"name": "Klara Base Preview v1"
},
"Klara-base-preview-v2": {
"name": "Klara Base Preview v2"
}
}
}
}
}Choosing a model
- Klara Base Preview v2: use it first for harder repository analysis, debugging, tests, and implementation loops.
- Klara Base Preview v1: use it for more direct technical analysis and focused edits.
The Klara previews support streaming and tool calls; the wire ids are in the config above. Full pricing is on the pricing & credits page.
3. Run your first request
Reference the model as advancedmind/<model-id>: the provider prefix you declared above, then the model id.
# from inside the repo you want to work in
opencode run -m advancedmind/Klara-base-preview-v2 \
"Explain what auth/session.go does, then propose a fix for the token refresh race."Or work interactively and switch models from the TUI:
# or start the TUI and pick the model from the model switcher
opencodeCost visibility
Every request is metered against your org balance and recorded with its model, token counts, and final cost. Watch spend on the Usage page, and top up or set a low-credit alert on Billing. A request that would run past your balance is blocked before any provider call, so an agent left running overnight cannot overspend.
Key scopes and limits
Give each tool its own key so you can revoke it without disrupting anything else. Two controls matter for an automated agent:
- Scope: use a
standardkey for ordinary Klara work and aresearchkey only for an approved Research Mode scope. - Monthly spend limit: set a per-key cap when you create the key so an unattended OpenCode session cannot run past it.
Manage and revoke keys on the API keys page.
Next: streaming, error handling, or the Aider setup guide.