GPT 3.5 is not configured despite having an API key

Hello, I have the discourse service on my own server.

I already installed the ai plugin.

I already installed the openai api.

but still, it tells me that gpt 3.5 is not configured, where is it configured? I thought it was just placing the openai api.

check

Does your API key works with a test request like the one below?

curl https://api.openai.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
     "model": "gpt-3.5-turbo",
     "messages": [{"role": "user", "content": "Say this is a test!"}],
     "temperature": 0.7
   }'
1 Like

I enter that code via ssh to my server (attaching the openai api) or where can I test?

You can run that from any terminal you have access to.

curl https://api.openai.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $12345679" \
  -d '{
     "model": "gpt-3.5-turbo",
     "messages": [{"role": "user", "content": "Say this is a test!"}],
     "temperature": 0.7
   }'

would this structure be? That is, leaving the “$” before and (") after the api key?

You would leave the quotes after yes, but you wouldn’t leave the $ before the key. The $OPENAI_API_KEY refers to an env variable.

this is the result

Captura de pantalla 2024-05-07 181053

I wonder if there is some sort of timing issue here or “recovery issue”

Can you remove one letter from the api key and then add one and see if it starts working?

@Falco I wonder if we just treat it as “configured” as soon as an API key is there. At that point you can look at logs to see if it breaks.

The test on config is incomplete anyway… API could be temporarily down, Key could expire a week later and it is still (configured), I think this is just too complicated, we should just remove the check and trust logs here.

Having a dashboard warning that triggered when the API key failed would be good. I’ve seen several people (including myself) configure things correctly except the service wants more cash.

Logs are hard to find for most people.

1 Like

Hello, I have tried several apis, even new ones.

In fact, I use those same APIs with other services such as a php script, a wordpress plugin, and they work without problems; but I don’t understand why when I put it here, it is not activated, I don’t know if I have to configure something additional, in addition to putting the api.

I have also put the name of the organization and removed it (although it says it is optional).

Can you have a look in logs is there anything there?

These, although they are old, there are no more recent ones

Give us a day or two, will see if we can ramp up logging here at a minimum

3 Likes

Friend, I was able to solve it. I needed to pass the basic code again so that the configuration would be applied (I thought it was only necessary to install it)


cd /var/discourse
./launcher rebuild app
1 Like

I’ve seen this on multiple occasions, it seems it takes a while after entering the API key before the “unconfigured” goes away.

2 Likes

I found the issue, patching it, we were caching that in a class so changes would not reflect.

7 Likes