← Blog
Kilo CodeIntegrationCoding agents

Kilo Code with Claude and GPT: Custom API Provider Setup

(prices in the text follow the live price list)

Short answer

To use Kilo Code with APIVAI, open Kilo Code's Settings, go to the Providers tab, click Custom provider, set Provider API to OpenAI Compatible, enter https://api.apivai.com/v1 as the Base URL, paste your APIVAI key into API key and add a model ID such as claude-sonnet-4-6 or gpt-5.5. For Claude only, you can choose Anthropic Messages as the Provider API instead, and in Kilo Code that option also takes https://api.apivai.com/v1 with /v1, because Kilo Code appends only /messages to the Base URL. As of 2026-10-10, Claude Sonnet 4.6 costs $1.15 / $5.74 per million input / output tokens through APIVAI, against the official $3.00 / $15.00. You pay per token from a prepaid balance, with no subscription.

What is Kilo Code, and why connect your own API key?

Kilo Code is an open-source AI coding agent that runs as a VS Code extension, a JetBrains plugin and a command-line tool. It plans changes, edits files across your project and runs commands with your approval. Kilo Code needs a model provider, and every step of a task is a request billed by that provider.

This guide follows the current Kilo Code documentation and the VS Code extension 7.8 (October 2026), where third-party APIs are added through the Custom provider dialog. If your settings screen has no Custom provider button, update the extension first.

APIVAI gives you one key for Claude and GPT models, billed per token below official list prices for most models, from a balance you top up yourself. The same key works in the OpenAI format and in the Anthropic format, so it fits every Provider API option Kilo Code offers.

Which Provider API should you choose in Kilo Code?

The custom provider dialog offers three protocols. With APIVAI, all three use the same Base URL:

Provider APIBase URLModelsModel list
OpenAI Compatiblehttps://api.apivai.com/v1Claude and GPTFetch models works
Anthropic Messageshttps://api.apivai.com/v1Claude onlyType the IDs yourself
OpenAI Responseshttps://api.apivai.com/v1GPTFetch models works

Pick OpenAI Compatible if you want one provider that covers Claude and GPT. Add an Anthropic Messages provider if you mostly work with Claude: Kilo Code then sends native Anthropic requests with cache_control markers, so repeated context is billed at the cache-read price of $0.12 per million tokens for Claude Sonnet 4.6 instead of the full input price. Cache writes cost $1.44 per million. OpenAI Responses is optional; GPT models already work through OpenAI Compatible.

How do you set up Kilo Code with APIVAI step by step?

Step 1: Create an APIVAI key

  1. Sign up at apivai.com with your email.
  2. Top up from $10 by card, crypto, Alipay or WeChat Pay. There is no free trial or subscription.
  3. In the Dashboard, create a key and copy it. Give it a budget limit if you want a hard cap on what Kilo Code can spend.

Step 2: Add APIVAI as a custom provider

  1. In VS Code, open the Kilo Code panel, click the gear icon to open Settings and go to the Providers tab.
  2. Scroll to the bottom and click Custom provider.
  3. Fill in the dialog as shown below, then click Submit.
FieldValue
Provider IDapivai (lowercase letters, numbers, hyphens or underscores)
Display nameAPIVAI
Provider APIOpenAI Compatible
Base URLhttps://api.apivai.com/v1
API keyYour APIVAI key
ModelsClick Fetch models and select, for example, claude-sonnet-4-6 and gpt-5.5

Once the Base URL and key are filled in, Kilo Code calls GET /v1/models with your key and shows a searchable list, so you only add IDs that APIVAI actually serves. If the fetch fails, check the key and URL, or click Add model and type the exact ID yourself. The Base URL contains /v1 exactly once; Kilo Code adds /chat/completions to it. After Submit, choose the model in Kilo Code's model picker.

You can check the same list from a terminal:

curl https://api.apivai.com/v1/models \
  -H "Authorization: Bearer YOUR_APIVAI_KEY"

Models are added and retired over time, so copy IDs from this list or from the pricing page.

Step 3 (optional): Add a Claude provider with Anthropic Messages

  1. Click Custom provider again.
  2. Set Provider ID to apivai-claude and Display name to "APIVAI Claude".
  3. Set Provider API to Anthropic Messages.
  4. Enter https://api.apivai.com/v1 as the Base URL and paste the same key into API key.
  5. Under Models, click Add model and type each Claude ID, for example claude-sonnet-4-6 and claude-opus-5-5. Fetch models is not available for this Provider API.
  6. Click Submit.

Keep /v1 here. Kilo Code's Anthropic Messages client treats the Base URL as the versioned API prefix (its own default is https://api.anthropic.com/v1) and adds only /messages, so your requests go to https://api.apivai.com/v1/messages. This is the opposite of Claude Code and Roo Code, where the Anthropic base URL is https://api.apivai.com without /v1. More on the Anthropic format is on the Claude API proxy page.

