---
title: Making API Requests for GenAI Results
slug: tutorials/making-api-requests-for-genai-results
docTags: 
createdAt: 2024-02-06T12:40:30.406Z
---

All of the **ElevateAI Generative AI API Endpoints** use a similar format, leveraging the unique **`interactionIdentifier`** returned upon successfully declaring the [audio](docId\:PqLj1vqO7gTf0iqj1LBVN), [chat](docId\:iD41ifX7uC0RZDlb7RbtO), or [transcription](docId:8OMp8XUfyRY9gaB1YIvul) interaction.&#x20;

When the desired <font color="#2166ae">`GET`</font> request<font color="#3694fc">**\***</font> successfully executes, an **`HTTP`** status is returned to indicate the request was successful, along with a **`JSON`** response providing details specific to that endpoint. &#x20;

All endpoints support a **`GET`** method; the [Ask ElevateAI Q\&A endpoint endpoint](docId:4JbLvbXQcii7uM6Vr1NzH) supports both **`POST`** and **`GET`** methods. &#x20;

- Details specific to individual endpoints are covered on the [GenAI API endpoints](docId\:ol6-WOAnmVfYuBweZq8rP) page

The general request format to be used for all of the Generative AI API requests is outlined below:

# <font color="#3694fc">// </font>General Request Format

