Skip to content

AI Query Assistant

rfx ask lets you query your codebase using natural language. An LLM turns your question into rfx query commands, Reflex runs them against your local index, and (optionally) the LLM answers from the results.

rfx ask needs an index (rfx index) and an LLM provider. Configure the provider with:

Terminal window
rfx llm config

This interactive wizard sets up your provider, API key, and model. Configuration is stored in ~/.reflex/config.toml and is shared with Pulse. (rfx ask --configure still works, but is deprecated in favor of rfx llm config.)

Check your current setup:

Terminal window
rfx llm status
Provider: anthropic
Model: claude-3-5-haiku-20241022
API key: configured (sk-ant-a...****)
Providerprovider valueDefault model
OpenAIopenai (default)gpt-4o-mini
Anthropicanthropicclaude-3-5-haiku-20241022
OpenRouteropenrouteranthropic/claude-sonnet-4
OpenAI-compatibleopenai-compatiblenone (you must set a model and base URL)

The OpenAI-compatible provider works with any server that exposes an OpenAI-style /chat/completions endpoint, such as a local model server. The API key is optional for this provider. Without one, requests are sent with no auth header.

You can also edit ~/.reflex/config.toml directly:

[semantic]
provider = "anthropic"
# model = "claude-3-5-haiku-20241022" # optional; overrides the per-provider model below
[credentials]
anthropic_api_key = "sk-ant-..."
anthropic_model = "claude-3-5-haiku-20241022"

The [credentials] section takes <provider>_api_key and <provider>_model for openai, anthropic, openrouter, and openai_compatible. OpenRouter also accepts openrouter_sort (price, speed, or throughput). For an OpenAI-compatible server:

[semantic]
provider = "openai-compatible"
[credentials]
openai_compatible_base_url = "http://localhost:1234/v1"
openai_compatible_model = "qwen2.5-coder"
# openai_compatible_api_key = "..." # optional

For CI or headless use, you can configure everything from the environment:

VariablePurpose
REFLEX_PROVIDEROverride the provider
REFLEX_MODELOverride the model
REFLEX_AI_API_KEYAPI key for whichever provider is selected
OPENAI_API_KEY, ANTHROPIC_API_KEY, OPENROUTER_API_KEY, OPENAI_COMPATIBLE_API_KEYProvider-specific API keys
OPENAI_COMPATIBLE_BASE_URL, OPENAI_COMPATIBLE_MODELFallback base URL and model for openai-compatible
REFLEX_LLM_TIMEOUT_SECONDSLLM request timeout (default: 30)

API keys are looked up in this order: ~/.reflex/config.toml, then REFLEX_AI_API_KEY, then the provider-specific variable.

Start a conversation about your code:

Terminal window
rfx ask

With no question, rfx ask opens an interactive chat TUI (same as rfx ask -i) with full conversation history. The assistant searches your codebase to ground its answers.

>> How does authentication work in this project?
>> What files would I need to change to add OAuth support?
>> Show me the error handling pattern used in the API handlers.

Slash commands inside the chat:

CommandAction
/clearClear conversation history (also Ctrl+L)
/compactSummarize old messages to save tokens (also Ctrl+K)
/model [provider] [model]Show or change provider/model
/helpShow help

Ctrl+U clears the input, Up/Down and PgUp/PgDn scroll, and Ctrl+C quits.

Ask a single question from the command line:

Terminal window
rfx ask "What does the handleRequest function do?"

By default, one-shot mode runs the generated queries right away. It prints them under a Generated Queries: heading, followed by the raw matches grouped by file (Found N total results across M files:).

Add --answer to get a conversational answer based on the search results, instead of the raw matches:

Terminal window
rfx ask "What database does this project use?" --answer

Enables multi-step reasoning. The assistant decides whether it needs more context, gathers it with tools, generates queries, runs them, evaluates the results, and refines them if needed:

Terminal window
rfx ask "How would I add a new API endpoint?" --agentic --answer
FlagDescription
--max-iterations <N>Maximum refinement iterations (default: 2)
--no-evalSkip result evaluation
--show-reasoningShow LLM reasoning at each phase
--verboseShow tool results and details
--quietSuppress progress output
Terminal window
rfx ask "Find all TODO comments" --execute

With --execute, rfx ask shows the generated queries and asks Run these queries against your codebase? [y/N] before running them. Anything but y aborts.

Terminal window
rfx ask "Find all TODO comments" --json --pretty

Returns the generated queries, the results, the total count, and (with --answer) the answer as JSON, without progress output.

Override the configured provider for a single query:

Terminal window
rfx ask "Explain the auth flow" --provider anthropic
rfx ask "Explain the auth flow" --provider openai-compatible

If your project has a REFLEX.md file in the root, rfx ask automatically includes it as context. This helps the assistant understand your project’s architecture, conventions, and terminology. See Configuration for details.

You can also inject extra context for a single question, for example from rfx context:

Terminal window
rfx ask "find auth" --additional-context "$(rfx context --framework)"

Use --debug to print the full LLM prompts.