Articles on: Developer API

AI Essay Writer API

Try it Out



You can test out the API without code by going to the FastAPI link with your web browser: https://essay.undetectable.ai/docs

Authentication



Undetectable.AI uses API keys to allow access to the API. You can get your API key at the top of the page in our developer portal.

UD expects for the API key to be included in all API requests to the server in a request body that looks like the following:

key: YOUR API KEY GOES HERE

You must replace YOUR API KEY GOES HERE with your personal API key.


AI Essay Writer



The AI Essay Writer

Submit



This endpoint allows you to send instructions for Essay generation.

POST https://essay.undetectable.ai/submit

Example Request



curl -X 'POST' \
  'https://essay.undetectable.ai/submit' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
    "apikey": "YOUR-API-KEY-GOES-HERE",
    "academicLevel": "HighSchool",
    "type": "Descriptive",
    "length": "Short",
    "input": "Generate an essay about ketogenic diet"
}'


Example Response



{
    "id": "59aa3531-37c3-4cf0-b89f-c66ae06ce552",
    "apikey": "kYsrtJXZsBOTYSdb5A7j8lhnPCW6hfiU",
    "type": "Descriptive",
    "academicLevel": "HighSchool",
    "length": "Short",
    "input": "Generate an essay about ketogenic diet",
    "model": "v2"
}


Here, the response contains the server-assigned id of the Essay. At this point the Essay is now enqueued for generation. You can use the /query API endpoint to query the status of the Essay generation request.


Query



This endpoint accepts a essay id returned by the /submit request. And returns the status of the essay generation request as well as the result of the operation.

POST https://essay.undetectable.ai/query

Example Request



curl -X 'POST' \
  'https://ai-detect.undetectable.ai/query' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "id": "ESSAY-ID-GOES-HERE"
}'


Example Response



{
    "id": "59aa3531-37c3-4cf0-b89f-c66ae06ce552",
    "input": "Generate an essay about ketogenic diet",
    "output": "The ketogenic diet, commonly referred to as the keto diet, is a high-fat, moderate-protein, and low-carbohydrate eating plan that has gained immense popularity in recent years. Its primary aim is to shift the body's metabolism away from carbohydrates and towards fat utilization for energy. This process, known as ketosis, occurs when the body is deprived of carbohydrates, forcing it to burn fat for fuel instead.\n\nThe composition of the ketogenic diet typically consists of about 70-75% fats, 20-25% proteins, and only 5-10% carbohydrates. Foods that are commonly included in this diet are avocados, nuts, seeds, olive oil, fatty fish, and low-carbohydrate vegetables such as leafy greens. By drastically reducing carbohydrate intake—often below 50 grams per day—individuals can effectively enter a state of ketosis within a few days.\n\nOne of the primary benefits touted by advocates of the ketogenic diet is its ability to aid in weight loss. By encouraging the body to burn fat stores, many individuals experience a significant reduction in body weight and fat percentage. Furthermore, ketosis has been linked to improved mental clarity, increased energy levels, and diminished hunger, as the body becomes more efficient at using fat as a primary energy source.\n\nHowever, the ketogenic diet is not without its challenges and potential downsides. Many individuals experience what is colloquially known as the \"keto flu,\" a collection of symptoms including fatigue, headache, and irritability as the body adapts to the new fuel source. Additionally, the restrictive nature of the diet can make it difficult to maintain long-term, leading some individuals to revert to their previous eating habits.\n\nIn conclusion, the ketogenic diet presents a unique approach to nutrition that emphasizes fat consumption and carbohydrate restriction. While it may offer significant benefits for weight loss and energy management, it also requires careful consideration and planning to ensure it can be sustained without adverse effects. As always, individuals should consult with healthcare professionals before embarking on significant dietary changes to ensure their chosen path aligns with their health goals.",
    "type": "Descriptive",
    "academicLevel": "HighSchool",
    "length": "Short",
    "wordcost": 0,
    "status": "done"
}


Here, "status": "done" signifies that the essay generation process has completed and that the value in the output field contains the generated output.

Errors



Most errors will be from incorrect parameters being sent to the API. Double check the parameters of each API call to make sure it's properly formatted, and try running the provided example code.

The generic error codes we use conform to the REST standard:

Error CodeMeaning
400Bad Request -- Your request is invalid.
403Forbidden -- The API key is invalid or there isn't sufficient credits (0.1 per word).
404Not Found -- The specified resource doesn't exist.
405Method Not Allowed -- You tried to access a resource with an invalid method.
406Not Acceptable -- You requested a format that isn't JSON.
410Gone -- The resource at this end point has been removed.
422Invalid Request Body -- You're request body is formatted incorrectly or invalid or there are missing parameters.
429Too Many Requests -- You're sending too many requests! Slow it down!
500Internal Server Error -- We had a problem with our server. Try again later.
503Service Unavailable -- We're temporarily offline for maintenance. Please try again later.

Updated on: 24/01/2025

Was this article helpful?

Share your feedback

Cancel

Thank you!