GETTING ERROR >> AttributeError: 'InferenceClient' object has no attribute 'post'

The solution that worked for me is importing Inference client directly.The HuggingFaceEndpoint,HuggingFacePipeline doesnt seem to be working for the new version of huggingface_hub.

from huggingface_hub import InferenceClient

client = InferenceClient(

    "mistralai/Mistral-7B-Instruct-v0.2",  #"openai/gpt-oss-120b"

    token=os.environ["HUGGINGFACEHUB_API_TOKEN"]

)




resp = client.chat.completions.create(

    model="mistralai/Mistral-7B-Instruct-v0.2", #"openai/gpt-oss-120b"

    messages=[

        {"role": "user", "content": "What is the health insurance coverage?"}

    ],

    max_tokens=1000,

    temperature=0.1

)




print(resp.choices[0].message["content"])
1 Like