Halftonex / npc-generator-gpt

Foundry VTT module - NPC generator for D&D5e powered by ChatGPT
Creative Commons Attribution 4.0 International
7 stars 10 forks source link

[BUG]: NPC Generator (GPT) | Request Denied #12

Closed TheBumblingGM closed 10 months ago

TheBumblingGM commented 10 months ago

Bug Description

NPC Generator (GPT) | Sending Request api.openai.com/v1/chat/completions:1 Failed to load resource: the server responded with a status of 401 () foundry.js:68326 NPC Generator (GPT) | Request Denied! Wait a few seconds and try again. (See console (F12) for more details) fetch @ foundry.js:68326 lib.js:43 Error: 401 | Message: You didn't provide an API key. You need to provide your API key in an Authorization header using Bearer auth (i.e. Authorization: Bearer YOUR_KEY), or as the password field (with blank username) if you're accessing the API from your browser and are prompted for a username and password. You can obtain an API key from https://platform.openai.com/account/api-keys. at npcGenGPTLib.callAI (lib.js:37:23) at async npcGenGPTGenerateNPC.initGeneration (generateNPC.js:61:30) callAI @ lib.js:43

Steps To Reproduce

  1. click Generate NPC
  2. input any options
  3. click create NPC
  4. recieves error message NPC Generator (GPT) | Request Denied! Wait a few seconds and try again. (See console (F12) for more details)

Foundry Version

Version 11 Build 315

Additional Information

using the DND 5E system 2.4.0

Halftonex commented 10 months ago

Hi @TheBumblingGM, as the error says you have to get an OpenAI private key. Keep also in mind that the module atm is not verified for dnd5e 2.4 version as you can see in foundry hovering the module. I have not verified the compatibility yet so it could be run into some bugs.

To get your private api key:

N.B. OpenAI's APIs are not free, although, given their limited usage by the module, they are very cost-effective. The average cost per generation is about $0.001. You can find the exact generation cost as log in the console (F12).

To check your available credit, please visit the following address: https://platform.openai.com/account/billing/overview