Use the model you already pay for
Ailoy runs Claude, GPT and Gemini through the CLIs you are already logged into. Switch to an API key, Bedrock, OpenRouter or your own server with one line.
# the CLI is the default
AgentBuilder("anthropic/claude-haiku-5-5")Every way to reach a model, from the same code
from ailoy import AgentBuilder
agent = await AgentBuilder("anthropic/claude-haiku-5-5").build()
async for output in agent.run("Plan my week"):
print(output["message"])AgentBuilder("anthropic/claude-haiku-5-5")AgentBuilder("anthropic")# .env
ANTHROPIC_API_KEY=...
# agent.py
ailoy.set_lang_model_provider("anthropic", "api")
AgentBuilder("anthropic/claude-haiku-5-5")# .env
AWS_BEARER_TOKEN_BEDROCK=...
# agent.py
ailoy.set_lang_model_provider("anthropic", "bedrock")
AgentBuilder("anthropic/claude-haiku-5-5")$ vllm serve deepseek-ai/DeepSeek-V3.2
# agent.py
ailoy.set_lang_model_provider("deepseek-ai", "vllm")
AgentBuilder("deepseek-ai/DeepSeek-V3.2")- 01
Your CLI login, no API key
Claude, GPT and Gemini run through Claude Code, Codex or Gemini CLI by default. If it works in your terminal, your agent works too.
- Needs
- The CLI on PATH, logged in
- Works with
- 02
Swap models with one string
Every model is named org/name. Change the string and the rest of your agent stays the same.
- Needs
- Only what the model’s backend needs
- Works with
- 03
Name the org, get its default
Leave off the model name and the CLI picks the model it would use on its own.
- Needs
- A CLI backend: the CLI decides the model
- Works with
- 04
Or the org’s own API
Set the org’s key and switch the backend to api. DeepSeek, Kimi, GLM and Qwen are on their API already.
- Needs
- The org’s key, such as ANTHROPIC_
API_ KEY or DEEPSEEK_ API_ KEY - Works with
- 05
Bedrock and OpenRouter, same name
Keep the model name you already use. Ailoy finds it in the Bedrock or OpenRouter catalog for you. Bedrock uses your AWS_REGION, else us-east-1.
- Needs
- AWS_
BEARER_ TOKEN_ BEDROCK, or OPENROUTER_ API_ KEY. Bedrock has every org but Google - Works with
- 06
Open models on your own server
Serve DeepSeek, Kimi, GLM or Qwen with vLLM. Ailoy reads the address from VLLM_BASE_URL, http://localhost:8000/v1 by default.
- Needs
- VLLM_
BASE_ URL, and VLLM_ API_ KEY if the server wants one - Works with
Plug in a model Ailoy does not ship
Give set_lang_model_provider a factory instead of a backend name. It returns any object with an infer method, so an in-house model or a test stub works like any other. This one hands back what you type.
class Echo:
async def infer(self, messages, tools, options):
text = messages[-1]["contents"][0]["text"]
return {
"message": {
"role": "assistant",
"contents": [{"type": "text", "text": text}],
},
"finish_reason": {"type": "stop"},
}
ailoy.set_lang_model_provider("mine", lambda org, name: Echo())
agent = await AgentBuilder("mine/echo").build()class Echo {
async infer(messages, tools, options) {
const text = messages[messages.length - 1].contents[0].text
return {
message: {
role: 'assistant',
contents: [{ type: 'text', text }],
},
finish_reason: { type: 'stop' },
}
}
}
setLangModelProvider('mine', (org, name) => new Echo())
const agent = await new AgentBuilder('mine/echo').build()Reply from mine/echo
Hello from my own model
Keep reading
FAQs
Can I use my Claude subscription?
Yes. Claude runs through the logged-in Claude Code CLI by default.
Can vLLM serve Claude or GPT?
No. vLLM covers deepseek-ai, moonshotai, zai-org and Qwen.
Do model options work on every backend?
Yes. thinking_effort and output_schema work the same whether the model runs through a CLI, an API, Bedrock, OpenRouter or vLLM.
Can I add a provider Ailoy does not ship?
Yes. Pass a factory to set_lang_model_provider.
Can I call a model without an agent?
Yes. LangModel.create runs a model on the messages you give it, with no tools and no history. infer returns the whole reply and infer_stream streams it.
Run your first agent
on your own model
Install the package, name a model and run it