#search #cli #kagi

app fastgpt

A CLI client for Kagi's FastGPT API

5 releases

0.2.2 Jul 31, 2025
0.2.1 Jul 31, 2025
0.1.3 May 29, 2025

#996 in Command line utilities

Download history 268/week @ 2025-05-23 118/week @ 2025-05-30 3/week @ 2025-06-06 7/week @ 2025-06-13 3/week @ 2025-07-04 87/week @ 2025-07-18 162/week @ 2025-07-25 123/week @ 2025-08-01 4/week @ 2025-08-08

460 downloads per month

MIT license

44KB
870 lines

Kagi FastGPT CLI

A command-line interface for Kagi's FastGPT API written in Rust.

image

Features

  • Conversation History - Maintain context across multiple questions
  • File Context Support - Add local files and directories as context for queries
  • JSON Output Format - Raw API response output for integrations
  • Session Management - Interactive commands for managing conversations and files

Installation

Using Cargo

cargo install fastgpt

From Source

  1. Clone this repository:
    git clone https://github.com/0xgingi/kagi-fastgpt-cli
    cd kagi-fastgpt-cli
    
  2. Build and install:
    cargo install --path .
    

Quick Start

  1. Get your API key from Kagi:

    • Navigate to Settings → Advanced → API portal
    • Click "Generate API Token"
    • Top off your API credits (1.5¢ per query)
  2. Set your API key (one time setup):

    fastgpt --config
    
  3. Start chatting:

    fastgpt
    

Usage

API Key Management

# Set API key
fastgpt --set-api-key "your-api-key"

# Show current API key
fastgpt --show-api-key

# Reset/remove stored API key
fastgpt --reset-api-key

Options

fastgpt [OPTIONS]

Options:
      --set-api-key <SET_API_KEY>  Set API key (will be saved for future use)
      --show-api-key               Show current API key
      --config                     Interactive configuraiton setup
      --cache                      Whether to allow cached responses [default: true]
      --json                       Output raw JSON response
      --reset-api-key              Reset stored API key
      --references                 Enable or disable showing references [default: true]
  -h, --help                       Print help
  -V, --version                    Print version

Examples

First-time setup

fastgpt --config

Start interactive chat

fastgpt

Start with JSON output enabled

fastgpt --json

Session Commands

While in interactive mode, you can use these special commands:

Conversation Management

  • /exit or /quit - Exit the session
  • /clear - Clear conversation history and start fresh
  • /history - Show your complete conversation history
  • /help - Display available commands
  • /balance - Check API balance

File Context Management

  • /add-file <path> - Add a file or directory to context for queries
  • /remove-file <path> - Remove a specific file from context
  • /list-files - Show all files currently in context
  • /clear-files - Remove all files from context

File Context Feature

The FastGPT CLI now supports adding local files and directories as context for your queries. This allows you to:

  • Ask questions about code files: Add source files and ask for explanations, reviews, or refactoring suggestions
  • Analyze documents: Include text files, markdown, configuration files, and more
  • Multi-file analysis: Add entire directories to analyze relationships between files
  • Persistent context: File contents remain available throughout your session

Supported File Types

The CLI automatically processes these file extensions:

  • Text: .txt, .md
  • Code: .rs, .py, .js, .ts, .html, .css
  • Config: .json, .xml, .yml, .yaml, .toml
  • Scripts: .sh, .bat

Usage Examples

# Add a single file
/add-file src/main.rs

# Add an entire directory
/add-file src/

# Ask questions about your files
What does the main function in main.rs do?

# List files in context
/list-files

# Remove a specific file
/remove-file src/main.rs

# Clear all file contexts
/clear-files

Configuration

The API key is stored in your system's config directory:

  • Linux: ~/.config/fastgpt/config.toml
  • macOS: ~/Library/Application Support/fastgpt/config.toml
  • Windows: %APPDATA%\fastgpt\config.toml

The config file is created automatically when you set your API key.

Pricing

  • 1.5¢ per query ($15 USD per 1000 queries) with web search enabled
  • Cached responses are free
  • Note: Follow-up questions include conversation context, which may result in longer queries

Dependencies

~14–29MB
~417K SLoC