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 builds the official llama.cpp server image (v1.0.0, pinned by digest) from a small GitHub repo and runs it 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

Deployment Dependencies

Implementation Details

ServiceSourceNetworkingStorage
llamacpprepo, llama.cpp:server-v1.0.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.
  • The service builds from the repo's main branch. When a new llama.cpp release is pinned there, Railway shows you an "update available" notice and you choose when to apply it; read the repo's CHANGELOG.md first. Model files stay on the volume.
  • 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
117
View Template
Weaviate
Vector database with hybrid search and an API key-protected API

GitHub Locker
1
View Template
Möbius Personal AI OS
Self-hosted AI agent that builds and runs apps for you, with memory.

Tracklayer
1