{"record":{"id":"1d2d110b301ec1f6","repo":"wandb/openui","slug":"invalid-model","errorCode":null,"errorMessage":"Invalid model","messagePattern":"Invalid model","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"backend/openui/server.py","lineNumber":208,"sourceCode":"                    **data,\n                )\n                gen = await ollama_stream_generator(response, data)\n            else:\n                response: AsyncStream[\n                    ChatCompletionChunk\n                ] = await ollama_openai.chat.completions.create(\n                    **data,\n                )\n\n                def gen():\n                    return openai_stream_generator(response, input_tokens, user_id, 0)\n\n            return StreamingResponse(gen(), media_type=\"text/event-stream\")\n        elif data.get(\"model\").startswith(\"dummy\"):\n            return StreamingResponse(\n                DummyStreamGenerator(data), media_type=\"text/event-stream\"\n            )\n        raise HTTPException(status=404, detail=\"Invalid model\")\n    except (ResponseError, APIStatusError) as e:\n        traceback.print_exc()\n        logger.exception(\"Known Error: %s\", str(e))\n        msg = str(e)\n        if hasattr(e, \"message\"):\n            msg = e.message\n        raise HTTPException(status_code=e.status_code, detail=msg)\n\n\n@app.exception_handler(RequestValidationError)\n@app.exception_handler(ValidationError)\nasync def validation_exception_handler(\n    request: Request, exc: RequestValidationError | ValidationError\n):\n    body = hasattr(exc, \"body\") and exc.body or None\n    logger.exception(\"Validation Error: %s\", exc)\n    traceback.print_exc()\n    return JSONResponse(","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/wandb/openui/blob/42d7ab4ab6650433486dfb12eb3783c393a3e475/backend/openui/server.py#L190-L226","documentation":"This is the fallback error in OpenUI's chat_completions endpoint: if the requested model name matches none of the known prefixes (openai, groq/, litellm/, ollama, etc.) and is not the 'dummy' generator, the endpoint raises HTTP 404 'Invalid model'. It means the model string could not be routed to any backend.","triggerScenarios":"POSTing to /chat/completions with a model value that lacks a recognized prefix (e.g. model='claude-3' with no 'groq/' or 'litellm/' prefix, or a misspelled prefix like 'groc/llama3'), or model missing/None so startswith never matches.","commonSituations":"Pasting a raw model id from another provider without the required routing prefix, typos in the prefix, upgrading OpenUI and using a model family the installed version doesn't route, or clients sending model=null.","solutions":["Prefix the model with a supported backend identifier, e.g. 'openai/gpt-4o', 'groq/llama3-70b-8192', or 'litellm/<model>'.","Check the exact spelling of the prefix against the elif chain in backend/openui/server.py chat_completions.","If you need an unlisted provider, add a routing branch in chat_completions or run it behind LiteLLM and use the litellm/ prefix.","Guard the client payload so model is always a non-empty routed string before calling the endpoint."],"exampleFix":"// before\n{\"model\": \"llama3-70b-8192\"}\n// after\n{\"model\": \"groq/llama3-70b-8192\"}","handlingStrategy":"validation","validationCode":"SUPPORTED_PREFIXES = (\"openai/\", \"groq/\", \"litellm/\", \"ollama/\", \"dummy\")\ndef validate_model(model: str) -> str:\n    if not model or not model.startswith(SUPPORTED_PREFIXES):\n        raise ValueError(f\"Model '{model}' lacks a supported routing prefix\")\n    return model","typeGuard":"def is_routed_model(model) -> bool:\n    return isinstance(model, str) and model.startswith((\"openai/\", \"groq/\", \"litellm/\", \"ollama/\", \"dummy\"))","tryCatchPattern":null,"preventionTips":["Always send models with their routing prefix","Keep a client-side constant of valid prefixes synced with server.py","Add an integration test hitting /chat/completions per supported prefix","Return the supported model list to clients instead of hardcoding"],"tags":["http-404","routing","model-selection","fastapi"],"backgroundTag":"invalid-model-name","analyzedSha":"42d7ab4ab6650433486dfb12eb3783c393a3e475","analyzedAt":"2026-09-01T05:00:32.200Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}