{"record":{"id":"50682a23218f211e","repo":"calesthio/OpenMontage","slug":"model-name-model-name-r-is-not-supported-for-api","errorCode":null,"errorMessage":"model_name {model_name!r} is not supported for api_family=generation","messagePattern":"model_name (.+?) is not supported for api_family=generation","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"tools/graphics/kling_official_image.py","lineNumber":259,"sourceCode":"            artifacts=[str(path) for path in paths],\n            cost_usd=self.estimate_cost(inputs),\n            duration_seconds=round(time.time() - start, 2),\n            model=request[\"model\"],\n        )\n\n    def _build_request(self, inputs: dict[str, Any]) -> dict[str, Any]:\n        api_family = str(inputs.get(\"api_family\", \"generation\"))\n        if inputs.get(\"operation\") == \"omni\":\n            api_family = \"omni\"\n        if api_family == \"omni\":\n            return self._build_omni_request(inputs)\n        return self._build_generation_request(inputs)\n\n    def _build_generation_request(self, inputs: dict[str, Any]) -> dict[str, Any]:\n        prompt = self._prompt(inputs)\n        model_name = str(inputs.get(\"model_name\") or \"kling-v3\")\n        if model_name not in IMAGE_GENERATION_MODELS:\n            raise ValueError(f\"model_name {model_name!r} is not supported for api_family=generation\")\n        payload: dict[str, Any] = {\n            \"model_name\": model_name,\n            \"prompt\": prompt,\n            \"resolution\": inputs.get(\"resolution\", \"1k\"),\n            \"n\": int(inputs.get(\"n\", 1) or 1),\n            \"aspect_ratio\": inputs.get(\"aspect_ratio\", \"16:9\"),\n        }\n        if len(prompt) > 2500:\n            raise ValueError(\"prompt exceeds Kling image generation limit of 2500 characters\")\n        if inputs.get(\"negative_prompt\"):\n            payload[\"negative_prompt\"] = inputs[\"negative_prompt\"]\n        image = normalize_image_input(inputs.get(\"image_url\"), inputs.get(\"image_path\"))\n        if image:\n            payload[\"image\"] = image\n        if inputs.get(\"image_reference\"):\n            payload[\"image_reference\"] = inputs[\"image_reference\"]\n        for key in (\"image_fidelity\", \"human_fidelity\"):\n            if inputs.get(key) is not None:","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/calesthio/OpenMontage/blob/95e1c3d0ab93482159818560f6a8c8e866b9139f/tools/graphics/kling_official_image.py#L241-L277","documentation":"ValueError raised when building a Kling image-generation request (api_family=generation, the default, targeting /v1/images/generations) with a model_name that is not in the IMAGE_GENERATION_MODELS allowlist. The tool refuses to submit an unknown model rather than letting the API fail opaquely.","triggerScenarios":"Explicitly passing model_name of an omni-family model (e.g. kling-image-o1) while api_family stays 'generation'; passing a video model name; typo like 'kling-v4' or 'kling-v3 ' (whitespace); passing an empty-ish value is safe (defaults to kling-v3) — only non-member strings raise.","commonSituations":"Copy-pasting a model name from a different tool or API family; Kling released a new model not yet in the allowlist; mixing up the generation and omni API families.","solutions":["Use a model from IMAGE_GENERATION_MODELS (e.g. kling-v3) for api_family=generation","If you want an omni model such as kling-image-o1, set operation='omni' or api_family='omni' instead","Check for typos/whitespace in the model_name string","If Kling shipped a genuinely new model, update IMAGE_GENERATION_MODELS in kling_official_image.py after verifying API support"],"exampleFix":"// before\ninputs = {\"api_family\": \"generation\", \"model_name\": \"kling-image-o1\"}\n// after\ninputs = {\"api_family\": \"omni\", \"model_name\": \"kling-image-o1\"}","handlingStrategy":"validation","validationCode":"IMAGE_GENERATION_MODELS = {\"kling-v3\"}  # mirror the tool's allowlist\nmodel = inputs.get(\"model_name\") or \"kling-v3\"\nassert model in IMAGE_GENERATION_MODELS, f\"unsupported generation model: {model}\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep a shared model-allowlist constant between caller and tool config","Never reuse omni model names with the default api_family","Re-validate allowlists when upgrading the tool"],"tags":["kling","image-generation","validation","model-name"],"backgroundTag":null,"analyzedSha":"95e1c3d0ab93482159818560f6a8c8e866b9139f","analyzedAt":"2026-08-15T06:31:20.014Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}