Can't access to dalle3 using the openai api

When I call this method:

                openai.api_key = self.personality_config.config["openai_key"]
                response = openai.images.generate(
                    prompt=self.previous_sd_positive_prompt.strip(),
                    quality="standard",
                    size=f"{self.personality_config.width}x{self.personality_config.height}",
                    n=1,
                    )

I get this error:
h11._util.LocalProtocolError: Illegal header value b’Bearer ’

1 Like

I’m also getting this while trying to access the LMStudio local inference server.

from openai import OpenAI

client = OpenAI(
    base_url='http://localhost:1234',
    api_key=''
)

completion = client.chat.completions.create(
  model="local-model", # this field is currently unused
  messages=[
    {"role": "system", "content": "Always answer in rhymes."},
    {"role": "user", "content": "Introduce yourself."}
  ],
  temperature=0.7,
)

print(completion.choices[0].message)

httpx.LocalProtocolError: Illegal header value b'Bearer '

Edit: This was because I had an empty API key. LMStudio doesn’t require one, but there still has to be something.