AI Agent Deployment Guide: Cloud and Local Setup
Learn how to deploy an AI agent using cloud-hosted or local models. This guide covers prerequisites, CLI installation, model configuration, deployment checks, troubleshooting, and security practices to help you balance model capability, hardware requirements, and data privacy.
1. Prepare and Choose a Deployment Mode
Before installing anything, understand the differences between cloud and local deployment so you can avoid unnecessary migrations later.
Cloud Mode
- Model inference runs in the cloud, while your computer runs only a lightweight command-line client.
- Local hardware requirements are minimal; a typical office computer is sufficient.
- Cloud services offer access to larger, more capable flagship models.
- Code is sent to a remote service for processing, so you need to assess data compliance requirements and network dependencies.
Local Mode
- Inference runs on your machine, keeping code within your local environment and giving you greater control over privacy and compliance.
- The setup can work without an internet connection once the required components and models are installed.
- Model quality and responsiveness depend heavily on GPU memory, system RAM, and quantization.
- You must maintain model files and the inference runtime yourself.
For everyday development and access to the strongest model capabilities, cloud mode is generally the better choice. For confidential code, restricted networks, or extensive customization, consider local mode. Both modes can coexist, allowing you to switch between them within the same workflow.
2. Deploy in Cloud Mode
2.1 Check Prerequisites
Before installing the agent CLI, confirm that the following components are available:
| Component | Requirement | Check |
|---|---|---|
| JavaScript runtime | Version 18 or later; 20.x LTS recommended in this setup | runtime --version |
| Package manager | Bundled with the runtime; version 10.x or later recommended | pkg-manager --version |
| Version control tool | Command-line and collaboration support | vcs --version |
| Terminal | Support for a modern shell and UTF-8 output | — |
These command names are illustrative. Use the actual commands provided by your installed tools.
If your versions are too old, obtain an LTS installer from the relevant official source. After installation, reopen your terminal so that environment variable changes take effect.
2.2 Install the Agent CLI
Install the CLI globally using your package manager:
# Replace <agent-cli> with the actual package namepkg-manager install -g <agent-cli>
Verify the installation:
<agent-cli> --version
If the command prints a version number, installation was successful. A “command not found” error usually means the global installation directory is missing from PATH. Inspect the global installation location with pkg-manager root -g, then ensure the corresponding executable directory is included in PATH.
2.3 Launch the CLI and Connect a Model
Start the agent:
<agent-cli>
The initial setup typically asks you to select a model source. Common options include:
- Entering an API key obtained from your chosen cloud model provider’s console.
- Configuring a custom inference endpoint, where the CLI supports an OpenAI-style API.
- Switching to a local inference runtime later.
Best practice: Do not store API keys in plaintext configuration files or commit them to a code repository. Prefer environment-variable injection or an operating-system credential manager.
The following illustrates the environment variables a CLI might use; actual names depend on the tool:
# Example environment variable configurationexport AGENT_API_KEY="sk-xxxxxxxx"export AGENT_API_BASE="https://<your-model-endpoint>/v1"
Once configured, run a simple task—for example, ask the agent to generate and explain a function—to verify the end-to-end connection.
3. Deploy in Local Mode
3.1 Install a Local Inference Runtime
Choose a widely used local inference runtime and follow its installation instructions. After installation, check the runtime and confirm that its service is running:
# Example runtime checks<local-runtime> --version<local-runtime> list
Local runtimes typically expose an HTTP service on your machine. Port 11434 is a common default for runtimes using this setup, and the agent CLI communicates with the service through that endpoint.
3.2 Choose and Download a Model
Select a model size that fits your hardware. A smaller model that runs smoothly is usually more practical than a larger model that struggles to respond.
| Hardware | Suggested Model Size | Notes |
|---|---|---|
| NVIDIA GPU with at least 8 GB of VRAM | Quantized 7B coding model | A balance of generation quality and speed |
| CPU-only or lower-spec machine | Quantized 3B model | Usable, but responses may be slower |
| Very limited hardware or workflow testing | 1.5B model | Best suited to trying the workflow |
These are general sizing guidelines; actual memory use and performance depend on the model and quantization configuration.
A model download command typically looks like this:
<local-runtime> pull <model-name>
Selection tips: Prefer open-source models trained or further optimized for coding tasks. If GPU memory is limited, use a quantized version, such as Q4, to reduce memory requirements, typically with a limited loss in quality.
The first model load can take longer than subsequent requests. Depending on the runtime’s configuration and available memory, the model may remain loaded in GPU memory afterward.
3.3 Point the Agent to the Local Model
The key step is configuring the CLI to use the local inference endpoint. This is commonly done through environment variables or a configuration file.
# Example configuration for a local inference serviceexport AGENT_MODEL_PROVIDER="local"export AGENT_MODEL_BASE="http://localhost:11434"export AGENT_MODEL_NAME="<model-name>"
These variable names are illustrative; use the settings supported by your CLI.
If the CLI supports interactive model switching, you may also be able to select the local model using a command such as /model. Restart the CLI after changing its configuration.
4. Validate the Deployment and Integration
Check the setup in stages:
- Connectivity: Use
curlto request the local endpoint’s health-check or model-list API and confirm that the service is reachable. - Model response: Ask the agent a simple question and verify that it responds using the intended local model.
- Agent capabilities: In a real project directory, test core functions such as reading files, modifying code, and executing commands.
- Performance: Observe time to first token and generation throughput. If performance is too slow, reduce the model size or use quantization.
The following is an illustrative integration check. The endpoint, flags, and input method must match your runtime and CLI:
# 1. Check runtime availabilitycurl -s http://localhost:11434/api/tags > /dev/null && echo "runtime OK"# 2. Check CLI availability<agent-cli> --version# 3. Run an end-to-end testecho "Explain this code in one sentence" | <agent-cli> --model <model-name>
5. Common Issues and Troubleshooting
- The command is unavailable after installation: Reopen the terminal and check that the global executable directory is in
PATH. - Cloud authentication fails: Verify that the API key is valid, the endpoint address is correct, and the service is reachable.
- The local model does not respond: Confirm that the inference runtime is running, its port is not occupied by another process, and firewall rules allow local loopback access.
- Responses are extremely slow or memory runs out: Use a smaller model or a more heavily quantized version, and close other applications consuming GPU memory.
- Non-ASCII output appears garbled: Make sure the terminal uses UTF-8 encoding.
- A proxy interferes with local requests: Configure proxy bypass rules for the local endpoint so that localhost traffic connects directly.
6. Security and Maintenance
- Manage credentials: Inject API keys through environment variables, rotate them regularly, and never commit them to a repository.
- Apply least privilege: Restrict the agent’s working directory and command-execution permissions. Avoid granting write access to sensitive system paths.
- Keep audit logs: Record file changes and executed commands so that actions can be reviewed and traced.
- Manage updates: Keep the CLI and local runtime reasonably up to date, but validate updates in a test directory before using them in production.
- Organize model files: Store large local model files in a dedicated disk directory to simplify management and reduce accidental deletion or scattered storage.
With prerequisites in place, cloud deployment can often be completed within an hour. You can then add local deployment according to your hardware capacity. Keeping both options available lets you balance model capability, cost, and data security on a task-by-task basis.
