Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/cute-lines-pump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"kilocode-docs": minor
"@kilocode/cli": minor
"kilo-code": minor
---

Add support for Claude Code Native integration.
41 changes: 41 additions & 0 deletions apps/kilocode-docs/docs/providers/claude-code-native.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
sidebar_label: Claude Code Native
---

# Using Claude Code With Kilo Code

Claude Code is Anthropic's official CLI that provides direct access to Claude models from your terminal. Using Claude Code with Kilo Code lets you leverage your existing CLI setup without needing separate API keys. This implementation uses an updated technique to speak directly to the Claude API, eliminating many of the downsides of the previous implementation. It is cache efficient, and token efficient.

## Supported Models

Kilo Code supports the following Claude models through Claude Code:

- **Claude Opus 4.5** (Most capable)
- **Claude Sonnet 4.5** (Latest, recommended)
- **Claude 4.5 Haiku** (Fast responses)

## Preparing to Configure

1. Install `claude` using the Homebrew or 'native' [installation methods](https://claudelog.com/install-claude-code/):

- macOS or Linux: `curl -fsSL https://claude.ai/install.sh | bash`
- macOS: `brew install --cask claude-code`
- Windows: `irm https://claude.ai/install.ps1 | iex`

2. Login to `claude` and get a long lived token (good for one year): `claude setup-token`

3. Record the token value - it will not be shown again.

## Configuration in Kilo Code

1. **Open Kilo Code Settings:** Click the gear icon (<Codicon name="gear" />) in the Kilo Code panel.
2. **Select Provider:** Choose "Claude Code Native" from the "API Provider" dropdown.
3. **Select Model:** Choose your desired Claude model from the "Model" dropdown.
4. **Enter your Token:** Using the token from recorded above, enter it as your API key
5. Use claude as normal!

## Tips and Notes

- **Advanced Reasoning:** Full support for Claude's thinking modes and reasoning capabilities when available.
- **Context Windows:** Claude models have large context windows, allowing you to include significant amounts of code and context in your prompts.
- **Enhance Prompt Feature:** Full compatibility with Kilo Code's Enhance Prompt feature, allowing you to automatically improve and refine your prompts before sending them to Claude.
1 change: 1 addition & 0 deletions apps/kilocode-docs/sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const sidebars: SidebarsConfig = {
"providers/cerebras", // kilocode_change
"providers/chutes-ai",
"providers/claude-code",
"providers/claude-code-native",
"providers/deepseek",
"providers/fireworks",
"providers/gemini",
Expand Down
1 change: 1 addition & 0 deletions cli/src/constants/providers/labels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const PROVIDER_LABELS: Record<ProviderName, string> = {
gemini: "Google Gemini",
vertex: "GCP Vertex AI",
"claude-code": "Claude Code",
claudecodenative: "Claude Code Native",
mistral: "Mistral",
groq: "Groq",
deepseek: "DeepSeek",
Expand Down
10 changes: 10 additions & 0 deletions cli/src/constants/providers/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ import {
rooDefaultModelId,
claudeCodeModels,
claudeCodeDefaultModelId,
claudecodenativeModels,
claudecodenativeDefaultModelId,
geminiCliModels,
geminiCliDefaultModelId,
minimaxModels,
Expand Down Expand Up @@ -158,6 +160,7 @@ export const PROVIDER_TO_ROUTER_NAME: Record<ProviderName, RouterName | null> =
featherless: null,
roo: null,
"claude-code": null,
claudecodenative: null,
"gemini-cli": null,
"virtual-quota-fallback": null,
huggingface: null,
Expand Down Expand Up @@ -210,6 +213,7 @@ export const PROVIDER_MODEL_FIELD: Record<ProviderName, string | null> = {
featherless: null,
roo: null,
"claude-code": null,
claudecodenative: "apiModelId",
"gemini-cli": null,
"virtual-quota-fallback": null,
huggingface: null,
Expand Down Expand Up @@ -271,6 +275,7 @@ export const DEFAULT_MODEL_IDS: Partial<Record<ProviderName, string>> = {
litellm: "gpt-4",
"qwen-code": qwenCodeDefaultModelId,
"claude-code": claudeCodeDefaultModelId,
claudecodenative: claudecodenativeDefaultModelId,
doubao: doubaoDefaultModelId,
fireworks: fireworksDefaultModelId,
"io-intelligence": "deepseek-ai/DeepSeek-R1-0528",
Expand Down Expand Up @@ -413,6 +418,11 @@ export function getModelsByProvider(params: {
models: claudeCodeModels as ModelRecord,
defaultModel: claudeCodeDefaultModelId,
}
case "claudecodenative":
return {
models: claudecodenativeModels as ModelRecord,
defaultModel: claudecodenativeDefaultModelId,
}
case "gemini-cli":
return {
models: geminiCliModels as ModelRecord,
Expand Down
8 changes: 8 additions & 0 deletions cli/src/constants/providers/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,13 @@ export const getProviderSettings = (provider: ProviderName, config: ProviderSett
createFieldConfig("claudeCodeMaxOutputTokens", config, "8000"),
]

case "claudecodenative":
return [
createFieldConfig("apiKey", config),
createFieldConfig("apiModelId", config, "claude-sonnet-4-5"),
createFieldConfig("anthropicBaseUrl", config, "Default"),
]

case "mistral":
return [
createFieldConfig("mistralApiKey", config),
Expand Down Expand Up @@ -1059,6 +1066,7 @@ export const PROVIDER_DEFAULT_MODELS: Record<ProviderName, string> = {
gemini: "gemini-1.5-pro-latest",
vertex: "claude-3-5-sonnet@20241022",
"claude-code": "claude-3-5-sonnet-20241022",
claudecodenative: "claude-sonnet-4-5",
mistral: "mistral-large-latest",
groq: "llama-3.1-70b-versatile",
deepseek: "deepseek-chat",
Expand Down
1 change: 1 addition & 0 deletions cli/src/constants/providers/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const PROVIDER_REQUIRED_FIELDS: Record<ProviderName, string[]> = {
bedrock: ["awsAccessKey", "awsSecretKey", "awsRegion", "apiModelId"],
gemini: ["geminiApiKey", "apiModelId"],
"claude-code": ["claudeCodePath", "apiModelId"],
claudecodenative: ["apiKey", "apiModelId"],
mistral: ["mistralApiKey", "apiModelId"],
groq: ["groqApiKey", "apiModelId"],
deepseek: ["deepSeekApiKey", "apiModelId"],
Expand Down
20 changes: 19 additions & 1 deletion packages/types/src/provider-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
xaiModels,
internationalZAiModels,
minimaxModels,
claudecodenativeModels,
} from "./providers/index.js"

/**
Expand Down Expand Up @@ -162,6 +163,7 @@ export const providerNames = [
"vertex",
"xai",
"zai",
"claudecodenative",
] as const

export const providerNamesSchema = z.enum(providerNames)
Expand Down Expand Up @@ -226,6 +228,8 @@ const anthropicSchema = apiModelIdProviderModelSchema.extend({
anthropicBeta1MContext: z.boolean().optional(), // Enable 'context-1m-2025-08-07' beta for 1M context window.
})

const claudecodenativeSchema = anthropicSchema

const claudeCodeSchema = apiModelIdProviderModelSchema.extend({
claudeCodePath: z.string().optional(),
claudeCodeMaxOutputTokens: z.number().int().min(1).max(200000).optional(),
Expand Down Expand Up @@ -588,6 +592,7 @@ export const providerSettingsSchemaDiscriminated = z.discriminatedUnion("apiProv
rooSchema.merge(z.object({ apiProvider: z.literal("roo") })),
vercelAiGatewaySchema.merge(z.object({ apiProvider: z.literal("vercel-ai-gateway") })),
sapAiCoreSchema.merge(z.object({ apiProvider: z.literal("sap-ai-core") })), // kilocode_change
claudecodenativeSchema.merge(z.object({ apiProvider: z.literal("claudecodenative") })),
defaultSchema,
])

Expand Down Expand Up @@ -640,6 +645,7 @@ export const providerSettingsSchema = z.object({
...rooSchema.shape,
...vercelAiGatewaySchema.shape,
...sapAiCoreSchema.shape, // kilocode_change
...claudecodenativeSchema.shape,
...codebaseIndexProviderSchema.shape,
})

Expand Down Expand Up @@ -741,14 +747,21 @@ export const modelIdKeysByProvider: Record<TypicalProvider, ModelIdKey> = {
roo: "apiModelId",
"vercel-ai-gateway": "vercelAiGatewayModelId",
"virtual-quota-fallback": "apiModelId",
claudecodenative: "apiModelId",
}

/**
* ANTHROPIC_STYLE_PROVIDERS
*/

// Providers that use Anthropic-style API protocol.
export const ANTHROPIC_STYLE_PROVIDERS: ProviderName[] = ["anthropic", "claude-code", "bedrock", "minimax"]
export const ANTHROPIC_STYLE_PROVIDERS: ProviderName[] = [
"anthropic",
"claude-code",
"bedrock",
"minimax",
"claudecodenative",
]

export const getApiProtocol = (provider: ProviderName | undefined, modelId?: string): "anthropic" | "openai" => {
if (provider && ANTHROPIC_STYLE_PROVIDERS.includes(provider)) {
Expand Down Expand Up @@ -894,4 +907,9 @@ export const MODELS_BY_PROVIDER: Record<
// Local providers; models discovered from localhost endpoints.
lmstudio: { id: "lmstudio", label: "LM Studio", models: [] },
ollama: { id: "ollama", label: "Ollama", models: [] },
claudecodenative: {
id: "claudecodenative",
label: "Claude Code Native",
models: Object.keys(claudecodenativeModels),
},
}
28 changes: 28 additions & 0 deletions packages/types/src/providers/anthropic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@ export const anthropicModels = {
supportsReasoningBudget: true,
supportsVerbosity: true, // kilocode_change
},
"claude-opus-4-5": {
maxTokens: 32_000, // Overridden to 8k if `enableReasoningEffort` is false.
contextWindow: 200_000,
supportsImages: true,
supportsPromptCache: true,
supportsNativeTools: true,
inputPrice: 5.0, // $5 per million input tokens
outputPrice: 25.0, // $25 per million output tokens
cacheWritesPrice: 6.25, // $6.25 per million tokens
cacheReadsPrice: 0.5, // $0.50 per million tokens
supportsReasoningBudget: true,
supportsVerbosity: true, // kilocode_change
},
"claude-opus-4-1-20250805": {
maxTokens: 32_000, // Overridden to 8k if `enableReasoningEffort` is false.
contextWindow: 200_000,
Expand Down Expand Up @@ -170,6 +183,21 @@ export const anthropicModels = {
description:
"Claude Haiku 4.5 delivers near-frontier intelligence at lightning speeds with extended thinking, vision, and multilingual support.",
},
"claude-haiku-4-5": {
maxTokens: 64_000,
contextWindow: 200_000,
supportsImages: true,
supportsPromptCache: true,
supportsNativeTools: true,
defaultToolProtocol: "native", // kilocode_change
inputPrice: 1.0,
outputPrice: 5.0,
cacheWritesPrice: 1.25,
cacheReadsPrice: 0.1,
supportsReasoningBudget: true,
description:
"Claude Haiku 4.5 delivers near-frontier intelligence at lightning speeds with extended thinking, vision, and multilingual support.",
},
} as const satisfies Record<string, ModelInfo>

export const ANTHROPIC_DEFAULT_MAX_TOKENS = 8192
11 changes: 11 additions & 0 deletions packages/types/src/providers/claudecodenative.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { ModelInfo } from "../model.js"
import { anthropicModels } from "./anthropic.js"

export type ClaudeCodeNativeModelId = keyof typeof claudecodenativeModels
export const claudecodenativeDefaultModelId: ClaudeCodeNativeModelId = "claude-sonnet-4-5"

export const claudecodenativeModels = {
"claude-sonnet-4-5": anthropicModels["claude-sonnet-4-5"],
"claude-opus-4-5": anthropicModels["claude-opus-4-5"],
"claude-haiku-4-5": anthropicModels["claude-haiku-4-5"],
} as const satisfies Record<string, ModelInfo>
4 changes: 4 additions & 0 deletions packages/types/src/providers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export * from "./featherless.js"
export * from "./fireworks.js"
export * from "./gemini.js"
// kilocode_change start
export * from "./claudecodenative.js"
export * from "./gemini-cli.js"
export * from "./ovhcloud.js"
export * from "./synthetic.js"
Expand Down Expand Up @@ -71,6 +72,7 @@ import { vercelAiGatewayDefaultModelId } from "./vercel-ai-gateway.js"
import { internationalZAiDefaultModelId, mainlandZAiDefaultModelId } from "./zai.js"
import { deepInfraDefaultModelId } from "./deepinfra.js"
import { minimaxDefaultModelId } from "./minimax.js"
import { claudecodenativeDefaultModelId } from "./claudecodenative.js"

// Import the ProviderName type from provider-settings to avoid duplication
import type { ProviderName } from "../provider-settings.js"
Expand Down Expand Up @@ -155,6 +157,8 @@ export function getProviderDefaultModelId(
return qwenCodeDefaultModelId
case "vercel-ai-gateway":
return vercelAiGatewayDefaultModelId
case "claudecodenative":
return claudecodenativeDefaultModelId
case "anthropic":
case "gemini-cli":
case "human-relay":
Expand Down
3 changes: 3 additions & 0 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import {
DeepInfraHandler,
MiniMaxHandler,
BasetenHandler,
ClaudeCodeNativeHandler,
} from "./providers"
// kilocode_change start
import { KilocodeOpenrouterHandler } from "./providers/kilocode-openrouter"
Expand Down Expand Up @@ -156,6 +157,8 @@ export function buildApiHandler(configuration: ProviderSettings): ApiHandler {
return new AnthropicHandler(options)
case "claude-code":
return new ClaudeCodeHandler(options)
case "claudecodenative":
return new ClaudeCodeNativeHandler(options)
// kilocode_change start
case "glama":
return new GlamaHandler(options)
Expand Down
Loading