Error Codes

If you encountered some error in your API and SDK calls, chances are there is an "error code" in the response message. Have a look at the error codes to know more and head to the bottom of the page to handle errors programmatically:

API Errors

Error CodeOverview

401 API key not provided / banned

Cause: Invalid Authentication

Solution: Ensure the correct API key and requesting organization is being used. Or

Cause: You are banned from using Gooey.AI’s API

402 Payment Required

Cause: Insufficient credits

Solution: Ensure you have sufficient credits to run the API call. You can add more credits to your account.

403 Invalid API Key

Cause: The requesting API key is not correct.

Solution: Ensure the API key used is correct, clear your browser cache, or generate a new one.

422 Validation Error

Cause: Your request was malformed or missing some required parameters, such as a token or an input.

Solution: The error message should advise you on the specific error made. Check the API documentation for the specific API method you are calling and make sure you are sending valid and complete parameters. You may also need to check the encoding, format, or size of your request data.

429 Too Many Requests

Cause: You have exceeded your rate limits Solution: Pace your requests. Read the Rate limit guide.

500 Internal Server Error

Cause: Issue on our servers.

Solution: Retry your request after a brief wait and contact us if the issue persists. Check the status page.

Handling Errors

We recommend that you programmatically handle errors. Here is an example to ensure that you can get the error codes in your console/environment

In the code snippet below the line if (!response.ok) { throw new Error(response.status); } provides the error codes in your console/environment.

import fetch from 'node-fetch';

const payload = {
  "search_query": "what are f-strings?",
  "documents": [
    "https://static.realpython.com/python-basics-sample-chapters.pdf",
    "https://edu.anarcho-copy.org/Programming%20Languages/Python/Automate%20the%20Boring%20Stuff%20with%20Python.pdf"
  ]
};

async function gooeyAPI() {
  const response = await fetch("https://api.gooey.ai/v2/doc-search", {
    method: "POST",
    headers: {
      "Authorization": "Bearer " + process.env["GOOEY_API_KEY"],
      "Content-Type": "application/json",
    },
    body: JSON.stringify(payload),
  });

  if (!response.ok) {
    throw new Error(response.status);
  }

  const result = await response.json();
  console.log(response.status, result);
}

gooeyAPI();

Last updated