| llama_serve_openai | R Documentation |
Loads a GGUF model once and exposes it over an OpenAI-compatible HTTP
API so any OpenAI client (OpenCode, ellmer, the 'openai' Python SDK, …)
can talk to it. Implements 'GET /v1/models' and
'POST /v1/chat/completions' (both blocking and 'stream = true'). The
HTTP/SSE layer is provided by drogonR; generation runs through
llamaR's streaming API (llama_gen_begin /
llama_gen_next / llama_gen_end).
llama_serve_openai(
model_path,
port = 11434L,
n_ctx = 4096L,
n_gpu_layers = -1L,
model_id = NULL,
host = "127.0.0.1",
template = NULL,
max_tokens = 512L,
...
)
model_path |
Path to a GGUF model file. |
port |
Port to listen on. Default |
n_ctx |
Context size for the loaded model. |
n_gpu_layers |
Layers to offload to GPU ( |
model_id |
Identifier reported in |
host |
Address to bind. Default |
template |
Chat template string, or |
max_tokens |
Default |
... |
Reserved for future options. |
The server is single-sequence: requests are handled one at a time on the main R thread (each streamed token is one event-loop pump). This is meant for a single local user/agent, not concurrent load.
drogonR is an optional dependency (Suggests); install it
with install.packages("drogonR") (or from its repository) before
calling this function.
Invisibly NULL. Blocks serving until drogonR::dr_stop()
is called (typically from another process or an interrupt).
[llama_gen_begin], [llama_generate]
## Not run:
llama_serve_openai("model.gguf", port = 11434L)
# In another shell, point any OpenAI client at
# http://127.0.0.1:11434/v1
# e.g. GET /v1/models and POST /v1/chat/completions
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.