Add Authorization header to curl examples.

This commit is contained in:
2025-10-26 17:28:01 +01:00
parent 4f94f63de3
commit d768845805

View File

@@ -13,9 +13,13 @@ Llamactl provides two ways to manage instances:
### Authentication ### Authentication
If authentication is enabled: Llamactl uses a **Management API Key** to authenticate requests to the management API (creating, starting, stopping instances). All curl examples below use `<token>` as a placeholder - replace this with your actual Management API Key.
By default, authentication is required. If you don't configure a management API key in your configuration file, llamactl will auto-generate one and print it to the terminal on startup. See the [Configuration](configuration.md) guide for details.
For Web UI access:
1. Navigate to the web UI 1. Navigate to the web UI
2. Enter your credentials 2. Enter your Management API Key
3. Bearer token is stored for the session 3. Bearer token is stored for the session
### Theme Support ### Theme Support
@@ -71,6 +75,7 @@ Each instance is displayed as a card showing:
# Create llama.cpp instance with local model file # Create llama.cpp instance with local model file
curl -X POST http://localhost:8080/api/v1/instances/my-llama-instance \ curl -X POST http://localhost:8080/api/v1/instances/my-llama-instance \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-H "Authorization: Bearer <token>" \
-d '{ -d '{
"backend_type": "llama_cpp", "backend_type": "llama_cpp",
"backend_options": { "backend_options": {
@@ -85,6 +90,7 @@ curl -X POST http://localhost:8080/api/v1/instances/my-llama-instance \
# Create MLX instance (macOS only) # Create MLX instance (macOS only)
curl -X POST http://localhost:8080/api/v1/instances/my-mlx-instance \ curl -X POST http://localhost:8080/api/v1/instances/my-mlx-instance \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-H "Authorization: Bearer <token>" \
-d '{ -d '{
"backend_type": "mlx_lm", "backend_type": "mlx_lm",
"backend_options": { "backend_options": {
@@ -101,6 +107,7 @@ curl -X POST http://localhost:8080/api/v1/instances/my-mlx-instance \
# Create vLLM instance # Create vLLM instance
curl -X POST http://localhost:8080/api/v1/instances/my-vllm-instance \ curl -X POST http://localhost:8080/api/v1/instances/my-vllm-instance \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-H "Authorization: Bearer <token>" \
-d '{ -d '{
"backend_type": "vllm", "backend_type": "vllm",
"backend_options": { "backend_options": {
@@ -121,6 +128,7 @@ curl -X POST http://localhost:8080/api/v1/instances/my-vllm-instance \
# Create llama.cpp instance with HuggingFace model # Create llama.cpp instance with HuggingFace model
curl -X POST http://localhost:8080/api/v1/instances/gemma-3-27b \ curl -X POST http://localhost:8080/api/v1/instances/gemma-3-27b \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-H "Authorization: Bearer <token>" \
-d '{ -d '{
"backend_type": "llama_cpp", "backend_type": "llama_cpp",
"backend_options": { "backend_options": {
@@ -134,6 +142,7 @@ curl -X POST http://localhost:8080/api/v1/instances/gemma-3-27b \
# Create instance on specific remote node # Create instance on specific remote node
curl -X POST http://localhost:8080/api/v1/instances/remote-llama \ curl -X POST http://localhost:8080/api/v1/instances/remote-llama \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-H "Authorization: Bearer <token>" \
-d '{ -d '{
"backend_type": "llama_cpp", "backend_type": "llama_cpp",
"backend_options": { "backend_options": {
@@ -146,6 +155,7 @@ curl -X POST http://localhost:8080/api/v1/instances/remote-llama \
# Create instance on multiple nodes for high availability # Create instance on multiple nodes for high availability
curl -X POST http://localhost:8080/api/v1/instances/multi-node-llama \ curl -X POST http://localhost:8080/api/v1/instances/multi-node-llama \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-H "Authorization: Bearer <token>" \
-d '{ -d '{
"backend_type": "llama_cpp", "backend_type": "llama_cpp",
"backend_options": { "backend_options": {
@@ -166,7 +176,8 @@ curl -X POST http://localhost:8080/api/v1/instances/multi-node-llama \
**Via API** **Via API**
```bash ```bash
curl -X POST http://localhost:8080/api/v1/instances/{name}/start curl -X POST http://localhost:8080/api/v1/instances/{name}/start \
-H "Authorization: Bearer <token>"
``` ```
## Stop Instance ## Stop Instance
@@ -177,7 +188,8 @@ curl -X POST http://localhost:8080/api/v1/instances/{name}/start
**Via API** **Via API**
```bash ```bash
curl -X POST http://localhost:8080/api/v1/instances/{name}/stop curl -X POST http://localhost:8080/api/v1/instances/{name}/stop \
-H "Authorization: Bearer <token>"
``` ```
## Edit Instance ## Edit Instance
@@ -194,6 +206,7 @@ Modify instance settings:
```bash ```bash
curl -X PUT http://localhost:8080/api/v1/instances/{name} \ curl -X PUT http://localhost:8080/api/v1/instances/{name} \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-H "Authorization: Bearer <token>" \
-d '{ -d '{
"backend_options": { "backend_options": {
"threads": 8, "threads": 8,
@@ -217,8 +230,9 @@ curl -X PUT http://localhost:8080/api/v1/instances/{name} \
Check instance status in real-time: Check instance status in real-time:
```bash ```bash
# Get instance details # Get instance logs
curl http://localhost:8080/api/v1/instances/{name}/logs curl http://localhost:8080/api/v1/instances/{name}/logs \
-H "Authorization: Bearer <token>"
``` ```
## Delete Instance ## Delete Instance
@@ -230,7 +244,8 @@ curl http://localhost:8080/api/v1/instances/{name}/logs
**Via API** **Via API**
```bash ```bash
curl -X DELETE http://localhost:8080/api/v1/instances/{name} curl -X DELETE http://localhost:8080/api/v1/instances/{name} \
-H "Authorization: Bearer <token>"
``` ```
## Instance Proxy ## Instance Proxy
@@ -238,8 +253,9 @@ curl -X DELETE http://localhost:8080/api/v1/instances/{name}
Llamactl proxies all requests to the underlying backend instances (llama-server, MLX, or vLLM). Llamactl proxies all requests to the underlying backend instances (llama-server, MLX, or vLLM).
```bash ```bash
# Get instance details # Proxy requests to the instance
curl http://localhost:8080/api/v1/instances/{name}/proxy/ curl http://localhost:8080/api/v1/instances/{name}/proxy/ \
-H "Authorization: Bearer <token>"
``` ```
All backends provide OpenAI-compatible endpoints. Check the respective documentation: All backends provide OpenAI-compatible endpoints. Check the respective documentation:
@@ -258,6 +274,7 @@ All backends provide OpenAI-compatible endpoints. Check the respective documenta
Check the health status of your instances: Check the health status of your instances:
```bash ```bash
curl http://localhost:8080/api/v1/instances/{name}/proxy/health curl http://localhost:8080/api/v1/instances/{name}/proxy/health \
-H "Authorization: Bearer <token>"
``` ```