Step 4: Set token limits in the config file

The dialog does not set context or output limits. Kilo Code's docs recommend setting limit.context and limit.output for custom models: if both are missing, they resolve to 0 and automatic context compaction is disabled. Edit the provider (the dialog links to Edit advanced settings in the JSON config file) or open the global config ~/.config/kilo/kilo.json and add limits under your provider:

{
  "provider": {
    "apivai": {
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "https://api.apivai.com/v1"
      },
      "models": {
        "claude-sonnet-4-6": {
          "name": "Claude Sonnet 4.6",
          "tool_call": true,
          "limit": { "context": 200000, "output": 16384 }
        }
      }
    }
  },
  "model": "apivai/claude-sonnet-4-6"
}

Set limit.context to the context window shown on the model's page and keep limit.output at 16384 (at least 4096). The key you entered in the dialog stays where Kilo Code saved it; to read it from an environment variable instead, add "apiKey": "{env:APIVAI_API_KEY}" to options (this works in the global config, not in a project-level kilo.json). The Kilo CLI reads the same file.

Which model should you choose in Kilo Code?

Prices per 1M input / output tokens as of 2026-10-10:

Model IDPrice (in / out)Good for
claude-sonnet-4-6$1.15 / $5.74Everyday coding: the default
claude-sonnet-5-5$0.77 / $3.82Coding with the newer Sonnet
claude-opus-5-5$1.54 / $7.65Planning, hardest bugs
claude-haiku-4-5$0.38 / $1.92Fast, cheap questions and small edits
gpt-6-sol$0.30 / $1.52GPT alternative for coding or review
gpt-6-luna$0.0144 / $0.0768Very cheap questions

Kilo Code's agents call tools on almost every step, so pick models that support function calling; all models above do. If a task keeps going in circles on Sonnet, switch that task to Opus rather than making Opus your default.

How much does Kilo Code cost with APIVAI?

Each step of an agent task resends the conversation and the files read so far, so input tokens dominate. Two worked examples:

  • One coding task on Claude Sonnet 4.6: about 25 requests of 35,000 input and 2,000 output tokens each. Cost: $1.29 with APIVAI, $3.38 at official prices.
  • A working month of three such tasks a day for 22 days (1,650 requests): $85.35 with APIVAI, $223 at official prices. Sending 20 quick questions a day to Claude Haiku 4.5 (8,000 input, 800 output tokens each, 440 a month) adds $2.01.

These figures ignore prompt caching, which lowers the cost of repeated context on the Anthropic Messages provider. Thinking tokens count as output tokens. Your real numbers per request are on the Dashboard. For a wider comparison, read Claude API pricing in 2026.

How do you fix common Kilo Code errors?

  • "Authentication failed" when fetching models, or 401: the key is incomplete, deleted or over its budget limit; check the Dashboard and paste the key again without spaces.
  • 404 Not Found: wrong /v1. In Kilo Code, every Provider API uses https://api.apivai.com/v1. Without /v1, Anthropic Messages calls /messages and OpenAI Compatible calls /chat/completions at the wrong path.
  • No models found with Anthropic Messages: expected; this Provider API has no model fetch. Add the Claude IDs with Add model.
  • Model not found: use the exact ID, such as claude-sonnet-4-6, not a display name. Compare with GET /v1/models.
  • Empty or truncated replies: thinking is on by default and uses output tokens. Set limit.output to 16384 (at least 4096).
  • Context is never compacted on long tasks: set limit.context and limit.output as in Step 4.
  • 429 Too Many Requests: the default limit is 60 requests per minute per key. Wait briefly, or ask support to raise it.

More on request formats is in the docs and on the OpenAI-compatible API page.

FAQ

Can I use Claude and GPT in Kilo Code with one key?

Yes. One APIVAI key works for every model. A single OpenAI Compatible provider can list Claude and GPT IDs side by side.

Should I use OpenAI Compatible or Anthropic Messages?

Use OpenAI Compatible for GPT models or one provider for everything. Add Anthropic Messages for Claude-heavy work, where Kilo Code uses prompt caching; its Base URL is also https://api.apivai.com/v1.

Why does Kilo Code need /v1 for Anthropic when Claude Code does not?

Claude Code's client adds /v1/messages to the base URL, while Kilo Code's Anthropic Messages client adds only /messages. Both end up at https://api.apivai.com/v1/messages.

Does the same setup work in the Kilo CLI?

Yes. The CLI reads the provider from kilo.json, so the config block in Step 4 works there too.

Does APIVAI store my code?

No. Request and response content is not logged; only usage data such as model, tokens and cost is kept for billing.

How is this different from Roo Code or Cline?

The models and key are the same, but the screens differ. See the Roo Code guide and the Cline guide.

Create an account, top up from $10 and paste your key into Kilo Code.

Ready to start?

Get your API key in 30 seconds. Pay as you go for Claude and GPT.

Get Started