Model Strategy
4-tier model hierarchy, AWS Bedrock routing, Anthropic fallback, and circuit breaker
4-Tier Model Strategy
Krawl uses a tiered model approach — cheaper/faster models for high-volume tasks, premium models for intelligence-critical work.
| Tier | Model | Tasks | Call Volume |
|---|---|---|---|
| Tier 1 (budget) | bedrock/us.anthropic.claude-haiku-4-5-20251001-v1:0 | Query generation, URL ranking, perspective discovery, memory extraction | High (10–30+ per session) |
| Tier 2 (mid) | bedrock/us.anthropic.claude-sonnet-4-6 | Learning extraction, flat agent loop | Moderate (5–15 per session) |
| Tier 3 (quality) | bedrock/us.anthropic.claude-sonnet-4-6 | Planning, gap analysis, review passes | Low (2–5 per session) |
| Tier 4 (apex) | bedrock/us.anthropic.claude-opus-4-7 | Synthesis, revision passes | 1 call per session |
| xAI | grok-4.20-0309-non-reasoning | X/Twitter search only | Per X search |
Why This Approach
- Cost control — Haiku handles 60%+ of LLM calls at ~10x lower cost than Opus
- Quality where it matters — Opus only fires once for the final synthesis, producing the best possible report
- Speed — Haiku is fast enough for real-time query generation during recursive search
Provider Routing
Primary: AWS Bedrock
All Claude models route through AWS Bedrock via litellm. The us. prefix uses cross-region inference profiles — AWS automatically routes to the least loaded region.
bedrock/us.anthropic.claude-haiku-4-5-20251001-v1:0
bedrock/us.anthropic.claude-sonnet-4-6
bedrock/us.anthropic.claude-opus-4-7Required env vars:
AWS_BEDROCK_ACCESS_KEY_IDAWS_BEDROCK_SECRET_ACCESS_KEYAWS_BEDROCK_REGION(default:us-east-1)
Fallback: Anthropic Direct API
If any Bedrock call fails, Krawl automatically retries with the equivalent Anthropic direct API model:
| Bedrock Model | Fallback Model |
|---|---|
bedrock/us.anthropic.claude-sonnet-4-6 | anthropic/claude-sonnet-4-6 |
bedrock/us.anthropic.claude-opus-4-7 | anthropic/claude-opus-4-7 |
bedrock/us.anthropic.claude-haiku-4-5-20251001-v1:0 | anthropic/claude-haiku-4-5-20251001 |
Requires ANTHROPIC_API_KEY to be set.
xAI (X/Twitter Search)
X/Twitter search uses xAI's Grok model directly — not through litellm or Bedrock. The API call goes straight to https://api.x.ai/v1.
Model: grok-4.20-0309-non-reasoning
Requires XAI_API_KEY.
Circuit Breaker
Krawl implements a circuit breaker pattern for Bedrock:
- Each Bedrock failure increments a counter
- After 3 consecutive failures, the circuit opens
- While open (5 minutes), all calls go directly to Anthropic fallback — skipping Bedrock entirely
- On the next successful Bedrock call, the circuit resets
Normal: Bedrock → (success) → reset counter
Bedrock → (fail) → counter++ → try Anthropic fallback
Bedrock → (fail) → counter++ → try Anthropic fallback
Bedrock → (fail) → counter=3 → CIRCUIT OPEN
Open: Skip Bedrock → Anthropic direct (for 5 minutes)
After 5min: Try Bedrock again
Bedrock → (success) → CIRCUIT RESET → counter=0Constants:
_CIRCUIT_FAIL_THRESHOLD = 3_CIRCUIT_OPEN_SECONDS = 300(5 minutes)
Model Override
You can override any model at the request level:
{
"query": "...",
"model": "anthropic/claude-sonnet-4-6"
}This overrides all phases (planning, research, synthesis). Useful for testing or when you want to force a specific provider.
You can also override via env vars:
MODEL_PLANNING=anthropic/claude-sonnet-4-6
MODEL_RESEARCH=anthropic/claude-sonnet-4-6
MODEL_SYNTHESIS=anthropic/claude-opus-4-7
MODEL_QUERY_GEN=anthropic/claude-haiku-4-5-20251001Opus 4.7 Notes
- Opus 4.7 does not support the
temperatureparameter — Krawl automatically omits it - Used only for synthesis (1 call per session) due to cost
- Produces the highest quality reports with better citation handling