Clear AI Docs
Ask or search…
K
Links

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:
  1. 1.
    Sign in and navigate to: https://clearai.net/folders
  2. 2.
    Name your project and click create.
  3. 3.
    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:
  1. 1.
    Launch your project dashboard.
  2. 2.
    Click the Details dropdown.
  3. 3.
    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.
post
https://clearai.net
/ai
Submit a query, get a response.
Take a look at how you might call this method:
Ruby
Python
Javascript
Java
Swift
Kotlin
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())
}