11import axios from "axios"
22import { z } from "zod"
3-
43import { type ModelInfo , IO_INTELLIGENCE_CACHE_DURATION } from "@roo-code/types"
5-
64import type { ModelRecord } from "../../../shared/api"
5+ import { parseApiPrice } from "../../../shared/cost"
76
87const ioIntelligenceModelSchema = z . object ( {
98 id : z . string ( ) ,
@@ -29,6 +28,15 @@ const ioIntelligenceModelSchema = z.object({
2928 is_blocking : z . boolean ( ) ,
3029 } ) ,
3130 ) ,
31+ max_tokens : z . number ( ) . nullable ( ) . optional ( ) ,
32+ context_window : z . number ( ) . optional ( ) ,
33+ supports_images_input : z . boolean ( ) . optional ( ) . default ( false ) ,
34+ supports_prompt_cache : z . boolean ( ) . optional ( ) . default ( false ) ,
35+ input_token_price : z . number ( ) . nullable ( ) . optional ( ) ,
36+ output_token_price : z . number ( ) . nullable ( ) . optional ( ) ,
37+ cache_write_token_price : z . number ( ) . nullable ( ) . optional ( ) ,
38+ cache_read_token_price : z . number ( ) . nullable ( ) . optional ( ) ,
39+ precision : z . string ( ) . nullable ( ) . optional ( ) ,
3240} )
3341
3442export type IOIntelligenceModel = z . infer < typeof ioIntelligenceModelSchema >
@@ -47,35 +55,22 @@ interface CacheEntry {
4755
4856let cache : CacheEntry | null = null
4957
50- /**
51- * Model context length mapping based on the documentation
52- * <mcreference link="https://docs.io.net/reference/get-started-with-io-intelligence-api" index="1">1</mcreference>
53- */
54- const MODEL_CONTEXT_LENGTHS : Record < string , number > = {
55- "meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8" : 430000 ,
56- "deepseek-ai/DeepSeek-R1-0528" : 128000 ,
57- "Intel/Qwen3-Coder-480B-A35B-Instruct-int4-mixed-ar" : 106000 ,
58- "openai/gpt-oss-120b" : 131072 ,
59- }
60-
61- const VISION_MODELS = new Set ( [
62- "Qwen/Qwen2.5-VL-32B-Instruct" ,
63- "meta-llama/Llama-3.2-90B-Vision-Instruct" ,
64- "meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8" ,
65- ] )
66-
6758function parseIOIntelligenceModel ( model : IOIntelligenceModel ) : ModelInfo {
68- const contextLength = MODEL_CONTEXT_LENGTHS [ model . id ] || 8192
69- // Cap maxTokens at 32k for very large context windows, or 20% of context length, whichever is smaller.
70- const maxTokens = Math . min ( contextLength , Math . ceil ( contextLength * 0.2 ) , 32768 )
71- const supportsImages = VISION_MODELS . has ( model . id )
59+ const contextWindow = model . context_window || 8192
60+
61+ // Use API max_tokens if provided, otherwise calculate 20% of context window
62+ const maxTokens = model . max_tokens && model . max_tokens > 0 ? model . max_tokens : Math . ceil ( contextWindow * 0.2 )
7263
7364 return {
7465 maxTokens,
75- contextWindow : contextLength ,
76- supportsImages,
77- supportsPromptCache : false ,
78- supportsComputerUse : false ,
66+ contextWindow,
67+ supportsImages : model . supports_images_input ,
68+ supportsPromptCache : model . supports_prompt_cache ,
69+ supportsComputerUse : false , // Not supported by IO Intelligence
70+ inputPrice : parseApiPrice ( model . input_token_price ) ,
71+ outputPrice : parseApiPrice ( model . output_token_price ) ,
72+ cacheWritesPrice : parseApiPrice ( model . cache_write_token_price ) ,
73+ cacheReadsPrice : parseApiPrice ( model . cache_read_token_price ) ,
7974 description : `${ model . id } via IO Intelligence` ,
8075 }
8176}
@@ -98,18 +93,17 @@ export async function getIOIntelligenceModels(apiKey?: string): Promise<ModelRec
9893 "Content-Type" : "application/json" ,
9994 }
10095
96+ // Note: IO Intelligence models endpoint does not require authentication
97+ // API key is optional for future use if needed
10198 if ( apiKey ) {
10299 headers . Authorization = `Bearer ${ apiKey } `
103- } else {
104- console . error ( "IO Intelligence API key is required" )
105- throw new Error ( "IO Intelligence API key is required" )
106100 }
107101
108102 const response = await axios . get < IOIntelligenceApiResponse > (
109103 "https://api.intelligence.io.solutions/api/v1/models" ,
110104 {
111105 headers,
112- timeout : 10_000 ,
106+ timeout : 10000 ,
113107 } ,
114108 )
115109
0 commit comments