Answer a question
curl --request POST \
--url https://api.answer.tinyfish.ai/ \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"question": "Who is the CEO of Stripe?"
}
'import requests
url = "https://api.answer.tinyfish.ai/"
payload = { "question": "Who is the CEO of Stripe?" }
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({question: 'Who is the CEO of Stripe?'})
};
fetch('https://api.answer.tinyfish.ai/', 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://api.answer.tinyfish.ai/",
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([
'question' => 'Who is the CEO of Stripe?'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$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://api.answer.tinyfish.ai/"
payload := strings.NewReader("{\n \"question\": \"Who is the CEO of Stripe?\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
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://api.answer.tinyfish.ai/")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"question\": \"Who is the CEO of Stripe?\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.answer.tinyfish.ai/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"question\": \"Who is the CEO of Stripe?\"\n}"
response = http.request(request)
puts response.read_body{
"answer": "Patrick Collison is the CEO and co-founder of Stripe.",
"citations": [
{
"url": "https://stripe.com/about",
"title": "About Stripe"
}
],
"request_id": "example-request-id"
}{
"error": {
"code": "INVALID_INPUT",
"message": "Invalid JSON or question. Unknown fields are rejected."
},
"request_id": "example-request-id"
}{
"error": {
"code": "MISSING_API_KEY",
"message": "Missing API key"
},
"request_id": "example-request-id"
}{
"error": {
"code": "INSUFFICIENT_CREDITS",
"message": "Insufficient wallet balance when enforced."
},
"request_id": "example-request-id"
}{
"error": {
"code": "TIER_ACCESS_DENIED",
"message": "TinyAnswer is not enabled for this account."
},
"request_id": "example-request-id"
}{
"error": {
"code": "RATE_LIMIT_EXCEEDED",
"message": "Rate limit exceeded"
},
"request_id": "example-request-id"
}{
"error": {
"code": "INTERNAL_ERROR",
"message": "Unexpected server error."
},
"request_id": "example-request-id"
}{
"error": {
"code": "BACKEND_UNAVAILABLE",
"message": "Upstream communication failed. Retry with backoff."
},
"request_id": "example-request-id"
}{
"error": {
"code": "SERVICE_BUSY",
"message": "Answer is temporarily unavailable"
},
"request_id": "example-request-id"
}{
"error": {
"code": "TIMEOUT",
"message": "Request timed out"
},
"request_id": "example-request-id"
}API Reference
Answer a question
Ask a natural-language question and receive an answer with web citations in a single JSON response. TinyAnswer must be enabled for your account. Use a personal API key; team API keys are not supported.
POST
/
Answer a question
curl --request POST \
--url https://api.answer.tinyfish.ai/ \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"question": "Who is the CEO of Stripe?"
}
'import requests
url = "https://api.answer.tinyfish.ai/"
payload = { "question": "Who is the CEO of Stripe?" }
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({question: 'Who is the CEO of Stripe?'})
};
fetch('https://api.answer.tinyfish.ai/', 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://api.answer.tinyfish.ai/",
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([
'question' => 'Who is the CEO of Stripe?'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$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://api.answer.tinyfish.ai/"
payload := strings.NewReader("{\n \"question\": \"Who is the CEO of Stripe?\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
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://api.answer.tinyfish.ai/")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"question\": \"Who is the CEO of Stripe?\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.answer.tinyfish.ai/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"question\": \"Who is the CEO of Stripe?\"\n}"
response = http.request(request)
puts response.read_body{
"answer": "Patrick Collison is the CEO and co-founder of Stripe.",
"citations": [
{
"url": "https://stripe.com/about",
"title": "About Stripe"
}
],
"request_id": "example-request-id"
}{
"error": {
"code": "INVALID_INPUT",
"message": "Invalid JSON or question. Unknown fields are rejected."
},
"request_id": "example-request-id"
}{
"error": {
"code": "MISSING_API_KEY",
"message": "Missing API key"
},
"request_id": "example-request-id"
}{
"error": {
"code": "INSUFFICIENT_CREDITS",
"message": "Insufficient wallet balance when enforced."
},
"request_id": "example-request-id"
}{
"error": {
"code": "TIER_ACCESS_DENIED",
"message": "TinyAnswer is not enabled for this account."
},
"request_id": "example-request-id"
}{
"error": {
"code": "RATE_LIMIT_EXCEEDED",
"message": "Rate limit exceeded"
},
"request_id": "example-request-id"
}{
"error": {
"code": "INTERNAL_ERROR",
"message": "Unexpected server error."
},
"request_id": "example-request-id"
}{
"error": {
"code": "BACKEND_UNAVAILABLE",
"message": "Upstream communication failed. Retry with backoff."
},
"request_id": "example-request-id"
}{
"error": {
"code": "SERVICE_BUSY",
"message": "Answer is temporarily unavailable"
},
"request_id": "example-request-id"
}{
"error": {
"code": "TIMEOUT",
"message": "Request timed out"
},
"request_id": "example-request-id"
}Authorizations
Body
application/json
Only question is accepted: 1–2,000 characters after trimming surrounding whitespace.
Was this page helpful?