Quick Start
Set up a knowledge base and query it via API in 5 minutes.
Create a project
Your API requests are authenticated using API keys. Without an API key, your requests will return an error. To get your API key, follow these steps:
Name your project and click create.
Upload the media you would like to query (note: be sure to select 'Yes' for API Access).
Get your API keys
Your API requests are authenticated using API keys. Without an API key, your requests will return an error. To get your API key, follow these steps:
Launch your project dashboard.
Click the Details dropdown.
Copy the API key to your clipboard.
Make your first request
To make your first request, send an authenticated request to the /ai
endpoint. This will post a query
and return a response, which is nice.
Submit a query, get a response.
POST
https://clearai.net/ai
Submits a query and returns a response, based on the media files indexed for the specific key in use.
Path Parameters
Query Parameters
Request Body
Take a look at how you might call this method:
require 'net/http'
require 'json'
url = URI('http://clearai.net/ai')
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request['Content-Type'] = 'application/json'
request['Authorization'] = 'Bearer your_api_key'
request.body = {
msg: 'your_message',
metadata: {
key1: 'value1',
key2: 'value2'
}
}.to_json
response = http.request(request)
puts response.read_body
import requests
url = 'http://clearai.net/ai'
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer your_api_key'
}
data = {
'msg': 'your_message',
'metadata': {
'key1': 'value1',
'key2': 'value2'
}
}
response = requests.post(url, headers=headers, json=data)
print(response.text)
const axios = require('axios');
const url = 'http://clearai.net/ai';
const headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer your_api_key'
};
const data = {
msg: 'your_message',
metadata: {
key1: 'value1',
key2: 'value2'
}
};
axios.post(url, data, { headers: headers })
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error(error);
});
import okhttp3.*;
public class Main {
public static void main(String[] args) {
OkHttpClient client = new OkHttpClient();
MediaType JSON = MediaType.parse("application/json; charset=utf-8");
String json = "{\"msg\": \"your_message\", \"metadata\": {\"key1\": \"value1\", \"key2\": \"value2\"}}";
RequestBody body = RequestBody.create(JSON, json);
Request request = new Request.Builder()
.url("http://clearai.net/ai")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", "Bearer your_api_key")
.build();
try {
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
} catch (IOException e) {
e.printStackTrace();
}
}
}
import Alamofire
let url = "http://clearai.net/ai"
let headers: HTTPHeaders = [
"Content-Type": "application/json",
"Authorization": "Bearer your_api_key"
]
let parameters: [String: Any] = [
"msg": "your_message",
"metadata": [
"key1": "value1",
"key2": "value2"
]
]
AF.request(url, method: .post, parameters: parameters, encoding: JSONEncoding.default, headers: headers)
.responseJSON { response in
switch response.result {
case .success(let value):
print(value)
case .failure(let error):
print(error)
}
}
import io.ktor.client.*
import io.ktor.client.features.json.*
import io.ktor.client.features.json.serializer.*
import io.ktor.client.request.*
import io.ktor.client.statement.*
import kotlinx.serialization.json.Json
suspend fun main() {
val client = HttpClient {
install(JsonFeature) {
val json = Json { ignoreUnknownKeys = true }
serializer = KotlinxSerializer(json)
}
}
val url = "http://clearai.net/ai"
val headers = mapOf(
"Content-Type" to "application/json",
"Authorization" to "Bearer your_api_key"
)
val parameters = mapOf(
"msg" to "your_message",
"metadata" to mapOf(
"key1" to "value1",
"key2" to "value2"
)
)
val response: HttpResponse = client.post(url) {
headers.forEach { (key, value) ->
header(key, value)
}
body = parameters
}
println(response.readText())
}