Kagi FastGPT
Get AI-generated answers with cited web sources using Kagi's FastGPT API. FastGPT runs a full web search under the hood and synthesizes results into a concise answer — ideal for factual questions, API lookups, and current-events queries.
This skill uses a Go binary for fast startup and no runtime dependencies. The binary can be downloaded pre-built or compiled from source.
Setup
Requires a Kagi account with API access enabled. Uses the same KAGI_API_KEY as the kagi-search skill.
- 1. Create an account at https://kagi.com/signup
- Navigate to Settings → Advanced → API portal: https://kagi.com/settings/api
- Generate an API Token
- Add funds at: https://kagi.com/settings/billing_api
- Add to your shell profile (
~/.profile or ~/.zprofile):
export KAGI_API_KEY="your-api-key-here"
- 6. Install the binary — see Installation below
Pricing
1.5¢ per query ($15 USD per 1000 queries). Cached responses are free.
Usage
CODEBLOCK1
Options
| Flag | Description |
|---|
| INLINECODE4 | Emit JSON output (see below) |
| INLINECODE5 |
Suppress references in text output |
|
--no-cache | Bypass cached responses (use for time-sensitive queries) |
|
--timeout <sec> | HTTP timeout in seconds (default: 30) |
Output
Default (text)
Prints the synthesized answer, followed by a numbered reference list:
CODEBLOCK2
Token usage and API balance are printed to stderr.
JSON (--json)
Returns a JSON object with:
- -
query — the original query - INLINECODE10 — the synthesized answer
- INLINECODE11 — tokens consumed
- INLINECODE12 — array of
{ title, url, snippet } objects - INLINECODE14 — API metadata (
id, node, ms)
When to Use
- - Use kagi-fastgpt when you need a direct answer synthesized from web sources (e.g. "What version of X was released last month?", "How do I configure Y?")
- Use kagi-search when you need raw search results to scan, compare, or extract data from yourself
- Use web-browser when you need to interact with a page or the content is behind JavaScript
Installation
Option A — Download pre-built binary (no Go required)
CODEBLOCK3
Pre-built binaries are available for Linux and macOS (amd64 + arm64) and Windows (amd64).
Option B — Build from source (requires Go 1.26+)
CODEBLOCK4
Alternatively, just run {baseDir}/kagi-fastgpt.sh directly — the wrapper auto-builds on first run if Go is available.
The binary has no external dependencies — only the Go standard library.
Kagi FastGPT
使用Kagi的FastGPT API获取带有引用网络来源的AI生成答案。FastGPT在底层执行完整的网络搜索,并将结果综合成简洁的答案——非常适合事实性问题、API查询和时事类问题。
此技能使用Go二进制文件实现快速启动,无运行时依赖。二进制文件可以下载预编译版本或从源代码编译。
设置
需要启用API访问权限的Kagi账户。使用与kagi-search技能相同的KAGIAPIKEY。
- 1. 在 https://kagi.com/signup 创建账户
- 导航至设置 → 高级 → API门户:https://kagi.com/settings/api
- 生成API令牌
- 在 https://kagi.com/settings/billing_api 添加资金
- 添加到您的shell配置文件(~/.profile或~/.zprofile):
bash
export KAGI
APIKEY=your-api-key-here
- 6. 安装二进制文件——参见下方的安装部分
定价
每次查询1.5美分(每1000次查询15美元)。缓存响应免费。
用法
bash
{baseDir}/kagi-fastgpt.sh 查询内容 # 提问(默认)
{baseDir}/kagi-fastgpt.sh 查询内容 --json # JSON输出
{baseDir}/kagi-fastgpt.sh 查询内容 --no-refs # 仅答案,无引用
{baseDir}/kagi-fastgpt.sh 查询内容 --no-cache # 绕过响应缓存
{baseDir}/kagi-fastgpt.sh 查询内容 --timeout 60 # 自定义超时(默认:30秒)
选项
| 标志 | 描述 |
|---|
| --json | 输出JSON格式(见下方) |
| --no-refs |
在文本输出中隐藏引用 |
| --no-cache | 绕过缓存响应(用于时间敏感查询) |
| --timeout <秒> | HTTP超时时间(秒)(默认:30) |
输出
默认(文本)
打印综合答案,后跟编号引用列表:
Python 3.11于2022年10月24日发布,引入了若干改进...
--- 引用 ---
[1] Python 3.11新特性 — Python 3.11.3文档
https://docs.python.org/3/whatsnew/3.11.html
Python 3.11的主要变化包括显著的性能改进...
[2] ...
令牌使用量和API余额将打印到stderr。
JSON(--json)
返回包含以下内容的JSON对象:
- - query — 原始查询
- output — 综合答案
- tokens — 消耗的令牌数
- references[] — { title, url, snippet }对象数组
- meta — API元数据(id、node、ms)
使用时机
- - 使用kagi-fastgpt:当您需要从网络来源综合的直接答案时(例如上个月发布了X的哪个版本?、如何配置Y?)
- 使用kagi-search:当您需要原始搜索结果自行浏览、比较或提取数据时
- 使用web-browser:当您需要与页面交互或内容在JavaScript后面时
安装
选项A — 下载预编译二进制文件(无需Go)
bash
OS=$(uname -s | tr [:upper:] [:lower:])
ARCH=$(uname -m)
case $ARCH in
x86_64) ARCH=amd64 ;;
aarch64|arm64) ARCH=arm64 ;;
esac
TAG=$(curl -fsSL https://api.github.com/repos/joelazar/kagi-skills/releases/latest | grep tag_name | cut -d -f4)
BINARY=kagi-fastgpt${TAG}${OS}_${ARCH}
mkdir -p {baseDir}/.bin
curl -fsSL https://github.com/joelazar/kagi-skills/releases/download/${TAG}/${BINARY} \
-o {baseDir}/.bin/kagi-fastgpt
chmod +x {baseDir}/.bin/kagi-fastgpt
验证校验和(推荐)
curl -fsSL https://github.com/joelazar/kagi-skills/releases/download/${TAG}/checksums.txt | \
grep ${BINARY} | sha256sum --check
预编译二进制文件适用于Linux和macOS(amd64 + arm64)以及Windows(amd64)。
选项B — 从源代码构建(需要Go 1.26+)
bash
cd {baseDir} && go build -o .bin/kagi-fastgpt .
或者,直接运行{baseDir}/kagi-fastgpt.sh——如果Go可用,包装器会在首次运行时自动构建。
该二进制文件没有外部依赖——仅使用Go标准库。