Loading
Skip to content
RedRouterRedRouter
Sign inBook call ↗

r2ai with RedRouter

r2ai is radare2's language-model plugin; this page configures RedRouter and asks it to explain one function in a lab binary.

Recipe, not run by RedRouter.

Setup

Install radare2 with r2pm and a C compiler. Use an authorized lab binary with a main function. These commands install r2ai and open the binary for analysis.

{
r2pm -Uci r2ai
printf 'RedRouter API key: '
read -r -s REDROUTER_API_KEY
printf '\n'
printf 'Path to your lab binary: '
read -r SAMPLE
OPENAI_API_KEY="$REDROUTER_API_KEY" r2 \
  -c 'r2ai -e api=openai' \
  -c 'r2ai -e baseurl=https://redrouter.org/v1' \
  -c 'r2ai -e model=red-cyber-1' \
  -c 'r2ai -e max_tokens=8192' \
  -c 'r2ai -e auto.yolo=false' \
  -c aa -c 's main' -c 'r2ai -q explain' "$SAMPLE"
}
r2pm -Uci r2ai
$REDROUTER_API_KEY = [System.Net.NetworkCredential]::new('', (Read-Host 'RedRouter API key' -AsSecureString)).Password
$SAMPLE = Read-Host 'Path to your lab binary'
$previousKey = $env:OPENAI_API_KEY
try {
  $env:OPENAI_API_KEY = $REDROUTER_API_KEY
  r2 -c 'r2ai -e api=openai' `
    -c 'r2ai -e baseurl=https://redrouter.org/v1' `
    -c 'r2ai -e model=red-cyber-1' `
    -c 'r2ai -e max_tokens=8192' `
    -c 'r2ai -e auto.yolo=false' `
    -c aa -c 's main' -c 'r2ai -q explain' $SAMPLE
} finally {
  $env:OPENAI_API_KEY = $previousKey
}

Free key check

GET /v1/key checks your key and its restrictions without generating tokens or spending inference credit. Run it before the analysis request.

{
printf 'RedRouter API key: '
read -r -s REDROUTER_API_KEY
printf '\n'
curl --fail-with-body -sS https://redrouter.org/v1/key \
  -H "Authorization: Bearer $REDROUTER_API_KEY"
}
$REDROUTER_API_KEY = [System.Net.NetworkCredential]::new('', (Read-Host 'RedRouter API key' -AsSecureString)).Password
Invoke-RestMethod -Method Get -Uri 'https://redrouter.org/v1/key' `
  -Headers @{ Authorization = "Bearer $REDROUTER_API_KEY" }

Known limits

  • The source recipe covers r2ai 1.5.4; the package manager may install a newer version.
  • Auto mode requires tool calling. Keep auto.yolo=false so proposed commands need approval.
  • Disassembly and strings enter the model context. Send only material you may share and verify claims against radare2's output.
  • Large contexts can exceed command-line limits when using curl; r2ai's http.use_files=true setting addresses that case.

Read the full r2ai setup guide.

↑ ↓ to select · Enter to open · Esc to close