Skip to content

Quick start

By default, Claude, GPT and Gemini run through their CLIs, so install and log in to the one for your model: Claude Code (claude), Codex (codex) or Gemini CLI (gemini).

To call the provider’s API instead, set its key in the environment and switch the org to the api backend before building the agent (setLangModelProvider in Node.js):

export ANTHROPIC_API_KEY=... # or OPENAI_API_KEY, GEMINI_API_KEY
ailoy.set_lang_model_provider("anthropic", "api")

Model providers lists every backend: the CLIs, each org’s own API, Amazon Bedrock, OpenRouter and vLLM.

pip install ailoy-py

This gives an agent a Python machine with ./artifacts mounted at /artifacts, and asks it to draw a chart there.

import asyncio
from ailoy import AgentBuilder
from virtx import ConsoleClient, Recipe
async def main() -> None:
console = await (
ConsoleClient.builder()
.image(Recipe("python:3.12-slim-trixie").step("pip install matplotlib"))
.mount("./artifacts", "/artifacts")
.network(True)
.build()
)
agent = await (
# For openai, use "openai/gpt-5.6-luna"
AgentBuilder("anthropic/claude-haiku-5-5")
.instruction("Write what you are asked for into /artifacts.")
.system_tools()
.console(console)
.build()
)
async for output in agent.run("Create a bar chart comparing the populations of European countries and save it to /artifacts/population.png."):
for part in output["message"]["contents"]:
if part["type"] == "text":
print(part["text"])
asyncio.run(main())

agent.run yields one complete message for each step of the tool loop, and run_stream yields token deltas as the model writes them.