Making API Requests for GenAI Results
All of the ElevateAI Generative AI API Endpoints use a similar format, leveraging the unique interactionIdentifier returned upon successfully declaring the audioaudio, chatchat, or transcriptiontranscription interaction.
When the desired GET request* successfully executes, an HTTP status is returned to indicate the request was successful, along with a JSON response providing details specific to that endpoint.
All endpoints support a GET method; the Ask ElevateAI Q&A endpointAsk ElevateAI endpoint supports both POST and GET methods.
- Details specific to individual endpoints are covered on the GenAI API endpointsGenerative AI API Endpoint Details page
The general request format to be used for all of the Generative AI API requests is outlined below:
// General Request Format
- interactionIdentifierstringrequiredDescription
- endpointstringrequiredDescription
- X-API-TokenstringrequiredDescription
- Accept-EncodingstringDescription
- Accept-LanguagestringDescription
curl --location --globoff 'https://api.elevateai.com/v1/interactions/{interactionIdentifier}/{endpoint}' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json'var request = require('request');
var options = {
'method': 'GET',
'url': 'https://api.elevateai.com/v1/interactions/{interactionIdentifier}/{endpoint}',
'headers': {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
var myHeaders = new Headers();
myHeaders.append("Accept", "application/json");
myHeaders.append("Content-Type", "application/json");
var requestOptions = {
method: 'GET',
headers: myHeaders,
redirect: 'follow'
};
fetch("https://api.elevateai.com/v1/interactions/{interactionIdentifier}/{endpoint}", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));import requests
import json
url = "https://api.elevateai.com/v1/interactions/{interactionIdentifier}/{endpoint}"
payload = {}
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
require "uri"
require "json"
require "net/http"
url = URI("https://api.elevateai.com/v1/interactions/{interactionIdentifier}/{endpoint}")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Accept"] = "application/json"
request["Content-Type"] = "application/json"
response = https.request(request)
puts response.read_body
Response varies per endpoint. See details on the Generative
AI API Endpoint Details page.
{
"errorMessage (string)"
}{
"errorMessage (string)"
}{
"errorMessage (string)"
}{
"errorMessage (string)"
}{
"errorMessage (string)"
}{
"errorMessage (string)"
}{
"errorMessage (string)"
}
// Retryable Responses
The following response codes leave the interaction endpoint in a retryable state.
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.