{"record":{"id":"5df58b7534c55936","repo":"spring-projects/spring-ai","slug":"thinkinglevel-s-is-not-supported-for-model-s-5df58b","errorCode":null,"errorMessage":"ThinkingLevel.%s is not supported for model '%s'. Supported levels: %s.","messagePattern":"ThinkingLevel\\.(.+?) is not supported for model '(.+?)'\\. Supported levels: (.+?)\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"models/spring-ai-google-genai/src/main/java/org/springframework/ai/google/genai/GoogleGenAiChatModel.java","lineNumber":930,"sourceCode":"\tprivate static void validateThinkingLevelForModel(GoogleGenAiThinkingLevel level, String modelName) {\n\t\tif (level == null || level == GoogleGenAiThinkingLevel.THINKING_LEVEL_UNSPECIFIED || modelName == null) {\n\t\t\treturn;\n\t\t}\n\t\t// Vertex AI style full resource names (e.g.\n\t\t// \"projects/{project}/locations/{location}/publishers/google/models/{model}\")\n\t\t// carry the model id as the last path segment.\n\t\tString modelId = modelName.substring(modelName.lastIndexOf('/') + 1).toLowerCase(Locale.ROOT);\n\t\tSet<GoogleGenAiThinkingLevel> supportedLevels = THINKING_LEVEL_SUPPORT_BY_MODEL.get(modelId);\n\t\tif (supportedLevels == null) {\n\t\t\treturn;\n\t\t}\n\t\tif (!supportedLevels.contains(level)) {\n\t\t\tif (supportedLevels.isEmpty()) {\n\t\t\t\tthrow new IllegalArgumentException(String.format(\n\t\t\t\t\t\t\"ThinkingLevel.%s is not supported for model '%s'. This model does not support thinkingLevel; use thinkingBudget instead.\",\n\t\t\t\t\t\tlevel, modelName));\n\t\t\t}\n\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\tString.format(\"ThinkingLevel.%s is not supported for model '%s'. Supported levels: %s.\", level,\n\t\t\t\t\t\t\tmodelName, supportedLevels.stream().map(Enum::name).collect(Collectors.joining(\", \"))));\n\t\t}\n\t}\n\n\tprivate List<Content> toGeminiContent(List<Message> instructions) {\n\n\t\tList<Content> contents = instructions.stream()\n\t\t\t.map(message -> Content.builder()\n\t\t\t\t.role(toGeminiMessageType(message.getMessageType()).getValue())\n\t\t\t\t.parts(messageToGeminiParts(message))\n\t\t\t\t.build())\n\t\t\t.toList();\n\n\t\treturn contents;\n\t}\n\n\tprivate List<SafetySetting> toGeminiSafetySettings(List<GoogleGenAiSafetySetting> safetySettings) {","sourceCodeStart":912,"sourceCodeEnd":948,"githubUrl":"https://github.com/spring-projects/spring-ai/blob/98a7beda4f29d80a71c5837eb4053b03a93a46f7/models/spring-ai-google-genai/src/main/java/org/springframework/ai/google/genai/GoogleGenAiChatModel.java#L912-L948","documentation":"Model-capability guard in GoogleGenAiChatModel.validateThinkingLevelForModel: the requested GoogleGenAiThinkingLevel is not in the per-model supported set looked up by model id (Vertex-style resource names are reduced to the last path segment), so the request would fail or be ignored by that model.","triggerScenarios":"Requesting a ThinkingLevel (e.g. THINKING_LEVEL_HIGH) on a model whose THINKING_LEVEL_SUPPORT_BY_MODEL entry contains other levels only (e.g. a model supporting only THINKING_LEVEL_LOW and THINKING_LEVEL_MEDIUM).","commonSituations":"Sharing options templates across Gemini 2.5 variants with differing level support; hardcoding a level tuned for Pro on Flash models; after changing model IDs in configuration.","solutions":["Use a model that supports the requested thinking level","Omit thinkingLevel or use THINKING_LEVEL_UNSPECIFIED","Pick a level from the supported-levels list in the message"],"exampleFix":"// before\noptions.thinkingLevel(GoogleGenAiThinkingLevel.THINKING_LEVEL_HIGH) // on a LOW/MEDIUM-only model\n// after\noptions.thinkingLevel(GoogleGenAiThinkingLevel.THINKING_LEVEL_MEDIUM)","handlingStrategy":"validation","validationCode":"// validate against the level list reported by the error/docs\nif (!Set.of(THINKING_LEVEL_LOW, THINKING_LEVEL_MEDIUM).contains(level)) {\n    throw new IllegalArgumentException(\"level not supported for this model\");\n}","typeGuard":null,"tryCatchPattern":"try { model.call(prompt); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"Supported levels:\")) pickSupportedLevel(e.getMessage()); else throw e; }","preventionTips":["Read the Supported levels list in the message and adjust","Don't share one options template across all Gemini variants","Pin model IDs and tune thinking levels per model"],"tags":["thinking","config","gemini","validation"],"backgroundTag":"unsupported-config-value","analyzedSha":"98a7beda4f29d80a71c5837eb4053b03a93a46f7","analyzedAt":"2026-09-11T14:15:49.441Z","contentChangedAt":"2026-09-11T14:15:49.441Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}