olololoe110399 / bedtime_stories

🚀 Excited to introduce "Unique Bedtime Chronicles" app! 🌙✨ Transform bedtime into a personalized adventure for your child. Craft custom stories, save favorites, and make bedtime unforgettable.
MIT License
20 stars 6 forks source link

Incorrect API key provided #6

Open andersfalt opened 7 months ago

andersfalt commented 7 months ago

I get the following error in the terminal

[log] { "provider": "AutoDisposeStateNotifierProvider<DefineStoryVM, WrapState<DefineStoryState>>", "newValue": "WrapState<DefineStoryState>(data: DefineStoryState(loading: true, text: null), appExceptionWrapper: null, isLoading: false, countLoading: 0)" } [OpenAI] Starting to reading stream response 2 [log] Emit Data: DefineStoryState(loading: false, text: null) [log] Emit: WrapState<DefineStoryState>(data: DefineStoryState(loading: true, text: null), appExceptionWrapper: AppError{appExceptionType: AppExceptionType.uncaugth, message: RequestFailedException(message: Incorrect API key provided: <sk-NM6A*****************************************MC1>. You can find your API key at https://platform.openai.com/account/api-keys., statusCode: 401), error: RequestFailedException(message: Incorrect API key provided: <sk-NM6A*****************************************MC1>. You can find your API key at https://platform.openai.com/account/api-keys., statusCode: 401)}, isLoading: false, countLoading: 0) [log] { "provider": "AutoDisposeStateNotifierProvider<DefineStoryVM, WrapState<DefineStoryState>>", "newValue": "WrapState<DefineStoryState>(data: DefineStoryState(loading: true, text: null), appExceptionWrapper: AppError{appExceptionType: AppExceptionType.uncaugth, message: RequestFailedException(message: Incorrect API key provided: <sk-NM6A*****************************************MC1>. You can find your API key at https://platform.openai.com/account/api-keys., statusCode: 401), error: RequestFailedException(message: Incorrect API key provided: <sk-NM6A*****************************************MC1>. You can find your API key at https://platform.openai.com/account/api-keys., statusCode: 401)}, isLoading: false, countLoading: 0)" } 2 [log] { "provider": "AutoDisposeStateNotifierProvider<DefineStoryVM, WrapState<DefineStoryState>>", "newValue": "WrapState<DefineStoryState>(data: DefineStoryState(loading: false, text: null), appExceptionWrapper: AppError{appExceptionType: AppExceptionType.uncaugth, message: RequestFailedException(message: Incorrect API key provided: <sk-NM6A*****************************************MC1>. You can find your API key at https://platform.openai.com/account/api-keys., statusCode: 401), error: RequestFailedException(message: Incorrect API key provided: <sk-NM6A*****************************************MC1>. You can find your API key at https://platform.openai.com/account/api-keys., statusCode: 401)}, isLoading: false, countLoading: 0)" }

olololoe110399 commented 7 months ago

@andersfalt

Check your API key and make sure input your API key in .env and run: make sync or dart run build_runner build --delete-conflicting-outputs

You can see your API key generated in project at path: lib/core/src/config/env.g.dart

Screenshot 2024-02-16 at 10 53 22
olololoe110399 commented 7 months ago

@andersfalt OMG @@ I think i know issue. You used: OPEN_AI_API_KEY=<sk-NM6A*****************************************MC1> => This not correct. You should be change to here: OPEN_AI_API_KEY=sk-NM6A*****************************************MC1

andersfalt commented 7 months ago

I did the changes that you suggested, but I am still getting the same error.

olololoe110399 commented 7 months ago

@andersfalt

You make sure run when change env? make sync or dart run build_runner build --delete-conflicting-outputs

olololoe110399 commented 7 months ago

And you make sure check your OPEN_AI_API_KEY ?

open terminal and run:

curl https://api.openai.com/v1/chat/completions   -H "Content-Type: application/json"   -H "Authorization: Bearer $OPEN_AI_API_KEY"   -d '{
    "model": "gpt-3.5-turbo",
    "messages": [
      {
        "role": "system",
        "content": "You are a poetic assistant, skilled in explaining complex programming concepts with creative flair."
      },
      {
        "role": "user",
        "content": "Compose a poem that explains the concept of recursion in programming."
      }
    ]
  }'