Ask Command

Ask Command🔗

The ask command provides single-turn question answering without maintaining a session.

Usage🔗

localgpt ask [OPTIONS] <QUESTION>

Options🔗

OptionDescription
-m, --model <MODEL>Override the default model
-f, --format <FORMAT>Output format: text (default) or json
--no-memoryDisable memory context loading
--no-toolsDisable tool execution

Examples🔗

Basic Question🔗

localgpt ask "What is the capital of France?"
# Paris is the capital of France.

JSON Output🔗

localgpt ask --format json "List 3 programming languages"

Output:

{
  "response": "1. Python\n2. JavaScript\n3. Rust",
  "model": "gpt-4",
  "tokens": {
    "prompt": 45,
    "completion": 12
  }
}

Using a Specific Model🔗

localgpt ask -m claude-3-sonnet "Explain quantum computing briefly"

Piping Input🔗

echo "Summarize this" | localgpt ask -
cat error.log | localgpt ask "What's wrong with this log?"

With Memory Context🔗

By default, ask loads relevant memory context:

# This will include relevant memory about your projects
localgpt ask "What was I working on last week?"

Disable memory loading for faster responses:

localgpt ask --no-memory "What is 2+2?"

Use Cases🔗

The ask command is ideal for:

  • Quick questions - Get an answer without starting a session
  • Scripting - Use in shell scripts with JSON output
  • Piping - Process output from other commands
  • One-off tasks - Translation, summarization, etc.

Comparison with Chat🔗

Featureaskchat
Multi-turnNoYes
Session persistenceNoYes
Memory contextOptionalAlways
Tool executionOptionalAlways
InteractiveNoYes

Exit Codes🔗

CodeMeaning
0Success
1Error (API, config, etc.)