{"record":{"id":"edc93eca445faff3","repo":"huggingface/transformers","slug":"server-is-pinned-to-self-model-manager-force-mod","errorCode":null,"errorMessage":"Server is pinned to '{self.model_manager.force_model}'; requested '{requested}'.","messagePattern":"Server is pinned to '(.+?)'; requested '(.+?)'\\.","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"src/transformers/cli/serving/utils.py","lineNumber":1114,"sourceCode":"\n    @staticmethod\n    def chunk_to_sse(chunk: \"str | pydantic.BaseModel\") -> str:\n        \"\"\"Format a pydantic model or string as an SSE ``data:`` line.\"\"\"\n        if isinstance(chunk, str):\n            return chunk if chunk.startswith(\"data: \") else f\"data: {chunk}\\n\\n\"\n        return f\"data: {chunk.model_dump_json(exclude_none=True)}\\n\\n\"\n\n    def _resolve_model(self, body: dict) -> tuple[str, \"PreTrainedModel\", \"ProcessorMixin | PreTrainedTokenizerFast\"]:\n        \"\"\"Apply force_model, load model + processor.\n\n        Returns ``(model_id, model, processor)``.\n        \"\"\"\n        from fastapi import HTTPException\n\n        if self.model_manager.force_model is not None:\n            requested = body.get(\"model\")\n            if requested is not None and requested != self.model_manager.force_model:\n                raise HTTPException(\n                    status_code=400,\n                    detail=(f\"Server is pinned to '{self.model_manager.force_model}'; requested '{requested}'.\"),\n                )\n            body[\"model\"] = self.model_manager.force_model\n\n        model_id = self.model_manager.process_model_name(body[\"model\"])\n        model, processor = self.model_manager.load_model_and_processor(model_id)\n\n        return model_id, model, processor\n\n    def _build_generation_config(\n        self, body: dict, model_generation_config: \"GenerationConfig\", use_cb: bool = False\n    ) -> \"GenerationConfig\":\n        \"\"\"Build a GenerationConfig from shared params (temperature, top_p, seed, generation_config JSON).\n\n        Subclasses should call ``super()._build_generation_config(...)`` then apply\n        endpoint-specific params (``max_tokens``, ``max_output_tokens``, etc.).\n","sourceCodeStart":1096,"sourceCodeEnd":1132,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/cli/serving/utils.py#L1096-L1132","documentation":"HTTP 400 from _resolve_model when the server was launched pinned to a single model (force_model) and the request explicitly names a different one. A pinned server rewrites body['model'] to the forced model for consistency, but refuses silently serving the wrong model when the client asked for another.","triggerScenarios":"Start the CLI with a forced model flag (e.g. transformers serve --model <id> pinning the server), then POST a chat/completions body whose 'model' field is a different model id.","commonSituations":"Reusing an OpenAI-compatible client configured with 'gpt-3.5-turbo' against a pinned local server; load balancers routing requests from mixed clients to one pinned replica; forgetting the deployment is pinned.","solutions":["Set the request's model field to the pinned model id, matching the server's launch flag","Or omit the model field entirely — the server fills in the forced model","Or restart the server without the pin if multi-model dispatch is actually required"],"exampleFix":"# before\n$ transformers serve --model openai-community/gpt2\nclient.post(body={'model': 'meta-llama/Llama-3.1-8B', ...})\n# after\nclient.post(body={'model': 'openai-community/gpt2', ...})","handlingStrategy":"validation","validationCode":"if pinned_model is not None:  # discovered from server config/docs endpoint\n    body['model'] = pinned_model\nresp = client.post('/v1/chat/completions', json=body)","typeGuard":null,"tryCatchPattern":"if resp.status_code == 400 and 'pinned to' in resp.text:\n    pinned = re.search(r\"pinned to '([^']+)'\", resp.text).group(1)\n    body['model'] = pinned\n    resp = client.post('/v1/chat/completions', json=body)","preventionTips":["Configure clients with the deployment's actual model id, or omit 'model' against pinned servers","Document the pinned model in the service catalog clients read from"],"tags":["api","serving","model-pinning","http-400"],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}