Skip to content

AI_LoadAPIKeyError: Unable to get the generateText() to find the API key from .env file. #1978

Answered by lgrammel
LincChad asked this question in Help
Discussion options

You must be logged in to vote

The error means that the API key is not available as an environment variable. You can set it up manually with createOpenai:

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

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by lgrammel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants