Most LLM-based products still stop at a chat box inside a web page. An AI agent goes a step further: it plugs into your messaging or collaboration channels, takes over a compute environment, and works around the clock on your behalf. This article explains the three-layer architecture behind such an agent — the LLM as the brain, the messaging channel as the interaction layer, and the server as the hands and feet — and walks through how to set it up in the cloud at low cost, covering server setup, LLM API credentials, configuration examples, security hardening, and ongoing operations and cost control.

    How to Build a Low-Cost 24/7 AI Agent in the Cloud: A Step-by-Step Setup Guide

    From a Chat Box to a Digital Assistant

    Over the past two years, large language models have advanced rapidly, yet most products based on them still look the same: a chat box on a web page. Recently, a new type of AI agent has been attracting attention from developers and investors alike. Their GitHub stars have climbed quickly, their popularity has even boosted sales of compact mini-PCs, and major cloud providers have rolled out one-click deployment options. What makes them so compelling?

    The key difference is that they move beyond a chatbot and become a digital assistant. A conventional chatbot only responds when you ask it something. An agent, by contrast, can connect to your messaging or collaboration tools, receive commands through chat messages, and take control of your compute environment. It can process emails, organize your schedule, and carry out multi-step compound tasks proactively, 24/7 — essentially a “cyber clone” of yourself.

    Many developers get stuck at the very first step: deployment. This guide takes a general, product-agnostic approach to building your own all-around assistant in the cloud at very low cost, using mainstream large language model capabilities.

    How an AI Agent Is Built: Brain, Channels, and Hands and Feet

    Before you start, it helps to understand how an agent fits together. A typical personal AI assistant has three layers:

    • Capability layer (the brain): One or more large language models provide reasoning, understanding, and generation. This is where the agent’s intelligence comes from, and it determines how complex a task the agent can handle.
    • Interaction layer (the channels): The entry points the agent uses to communicate with you, usually the messaging or collaboration platforms you already use. You send commands as messages, and the agent replies with results.
    • Execution layer (the hands and feet): The host environment where the agent runs, typically a cloud server. It carries out commands, reads and writes files, calls tools, and reports the results back to the brain.

    With these three layers in mind, deployment comes down to three things: set up a host environment (execution), connect LLM capabilities (the brain), and wire up a communication channel (interaction).

    Step 1: Set Up a Cloud Runtime Environment

    Choosing a cloud server ensures reliability and makes low-cost experimentation easy. An agent needs to stay online 24/7. A local machine that is shut down or loses its connection will interrupt it, whereas a cloud server is continuously online and reachable from the public internet.

    1. Get a server: Open your cloud provider’s website and choose a cloud server product (for example, Baidu AI Cloud).
    2. Pick a configuration: For a personal assistant, an entry-level instance with 2 vCPU, 4 GB of memory, and a 200 GB SSD is enough to run stably and is very cost-effective. If you later need to handle large numbers of files or concurrent tasks, you can scale up.
    3. Initialize the system: Once you have a running instance, open the console and do two things:
      • Reset the password: Choose a strong password that is hard to guess.
      • Log in remotely: Use SSH or the console’s built-in remote login feature.

    Once the system is ready, tidy up the basic environment. Update the package sources, install common tools, and create a dedicated working directory (such as /root/agent) for the agent’s configuration, memory, and workspace data.

    Step 2: Give the Agent a Brain

    Next, configure the agent’s brain, which sets its upper limit on intelligence. You need to connect the agent to a large language model and then to your messaging channel.

    1. Get Your LLM API Credentials

    Activate the model service you want to use in your provider’s console, then generate an API key that starts with sk-. Keep it somewhere safe. This key is the only credential used to call the model, and if it leaks, others can use it at your expense. Never hard-code it in public code or commit it to a public repository.

    2. Configure the Model

    Log in to the server and use the agent’s CLI to configure things in a structured way. The example below uses an LLM with a standard, chat-completions-compatible API. Replace the placeholders with your own values:

    1. # Configure the model provider (using a generic LLM API as an example)
    2. agent-cli config set models '{
    3. "mode": "merge",
    4. "providers": {
    5. "llm-provider": {
    6. "baseUrl": "https://api.example.com/v1",
    7. "apiKey": "your-api-key",
    8. "api": "standard-chat",
    9. "models": [
    10. {
    11. "id": "your-model-id",
    12. "name": "your-model-name",
    13. "reasoning": true,
    14. "input": ["text", "image"],
    15. "contextWindow": 200000,
    16. "maxTokens": 32768
    17. }
    18. ]
    19. }
    20. }
    21. }'

    A few key fields:

    • baseUrl: The API endpoint of the model service. Use the address your provider gives you.
    • apiKey: The key from the previous step. Keep it secure.
    • contextWindow: How much content the agent can “remember” at once. A larger value is better suited to long documents and complex tasks.
    • maxTokens: The upper limit on a single response, which affects how long replies can be.

    Then set the agent’s default behavior, including the default model, the workspace path, and the context compaction policy:

    1. # Configure the agent's default behavior
    2. agent-cli config set agents '{
    3. "defaults": {
    4. "model": { "primary": "llm-provider/your-model-name" },
    5. "workspace": "/root/agent",
    6. "compaction": { "enabled": true }
    7. }
    8. }'

    Compaction is especially useful in long conversations. When the message history approaches the context window limit, the agent automatically summarizes earlier messages so it can keep working within a limited window.

    Step 3: Connect a Messaging Channel

    With the brain ready, the agent needs “ears” and a “mouth,” which means an interaction channel. The usual approach is to connect it to a messaging or collaboration platform:

    • Create a bot account on your chosen platform and get its bot token.
    • Add the token to the agent’s configuration to establish a two-way messaging channel.
    1. # Bind a messaging channel token (example)
    2. agent-cli config set channels '{
    3. "messenger": { "enabled": true, "token": "your-bot-token" }
    4. }'

    Once connected, you send a message from a chat window on your phone or computer. The agent receives it in the cloud, uses the LLM to work out what to do, runs the corresponding commands on the server, and sends the results back to the same window. At this point, the loop is complete: send commands from anywhere, and the cloud executes them automatically.

    Securing Keys and Tokens

    Handle keys and tokens with care when injecting them into your configuration:

    • Use environment variables or encrypted configuration files. Avoid leaving plaintext secrets scattered across multiple scripts.
    • Apply least privilege to the agent. Grant the workspace directory only the read and write access it needs. Capabilities such as deletion and system-level operations should be disabled by default or require confirmation.
    • Reduce your public-facing surface. Open only the ports the server needs and block everything else with a firewall.
    • Rotate credentials. Replace API keys and tokens periodically to reduce the risk of long-term exposure.

    Operations, Cost, and Best Practices

    Once the agent is live, a few operational practices help keep it running reliably:

    1. Process supervision: Run the agent in the background with a process manager and configure it to restart automatically if it crashes.
    2. Logging and monitoring: Use a logging service to record what the agent does, and set up basic monitoring and alerts so you notice outages or resource exhaustion quickly.
    3. Cost control: LLM calls are billed by usage, so long conversations and frequent tasks can add up. Enable context compaction, choose an appropriately sized model for each task, and set a cap on request frequency.
    4. Backups: Back up the workspace and configuration files regularly so that mistakes do not cost you data.

    Conclusion

    An AI agent turns an LLM’s ability to understand requests into something you can act on, rather than just questions you can answer. Setting one up comes down to three pieces: a cloud host environment to execute tasks, an LLM to provide the intelligence, and a messaging channel to handle interaction. Once these are connected, you have a personal assistant that is always on call and ready to act on your commands.

    You do not need high-end hardware. With an entry-level cloud server and mainstream LLM capabilities, you can build your own agent from scratch at very low cost. What matters is not how powerful the model is, but whether you have connected a thinking brain to hands and feet that can actually get things done.