-
Using the AI SDK, I have been following the docs, and it says openai from '@ai-sdk/openai' should default to using OPENAI_API_KEY environment variable, but I keep getting this error: Any assistance will be appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The error means that the API key is not available as an environment variable. You can set it up manually with import { createOpenAI } from '@ai-sdk/openai';
const openai = createOpenAI({
apiKey: 'myApiKey' // should ideally be loaded from external place such as env variable
}); https://sdk.vercel.ai/providers/ai-sdk-providers/openai#provider-instance |
Beta Was this translation helpful? Give feedback.
The error means that the API key is not available as an environment variable. You can set it up manually with
createOpenai
:https://sdk.vercel.ai/providers/ai-sdk-providers/openai#provider-instance