1import asyncio
2from pathlib import Path
3from camelai_run import Agents
4
5async def main():
6 async with Agents() as agents:
7 agent = await agents.upsert(
8 "data-analyst-py",
9 model="openrouter/openai/gpt-6-luna",
10 instructions="You are a data analyst. Analyse attached files with js_exec (fs.readFile), never by eye. "
11 "Write your findings as a short Markdown report to /workspace/out/report.md and present_file it; "
12 "summarise it in your reply without linking to it.",
13 )
14 run = await agent.run("Which regions and products are growing or shrinking? Revenue = units * unit_price.",
15 files=[Path("sales.csv")])
16 print(run.text)
17 for f in run.raw.get("presented", []): # the files the agent handed over with present_file
18 downloaded = await agent.files.download(f["path"])
19 Path(Path(f["path"]).name).write_bytes(downloaded.data)
20 print("saved", Path(f["path"]).name)
21
22asyncio.run(main())
$pip install camelai-run # or: uv run main.py
$export CAMELAI_API_KEY=art_...
$python main.py
Comparing revenue in January and June 2026:
- Growing: All North products; South Widget and Gizmo; all West products.
- Shrinking: South Gadget, down 32.1% (from $1,092 to $741).
saved report.md