IFX guide
Check LLM costs on pull requests with GitHub Actions
Compare a proposed merge with its base branch. IFX estimates both at the same set of API prices and can fail the check if the change introduces a known retired model.
1. Add the workflow
Save this as .github/workflows/ifx-cost.yml. It scans source on the runner. It does not run your app, send prompts to a model, or need an LLM API key.
name: IFX LLM cost check
on:
pull_request:
permissions:
contents: read
jobs:
ifx-cost:
runs-on: ubuntu-latest
steps:
- name: Checkout proposed merge
uses: actions/checkout@v4
with:
path: proposed
persist-credentials: false
- name: Checkout base
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.sha }}
path: base
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Compare LLM calls
run: |
result=0
npx --yes ifx-optimizer@0.6.2 diff ./base ./proposed --fail-on retired --markdown --out ifx-report.md || result=$?
if [ -f ifx-report.md ]; then
cat ifx-report.md >> "$GITHUB_STEP_SUMMARY"
fi
exit "$result"Read the IFX LLM cost check run summary. The example pins the IFX CLI version so that it does not change until you update it.
2. Decide when the check should fail
Remove --fail-on retired to start in reporting mode. To also fail on a cost increase, add --calls 50000 --max-increase 100 to diff.
That caps the modeled increase at $100 per month assuming 50,000 calls monthly at each call site. It is not a spending limit on your provider account. To prevent merging on failure, require the ifx-cost status check in your repository settings.
3. Validate what the check found
A code scan can miss models selected at runtime or estimate token lengths incorrectly. Actual spend depends on usage, caching, batching, retries and what your provider charges. Check high-impact changes against billing data and representative task samples.
Check the model shutdown calendar or see what IFX Optimizer scans.