Skip to content

HuggingFace login #167

@SeriousJ55

Description

@SeriousJ55

I get the following error message with Huggingface:

openai.InternalServerError: Error code: 500 - {'error': 'litellm.AuthenticationError: HuggingfaceException - {"error":"Invalid username or password."}'}

I don't know where I should input my Huggingface credentials. This is my code:

import os
from openai import OpenAI

messages=[
	{
	  "role": "user",
	  "content": "Write a Python program to build an RL model to recite text from any position that the user provides, using only numpy."
	}
]

OPENAI_KEY = "optillm"
OPENAI_BASE_URL = "http://localhost:8000/v1"

os.environ["HUGGINGFACEHUB_API_TOKEN"] = "XXX"

client = OpenAI(api_key=OPENAI_KEY, base_url=OPENAI_BASE_URL)

response = client.chat.completions.create(
  model="huggingface/meta-llama/Llama-3.2-1B-Instruct",
  messages=messages,
  temperature=0.2,
)

print(response)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions