Skip to main content

On a real model

The same writer → reviewer flow, run on a real model instead of the dry harness.

You need
  • the afe-first-flow folder from Your first flow.
  • an OpenRouter API key in the environment, OPENROUTER_API_KEY.
At the end you have
  • the same ticket, run on a real model, with its tokens and its cost in the ledger.

Steps​

  1. Get a key at openrouter.ai and export it:

    export OPENROUTER_API_KEY=sk-or-...
  2. Replace config/models.yaml with a cheap real model:

    config/models.yaml
    # yaml-language-server: $schema=../../../../schemas/afe.dev-v1alpha1.json
    apiVersion: afe.dev/v1alpha1
    kind: Model
    metadata:
    name: cheap
    annotations:
    afe.dev/description: A cheap model for drafts and reviews
    spec:
    provider: openrouter
    model: deepseek/deepseek-v4-flash
    apiKeyEnv: OPENROUTER_API_KEY
  3. Run the flow without --dry, so the harness calls the model:

    afe run writer-reviewer -i request.yaml -c config/ --local
  4. Answer the approval at the prompt: type approve.

  5. The ticket ends with T-0001 ticket_done. The model's tokens and cost are recorded in the ticket's ledger. Read Budgets and loop guards to see where.

Troubleshooting​

Symptom: the run prints an error event and exits with code 1, with a 401 status in the message. Cause: OPENROUTER_API_KEY is missing, misspelled, or was not exported in this shell. Fix: export it again and re-run. afe never reads a key from a file, only from the environment.

Symptom: the run takes much longer than the dry harness, then fails with a 429 status. Cause: the model is rate-limited on your OpenRouter account. Fix: wait, or switch config/models.yaml to another model. afe retries a 429 three times with a backoff before it gives up.

See also​