AI agents on-prem or on a VPS: running agents on your own infrastructure
How to run AI agents on your own servers or a VPS: open-weight models, inference servers, hardware sizing, the hybrid option, security and GDPR, and when self-hosting is worth it.

Some companies cannot, or will not, send their data to an external AI service. Contracts with clients, sector rules, trade secrets or simply a strict data policy push them toward running AI on their own infrastructure. The good news is that open-weight models are now strong enough for many agent tasks. The less good news is that self-hosting moves the whole job of running AI onto you.
This article explains what an on-prem or VPS agent is made of, how to size it, the hybrid option many companies end up choosing, and when self-hosting is worth the effort.
What “self-hosted agent” can mean
There are two separate things you can host yourself:
- The agent: the loop, the tools, the connections to your systems and the logs.
- The model: the language model that decides each step.
You can host one and not the other. Three setups cover most cases:
| Setup | Agent runs | Model runs | Data leaves your perimeter? |
|---|---|---|---|
| Fully self-hosted | Your servers or VPS | Your GPU servers | No |
| Hybrid | Your servers or VPS | A provider’s API, ideally with EU processing | Only what the agent sends to the model |
| Managed | The provider’s platform | The provider | Yes, under the provider’s terms |
The hybrid setup is often underrated. The agent, the tools, the database and the logs stay with you; only the text the agent chooses to send goes to the model, under a data processing agreement. You can also filter or redact what is sent. For many companies that is enough control, at a fraction of the effort.
The building blocks of a fully self-hosted agent
- An open-weight model. Model families such as Llama, Qwen, Mistral, Gemma, DeepSeek and OpenAI’s gpt-oss publish weights you can run yourself. Check the licence of the exact model: some allow any commercial use, some add conditions.
- An inference server. Software that loads the model and serves it through an API. Ollama and llama.cpp are simple and good for small setups and testing. vLLM and SGLang are built for throughput when several users or agents call the model at once. Most expose an OpenAI-compatible API, so agent frameworks can use them directly.
- The agent layer. A framework or your own loop, with tools that reach your systems: ERP, CRM, file shares, databases. For many business agents, a workflow tool such as a self-hosted n8n is enough.
- Retrieval. If the agent answers from company documents, you need a search index and usually a vector store. See private RAG server: a reference architecture.
- Operations. Monitoring, logs, backups, updates, access control and someone responsible when it breaks.
Sizing the hardware
The main constraint is GPU memory. A model’s weights must fit in it, plus room for the context of the requests being processed. Quantisation, which stores weights with fewer bits, reduces memory needs at some cost in quality.
Rough orders of magnitude, with 4-bit quantisation:
| Model size | Approximate memory for weights | Typical hardware |
|---|---|---|
| Small (around 7-9B parameters) | around 5-6 GB | A single consumer or entry-level data-centre GPU; slow but possible on CPU |
| Medium (around 20-35B) | around 15-20 GB | One GPU with 24 GB or more |
| Large (around 70B) | around 40 GB or more | One or two GPUs with 48-80 GB |
| Very large (100B+, mixture-of-experts) | Much more | Several data-centre GPUs |
These figures are approximate and leave out the extra memory needed for long contexts and many parallel requests. Measure with your model, your context lengths and your expected load before you buy or rent.
What about a normal VPS? A CPU-only VPS can run a small model for light use: an internal assistant with a few users, classification or extraction jobs that are not time-sensitive. For an agent that makes many model calls per task, CPU inference is usually too slow. A VPS is, however, a very good home for the agent layer in the hybrid setup, or you can rent a GPU server from a cloud or hosting provider in the EU.
Choosing the model for an agent
Agents need more than good text. They need reliable tool calling, the ability to follow multi-step instructions and enough context length for the task. When you evaluate open models:
- Test tool calling on your tools, with your schemas, not just general benchmarks.
- Test multi-step tasks end to end. Small models often handle one step well and lose track over five.
- Check language quality if your users write in Romanian or another language besides English.
- Compare against a hosted model on the same cases, so you know what you gain and what you give up.
A common pattern is to use a small, fast local model for high-volume simple steps (classification, extraction, routing) and keep the hardest reasoning for a larger model, either local or, in a hybrid setup, through an API.
Security on your own infrastructure
Self-hosting removes one risk, data going to a third party, but keeps all the others, and adds some.
- Network isolation. The inference server should not be reachable from the internet. Put the agent and the model in a private network and expose only what users need, behind authentication.
- Least privilege for tools. The agent’s service accounts should only reach what the task requires. See AI system security: prompt injection and permissions.
- Prompt injection still applies. A malicious document on your own file share is just as dangerous as one from the internet.
- Updates. Inference servers and frameworks move fast and get security fixes. Plan regular updates.
- Logs with care. Agent logs contain the data the agent handled. Protect and retain them like the source data.
GDPR and the AI Act
Running AI on-prem simplifies some GDPR questions, because there is no external processor for the model, but it does not remove your obligations: a lawful basis, data minimisation, retention limits, security, and the rules on automated decisions that significantly affect people. Under the AI Act, obligations depend on the use case, not on where the model runs. See AI security, the AI Act and GDPR.
When self-hosting is worth it
Self-hosting makes sense when at least one of these is true:
- Data cannot leave, by contract, regulation or policy.
- Volume is high and steady, so dedicated hardware costs less than paying per call.
- You need offline or air-gapped operation.
- You need full control over the model version, so behaviour does not change unexpectedly.
It is usually not worth it when volume is low or irregular, when you need the strongest available reasoning, or when nobody on the team can operate GPU servers. In those cases, the hybrid setup gives most of the control for much less work.
A starter architecture for a mid-sized company
A setup that works well as a first step, and can grow:
- One VPS or internal server for the agent layer: a self-hosted workflow tool or a small agent service, the tool connectors to your ERP, CRM and file shares, a database for agent state and logs, and a reverse proxy with single sign-on in front of the user interface.
- One model endpoint: in the hybrid version, a provider’s API with EU processing; in the fully self-hosted version, a GPU server running vLLM with an open-weight model, reachable only from the agent server.
- A document index for the internal knowledge the agent needs, kept on the same private network.
- Monitoring and backups for all of it, with alerts when the agent’s queue grows or the model endpoint slows down.
Start with the hybrid version, measure volume, cost and the share of tasks the agent completes, and move the model in-house only if the numbers or the data rules call for it. Because the agent talks to the model through one standard interface, that move does not require rewriting the agent.
Frequently asked questions
Are open models good enough for agents?
For many well-defined tasks, yes: classification, extraction, routing, answering from documents, simple multi-step tasks. For long, complex tasks with many tools, the strongest hosted models still tend to be more reliable. Test on your cases.
Can I start on a VPS and grow later?
Yes. Start with the agent on a VPS and a model through an API, then move the model in-house when volume or data rules justify it. If your agent uses an OpenAI-compatible interface, switching the model is mostly configuration.
What does it cost?
It depends on the model size, the load and whether you buy or rent GPUs. Compare the monthly cost of the hardware and the people who operate it against the cost per call of an API at your expected volume, and include the time to maintain the system.
Is a self-hosted agent automatically GDPR-compliant?
No. It removes the model provider as a processor, but you still need the same data protection measures for everything the agent touches.
What to bring to a first conversation
Bring your data constraints, the expected volume, the tasks the agent would do and the systems it must reach. From that we can decide between fully self-hosted, hybrid and managed, and size the first setup. For the broader picture, see what AI agents are and choosing an AI provider.