deepai-org / deepai-js-client

Simple Javascript Client Library for Browser and Node.js for calling DeepAI's APIs
https://deepai.org
BSD 2-Clause "Simplified" License
37 stars 12 forks source link

ERROR: Text Generator request failed with 401 #51

Closed ConnieZi closed 1 year ago

ConnieZi commented 1 year ago

SUMMARY: Used the example code and the quick-start API key to make an API call to the text generator, but got 401 DESCRIPTION: I am trying to embed some interactions with Deep AI in an Angular application(though this won't affect how the API code should perform). The code of calling the API is binded with a button, so that I can test the functionality by clicking the button. When I clicked the button(make the API call) in a normal Chrome browser, it failed with 401. When i clicked the button in an incognito Chrome window, it worked for several times, but most of the time, it failed with 401.

REPRODUCTION STEPS: js/ts file:

onSubmit() {

  let text = "coffee shop mission statement";
  deepai.setApiKey('quickstart-QUdJIGlzIGNvbWluZy4uLi4K');

  (async function() {
      var resp = await deepai.callStandardApi("text-generator", {
              text: text,
      });
      await console.log(resp.output);
  })()
  }

html file:

<form (ngSubmit)="onSubmit()">
    <label for="userInput">User Input:</label>
    <input type="text" id="userInput" name="userInput" [(ngModel)]="userInput" />
    <button type="submit">Submit</button>
  </form>

OBSERVED BEHAVIOR:

Screen Shot 2023-04-05 at 9 03 32 PM
danielrhodeswarp commented 1 year ago

I am also getting "401 Unauthorized" errors when running the sample code from deepai.org / npmjs.com

DJStompZone commented 1 year ago

Hello @danielrhodeswarp and @ConnieZi,

Thank you for bringing this to our attention. Based on the details provided, it seems you might be encountering this "401 Unauthorized" error due to the usage of a demo API key quickstart-.... The demo API keys have limited uses and once they exceed those uses, they return a 401 error.

To resolve this:

Please sign in to obtain a fresh API key or ensure that your API key has available uses left. Replace the old API key in your code with the fresh one. Test the functionality again. If you encounter the same issue even after trying with a new API key, please open a new issue with the relevant details, and we'll be more than happy to assist you further.

Closing this issue for now. Thanks for using our platform, and let us know if you have any other questions or concerns.