BadRequestError
--------------------------------------------------------------------------- HTTPError Traceback (most recent call last) File /Volumes/KODAK/folder_03/rag_system/venv/lib/python3.10/site-packages/huggingface_hub/utils/_errors.py:304, in hf_raise_for_status(response, endpoint_name) **303** try: → 304 response.raise_for_status() **305** except HTTPError as e: File /Volumes/KODAK/folder_03/rag_system/venv/lib/python3.10/site-packages/requests/models.py:1024, in Response.raise_for_status(self) **1023** if http_error_msg: → 1024 raise HTTPError(http_error_msg, response=self) HTTPError: 400 Client Error: Bad Request for url: https://api-inference.huggingface.co/models/openai/gpt-oss-120b/v1/chat/completions The above exception was the direct cause of the following exception: BadRequestError Traceback (most recent call last) Cell In1], line 16 **12** raise ValueError(“HF_API_TOKEN not found in .env file. Please check your .env.”) **14** client = InferenceClient(api_key=hf_token) —> 16 completion = client.chat.completions.create( **17** model=“openai/gpt-oss-120b”, **18** messages= **19** { **20** “role”: “user”, **21** “content”: “What is the advantage of AI? Can you list them properly?” **22** } **23** ], **24** ) **26** print(completion.choices0].message.content) File /Volumes/KODAK/folder_03/rag_system/venv/lib/python3.10/site-packages/huggingface_hub/inference/_client.py:837, in InferenceClient.chat_completion(self, messages, model, stream, frequency_penalty, logit_bias, logprobs, max_tokens, n, presence_penalty, response_format, seed, stop, temperature, tool_choice, tool_prompt, tools, top_logprobs, top_p) **833** # `model` is sent in the payload. Not used by the server but can be useful for debugging/routing. **834** # If it’s a ID on the Hub => use it. Otherwise, we use a random string. **835** model_id = model if not is_url and model.count(“/”) == 1 else “tgi” → [837 data = self.post( **838** model=model_url, **839** json=dict( **840** model=model_id, **841** messages=messages, **842** frequency_penalty=frequency_penalty, **843** logit_bias=logit_bias, **844** logprobs=logprobs, **845** max_tokens=max_tokens, **846** n=n, **847** presence_penalty=presence_penalty, **848** response_format=response_format, **849** seed=seed, **850** stop=stop, **851** temperature=temperature, **852** tool_choice=tool_choice, **853** tool_prompt=tool_prompt, **854** tools=tools, **855** top_logprobs=top_logprobs, **856** top_p=top_p, **857** stream=stream, **858** ), **859** stream=stream, **860** ) **862** if stream: **863** return _stream_chat_completion_response(data) # type: ignore[arg-type] File /Volumes/KODAK/folder_03/rag_system/venv/lib/python3.10/site-packages/huggingface_hub/inference/_client.py:304, in InferenceClient.post(self, json, data, model, task, stream) **301** raise InferenceTimeoutError(f"Inference call timed out: {url}“) from error # type: ignore **303** try: → [304 hf_raise_for_status(response) **305** return response.iter_lines() if stream else response.content **306** except HTTPError as error: File /Volumes/KODAK/folder_03/rag_system/venv/lib/python3.10/site-packages/huggingface_hub/utils/_errors.py:358, in hf_raise_for_status(response, endpoint_name) **354** elif response.status_code == 400: **355** message = ( **356** f”\n\nBad request for {endpoint_name} endpoint:" if endpoint_name is not None else “\n\nBad request:” **357** ) → [358 raise BadRequestError(message, response=response) from e **360** elif response.status_code == 403: **361** message = ( **362** f"\n\n{response.status_code} Forbidden: {error_message}." **363** + f"\nCannot access content at: {response.url}." **364** + "\nIf you are trying to create or update content, " **365** + “make sure you have a token with the `write` role.” **366** ) BadRequestError: (Request ID: Root=1-68ac15f0-7240d458234f8f3e22614d08;3b898b74-1f51-4ebd-9943-d86ce6c8a03a) Bad request: Bad Request: The endpoint is paused, ask a maintainer to restart it