Deploy llama.cpp Server

llama.cpp server with an OpenAI-compatible API running GGUF models on CPU.

Deploy llama.cpp Server

/models

Deploy and Host llama.cpp Server on Railway

llama.cpp is the widely used C/C++ engine for running large language models locally, and llama-server is its lightweight HTTP server. It loads GGUF models, offers an OpenAI-compatible chat and completions API with streaming, tool calling and JSON schema output, and runs efficiently on CPUs without a GPU.

About Hosting llama.cpp Server

This template deploys the official llama.cpp server image (v0.5.0) on CPU with ggml-org/Qwen3-0.6B-GGUF as the default model. The model is downloaded from Hugging Face on first start into a Railway volume and reused on restarts. Every request needs the generated API key. The thread count is pinned to 4: containers see the host's cores, and the default over-subscribed the CPU quota and slowed generation to a crawl. With 4 threads the small model generated about 70 to 90 tokens per second in testing. Larger models need more memory and a bigger plan.

Common Use Cases

  • A private OpenAI-compatible endpoint for small open models
  • Offline or low-cost LLM features such as classification, extraction and summaries
  • Testing prompts and tools against local models before scaling up

Dependencies for llama.cpp Server Hosting

  • ghcr.io/ggml-org/llama.cpp:server-v0.5.0 (official image)
  • A Railway volume at /models for downloaded GGUF files

Deployment Dependencies

Implementation Details

ServiceImageNetworkingStorage
llamacppllama.cpp:server-v0.5.0public domain on 8080; private IPv4/IPv6volume at /models
curl "$OPENAI_BASE_URL/chat/completions" -H "Authorization: Bearer $LLAMA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "qwen3-0.6b", "messages": [{"role": "user", "content": "Hello"}]}'

Any OpenAI SDK works with base_url=${{llamacpp.OPENAI_BASE_URL}} and api_key=${{llamacpp.LLAMA_API_KEY}}.

VariableDefaultPurpose
LLAMA_ARG_HF_REPOggml-org/Qwen3-0.6B-GGUFModel repo (append :Q4_K_M to pick a quant)
LLAMA_ARG_ALIASqwen3-0.6bModel name reported by the API
LLAMA_ARG_THREADS4CPU threads; keep at or below your vCPUs
LLAMA_ARG_CTX_SIZE4096Context window
LLAMA_API_KEYgeneratedRequired bearer token

Notes:

  • Every llama-server flag has a LLAMA_ARG_* variable; see the server documentation.
  • Add /no_think to Qwen3 prompts to skip the reasoning block for short answers.

This is a community-maintained deployment package and does not imply affiliation with or endorsement by the llama.cpp Server project or its maintainers.

Why Deploy llama.cpp Server on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying llama.cpp Server on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.


Template Content

More templates in this category

View Template
Chat Chat
Chat Chat, your own unified chat and search to AI platform.

okisdev
116
View Template
stella
Self-host stella with web, API, Postgres, Redis, and object storage.

Jan Kubica
7
View Template
Hermes Agent | OpenClaw Alternative with Dashboard
Self-Hosted Hermes AI Agent for Telegram, Discord & Slack

codestorm
79