:::ApiMethodV2
```json
{
  "tab": "examples",
  "url": "https://api.elevateai.com/v1/interactions/{interactionIdentifier}/{endpoint}",
  "name": "Retrieve Generative AI Response",
  "method": "GET",
  "request": {
    "pathParameters": [
      {
        "kind": "required",
        "name": "interactionIdentifier",
        "type": "string",
        "description": "interactionIdentifier returned upon successfully declaring the interaction"
      },
      {
        "name": "endpoint",
        "kind": "required",
        "type": "string",
        "description": "The specific API endpoint for the desired Generative AI response.  Endpoints are covered on the Generative AI API Endpoint Details page.",
        "children": []
      }
    ],
    "queryParameters": [],
    "headerParameters": [
      {
        "kind": "required",
        "name": "X-API-Token",
        "type": "string",
        "description": "Valid API key associated with your account for authentication and usage tracking"
      },
      {
        "kind": "optional",
        "name": "Accept-Encoding",
        "type": "string",
        "description": "Recommended for bandwidth optimization, will be 'gzip, deflate, br'"
      },
      {
        "name": "Accept-Language",
        "kind": "optional",
        "type": "string",
        "description": "To be used for the Summary endpoint only (ignored for other endpoints).  Specify the language code for the desired language of the response (e.g. pt-BR).  Default is English.",
        "children": []
      }
    ],
    "bodyDataParameters": [],
    "formDataParameters": []
  },
  "results": {
    "languages": [
      {
        "id": "z4oJaIchyK2u3vEsn0Hc_",
        "code": "\nResponse varies per endpoint.  See details on the Generative \nAI API Endpoint Details page.\n",
        "language": "200",
        "customLabel": ""
      },
      {
        "id": "6qtTbZWCFEZJoynVEKZ7J",
        "code": "{\r\n  \"errorMessage (string)\"\r\n}",
        "language": "404",
        "customLabel": ""
      },
      {
        "id": "MMXzG5yT44i1NrwPtNsZ0",
        "language": "408",
        "code": "{\n  \"errorMessage (string)\"\n}",
        "customLabel": ""
      },
      {
        "id": "KfxIDu7UjMwezKkPdmLGS",
        "language": "409",
        "code": "{\n  \"errorMessage (string)\"\n}",
        "customLabel": ""
      },
      {
        "id": "fxUu7xZdS9SKZXgKwqYs6",
        "language": "422",
        "code": "{\n  \"errorMessage (string)\"\n}",
        "customLabel": ""
      },
      {
        "id": "8GWtb2S2si_RZSTXr43NS",
        "language": "429",
        "code": "{\n  \"errorMessage (string)\"\n}",
        "customLabel": ""
      },
      {
        "id": "kKg0MWjJZ0tiQbag-Mrlg",
        "language": "500",
        "code": "{\n  \"errorMessage (string)\"\n}",
        "customLabel": ""
      },
      {
        "id": "EfYXrEwBSFmFamAJRxIrB",
        "language": "504",
        "code": "{\n  \"errorMessage (string)\"\n}",
        "customLabel": ""
      }
    ],
    "selectedLanguageId": "EfYXrEwBSFmFamAJRxIrB"
  },
  "examples": {
    "languages": [
      {
        "id": "UmmDKJjJMMC26zwNWT4zD",
        "language": "curl",
        "code": "curl --location --globoff 'https://api.elevateai.com/v1/interactions/{interactionIdentifier}/{endpoint}' \\\n--header 'Accept: application/json' \\\n--header 'Content-Type: application/json'",
        "customLabel": ""
      },
      {
        "id": "PWWVbXEHuwgBzdr60DE1A",
        "language": "nodejs",
        "code": "var request = require('request');\nvar options = {\n   'method': 'GET',\n   'url': 'https://api.elevateai.com/v1/interactions/{interactionIdentifier}/{endpoint}',\n   'headers': {\n      'Accept': 'application/json',\n      'Content-Type': 'application/json'\n   }\n};\nrequest(options, function (error, response) {\n   if (error) throw new Error(error);\n   console.log(response.body);\n});\n",
        "customLabel": ""
      },
      {
        "id": "w2Ghhrl-_AvckIqArqDsv",
        "language": "javascript",
        "code": "var myHeaders = new Headers();\nmyHeaders.append(\"Accept\", \"application/json\");\nmyHeaders.append(\"Content-Type\", \"application/json\");\n\nvar requestOptions = {\n   method: 'GET',\n   headers: myHeaders,\n   redirect: 'follow'\n};\n\nfetch(\"https://api.elevateai.com/v1/interactions/{interactionIdentifier}/{endpoint}\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));",
        "customLabel": ""
      },
      {
        "id": "KC32W5xJn4IIa7Sv9XzXB",
        "language": "python",
        "code": "import requests\nimport json\n\nurl = \"https://api.elevateai.com/v1/interactions/{interactionIdentifier}/{endpoint}\"\n\npayload = {}\nheaders = {\n   'Accept': 'application/json',\n   'Content-Type': 'application/json'\n}\n\nresponse = requests.request(\"GET\", url, headers=headers, data=payload)\n\nprint(response.text)\n",
        "customLabel": ""
      },
      {
        "id": "7qsihIYKDYdm4cvf3I1Ly",
        "language": "ruby",
        "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://api.elevateai.com/v1/interactions/{interactionIdentifier}/{endpoint}\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Get.new(url)\nrequest[\"Accept\"] = \"application/json\"\nrequest[\"Content-Type\"] = \"application/json\"\n\nresponse = https.request(request)\nputs response.read_body\n",
        "customLabel": ""
      }
    ],
    "selectedLanguageId": "PWWVbXEHuwgBzdr60DE1A"
  },
  "description": "",
  "currentNewParameter": {
    "label": "Header Parameter",
    "value": "headerParameters"
  },
  "autoGeneratedAnchorSlug": "retrieve-generative-ai-response",
  "legacyHash": "2iKYn-P9WdHriWeSNyWh9"
}
```
:::



# <font color="#3694fc">//</font> Retryable Responses

The following response codes leave the interaction endpoint in a retryable state. &#x20;

Calling code should handle these responses gracefully and retry appropriately:

| **Response** | **Message**         | **Meaning**                                                                                                                                                   |
| ------------ | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **408**      | **RequestTimeout**  | The Generative AI model was not able to respond in an acceptable amount of time.                                                                              |
| **429**      | **TooManyRequests** | By default, each account is allowed up to 10 simultaneous Generative AI requests at one time.  This response indicates that more than 10 are being attempted. |



**Need more help?** Contact the [ElevateAI Support team](mailto\:support@elevateai.com). &#x20;
