fastgpt

Crates.iofastgpt
lib.rsfastgpt
version0.2.2
created_at2025-05-28 15:42:11.119955+00
updated_at2025-07-31 13:13:27.705004+00
descriptionA CLI client for Kagi's FastGPT API
homepagehttps://github.com/0xgingi/kagi-fastgpt-cli
repositoryhttps://github.com/0xgingi/kagi-fastgpt-cli
max_upload_size
id1692972
size103,831
0xGingi (0xGingi)

documentation

https://github.com/0xgingi/kagi-fastgpt-cli

README

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
Commit count: 15

cargo fmt