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:
rfx llm configThis 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:
rfx llm statusProvider: anthropicModel: claude-3-5-haiku-20241022API key: configured (sk-ant-a...****)Supported providers
Section titled “Supported providers”| Provider | provider value | Default model |
|---|---|---|
| OpenAI | openai (default) | gpt-4o-mini |
| Anthropic | anthropic | claude-3-5-haiku-20241022 |
| OpenRouter | openrouter | anthropic/claude-sonnet-4 |
| OpenAI-compatible | openai-compatible | none (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.
Manual configuration
Section titled “Manual configuration”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 = "..." # optionalEnvironment variables
Section titled “Environment variables”For CI or headless use, you can configure everything from the environment:
| Variable | Purpose |
|---|---|
REFLEX_PROVIDER | Override the provider |
REFLEX_MODEL | Override the model |
REFLEX_AI_API_KEY | API key for whichever provider is selected |
OPENAI_API_KEY, ANTHROPIC_API_KEY, OPENROUTER_API_KEY, OPENAI_COMPATIBLE_API_KEY | Provider-specific API keys |
OPENAI_COMPATIBLE_BASE_URL, OPENAI_COMPATIBLE_MODEL | Fallback base URL and model for openai-compatible |
REFLEX_LLM_TIMEOUT_SECONDS | LLM 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.
Interactive mode
Section titled “Interactive mode”Start a conversation about your code:
rfx askWith 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:
| Command | Action |
|---|---|
/clear | Clear conversation history (also Ctrl+L) |
/compact | Summarize old messages to save tokens (also Ctrl+K) |
/model [provider] [model] | Show or change provider/model |
/help | Show help |
Ctrl+U clears the input, Up/Down and PgUp/PgDn scroll, and Ctrl+C quits.
One-shot mode
Section titled “One-shot mode”Ask a single question from the command line:
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:).
Answer mode
Section titled “Answer mode”Add --answer to get a conversational answer based on the search results, instead of the raw matches:
rfx ask "What database does this project use?" --answerAgentic mode
Section titled “Agentic mode”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:
rfx ask "How would I add a new API endpoint?" --agentic --answer| Flag | Description |
|---|---|
--max-iterations <N> | Maximum refinement iterations (default: 2) |
--no-eval | Skip result evaluation |
--show-reasoning | Show LLM reasoning at each phase |
--verbose | Show tool results and details |
--quiet | Suppress progress output |
Confirm before running
Section titled “Confirm before running”rfx ask "Find all TODO comments" --executeWith --execute, rfx ask shows the generated queries and asks Run these queries against your codebase? [y/N] before running them. Anything but y aborts.
JSON output
Section titled “JSON output”rfx ask "Find all TODO comments" --json --prettyReturns the generated queries, the results, the total count, and (with --answer) the answer as JSON, without progress output.
Provider selection
Section titled “Provider selection”Override the configured provider for a single query:
rfx ask "Explain the auth flow" --provider anthropicrfx ask "Explain the auth flow" --provider openai-compatibleProject context
Section titled “Project context”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:
rfx ask "find auth" --additional-context "$(rfx context --framework)"Use --debug to print the full LLM prompts.
Next steps
Section titled “Next steps”- AI Integration — MCP server and JSON output for agent workflows
- Configuration — project configuration
- CLI Commands — full
rfx askreference