# Installation

https://ailoy.co/docs/guides/installation/

Install Ailoy and virtx, and set up a way for the agent's model to run.

An agent needs Ailoy and virtx's packages, a way for its model to run, and a machine that can run its sandbox.

## Requirements

- Python 3.11 or later, Node.js 22 or later, or Rust 1.95 or later.
- For the machine that runs the sandbox, which is yours unless the virtx server runs elsewhere, depending on its OS:
  - **Linux:** KVM, with `/dev/kvm` open to your user and virtualization enabled in the firmware. Most kernels have KVM built in.
  - **macOS:** Apple silicon.
  - **Windows:** Windows 11 or later, with the Windows Hypervisor Platform turned on (below).

### Windows

The Windows Hypervisor Platform is off by default. With virtualization enabled in the firmware, turn it on from an administrator PowerShell, then restart:

```powershell
Enable-WindowsOptionalFeature -Online -FeatureName HypervisorPlatform
```

## Packages

**Python**

```sh
pip install ailoy-py
```

This installs `virtx` too, the package your code makes sandboxes with.

**Node.js**

```sh
npm install @brekkylab/ailoy
```

This installs `@brekkylab/virtx` too, the package your code makes sandboxes with. With pnpm, which keeps a package from importing what it did not list, add `@brekkylab/virtx` yourself.

**Rust**

```sh
cargo add ailoy virtx futures anyhow tokio --features tokio/macros,tokio/rt-multi-thread
```

`virtx` is the crate your code makes sandboxes with. Cargo lets your code use only the crates it lists, so add it beside `ailoy`. `tokio`, `futures` and `anyhow` are what the examples on these pages run on.

You don't install virtx's server separately: the first `Client.spawn()` (`Client::spawn_virtx` in Rust) downloads it into virtx's cache.

## A model to run

### With a CLI login (default)

Claude, GPT and Gemini run through their CLIs by default, so the examples need no key. Install the one for your model and log in:

| CLI | Log in | Check |
| --- | --- | --- |
| [Claude Code](https://docs.anthropic.com/en/docs/claude-code) | `claude auth login` | `claude auth status` |
| [Codex](https://github.com/openai/codex) | `codex login` | `codex login status` |
| [Gemini CLI](https://github.com/google-gemini/gemini-cli) | Run `gemini` and sign in | |

Without a login, the first turn fails with the CLI's own message, such as Claude Code's "Not logged in".

### With an API key

Set the key, and switch the org to the `api` backend before building the agent:

```sh
export ANTHROPIC_API_KEY=...   # or OPENAI_API_KEY, GEMINI_API_KEY
```

**Python**

```python
import ailoy

ailoy.set_lang_model_provider("anthropic", "api")
```

**Node.js**

```js
const { setLangModelProvider } = require('@brekkylab/ailoy')

setLangModelProvider('anthropic', 'api')
```

**Rust**

```rust
ailoy::model::set_lang_model_provider("anthropic", ailoy::model::Backend::Api);
```

[Model providers](https://ailoy.co/docs/guides/model-providers/) lists every backend: the CLIs, each org’s own API, Amazon Bedrock, OpenRouter and a server you run yourself (vLLM, llama-server, Ollama, LM Studio).

## Troubleshooting

| What you see | Cause | Fix |
| --- | --- | --- |
| `boot_failed`, when a sandbox is made | This machine can't boot a VM. | **Linux:** open `/dev/kvm` to your user with `sudo usermod -aG kvm $USER`, then log in again. **Windows:** turn on the [Hypervisor Platform](#windows). **Any OS:** turn on virtualization (Intel VT-x, AMD-V) in the firmware. Set `KRUN_LOG=debug` to see the hypervisor's own messages after `last logged`. |
| `no virtx-stdio release … for macos-x86_64` | virtx runs on Apple silicon only, not on an Intel Mac. | Run the virtx server on another machine and connect to it ([Hello world](https://virtx.sh/docs/hello-world/)). |
| `fetching …/virtx/releases/…`, on the first `Client.spawn()` | The server's download failed. | Check the network or proxy, set `VIRTX_DIST_URL` to a mirror, or download the server yourself and point `VIRTX_STDIO` at it ([Environment variables](https://virtx.sh/docs/reference/api/#environment-variables)). |
| `… does not match its SHA256SUMS` | The download came back changed, as a proxy may do. | Try again, or set `VIRTX_STDIO` as above. |
| An error from the model's CLI or API on the first turn | It comes from the model's backend, not the sandbox. | See [Model providers](https://ailoy.co/docs/guides/model-providers/#troubleshooting). |

## Next

- [How an agent works](https://ailoy.co/docs/concepts/): where each part runs and what happens in a turn.
- [Defining an agent](https://ailoy.co/docs/guides/agents/): everything an `AgentBuilder` can give an agent.
