> ## Documentation Index
> Fetch the complete documentation index at: https://runinfra.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Aider

> Connect Aider to RunInfra with its native OpenAI-compatible settings.

Use RunInfra models in Aider through its native OpenAI-compatible settings.

Support level: `ready`. Connect supports automatic setup.

## Connect Aider

Have Aider installed, a workspace API key, and available RunInfra credits.

```bash theme={"dark"}
npx @runinfra/connect aider
```

In an interactive terminal, Connect starts login if needed. Review and approve the proposed changes. Connect saves a snapshot, writes the settings and model metadata, and makes a real Chat Completions request that uses credits.

To choose a model during setup:

```bash theme={"dark"}
npx @runinfra/connect aider on --model deepseek-v4-flash
```

See [Connect](/docs/tools-sdks/connect) for status, diagnostics, and key replacement.

## What Connect writes

| Platform        | Configuration                   | Model metadata                             |
| --------------- | ------------------------------- | ------------------------------------------ |
| macOS and Linux | `~/.aider.conf.yml`             | `~/.aider.model.metadata.json`             |
| Windows         | `%USERPROFILE%\.aider.conf.yml` | `%USERPROFILE%\.aider.model.metadata.json` |

Both files live in your home directory. Connect does not move them to an application-data or XDG directory.

The YAML sets `model` to `openai/<slug>` and `openai-api-base` to `https://api.runinfra.ai/v1`. The metadata contains catalog token limits under each `openai/<slug>` entry: `max_input_tokens`, `max_output_tokens`, and `max_tokens`. Here, `max_tokens` is the output limit.

The catalog supplies token limits, not cost data. Existing cost fields are preserved but are not verified by this catalog. Unknown cost warnings may remain. Connect does not add tool or reasoning capability fields to the metadata.

### Key placement

The default literal mode writes your key to `openai-api-key` in `.aider.conf.yml`. Helper mode removes an owned saved literal and requires Aider's native environment variable:

```bash theme={"dark"}
npx @runinfra/connect aider on --key-source helper
```

Set `RUNINFRA_API_KEY` securely, then run the handoff in the environment that launches Aider:

<Tabs>
  <Tab title="macOS and Linux">
    ```bash theme={"dark"}
    export AIDER_OPENAI_API_KEY="$RUNINFRA_API_KEY"
    ```
  </Tab>

  <Tab title="PowerShell">
    ```powershell theme={"dark"}
    $env:AIDER_OPENAI_API_KEY = $env:RUNINFRA_API_KEY
    ```
  </Tab>
</Tabs>

For GUI apps and background services, set `RUNINFRA_API_KEY` securely in their launch environment and restart them with the native handoff above. On Windows, use the user environment and also set `AIDER_OPENAI_API_KEY` there before restarting the launcher. GUI and Start menu launches do not inherit a terminal-only assignment. Connect does not write YAML environment interpolation.

## Verify

Aider 0.86.2 completed a verified round trip through RunInfra using the Connect-written `.aider.conf.yml` and `.aider.model.metadata.json`.

This manual verification template is docs-only. Connect does not execute it:

```bash theme={"dark"}
aider --chat-mode ask --no-git --no-auto-commits --no-analytics --no-check-update --no-show-release-notes --no-show-model-warnings --message "Reply exactly RUNINFRA_OK. Do not use tools."
```

Use an authorized isolated scratch environment. The prompt is not a tool permission boundary, and a reply alone does not prove the request destination. Confirm the selected provider and destination after restart.

<Warning>
  Aider loads home, repository, current-directory, and selected dotenv files with `override=True`. Those files can replace the initial shell environment. The default git-root `.env` is loaded last after deduplication and can override a current-directory `.env` when you launch from a subdirectory. An explicitly selected dotenv file can change that ordering.

  Dotenv files and Aider `set-env` settings can introduce `OPENAI_BASE_URL` overrides. A plain `OPENAI_API_KEY` does not override a saved YAML `openai-api-key`.
</Warning>

## Restart

Restart Aider in a new Aider process to load the selected model and credentials.

## Troubleshooting

| Symptom                                 | What to check                                                                                                                                                                                                                                                                        |
| --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Aider uses another model or destination | Repository and current-directory `.aider.conf.yml` and metadata files, explicit command options, and `AIDER_` environment options can override the home files.                                                                                                                       |
| Connect refuses an environment override | Review `OPENAI_BASE_URL`, `AIDER_MODEL`, `AIDER_OPENAI_API_BASE`, `AIDER_OPENAI_API_KEY`, and `AIDER_MODEL_METADATA_FILE`. Any defined value that differs from the planned setting, including an empty or whitespace value, is refused. Windows checks case-insensitive aliases too. |
| Connect refuses the existing YAML       | Review `model-metadata-file` and any saved OpenAI credential. Connect does not replace a foreign credential or guess unsupported YAML values.                                                                                                                                        |
| The key differs from the one you set    | Check dotenv precedence and the actual launch environment, including a separate GUI launcher.                                                                                                                                                                                        |

The planning check cannot prevent later project, command-line, dotenv, model `extra_params`, or `set-env` changes from redirecting Aider. Confirm the actual destination after restart.

## Revert

```bash theme={"dark"}
npx @runinfra/connect aider off
```

With intact state and snapshots, `off` restores the original bytes from before the first `on` in the active connection. It removes managed files that did not exist then. Later `on` calls and key rotations keep that restore point.

If either managed file changed after setup, Connect refuses to overwrite it. Back up and review the edits before choosing to discard them:

```bash theme={"dark"}
npx @runinfra/connect aider off --force
```

Connect saves the current contents in a recovery snapshot and prints its id before restoring the origin. Keep the snapshots. If the origin snapshot is missing, cleanup is not a promise of original-byte restoration; see [Connect recovery](/docs/tools-sdks/connect#what-off-restores).

Restore any manual `AIDER_OPENAI_API_KEY` environment changes yourself. File restoration does not change project overrides or dotenv files outside the managed pair.

## Related

<Columns cols={3}>
  <Card title="Connect" icon="plug" href="/docs/tools-sdks/connect">
    Set up, inspect, and restore your coding agent.
  </Card>

  <Card title="Chat completions" icon="braces" href="/docs/api-reference/chat-completions">
    Read the request contract.
  </Card>

  <Card title="Models" icon="list" href="/docs/api-reference/models">
    Find model ids and context windows.
  </Card>
</Columns>
