OpenAI API Keys

Hi there, We have generated our own API key for our OpenAI plugin, however the API key shows zero usage. Correspondingly we are getting rate limiting errors telling us to wait 20 million days (!!!). I've checked the guide docs on its usage and we're doing everything correctly, so I can't really figure this one out.
No description
10 Replies
Simon
Simon3mo ago
You could just use the openAI package yourself. That should be a quick fix - don't see any benefits to using gadget's encapsulation.

import OpenAI from "openai";
const openaiApiKey = process.env.OPENAI_API_KEY;

// Initialize OpenAI
if (!openaiApiKey) {
throw new Error("OPENAI_API_KEY environment variable is not set");
}
const openai = new OpenAI({
apiKey: openaiApiKey,
});

const completion = await openai.responses.create({ ...

import OpenAI from "openai";
const openaiApiKey = process.env.OPENAI_API_KEY;

// Initialize OpenAI
if (!openaiApiKey) {
throw new Error("OPENAI_API_KEY environment variable is not set");
}
const openai = new OpenAI({
apiKey: openaiApiKey,
});

const completion = await openai.responses.create({ ...
Chocci_Milk
Chocci_Milk3mo ago
@Dave, could you please share a trace id so that I can take a look at the potential cause of this?
Dave
DaveOP3mo ago
@Chocci_Milk 1b2156cb7d58feca81ab67cf5d570543
Chocci_Milk
Chocci_Milk3mo ago
So it looks like its OpenAI telling you that you're making too many requests to it. That's all I could really find out about it. Typically, I've seen this happen when you're either close to the billing cap for your account or you have a lower plan
Dave
DaveOP3mo ago
The issue is our API key is showing zero usage We're getting some results, so we should be seeing usage Which makes me think for some reason it's still using your dev API keys rather than the one we've set
Chocci_Milk
Chocci_Milk3mo ago
In your app configs, I see the development and production OpenAI key configs being different I think that this is actually our OpenAI proxy thats giving you a 429. I'd need to get some more information to be sure It doesn't seem correct because the amount of requests is quite low and I would expect us to simply send the request through if you had your own credentials Ok so we've found an issue. To get you unstuck we recommend that you switch back to the Gadget managed connection, save, and switch back to your API key
Dave
DaveOP3mo ago
We're not getting any more errors — but still not seeing any usage
Chocci_Milk
Chocci_Milk3mo ago
That I'm not sure what to say. Let me take a look at your connection again I'm not sure that the restart fixed the issue Maybe try adding an empty file and removing it
Dave
DaveOP3mo ago
Adding an empty file to what?
Chocci_Milk
Chocci_Milk3mo ago
To your application Maybe make an action file? That would recreate your client

Did you find this page helpful?