Asks for an AI-generated answer from query.
curl --request POST \
--url https://cite.petal.org/api/ai/session/{ai_session_id}/qa/create \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"query": "<string>",
"chat_model": "<string>",
"language": "English (US)",
"meta": {},
"restrict_to_context": "True",
"use_cells": "True",
"use_context": "True",
"use_history": "True",
"use_meta": "True"
}
'import requests
url = "https://cite.petal.org/api/ai/session/{ai_session_id}/qa/create"
payload = {
"query": "<string>",
"chat_model": "<string>",
"language": "English (US)",
"meta": {},
"restrict_to_context": "True",
"use_cells": "True",
"use_context": "True",
"use_history": "True",
"use_meta": "True"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
query: '<string>',
chat_model: '<string>',
language: 'English (US)',
meta: {},
restrict_to_context: 'True',
use_cells: 'True',
use_context: 'True',
use_history: 'True',
use_meta: 'True'
})
};
fetch('https://cite.petal.org/api/ai/session/{ai_session_id}/qa/create', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://cite.petal.org/api/ai/session/{ai_session_id}/qa/create",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'query' => '<string>',
'chat_model' => '<string>',
'language' => 'English (US)',
'meta' => [
],
'restrict_to_context' => 'True',
'use_cells' => 'True',
'use_context' => 'True',
'use_history' => 'True',
'use_meta' => 'True'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://cite.petal.org/api/ai/session/{ai_session_id}/qa/create"
payload := strings.NewReader("{\n \"query\": \"<string>\",\n \"chat_model\": \"<string>\",\n \"language\": \"English (US)\",\n \"meta\": {},\n \"restrict_to_context\": \"True\",\n \"use_cells\": \"True\",\n \"use_context\": \"True\",\n \"use_history\": \"True\",\n \"use_meta\": \"True\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://cite.petal.org/api/ai/session/{ai_session_id}/qa/create")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"<string>\",\n \"chat_model\": \"<string>\",\n \"language\": \"English (US)\",\n \"meta\": {},\n \"restrict_to_context\": \"True\",\n \"use_cells\": \"True\",\n \"use_context\": \"True\",\n \"use_history\": \"True\",\n \"use_meta\": \"True\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://cite.petal.org/api/ai/session/{ai_session_id}/qa/create")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"query\": \"<string>\",\n \"chat_model\": \"<string>\",\n \"language\": \"English (US)\",\n \"meta\": {},\n \"restrict_to_context\": \"True\",\n \"use_cells\": \"True\",\n \"use_context\": \"True\",\n \"use_history\": \"True\",\n \"use_meta\": \"True\"\n}"
response = http.request(request)
puts response.read_body[
{
"ai_session_id": 123,
"created_at": "<string>",
"id": 123,
"meta": {},
"query": "<string>",
"task_id": "<string>",
"task_status": "<string>",
"user_id": 123,
"user_rating": "<string>",
"response": "<string>"
}
][
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"ctx": {}
}
]AI Chat
Create a chat message
Create a new message in a given AI Session
POST
/
api
/
ai
/
session
/
{ai_session_id}
/
qa
/
create
Asks for an AI-generated answer from query.
curl --request POST \
--url https://cite.petal.org/api/ai/session/{ai_session_id}/qa/create \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"query": "<string>",
"chat_model": "<string>",
"language": "English (US)",
"meta": {},
"restrict_to_context": "True",
"use_cells": "True",
"use_context": "True",
"use_history": "True",
"use_meta": "True"
}
'import requests
url = "https://cite.petal.org/api/ai/session/{ai_session_id}/qa/create"
payload = {
"query": "<string>",
"chat_model": "<string>",
"language": "English (US)",
"meta": {},
"restrict_to_context": "True",
"use_cells": "True",
"use_context": "True",
"use_history": "True",
"use_meta": "True"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
query: '<string>',
chat_model: '<string>',
language: 'English (US)',
meta: {},
restrict_to_context: 'True',
use_cells: 'True',
use_context: 'True',
use_history: 'True',
use_meta: 'True'
})
};
fetch('https://cite.petal.org/api/ai/session/{ai_session_id}/qa/create', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://cite.petal.org/api/ai/session/{ai_session_id}/qa/create",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'query' => '<string>',
'chat_model' => '<string>',
'language' => 'English (US)',
'meta' => [
],
'restrict_to_context' => 'True',
'use_cells' => 'True',
'use_context' => 'True',
'use_history' => 'True',
'use_meta' => 'True'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://cite.petal.org/api/ai/session/{ai_session_id}/qa/create"
payload := strings.NewReader("{\n \"query\": \"<string>\",\n \"chat_model\": \"<string>\",\n \"language\": \"English (US)\",\n \"meta\": {},\n \"restrict_to_context\": \"True\",\n \"use_cells\": \"True\",\n \"use_context\": \"True\",\n \"use_history\": \"True\",\n \"use_meta\": \"True\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://cite.petal.org/api/ai/session/{ai_session_id}/qa/create")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"<string>\",\n \"chat_model\": \"<string>\",\n \"language\": \"English (US)\",\n \"meta\": {},\n \"restrict_to_context\": \"True\",\n \"use_cells\": \"True\",\n \"use_context\": \"True\",\n \"use_history\": \"True\",\n \"use_meta\": \"True\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://cite.petal.org/api/ai/session/{ai_session_id}/qa/create")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"query\": \"<string>\",\n \"chat_model\": \"<string>\",\n \"language\": \"English (US)\",\n \"meta\": {},\n \"restrict_to_context\": \"True\",\n \"use_cells\": \"True\",\n \"use_context\": \"True\",\n \"use_history\": \"True\",\n \"use_meta\": \"True\"\n}"
response = http.request(request)
puts response.read_body[
{
"ai_session_id": 123,
"created_at": "<string>",
"id": 123,
"meta": {},
"query": "<string>",
"task_id": "<string>",
"task_status": "<string>",
"user_id": 123,
"user_rating": "<string>",
"response": "<string>"
}
][
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"ctx": {}
}
]Authorizations
Path Parameters
Body
application/json
Response
OK
