Skip to content

Commit 69d5667

Browse files
authored
Merge pull request #3466 from Kilo-Org/feat/add-inception-as-provider
feat (provider): add inception labs as a provider
2 parents 91f556f + 4090281 commit 69d5667

File tree

25 files changed

+468
-30
lines changed

25 files changed

+468
-30
lines changed

.changeset/puny-brooms-listen.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"kilo-code": minor
3+
---
4+
5+
Thanks @pranjaldatta! Added support for Inception as a provider

packages/types/src/global-settings.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@ export const SECRET_STATE_KEYS = [
223223
// kilocode_change start
224224
"kilocodeToken",
225225
"syntheticApiKey",
226+
"ovhCloudAiEndpointsApiKey",
227+
"inceptionLabsApiKey",
226228
// kilocode_change end
227229
"codebaseIndexOpenAiCompatibleApiKey",
228230
"codebaseIndexGeminiApiKey",
@@ -235,7 +237,6 @@ export const SECRET_STATE_KEYS = [
235237
"featherlessApiKey",
236238
"ioIntelligenceApiKey",
237239
"vercelAiGatewayApiKey",
238-
"ovhCloudAiEndpointsApiKey", // kilocode_change
239240
] as const
240241

241242
// Global secrets that are part of GlobalSettings (not ProviderSettings)

packages/types/src/kilocode/native-function-calling.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const nativeFunctionCallingProviders = [
1919
"zai",
2020
"synthetic",
2121
"human-relay",
22+
"inception",
2223
] satisfies ProviderName[] as ProviderName[]
2324

2425
const modelsDefaultingToJsonKeywords = ["claude-haiku-4.5", "claude-haiku-4-5"]

packages/types/src/provider-settings.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export const dynamicProviders = [
5353
"ovhcloud",
5454
"chutes",
5555
"gemini",
56+
"inception",
5657
// kilocode_change end
5758
"deepinfra",
5859
"io-intelligence",
@@ -149,6 +150,7 @@ export const providerNames = [
149150
"gemini-cli",
150151
"virtual-quota-fallback",
151152
"synthetic",
153+
"inception",
152154
// kilocode_change end
153155
"sambanova",
154156
"vertex",
@@ -413,6 +415,12 @@ const sambaNovaSchema = apiModelIdProviderModelSchema.extend({
413415
})
414416

415417
// kilocode_change start
418+
const inceptionSchema = apiModelIdProviderModelSchema.extend({
419+
inceptionLabsBaseUrl: z.string().optional(),
420+
inceptionLabsApiKey: z.string().optional(),
421+
inceptionLabsModelId: z.string().optional(),
422+
})
423+
416424
const ovhcloudSchema = baseProviderSettingsSchema.extend({
417425
ovhCloudAiEndpointsApiKey: z.string().optional(),
418426
ovhCloudAiEndpointsModelId: z.string().optional(),
@@ -524,6 +532,7 @@ export const providerSettingsSchemaDiscriminated = z.discriminatedUnion("apiProv
524532
kilocodeSchema.merge(z.object({ apiProvider: z.literal("kilocode") })),
525533
virtualQuotaFallbackSchema.merge(z.object({ apiProvider: z.literal("virtual-quota-fallback") })),
526534
syntheticSchema.merge(z.object({ apiProvider: z.literal("synthetic") })),
535+
inceptionSchema.merge(z.object({ apiProvider: z.literal("inception") })),
527536
// kilocode_change end
528537
groqSchema.merge(z.object({ apiProvider: z.literal("groq") })),
529538
huggingFaceSchema.merge(z.object({ apiProvider: z.literal("huggingface") })),
@@ -559,6 +568,8 @@ export const providerSettingsSchema = z.object({
559568
...kilocodeSchema.shape,
560569
...virtualQuotaFallbackSchema.shape,
561570
...syntheticSchema.shape,
571+
...ovhcloudSchema.shape,
572+
...inceptionSchema.shape,
562573
// kilocode_change end
563574
...openAiNativeSchema.shape,
564575
...mistralSchema.shape,
@@ -585,7 +596,6 @@ export const providerSettingsSchema = z.object({
585596
...rooSchema.shape,
586597
...vercelAiGatewaySchema.shape,
587598
...codebaseIndexProviderSchema.shape,
588-
...ovhcloudSchema.shape, // kilocode_change
589599
})
590600

591601
export type ProviderSettings = z.infer<typeof providerSettingsSchema>
@@ -621,6 +631,7 @@ export const modelIdKeys = [
621631
"deepInfraModelId",
622632
"kilocodeModel",
623633
"ovhCloudAiEndpointsModelId", // kilocode_change
634+
"inceptionLabsModelId", // kilocode_change
624635
] as const satisfies readonly (keyof ProviderSettings)[]
625636

626637
export type ModelIdKey = (typeof modelIdKeys)[number]
@@ -677,6 +688,7 @@ export const modelIdKeysByProvider: Record<TypicalProvider, ModelIdKey> = {
677688
kilocode: "kilocodeModel",
678689
"virtual-quota-fallback": "apiModelId",
679690
ovhcloud: "ovhCloudAiEndpointsModelId", // kilocode_change
691+
inception: "inceptionLabsModelId", // kilocode_change
680692
}
681693

682694
/**
@@ -808,9 +820,10 @@ export const MODELS_BY_PROVIDER: Record<
808820
openrouter: { id: "openrouter", label: "OpenRouter", models: [] },
809821
requesty: { id: "requesty", label: "Requesty", models: [] },
810822
unbound: { id: "unbound", label: "Unbound", models: [] },
811-
ovhcloud: { id: "ovhcloud", label: "OVHcloud AI Endpoints", models: [] }, // kilocode_change
812823

813824
// kilocode_change start
825+
ovhcloud: { id: "ovhcloud", label: "OVHcloud AI Endpoints", models: [] },
826+
inception: { id: "inception", label: "Inception", models: [] },
814827
kilocode: { id: "kilocode", label: "Kilocode", models: [] },
815828
"kilocode-openrouter": { id: "kilocode-openrouter", label: "Kilocode", models: [] }, // temporarily needed to satisfy because we're using 2 inconsistent names apparently
816829
"virtual-quota-fallback": { id: "virtual-quota-fallback", label: "Virtual Quota Fallback", models: [] },
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// kilocode_change - file added
2+
3+
import type { ModelInfo } from "../model.js"
4+
5+
// Default fallback values for Inception when model metadata is not yet loaded.
6+
7+
export const inceptionDefaultModelId = "mercury-coder"
8+
9+
export const inceptionDefaultModelInfo: ModelInfo = {
10+
maxTokens: 8192,
11+
contextWindow: 128000,
12+
supportsImages: false,
13+
supportsPromptCache: false,
14+
inputPrice: 0.00000025,
15+
outputPrice: 0.000001,
16+
cacheReadsPrice: 0,
17+
cacheWritesPrice: 0,
18+
}

packages/types/src/providers/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export * from "./gemini.js"
1212
export * from "./gemini-cli.js"
1313
export * from "./ovhcloud.js"
1414
export * from "./synthetic.js"
15+
export * from "./inception.js"
1516
// kilocode_change end
1617
export * from "./glama.js"
1718
export * from "./groq.js"

src/api/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import {
5050
} from "./providers"
5151
// kilocode_change start
5252
import { KilocodeOpenrouterHandler } from "./providers/kilocode-openrouter"
53+
import { InceptionLabsHandler } from "./providers/inception"
5354
// kilocode_change end
5455
import { NativeOllamaHandler } from "./providers/native-ollama"
5556

@@ -191,6 +192,10 @@ export function buildApiHandler(configuration: ProviderSettings): ApiHandler {
191192
// kilocode_change start
192193
case "synthetic":
193194
return new SyntheticHandler(options)
195+
case "inception":
196+
return new InceptionLabsHandler(options)
197+
case "ovhcloud":
198+
return new OVHcloudAIEndpointsHandler(options)
194199
// kilocode_change end
195200
case "io-intelligence":
196201
return new IOIntelligenceHandler(options)
@@ -202,10 +207,6 @@ export function buildApiHandler(configuration: ProviderSettings): ApiHandler {
202207
return new FeatherlessHandler(options)
203208
case "vercel-ai-gateway":
204209
return new VercelAiGatewayHandler(options)
205-
// kilocode_change start
206-
case "ovhcloud":
207-
return new OVHcloudAIEndpointsHandler(options)
208-
// kilocode_change end
209210
default:
210211
apiProvider satisfies "gemini-cli" | undefined
211212
return new AnthropicHandler(options)
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// kilocode_change - file added
2+
3+
import axios from "axios"
4+
import { object, z } from "zod"
5+
6+
import { type ModelInfo } from "@roo-code/types"
7+
8+
import { DEFAULT_HEADERS } from "../constants"
9+
10+
// Inception models endpoint follows OpenAI /models shape wiht an added metadata object
11+
12+
const InceptionModelPricingSchema = z.object({
13+
prompt: z.number().describe("Pricing per 1 input token"),
14+
completion: z.number().describe("Pricing per 1 output token"),
15+
image: z.number().describe("Pricing per 1 image"),
16+
request: z.number().describe("Pricing per 1 request"),
17+
input_cache_reads: z.number().describe("Pricing per 1 token for cache reads"),
18+
input_cache_writes: z.number().describe("Pricing per 1 token for cache writes"),
19+
})
20+
21+
const InceptionModelSchema = z.object({
22+
id: z.string(),
23+
name: z.string(),
24+
created: z.number(),
25+
input_modalities: z.string().array(),
26+
output_modalities: z.string().array(),
27+
context_length: z.number().int(),
28+
max_output_length: z.number().int(),
29+
pricing: InceptionModelPricingSchema,
30+
suported_sampling_parameters: z.string().array(),
31+
supported_features: z.string().array(),
32+
supports_prefix_caching: z.boolean().default(false),
33+
34+
description: z.string().optional(),
35+
})
36+
37+
const InceptionModelsResponseSchema = z.object({ data: z.array(InceptionModelSchema) })
38+
39+
export async function getInceptionModels(
40+
apiKey?: string,
41+
baseUrl: string = "https://api.inceptionlabs.ai/v1/",
42+
): Promise<Record<string, ModelInfo>> {
43+
const models: Record<string, ModelInfo> = {}
44+
const url = `${baseUrl.replace(/\/$/, "")}/models`
45+
const headers: Record<string, string> = { ...DEFAULT_HEADERS }
46+
47+
if (apiKey) headers["Authorization"] = `Bearer ${apiKey}`
48+
49+
const response = await axios.get(url, { headers })
50+
51+
const parsed = InceptionModelsResponseSchema.safeParse(response.data)
52+
const data = parsed.success ? parsed.data.data : response.data?.data || []
53+
54+
for (const m of data as Array<z.infer<typeof InceptionModelSchema>>) {
55+
const info: ModelInfo = {
56+
contextWindow: m.context_length,
57+
maxTokens: m.max_output_length,
58+
inputPrice: m.pricing.prompt,
59+
outputPrice: m.pricing.completion,
60+
description: m.description,
61+
supportsPromptCache: m.supports_prefix_caching,
62+
supportsImages: false,
63+
cacheReadsPrice: m.pricing.input_cache_reads,
64+
cacheWritesPrice: m.pricing.input_cache_writes,
65+
}
66+
models[m.id] = info
67+
}
68+
69+
return models
70+
}

src/api/providers/fetchers/modelCache.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { getIOIntelligenceModels } from "./io-intelligence"
2727
import { getOvhCloudAiEndpointsModels } from "./ovhcloud"
2828
import { getChutesModels } from "./chutes"
2929
import { getGeminiModels } from "./gemini"
30+
import { getInceptionModels } from "./inception"
3031
// kilocode_change end
3132

3233
import { getDeepInfraModels } from "./deepinfra"
@@ -134,6 +135,9 @@ export const getModels = async (options: GetModelsOptions): Promise<ModelRecord>
134135
models = await getHuggingFaceModels()
135136
break
136137
// kilocode_change start
138+
case "inception":
139+
models = await getInceptionModels()
140+
break
137141
case "ovhcloud":
138142
models = await getOvhCloudAiEndpointsModels()
139143
break

0 commit comments

Comments
 (0)