Factory Droid is an enterprise-grade AI coding agent that lives in your terminal and handles end-to-end development workflows.Because terminal agents frequently read massive error logs and local .env files, routing Factory Droid through LLM Router is highly recommended. It automatically prunes bloated terminal history to save costs and redacts your local API keys before they are sent to third-party AI providers.
You need to edit Factory Droid’s local settings file.Configuration file location:
macOS/Linux: ~/.factory/settings.json
Windows: %USERPROFILE%\.factory\settings.json
You can configure LLM Router using either the OpenAI format or the Anthropic
format. Remember to replace your_llm_router_key with your actual API Key.
Method A: OpenRouter / OpenAI Protocol (Recommended)
Use this to let LLM Router automatically handle routing, or to specifically request OpenAI/Llama models.
{ "customModels": [ { "displayName": "LLM Router (Auto Fallback)", "model": "openai/gpt-4o", // Or use a tag-based routed model "baseUrl": "https://api.llmrouter.app/v1", "apiKey": "your_llm_router_key", "provider": "generic-chat-completion-api", "maxOutputTokens": 8192 } ]}
Method B: Anthropic Protocol
Use this if you specifically want to route to Claude models using Anthropic’s native formatting.
Terminal-based agents are powerful, but they are incredibly token-hungry and pose unique security risks.
PII Redaction: Droid often reads your local directory to understand context. If it accidentally reads your .env file, LLM Router will automatically redact your database passwords and AWS keys before sending the prompt to OpenAI or Anthropic.
Context Pruning: If Droid runs a build command (npm run build) and it spits out 10,000 lines of terminal logs, LLM Router’s Middle-Out Compression will truncate the bloated middle sections, saving you massive amounts of input token costs.
Resilience: If OpenAI goes down while Droid is refactoring a file, LLM Router will automatically fall back to another provider without breaking your terminal session.