Can't get AI Assistant to work

I placed my OpenAI API key in the .env file in the OPENAI_API_KEY key, then docker compose down && docker compose up -d but when I went to use AI Assistant, I get a toast notification saying "An error occurred.". I don't even know where the logs are to check what's happening.
No description
20 Replies
inder
inder2mo ago
Check for logs in devtools. This issue was fixed a while ago https://github.com/supabase/supabase/pull/35804 https://github.com/supabase/supabase/pull/35812 Verify that the key is working
Epifeny
EpifenyOP2mo ago
Thanks for responding. The logs in my browser developer tools show:
21:57:29.906
XHRGET
https://MYSITE/api/v1/projects/default/api-keys?reveal=false
[HTTP/2 404 6ms]
21:57:29.906
XHRGET
https://MYSITE/api/v1/projects/default/api-keys?reveal=false
[HTTP/2 404 6ms]
---- I see you mentioned Github issues from May, while this installation was setup using the Self Hosting documentation, just yesterday and using the studio image supabase/studio:2025.06.30-sha-6f5982d. The API works:
$ docker exec -it supabase-studio sh -c 'curl https://api.openai.com/v1/models -H "Authorization: Bearer $OPENAI_API_KEY"'
{
"object": "list",
"data": [
{
"id": "gpt-4-0613",
"object": "model",
"created": 1686588896,
"owned_by": "openai"
},
{
"id": "gpt-4",
"object": "model",
"created": 1687882411,
"owned_by": "openai"
},
{
"id": "gpt-3.5-turbo",
"object": "model",
<snip>
$ docker exec -it supabase-studio sh -c 'curl https://api.openai.com/v1/models -H "Authorization: Bearer $OPENAI_API_KEY"'
{
"object": "list",
"data": [
{
"id": "gpt-4-0613",
"object": "model",
"created": 1686588896,
"owned_by": "openai"
},
{
"id": "gpt-4",
"object": "model",
"created": 1687882411,
"owned_by": "openai"
},
{
"id": "gpt-3.5-turbo",
"object": "model",
<snip>
I did now try to use the newer studio version 2025.06.30-sha-6f5982d and it still doesn't work. I've attached another SS from the newer version.
No description
inder
inder2mo ago
These logs are for different issue. Its trying to fetch new api keys which hasn't been implemented.
21:57:29.906
XHRGET
https://MYSITE/api/v1/projects/default/api-keys?reveal=false
[HTTP/2 404 6ms]
21:57:29.906
XHRGET
https://MYSITE/api/v1/projects/default/api-keys?reveal=false
[HTTP/2 404 6ms]
To get rid of this error specifically, you can use the previous studio img: supabase/studio:2025.06.23-sha-17632f7 For the AI error, look into network tab when request is made
Epifeny
EpifenyOP2mo ago
curl ^"https://MYSITE/api/ai/sql/generate-v3^" ^
-X POST ^
-H ^"User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101 Firefox/140.0^" ^
-H ^"Accept: */*^" ^
-H ^"Accept-Language: en-US,en;q=0.5^" ^
-H ^"Accept-Encoding: gzip, deflate, br, zstd^" ^
-H ^"Referer: https://MYSITE/project/default^" ^
-H ^"content-type: application/json^" ^
-H ^"x-request-id: 6cc1933f-c3fd-4a7f-84b1-d6097fe96a8e^" ^
-H ^"Origin: https://MYSITE^" ^
-H ^"Authorization: Basic <HIDDEN>" ^
-H ^"Connection: keep-alive^" ^
-H ^"Cookie: sidebar:state=false; __stripe_mid=4d311e0a-80e2-49cc-81be-7bd73ec710c8f27b34^" ^
-H ^"Sec-Fetch-Dest: empty^" ^
-H ^"Sec-Fetch-Mode: cors^" ^
-H ^"Sec-Fetch-Site: same-origin^" ^
-H ^"Priority: u=4^" ^
-H ^"Pragma: no-cache^" ^
-H ^"Cache-Control: no-cache^" ^
-H ^"TE: trailers^" ^
--data-raw ^"\"{\\\"messages\\\":^[{\\\"role\\\":\\\"user\\\",\\\"createdAt\\\":\\\"2025-07-18T19:07:25.100Z\\\",\\\"content\\\":\\\"test\\\",\\\"id\\\":\\\"c61b1c07-09a0-43c6-aca4-3cb81b058414\\\",\\\"parts\\\":^[{\\\"type\\\":\\\"text\\\",\\\"text\\\":\\\"test\\\"}^]},{\\\"role\\\":\\\"user\\\",\\\"createdAt\\\":\\\"2025-07-18T19:13:23.061Z\\\",\\\"content\\\":\\\"test\\\",\\\"id\\\":\\\"93f930ad-ec02-4ae4-91aa-8cc87ae9745d\\\",\\\"parts\\\":^[{\\\"type\\\":\\\"text\\\",\\\"text\\\":\\\"test\\\"}^]}^],\\\"aiOptInLevel\\\":\\\"schema\\\",\\\"projectRef\\\":\\\"default\\\",\\\"connectionString\\\":\\\"\\\",\\\"schema\\\":\\\"public\\\",\\\"chatName\\\":\\\"Untitled\\\",\\\"includeSchemaMetadata\\\":true,\\\"orgSlug\\\":\\\"default-org-slug\\\"}\"^"
curl ^"https://MYSITE/api/ai/sql/generate-v3^" ^
-X POST ^
-H ^"User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101 Firefox/140.0^" ^
-H ^"Accept: */*^" ^
-H ^"Accept-Language: en-US,en;q=0.5^" ^
-H ^"Accept-Encoding: gzip, deflate, br, zstd^" ^
-H ^"Referer: https://MYSITE/project/default^" ^
-H ^"content-type: application/json^" ^
-H ^"x-request-id: 6cc1933f-c3fd-4a7f-84b1-d6097fe96a8e^" ^
-H ^"Origin: https://MYSITE^" ^
-H ^"Authorization: Basic <HIDDEN>" ^
-H ^"Connection: keep-alive^" ^
-H ^"Cookie: sidebar:state=false; __stripe_mid=4d311e0a-80e2-49cc-81be-7bd73ec710c8f27b34^" ^
-H ^"Sec-Fetch-Dest: empty^" ^
-H ^"Sec-Fetch-Mode: cors^" ^
-H ^"Sec-Fetch-Site: same-origin^" ^
-H ^"Priority: u=4^" ^
-H ^"Pragma: no-cache^" ^
-H ^"Cache-Control: no-cache^" ^
-H ^"TE: trailers^" ^
--data-raw ^"\"{\\\"messages\\\":^[{\\\"role\\\":\\\"user\\\",\\\"createdAt\\\":\\\"2025-07-18T19:07:25.100Z\\\",\\\"content\\\":\\\"test\\\",\\\"id\\\":\\\"c61b1c07-09a0-43c6-aca4-3cb81b058414\\\",\\\"parts\\\":^[{\\\"type\\\":\\\"text\\\",\\\"text\\\":\\\"test\\\"}^]},{\\\"role\\\":\\\"user\\\",\\\"createdAt\\\":\\\"2025-07-18T19:13:23.061Z\\\",\\\"content\\\":\\\"test\\\",\\\"id\\\":\\\"93f930ad-ec02-4ae4-91aa-8cc87ae9745d\\\",\\\"parts\\\":^[{\\\"type\\\":\\\"text\\\",\\\"text\\\":\\\"test\\\"}^]}^],\\\"aiOptInLevel\\\":\\\"schema\\\",\\\"projectRef\\\":\\\"default\\\",\\\"connectionString\\\":\\\"\\\",\\\"schema\\\":\\\"public\\\",\\\"chatName\\\":\\\"Untitled\\\",\\\"includeSchemaMetadata\\\":true,\\\"orgSlug\\\":\\\"default-org-slug\\\"}\"^"
Response:
3:"An error occurred."
3:"An error occurred."
See SS, took almost 7s to respond
No description
inder
inder2mo ago
What is the status code of response?
Epifeny
EpifenyOP2mo ago
200
inder
inder2mo ago
Do you see ai response in preview tab ? 200 means successful
Epifeny
EpifenyOP2mo ago
preview tab?
Epifeny
EpifenyOP2mo ago
No description
inder
inder2mo ago
Try making a request yourself with the openai api. This is the prompt supabase uses on the backend https://github.com/supabase/supabase/blob/master/apps/studio/pages/api/ai/sql/generate-v3.ts#L74
Epifeny
EpifenyOP2mo ago
Checking ...
Epifeny
EpifenyOP2mo ago
Starting script...
API key found, making requests...
Making standard request...
Starting makeSupabaseStyleRequest...
Making OpenAI API call...
Error in makeSupabaseStyleRequest: 429 You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.
Full error: RateLimitError: 429 You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.
at APIError.generate (file:///opt/supabase-project/test_api/node_modules/openai/core/error.mjs:59:20)
at OpenAI.makeStatusError (file:///opt/supabase-project/test_api/node_modules/openai/client.mjs:156:32)
at OpenAI.makeRequest (file:///opt/supabase-project/test_api/node_modules/openai/client.mjs:301:30)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async makeSupabaseStyleRequest (file:///opt/supabase-project/test_api/supabase-openai.js:110:24)
at async main (file:///opt/supabase-project/test_api/supabase-openai.js:227:5) {
status: 429,
Starting script...
API key found, making requests...
Making standard request...
Starting makeSupabaseStyleRequest...
Making OpenAI API call...
Error in makeSupabaseStyleRequest: 429 You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.
Full error: RateLimitError: 429 You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.
at APIError.generate (file:///opt/supabase-project/test_api/node_modules/openai/core/error.mjs:59:20)
at OpenAI.makeStatusError (file:///opt/supabase-project/test_api/node_modules/openai/client.mjs:156:32)
at OpenAI.makeRequest (file:///opt/supabase-project/test_api/node_modules/openai/client.mjs:301:30)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async makeSupabaseStyleRequest (file:///opt/supabase-project/test_api/supabase-openai.js:110:24)
at async main (file:///opt/supabase-project/test_api/supabase-openai.js:227:5) {
status: 429,
Yet I've never even used the API
No description
Epifeny
EpifenyOP2mo ago
Or is this Supabase rate limit? Not OpenAI?
inder
inder2mo ago
No this isn't coming from supabase.
Epifeny
EpifenyOP2mo ago
Yea, stupid question on my part
inder
inder2mo ago
You'll have to ask about this from chatgpt support/forums.
Epifeny
EpifenyOP2mo ago
Yes Ty
Epifeny
EpifenyOP2mo ago
Fixed. I checked billing and saw $0.00 credits. Even though usage showed a $120 budget, nothing would be used since the Pay as you go credit balance was at zero. Honestly, I expected Supabase’s UX to at least return OpenAI’s original 429 You exceeded your current quota error and not the generic An error occurred..
No description
No description
Epifeny
EpifenyOP2mo ago
@inder :solved:
inder
inder2mo ago
Ya, actual error msg would've saved a lot of time. I'd recommend to open an issue on supabase github repo. This forum isn't monitored by the team.

Did you find this page helpful?