Skip to content

A real coding run · 29 October 2026

Fix a bug with OpenCode. See what it costs.

Connect your tool, fix one small JavaScript bug and check the bill. Our measured OpenCode run used 26 credits and passed all three tests.

An internal product test using OpenCode 2.2.0 and Swift (fast). This is one observed result, not a fixed price or a customer testimonial.

1. Connect with a capped key

You need Node.js and OpenCode installed. Use a new empty folder for this exercise. Sign in to developer setup, create a dedicated API key and keep a monthly spending cap on it. Copy the secret once and store it outside your project.

Record your starting balance in Billing. Pause other AI activity on the account while measuring this task. A key cap limits spend; it does not add credits or guarantee that a request can reserve enough credits to start.

OpenCode 2.2.0 configuration used for this task

Save only your secret in a private file outside the project. Replace the absolute path below with that file's location. Restrict its file permissions (on macOS/Linux, use chmod 600). Save this configuration as opencode.json in the exercise folder. It limits the agent to these files, this test command and five steps.

opencode.json — OpenCode 2.2.0
{
  "$schema": "https://opencode.ai/config.json",
  "providers": {
    "velatl": {
      "package": "@opencode/ai/providers/openai-compatible",
      "name": "VelATL",
      "settings": {
        "baseURL": "https://velatl.ai/api/v1",
        "apiKey": "{file:/absolute/path/to/your/private/velatl.key}"
      },
      "models": {
        "fast": {
          "name": "Swift",
          "limit": {
            "context": 32768,
            "output": 1024
          }
        }
      }
    }
  },
  "model": "velatl/fast",
  "agents": {
    "build": {
      "steps": 5,
      "permissions": [
        {
          "action": "*",
          "resource": "*",
          "effect": "deny"
        },
        {
          "action": "read",
          "resource": "average*",
          "effect": "allow"
        },
        {
          "action": "edit",
          "resource": "average.mjs",
          "effect": "allow"
        },
        {
          "action": "shell",
          "resource": "node --test average.test.mjs",
          "effect": "allow"
        }
      ]
    }
  }
}

This is a version-specific example. For other versions, see the OpenCode setup guide. Check current model availability and rates before running; the recorded test used model ID fast.

Using VS Code? Follow the Cline setup with the same task. Our Cline 4.1.26 run passed in VS Code 1.144.0 using Settings → Terminal → Background Exec. Keep command approval enabled. The 26-credit measurement below belongs to OpenCode.

2. Give it a bug you can verify

Create these two files in the empty folder. The function calculates an average, but returns NaN when the array is empty. We want null for that case.

average.mjs — before the fix
export function average(numbers) {
  return numbers.reduce((sum, n) => sum + n, 0) / numbers.length;
}
average.test.mjs — keep these tests unchanged
import test from "node:test";
import assert from "node:assert/strict";
import { average } from "./average.mjs";

test("positive numbers", () => assert.equal(average([2, 4, 6]), 4));
test("negative numbers", () => assert.equal(average([-2, -4, -6]), -4));
test("empty input has no average", () => assert.equal(average([]), null));

Run the tests yourself first. You should see two passes and one failure. This local command does not call VelATL or spend credits.

Run in the exercise folder
node --test average.test.mjs

Start OpenCode from that folder with opencode --standalone, select velatl/fast, and send this prompt. Sending it starts paid-in-credits AI work.

Task prompt
Fix average.mjs so average([]) returns null. Do not modify the tests. Read only average.mjs and average.test.mjs, make the smallest correction, then run node --test average.test.mjs. Stay inside this project; do not use web or other external tools. Finish with the test result.

Review the proposed edit and command before approving. If the agent goes outside the task, stop it. Do not repeatedly retry a failing request without checking the error and usage.

3. Check the fix and the actual spend

In our run the agent added this guard before the calculation, then ran the tests. Run the command again yourself to verify the result.

The correction
if (numbers.length === 0) return null;
Recorded OpenCode result · 29 October 2026
Tests before2 passed, 1 failed
Tests after3 passed, 0 failed
Starting balance10,663 credits
Ending balance10,637 credits
Measured task spend26 credits

After all requests finish, refresh Billing and subtract your ending balance from your starting balance. This measures the whole task only if no other usage or credit grants happened during the interval. Check the dedicated key's usage in Settings too.

Credit activity includes reservations and refunds: the reservation alone is not the final charge. Longer prompts, file context, tool definitions, retries and model choice change the cost. Your result may differ from 26 credits.

Editor token counts are useful, but a displayed $0 can simply mean no dollar prices are configured. Use VelATL's settled credit usage to assess spend. A successful API request confirms connectivity; your tests confirm whether the coding task succeeded.

4. Top up with UPI when you need more

  1. Open Billing → Buy credits (one-time). Review the current pack price and credit amount before choosing it.
  2. In Razorpay checkout, enter the required contact details and select UPI. Follow the displayed QR or payment instructions and authorize privately in your UPI app.
  3. Return to Billing. Check that the payment is captured and the credit grant appears. The server confirms payment before adding credits.

If your bank shows a debit but credits are missing, check payment history and contact support before paying again. Never share a UPI PIN, OTP or API key. This walkthrough verified opening live checkout; the test stopped before payment, so it does not demonstrate a completed purchase.

Now try it with your own account

Follow the setup checklist, run this task, then compare your test result and actual credit usage.

Open the setup checklist →