kagi-fastgpt

TotalClaw 作者 totalclaw

通过 Kagi 的 FastGPT API 提出问题并获得由实时网络搜索支持的人工智能合成答案。返回带有引用参考文献的直接答案。当您需要快速、权威的答案而不是原始搜索结果时使用。

安装 / 下载方式

TotalClaw CLI推荐
totalclaw skills install shop:totalclaw:totalclaw~joelazar-kagi-fastgpt
cURL直接下载,无需登录
curl -fsSL https://skills.taituai.com/api/skills/totalclaw%3Atotalclaw~joelazar-kagi-fastgpt/file -o joelazar-kagi-fastgpt.md
# Kagi FastGPT

Get AI-generated answers with cited web sources using [Kagi's FastGPT API](https://help.kagi.com/kagi/api/fastgpt.html). 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
2. Navigate to Settings → Advanced → API portal: https://kagi.com/settings/api
3. Generate an API Token
4. Add funds at: https://kagi.com/settings/billing_api
5. Add to your shell profile (`~/.profile` or `~/.zprofile`):
   ```bash
   export KAGI_API_KEY="your-api-key-here"
   ```
6. Install the binary — see [Installation](#installation) below

## Pricing

1.5¢ per query ($15 USD per 1000 queries). Cached responses are free.

## Usage

```bash
{baseDir}/kagi-fastgpt.sh "query"                        # Ask a question (default)
{baseDir}/kagi-fastgpt.sh "query" --json                 # JSON output
{baseDir}/kagi-fastgpt.sh "query" --no-refs              # Answer only, no references
{baseDir}/kagi-fastgpt.sh "query" --no-cache             # Bypass response cache
{baseDir}/kagi-fastgpt.sh "query" --timeout 60           # Custom timeout (default: 30s)
```

### Options

| Flag | Description |
|------|-------------|
| `--json` | Emit JSON output (see below) |
| `--no-refs` | 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:

```
Python 3.11 was released on October 24, 2022 and introduced several improvements...

--- References ---
[1] What's New In Python 3.11 — Python 3.11.3 documentation
    https://docs.python.org/3/whatsnew/3.11.html
    The headline changes in Python 3.11 include significant performance improvements...
[2] ...
```

Token usage and API balance are printed to stderr.

### JSON (`--json`)

Returns a JSON object with:

- `query` — the original query
- `output` — the synthesized answer
- `tokens` — tokens consumed
- `references[]` — array of `{ title, url, snippet }` objects
- `meta` — 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)

```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

# Verify checksum (recommended)
curl -fsSL "https://github.com/joelazar/kagi-skills/releases/download/${TAG}/checksums.txt" | \
  grep "${BINARY}" | sha256sum --check
```

Pre-built binaries are available for Linux and macOS (amd64 + arm64) and Windows (amd64).

### Option B — Build from source (requires Go 1.26+)

```bash
cd {baseDir} && go build -o .bin/kagi-fastgpt .
```

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's FastGPT API](https://help.kagi.com/kagi/api/fastgpt.html) 获取带有引用网络来源的 AI 生成答案。FastGPT 在底层运行完整的网络搜索,并将结果综合成简洁的答案——非常适合事实性问题、API 查询和时事查询。

本技能使用一个 Go 二进制文件,以实现快速启动且无运行时依赖。该二进制文件可以下载预构建版本,也可以从源码编译。

## 设置

需要一个启用了 API 访问权限的 Kagi 账户。使用与 `kagi-search` 技能相同的 `KAGI_API_KEY`。

1. 在 https://kagi.com/signup 创建账户
2. 进入 Settings → Advanced → API portal: https://kagi.com/settings/api
3. 生成一个 API Token
4. 在此充值:https://kagi.com/settings/billing_api
5. 添加到你的 shell 配置文件(`~/.profile` 或 `~/.zprofile`):
   ```bash
   export KAGI_API_KEY="your-api-key-here"
   ```
6. 安装二进制文件——参见下方的 [Installation](#installation)

## 定价

每次查询 1.5¢(每 1000 次查询 15 美元)。缓存的响应免费。

## 用法

```bash
{baseDir}/kagi-fastgpt.sh "query"                        # Ask a question (default)
{baseDir}/kagi-fastgpt.sh "query" --json                 # JSON output
{baseDir}/kagi-fastgpt.sh "query" --no-refs              # Answer only, no references
{baseDir}/kagi-fastgpt.sh "query" --no-cache             # Bypass response cache
{baseDir}/kagi-fastgpt.sh "query" --timeout 60           # Custom timeout (default: 30s)
```

### 选项

| Flag | 说明 |
|------|-------------|
| `--json` | 输出 JSON(见下文) |
| `--no-refs` | 在文本输出中抑制引用 |
| `--no-cache` | 绕过缓存响应(用于时效性查询) |
| `--timeout <sec>` | HTTP 超时时间(秒)(默认:30) |

## 输出

### 默认(文本)

打印综合后的答案,后跟一个带编号的引用列表:

```
Python 3.11 was released on October 24, 2022 and introduced several improvements...

--- References ---
[1] What's New In Python 3.11 — Python 3.11.3 documentation
    https://docs.python.org/3/whatsnew/3.11.html
    The headline changes in Python 3.11 include significant performance improvements...
[2] ...
```

Token 用量和 API 余额会打印到 stderr。

### JSON(`--json`)

返回一个包含以下内容的 JSON 对象:

- `query` — 原始查询
- `output` — 综合后的答案
- `tokens` — 消耗的 token 数
- `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

# Verify checksum (recommended)
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 标准库。