darrenburns / elia

A snappy, keyboard-centric terminal user interface for interacting with large language models. Chat with ChatGPT, Claude, Llama 3, Phi 3, Mistral, Gemma and more.
Apache License 2.0
1.86k stars 115 forks source link

How to properly configure elia to use OpenAI with `api_base` #73

Open paw-lu opened 4 months ago

paw-lu commented 4 months ago

If I set the environment variables OPENAI_API_KEY and OPENAI_BASE_URL, I can successfully run this python script:

from openai import OpenAI
client = OpenAI()

chat_completion = client.chat.completions.create(
    messages=[
        {
            "role": "user",
            "content": "Hello world!",
        }
    ],
    model="gpt-3.5-turbo",
)
print(chat_completion.choices[0].message.content)
$ export OPENAI_API_KEY = "abc123"
$ export OPENAI_BASE_URL = "https://paw-lu.com/api/v1"
$ python run_openai.py
Hello! How can I assist you today?

However when I try to use the same values in elia's config:

[[ models ]]
name = "gpt-3.5-turbo"
display_name = "Hello"
api_key = "abc123"
api_base = "https://paw-lu.com/api/v1"

I get a 500: internal server error from OpenAI.

What am I doing wrong here that makes the two inconsistent?