{"record":{"id":"c1589b9ee44dfb23","repo":"wandb/openui","slug":"model-not-supported","errorCode":null,"errorMessage":"Model not supported","messagePattern":"Model not supported","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"backend/openui/server.py","lineNumber":136,"sourceCode":"        raise HTTPException(status_code=401, detail=\"Login required to use OpenUI\")\n    user_id = request.session[\"user_id\"]\n    yesterday = datetime.now() - timedelta(days=1)\n    tokens = Usage.tokens_since(user_id, yesterday.date())\n    if config.ENV == config.Env.PROD and tokens > config.MAX_TOKENS:\n        raise HTTPException(\n            status_code=429,\n            detail=\"You've exceeded our usage quota, come back tomorrow to generate more UI.\",\n        )\n    try:\n        data = await request.json()  # chat_request.model_dump(exclude_unset=True)\n        input_tokens = count_tokens(data[\"messages\"])\n        # TODO: we always assume 4096 max tokens (random fudge factor here)\n        data[\"max_tokens\"] = 4096 - input_tokens - 20\n        # TODO: refactor all these blocks into one once Ollama supports vision\n        # OpenAI Models\n        if data.get(\"model\").startswith(\"gpt\"):\n            if data[\"model\"] == \"gpt-4\" or data[\"model\"] == \"gpt-4-32k\":\n                raise HTTPException(status=400, data=\"Model not supported\")\n            response: AsyncStream[\n                ChatCompletionChunk\n            ] = await openai.chat.completions.create(\n                **data,\n            )\n            # gpt-4 tokens are 20x more expensive\n            multiplier = 20 if \"gpt-4\" in data[\"model\"] else 1\n            return StreamingResponse(\n                openai_stream_generator(response, input_tokens, user_id, multiplier),\n                media_type=\"text/event-stream\",\n            )\n        # Groq Models\n        elif data.get(\"model\").startswith(\"groq/\"):\n            data[\"model\"] = data[\"model\"].replace(\"groq/\", \"\")\n            if groq is None:\n                raise HTTPException(status=500, detail=\"Groq API key is not set.\")\n            response: AsyncStream[\n                ChatCompletionChunk","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/wandb/openui/blob/42d7ab4ab6650433486dfb12eb3783c393a3e475/backend/openui/server.py#L118-L154","documentation":"chat_completions supports gpt-3.5* and gpt-4-vision style models but explicitly rejects gpt-4 and gpt-4-32k with HTTPException(status=400, data='Model not supported'). Note the bug: HTTPException's keyword is `detail`, not `data`, and `status` should be `status_code`, so this raises a malformed HTTPException/TypeError at runtime rather than a clean 400.","triggerScenarios":"Requesting chat completions with data['model'] == 'gpt-4' or 'gpt-4-32k' — the server intentionally refuses these models (pricing/vision support reasons).","commonSituations":"Client defaults to 'gpt-4' in their OpenAI SDK config; older tutorials/examples use gpt-4; model list not filtered before sending.","solutions":["Use a supported model such as 'gpt-3.5-turbo' or a gpt-4 vision-capable variant the server accepts.","Fix the backend call to HTTPException(status_code=400, detail='Model not supported').","Add client-side model validation against the server's supported list before sending.","Update the OpenUI deployment/config so newer model names are handled."],"exampleFix":"// before\nraise HTTPException(status=400, data=\"Model not supported\")\n// after\nraise HTTPException(status_code=400, detail=\"Model not supported\")","handlingStrategy":"validation","validationCode":"SUPPORTED = {'gpt-3.5-turbo'}  # plus vision-capable variants the server accepts\nif data['model'] in {'gpt-4', 'gpt-4-32k'}:\n    raise ValueError(f'Model {data[\"model\"]!r} not supported by OpenUI')","typeGuard":null,"tryCatchPattern":"try:\n    r = s.post(url, json=payload)\n    r.raise_for_status()\nexcept requests.HTTPError as e:\n    if e.response.status_code == 400 and 'not supported' in e.response.text.lower():\n        payload['model'] = 'gpt-3.5-turbo'\n        r = s.post(url, json=payload)","preventionTips":["Filter model lists against server-supported models before sending","Don't default clients to 'gpt-4' or 'gpt-4-32k'","Fix the backend HTTPException kwargs (status_code/detail)","Pin an explicit model in client config rather than relying on SDK defaults"],"tags":["http","openai","model-config","python","fastapi"],"backgroundTag":"unsupported-model-400","analyzedSha":"42d7ab4ab6650433486dfb12eb3783c393a3e475","analyzedAt":"2026-09-01T05:00:32.200Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}