Skip to content
On this page

FastGPT

FastGPT is a Kagi service using powerful LLMs to answer user queries running a full search engine underneath. Think ChatGPT, but on steroids and faster! You can try the web app here.

Quick start

  1. Get the API key (requires a Kagi account)
  2. Top off your API credits.
  3. Call the API. See example usage.

API key

To obtain an API key you will first need to create a Kagi account.

Then, navigate to Settings -> Advanced -> API portal, or click here to go directly.

Click "Generate API Token".

API Credits

The FastGPT API uses pre-paid API credits. You can manage API credits in the API billing page of your Kagi settings.

Using API with insufficient credits will produce "Insufficient credit to perform this request." response message.

Pricing

Pricing for FastGPT is a flat rate per-query:

  • 1.5¢ per query ($15 USD per 1000 queries) when web_search is enabled.
  • (Out of service) 0.15¢ per query ($1.5 USD per 1000 queries) when web_search is disabled.

Cached responses, as with all other Kagi APIs, are free.

NOTE: Currently, the web_search parameter is out of service, and may be removed. Trying to pass any value other than true will result in error.

Support

You can reach out through support@kagi.com, our Discord server or KagiFeedback.org.

Endpoints

Answer Query

POST /fastgpt

Answer a query.

Returns a FastGPT Answer.

Parameters

FieldTypeRequiredDescription
querystringYesA query to be answered.
cacheboolNoWhether to allow cached requests & responses. (default true)
web_searchboolNoWhether to perform web searches to enrich answers (default true)

NOTE: Currently, the web_search parameter is out of service, and may be removed. Trying to pass any value other than true will result in error.

Examples

POST request with web search

shell
curl -v \
  -H "Authorization: Bot $TOKEN" \
  -H "Content-Type: application/json" \
  --data '{"query": "Python 3.11"}' \
  https://kagi.com/api/v0/fastgpt

Alternatively in python:

python
import requests

base_url = 'https://kagi.com/api/v0/fastgpt'
data = {
    "query": "python 3.11",
}
headers = {'Authorization': f'Bot {TOKEN}'}

response = requests.post(base_url, headers=headers, json=data)
print(response.json())
Response
json
{
  "meta": {
    "id": "120145af-f057-466d-9e6d-7829ac902adc",
    "node": "us-east",
    "ms": 7943
  },
  "data": {
    "output": "Python 3.11 was released in 2021 and introduced several new features compared to previous versions:
    - Faster performance: The interpreter was optimized, resulting in up to 1.25x speedup on benchmarks.[1]
    - New syntax features: Exception groups were added using PEP 654.[1]    
    - Traceback annotation: The new version includes a feature to annotate tracebacks to make them more intelligible.[2]
    - Type hint improvements: Type hints were made more powerful.[3]",
    "tokens": 757,
    "references": [
      {"title": "What's New In Python 3.11 — Python 3.11.3 documentation", "snippet": "...", "url": "https://docs.python.org/3/whatsnew/3.11.html"}, 
      {"title": "Introducing the New Features in Python 3.11 -", "snippet": "...", "url": "https://earthly.dev/blog/python-3.11-new-features/"}
    ]
  }
}

Objects

FastGPT Answer

FieldTypeDescription
outputstringAnswer output
referencesarray of Reference objectThe search results that are referred in the answer.
tokensintAmount of tokens processed

Reference object

FieldTypeDescription
titlestringTitle of the referenced search result.
snippetstringSnippet of the referenced search result.
urlstringURL of the referenced search result.