Claude AI Agent: Run Claude in Your Own Self-Hosted Agent
A Claude AI agent is an AI agent that uses a Claude model as its reasoning engine and adds memory, tools and a way to run without you typing. POLYROB is an open-source agent you host yourself: you give it an Anthropic API key or sign in with a Claude plan, and Claude becomes the model behind your chats, goals and scheduled jobs.
The phrase covers several different things, so this guide separates them, then shows the setup step by step. Every POLYROB fact below comes from the public repository at release v1.7.6, and the sources are listed at the end.
What does “Claude AI agent” mean?
Three things get the same name.
- A coding agent from Anthropic. Claude Code is described by Anthropic as “an agentic coding tool that reads your codebase, edits files, runs commands, and integrates with your development tools” (Claude Code overview, fetched 2026-11-10).
- An agent you build yourself on the Claude API. You write the loop, the tools and the memory.
- A self-hosted agent that uses Claude as its model. The loop, tools, memory, chat apps and limits already exist, and you choose Claude as the model. This is the case POLYROB covers.
If you want a coding assistant inside your repository, the first kind is built for that. If you want an agent that remembers you, answers in Telegram or Slack, and works on a goal while you are away, the third kind is the closer fit. They are not exclusive: POLYROB can also reach Claude Desktop, covered below.
How do you connect Claude to POLYROB?
There are two ways in. One uses an API key. The other uses a Claude plan sign-in, and it carries a warning you should read first.
Option 1: an Anthropic API key
Install POLYROB, then store the key. The command prompts for it with hidden input.
curl -fsSL https://polyrob.dev/install.sh | bash
polyrob config set ANTHROPIC_API_KEY
polyrob model list
polyrob model list prints every provider with whether a key is present, its models and the default. The key lives in ~/.polyrob/.env. For scripted setups, polyrob setup --no-prompt --anthropic-key <key> does the same without prompts. The Anthropic SDK is an optional extra named anthropic in pyproject.toml.
Option 2: a Claude Pro or Max sign-in
Claude plans issue no API key, so POLYROB signs in instead. It is off by default everywhere.
polyrob config set LLM_OAUTH_ENABLED true
polyrob auth add anthropic-oauth
polyrob auth status
Read this before you connect. Anthropic publishes no OAuth client id for third-party apps, so connecting authenticates POLYROB as Claude Code’s own client. The POLYROB docs call it a real terms-of-service exposure that lands on your account, and polyrob auth add says so and asks before it acts. If that risk is not acceptable, use an API key. The subscription row records no per-token cost, and the model it lists is claude-sonnet-4-5. It is also left out of automatic failover.
How do you pick which Claude model it uses?
With several keys set, POLYROB picks the first provider with a usable key in this order: openrouter, anthropic, openai, gemini, nvidia, deepseek. Adding a new key can change the default, so pin Claude:
polyrob model set-default anthropic claude-sonnet-5
polyrob run -p anthropic -m claude-sonnet-5 "summarize https://example.com"
The pinned model serves chat, scheduled jobs and goals on that provider. In chat, /model <name> switches it live. The model catalog in modules/llm/model_catalog.py lists these Anthropic ids:
| Model id | Context window |
|---|---|
claude-fable-5-1 | 1,000,000 tokens |
claude-fable-5 | 1,000,000 tokens |
claude-opus-5 | 1,000,000 tokens |
claude-opus-4-8 | 1,000,000 tokens |
claude-sonnet-5 | 1,000,000 tokens |
claude-sonnet-4-6 | 1,000,000 tokens |
claude-haiku-4-5 | 200,000 tokens |
Older 4.5 and 4.1 ids are also registered, and older Claude 3.x names map onto the 4.5 models. Provider catalogs change often, so check Anthropic’s own model page for what your key can call today.
Two settings tune how Claude is called:
- Prompt caching is on by default.
ANTHROPIC_CACHE_TTLtakesauto,5mor1h. Withauto, an interactive chat gets a 1-hour cache window and an autonomous cron or goal run gets 5 minutes.LLM_PROMPT_CACHE=falseturns it off.polyrob doctorand/contextshow the cache effect on cost. - Extended thinking is off by default.
THINKING_CONFIG_ENABLED=trueturns on per-provider reasoning settings, and the docs note it changes cost and latency.
What can a Claude AI agent do once it is running?
The model is one part. The rest is what POLYROB adds around it.
- Remembers you. Cross-session memory is on by default, using keyword recall over SQLite, with an optional local vector index. See the guide to a personal AI agent for the memory, persona and SOUL details.
- Lives in your chats. Terminal, web console and eight chat surfaces: Telegram, email, WhatsApp, Discord, Slack, Signal, Feishu/Lark and DingTalk.
- Works on goals and schedules. Goals and jobs live in SQLite and survive restarts, once you switch autonomy on. The autonomous AI agent guide explains the levels.
- Uses tools. Web fetch, a Playwright browser, files, git and GitHub, a persistent shell, an MCP client and sub-agents. Code execution is off by default.
- Loads skills. Reusable procedures it loads on demand, covered in agent skills.
On a Claude model that supports deferred tools, POLYROB declares tools it loads mid-session as deferred. This is on by default through ANTHROPIC_DEFERRED_TOOLS, and it keeps the cached prompt prefix intact. If the API declines, POLYROB falls back to the plain tool list once and says so in the log.
Can it work with Claude Desktop and CLAUDE.md?
Yes, in two small ways.
- Set
MCP_SERVE_ENABLED=trueand POLYROB mounts an inbound MCP server atPOST /mcp, which Claude Desktop or Cursor can use. It is off by default. - When run from a repository with
POLYROB_LOCALset, the agent loads one context file:polyrob.md, thenPOLYROB.md,AGENTS.md,CLAUDE.md,.cursorrules. The highest precedence wins and files are never joined. Apolyrob.mdsteers POLYROB without touching the file your other tools read.
How do you keep a Claude agent from running up a bill?
Claude is a metered API, so limits matter. POLYROB’s are mechanisms you can read:
- Each autonomous run stops at a step cap and a spend cap. By default that is 150 steps and $2.00 of provider spend, and the run says why it stopped. This is per run, not a daily or monthly budget, and the spend check can fail open if the probe errors.
RUN_BUDGET_USD=<dollars>sets a per-session ceiling on real provider cost for interactive use./pausestops autonomous work and survives a restart.- On a billing, quota or rate-limit error, POLYROB fails over to the next usable provider. Pin one provider if you do not want that.
To cap Claude spend further, set the budget low first and raise it after you have watched a few runs.
Where does POLYROB fall short for this?
- Claude plan sign-in is a risk. It works by presenting as Claude Code’s client. Use an API key if you cannot accept account risk.
- It is not Claude-only. Claude is one of six built-in providers, so it is not a Claude-first product.
- You operate it. You install, update and watch cost. Linux, macOS and WSL2 only, with no native desktop or phone apps.
- Fewer chat apps than some agents. Eight surfaces. A dated table with other projects is in the POLYROB comparison.
- A young project with a small community. Wallet code is unaudited and is an opt-in extra.
Claude AI agent questions
Is Claude AI agent the same as Claude Code?
No. Claude Code is Anthropic’s agentic coding tool for your repository. A Claude AI agent in the sense used here is a separate agent that calls a Claude model, such as POLYROB, with memory, chat apps and scheduled work around it.
Do I need an Anthropic API key?
You need either an API key or a Claude Pro or Max sign-in. The key is the cleaner route. The sign-in is off until you set LLM_OAUTH_ENABLED, and it carries the terms-of-service risk described above.
Can I run it without Claude?
Yes. OpenAI, Gemini, DeepSeek, OpenRouter and NVIDIA NIM are built in, and any OpenAI- or Anthropic-compatible endpoint, including a local Ollama, can be declared in ~/.polyrob/providers.yaml. See how to self-host an AI agent.
Which Claude model should I start with?
Start with one that your key can call and pin it with polyrob model set-default anthropic <model>. This guide uses claude-sonnet-5 as its example pin. Switch with /model in chat if it is not enough.
Does my data stay on my machine?
Memory, goals and sessions are local files. Prompts go to Anthropic when Claude is the model. Since version 1.7.5 the installer also sends one anonymous count after a fresh install (version, OS and install method, no ID). --no-telemetry or DO_NOT_TRACK=1 turns that off.
Where do you start?
Install it, add the key, pin the model and run one task before you switch on autonomy.
curl -fsSL https://polyrob.dev/install.sh | bash
polyrob config set ANTHROPIC_API_KEY
polyrob model set-default anthropic claude-sonnet-5
polyrob doctor
Install POLYROB or read the docs. The source is MIT licensed at github.com/theselfruleorg/polyrob.
Sources
POLYROB facts are from the public repository at release v1.7.6 (github.com/theselfruleorg/polyrob).
- docs/guide/[email protected] (keys, provider order,
set-default, OAuth sign-in and warning, caching, thinking,RUN_BUDGET_USD,providers.yaml, MCP server, context files, deferred tools) - docs/guide/[email protected] (keys, subscription plans)
- modules/llm/[email protected] (
anthropicprovider,anthropic-oauthrow and its model) - modules/llm/[email protected] (Anthropic model ids and context windows)
- docs/[email protected] (step and spend caps, flags) and docs/[email protected] (dated 2026-10-27)
- Claude Code description: Anthropic Claude Code overview, fetched 2026-11-10.
POLYROB is an open-source AI agent you run and own. Install it or read the docs.