http://localhost:8080/
- List available models:
GET /models
- Load a model:
POST /load_model
- Unload the current model:
POST /unload_model
- Get the current loaded model:
GET /current_model
- Generate output:
POST /generate
- Download a model from Hugging Face:
POST /pull
- Delete a model:
POST /rm
Returns the list of available models in the ~/RKLLAMA/models
directory.
GET /models
-
200 OK: List of available models.
{ "models": [ "model1.rkllm", "model2.rkllm", "model3.rkllm" ] }
-
500 Internal Server Error: Directory not found.
{ "error": "The directory ~/RKLLAMA/models is not found." }
curl -X GET http://localhost:8080/models
Loads a specific model into memory.
POST /load_model
Content-Type: application/json
{
"model_name": "model_name.rkllm"
}
-
200 OK: Model loaded successfully.
{ "message": "Model <model_name> loaded successfully." }
-
400 Bad Request: A model is already loaded or parameters are missing.
{ "error": "A model is already loaded. Please unload it first." }
-
400 Bad Request: Model not found.
{ "error": "Model <model_name> not found in the /models directory." }
curl -X POST http://localhost:8080/load_model \
-H "Content-Type: application/json" \
-d '{"model_name": "model1.rkllm"}'
Unloads the currently loaded model.
POST /unload_model
-
200 OK: Success.
{ "message": "Model unloaded successfully." }
-
400 Bad Request: No model is loaded.
{ "error": "No model is currently loaded." }
curl -X POST http://localhost:8080/unload_model
Returns the name of the currently loaded model.
GET /current_model
-
200 OK: Success.
{ "model_name": "model_name" }
-
404 Not Found: No model is loaded.
{ "error": "No model is currently loaded." }
curl -X GET http://localhost:8080/current_model
Generates a response using the loaded model.
POST /generate
Content-Type: application/json
{
"messages": "prompt or chat_template",
"stream": true
}
-
200 OK: Generated response.
{ "id": "rkllm_chat", "object": "rkllm_chat", "created": null, "choices": [{ "role": "assistant", "content": "rkllama_output", "finish_reason": "stop" }], "usage": { "prompt_tokens": null, "completion_tokens": null, "total_tokens": null } }
-
400 Bad Request: No model is loaded.
{ "error": "No model is currently loaded." }
curl -X POST http://localhost:8080/generate \
-H "Content-Type: application/json" \
-d '{"messages": "Hello, how are you?", "stream": false}'
Downloads and installs a model from Hugging Face.
POST /pull
Content-Type: application/json
{
"model": "hf/username/repo/file.rkllm"
}
- 200 OK: Download in progress.
Downloading <file> (<size> MB)...
<progress>%
- 400 Bad Request: Download error.
Error during download: <error>
curl -X POST http://localhost:8080/pull \
-H "Content-Type: application/json" \
-d '{"model": "hf/username/repo/file.rkllm"}'
Deletes a specific model.
POST /rm
Content-Type: application/json
{
"model": "model_name.rkllm"
}
-
200 OK: Success.
{ "message": "The model has been successfully deleted." }
-
404 Not Found: Model not found.
{ "error": "The model: {model} cannot be found." }
curl -X DELETE http://localhost:8080/rm \
-H "Content-Type: application/json" \
-d '{"model": "model1.rkllm"}'
Displays a welcome message and a link to the GitHub project.
- 200 OK:
{ "message": "Welcome to RK-LLama!", "github": "https://github.com/notpunhnox/rkllama" }
curl -X GET http://localhost:8080/
- 400: Bad Request due to incorrect parameters.
- 404: Resource not found.
- 500: Internal server error.
- Parameter Validation: Always double-check model names and file paths.
- Troubleshooting: Check server logs for more details on internal errors.