401 Unauthorized Error when trying to use chat
joshuadanpeterson opened this issue · comments
I'm getting an API error when I try to use the smart connections chat. I have the API key in place, but it won't let me choose a model. I checked the console and saw these errors:
POST https://api.openai.com/v1/chat/completions 401 (Unauthorized)
stream @ plugin:smart-connections:5647
full_text @ plugin:smart-connections:6278
stream @ plugin:smart-connections:6253
complete @ plugin:smart-connections:6115
await in complete (async)
new_user_message @ plugin:smart-connections:8053
await in new_user_message (async)
new_user_message @ plugin:smart-connections:8279
eval @ plugin:smart-connections:6664
plugin:smart-connections:6273 CustomEvent {isTrusted: false, data: '{\n "error": {\n "message": "Incorrect API… null,\n "code": "invalid_api_key"\n }\n}\n', source: SmartStreamer, detail: null, type: 'error', …}
eval @ plugin:smart-connections:6273
eval @ plugin:smart-connections:5623
dispatchEvent @ plugin:smart-connections:5622
onStreamFailure_fn @ plugin:smart-connections:5672
onStreamProgress_fn @ plugin:smart-connections:5685
XMLHttpRequest.send (async)
stream @ plugin:smart-connections:5647
full_text @ plugin:smart-connections:6278
stream @ plugin:smart-connections:6253
complete @ plugin:smart-connections:6115
await in complete (async)
new_user_message @ plugin:smart-connections:8053
await in new_user_message (async)
new_user_message @ plugin:smart-connections:8279
eval @ plugin:smart-connections:6664
plugin:smart-connections:6155 CustomEvent {isTrusted: false, data: '{\n "error": {\n "message": "Incorrect API… null,\n "code": "invalid_api_key"\n }\n}\n', source: SmartStreamer, detail: null, type: 'error', …}
complete @ plugin:smart-connections:6155
await in complete (async)
new_user_message @ plugin:smart-connections:8053
await in new_user_message (async)
new_user_message @ plugin:smart-connections:8279
eval @ plugin:smart-connections:6664
plugin:smart-connections:7379 chat_ml
![Screenshot 2024-05-11 at 20 16 43](https://private-user-images.githubusercontent.com/6033094/329821639-9283324b-cd0c-48ac-ba31-97292b83d2bf.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjI2NzM3NzcsIm5iZiI6MTcyMjY3MzQ3NywicGF0aCI6Ii82MDMzMDk0LzMyOTgyMTYzOS05MjgzMzI0Yi1jZDBjLTQ4YWMtYmEzMS05NzI5MmI4M2QyYmYucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgwMyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MDNUMDgyNDM3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZGNhOTE4MDNmZWRjN2JiNDY5ZDcwOWE2NGFhN2Q5ZTQxNDY1M2JmNWVmMjMzYWYyN2NiOGZlMzAwZTNjMjljZiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.7iNLTLYGSxDoW7T9WzvjY9egICaJcitZpzmTeDKt86c)
The chat worked for me for a little bit, but then it started giving me that message. I didn't do anything different. I even downloaded the update and restarted my Obsidian to see if that would make a difference and it didn't.
When I press "Refresh Model List", I get:
plugin:smart-connections:5864
GET https://api.openai.com/v1/models 401 (Unauthorized)
fetch_openai_models @ plugin:smart-connections:5864
get_models @ plugin:smart-connections:6372
get_view_data @ plugin:smart-connections:7148
render @ plugin:smart-connections:6961
changed_smart_chat_model @ plugin:smart-connections:7123
await in changed_smart_chat_model (async)
eval @ plugin:smart-connections:7049
(anonymous) @ app.js:1
plugin:smart-connections:5887 Failed to fetch model data: Error: Network response was not ok
at Object.fetch_openai_models [as openai] (plugin:smart-connections:5870:17)
at async ScChatModel.get_models (plugin:smart-connections:6372:26)
at async SmartChatSettings.get_view_data (plugin:smart-connections:7148:42)
at async SmartChatSettings.render (plugin:smart-connections:6961:70)
![Screenshot 2024-05-11 at 20 16 29](https://private-user-images.githubusercontent.com/6033094/329821657-ef1f1d0a-fd07-4768-bb84-2187c0b4b3cb.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjI2NzM3NzcsIm5iZiI6MTcyMjY3MzQ3NywicGF0aCI6Ii82MDMzMDk0LzMyOTgyMTY1Ny1lZjFmMWQwYS1mZDA3LTQ3NjgtYmI4NC0yMTg3YzBiNGIzY2IucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgwMyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MDNUMDgyNDM3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NDMyNjJiMTA3MjBiMDg5Y2ZmYzdiY2EzMDViMmYwMzk4YTUxODRlNDBlYzkwNTkzMzM2MTE0ZTA1OThmZGM3NiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.zvrv2GVW19M3grkyNkmc-LqorqnmooGJtpmTNNy7u3k)
Is this still a problem? It should work if you have an API key connected. When you hit save the API key, does it say it was successful? 🌸
Is this still a problem? It should work if you have an API key connected. When you hit save the API key, does it say it was successful? 🌸
I updated the plugin and created a new API key. It works perfectly now.