=============== LIBRARY RULES =============== From library maintainers: - Run `amicu validate` and `amicu plan` before `amicu apply`, and review the plan. - Start a new project with `amicu init` or `amicu init --example `. - Never put API keys in HCL files; reference them with `secret(...)` in a `credential` block. - Use `amicu destroy` to stop deployments so state stays in sync. - Run `amicu doctor` when local setup or provider credentials fail. ### Initialize a project with amicu init --example Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/quickstart.mdx Creates a directory and runs `amicu init --example` to generate a starter project. The `--example` flag picks a starter matching the detected machine: macOS gets `mac`, Linux with `nvidia-smi` gets `linux-cuda`, otherwise `linux-cpu`. Windows detection follows Linux rules. It creates `amicu.hcl`, `variables.amicu.hcl`, and `.amicu/`, and never overwrites existing files. ```bash mkdir my-stack && cd my-stack amicu init --example ``` -------------------------------- ### HCL example: model, hardware_profile, and deployment resources Source: https://github.com/andypalmi/amicu/blob/main/README.md Defines a Qwen3.5-27B model from Hugging Face, a local Apple Silicon hardware profile, and a deployment using llama_cpp runtime. The api_key is set with secret(...) and is required off-machine. The deployment records state before starting and removes it after stop is confirmed. ```hcl resource "model" "qwen35_27b" { source { registry = "hugging_face" reference = "unsloth/Qwen3.5-27B-GGUF" } architecture = "qwen35" modalities = ["text"] artifact { format = "gguf" quantization = "q4_k_m" } context_length = 262144 n_layers = 64 n_kv_layers = 16 n_kv_heads = 4 head_dim = 256 variant { quantization = "q4_k_m" file = "Qwen3.5-27B-Q4_K_M.gguf" size = "16740812704B" } } resource "hardware_profile" "local_dev" { provider = "local_apple" accelerator { kind = "apple_silicon" model = "m4_pro" count = 1 memory = "48GiB" } memory = "48GiB" } resource "deployment" "qwen35_27b_local" { model = model.qwen35_27b.id hardware = hardware_profile.local_dev.id runtime = "llama_cpp" llama_cpp { context_length = 262144 port = 8000 n_gpu_layers = -1 extra_args = ["--n-predict", "65536"] } } ``` -------------------------------- ### Bash: amicu init, plan, apply, destroy commands Source: https://github.com/andypalmi/amicu/blob/main/README.md Shows the core amicu CLI workflow. `amicu init --example` scaffolds a config sized to the machine, while plain `amicu init` writes an empty file. `amicu plan` checks memory fit and diffs against state, `amicu apply` shows the plan, asks approval, starts the model, and checks the endpoint, and `amicu destroy` stops and removes recorded deployments with approval. ```bash amicu init --example # scaffolds a config like the above, sized to this machine (plain `amicu init` writes an empty file) amicu plan # checks it fits in memory and shows what apply would do, diffed against state amicu apply # shows the plan, asks for approval, starts the model, checks the endpoint amicu destroy # stops and removes the recorded deployments (asks for approval) ``` -------------------------------- ### Full amicu local deployment example (HCL) Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/providers/local.mdx Defines a model, hardware profile, and deployment for a local setup. The model uses a Hugging Face GGUF file, the hardware profile targets Apple Silicon, and the deployment uses llama.cpp with GPU offloading. On Apple Silicon, n_gpu_layers = -1 offloads every layer to Metal; lower it or use 0 for CPU only if memory is tight. ```hcl resource "model" "support_chat" { source { registry = "hugging_face" reference = "unsloth/Qwen3.5-9B-GGUF" } architecture = "qwen35" modalities = ["text"] artifact { format = "gguf" quantization = "q4_k_m" } context_length = 8192 variant { quantization = "q4_k_m" file = "Qwen3.5-9B-Q4_K_M.gguf" size = "5680522464B" } } resource "hardware_profile" "dev_mac" { provider = "local_apple" accelerator { kind = "apple_silicon" model = "m4_pro" count = 1 memory = "48GiB" } memory = "48GiB" } resource "deployment" "support_local" { model = model.support_chat.id hardware = hardware_profile.dev_mac.id runtime = "llama_cpp" api_key = secret("LOCAL_API_KEY") llama_cpp { context_length = 8192 port = 8000 n_gpu_layers = -1 } } ``` -------------------------------- ### Validate, plan, and apply with amicu CLI Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/quickstart.mdx Runs `amicu doctor`, `amicu validate`, `amicu plan`, and `amicu apply` to check the environment, validate configuration, show the plan, and deploy. `doctor` and `plan` compare the local hardware profile with the machine; if the profile declares more memory than available, they print warning `AMICU-MEM-003`. `apply` shows the plan, asks for approval, installs a user service, starts it, and waits up to 15 minutes for `/health`. ```bash amicu doctor amicu validate amicu plan amicu apply ``` -------------------------------- ### List amicu init example flags Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/quickstart.mdx Shows the available `--example` flags for `amicu init`. Each flag selects a specific starter: `mac` for Apple Silicon, `linux-cuda` for NVIDIA GPU, `linux-cpu` for no GPU, and `modal` for Modal serverless GPU (Path B). The bare `--example` detects the machine automatically. ```bash amicu init --example # detect this machine amicu init --example mac # Apple Silicon, llama.cpp with Metal amicu init --example linux-cuda # NVIDIA GPU, llama.cpp with all layers on the GPU amicu init --example linux-cpu # no GPU, llama.cpp on the CPU amicu init --example modal # Modal serverless GPU (Path B) ``` -------------------------------- ### Install amicu on Windows with PowerShell Source: https://github.com/andypalmi/amicu/blob/main/README.md Uses the PowerShell installer to download and install amicu on Windows (x86_64). ```powershell powershell -ExecutionPolicy Bypass -c "irm https://amicu.dev/install.ps1 | iex" ``` -------------------------------- ### Install amicu with Homebrew Source: https://github.com/andypalmi/amicu/blob/main/README.md Installs amicu via the Homebrew tap andypalmi/tap. ```bash brew install andypalmi/tap/amicu ``` -------------------------------- ### Check amicu installation Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/quickstart.mdx Verify the installation by checking the version and help output. Run in a new terminal after installation. ```bash amicu --version amicu --help ``` -------------------------------- ### Install amicu from source with Cargo Source: https://github.com/andypalmi/amicu/blob/main/README.md Builds and installs amicu-cli from the GitHub repository. Requires Rust 1.97 or newer. Installs into ~/.cargo/bin. ```bash cargo install --locked --git https://github.com/andypalmi/amicu amicu-cli # installs into ~/.cargo/bin ``` -------------------------------- ### Install amicu on macOS and Linux Source: https://github.com/andypalmi/amicu/blob/main/README.md Downloads a prebuilt binary and places it in ~/.local/bin. The installer edits your shell profile, so open a new shell before running amicu. ```bash curl -LsSf https://amicu.dev/install.sh | sh ``` -------------------------------- ### Starter amicu.hcl configuration for local deployment Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/quickstart.mdx Example `amicu.hcl` generated by `amicu init --example`. Defines a model resource, hardware profile, and deployment for a local Apple Silicon machine with 48 GiB memory. The model id, file name, and context length depend on the machine. `variant.size` is an integer number of bytes; `"16740812704B"` and `"16740812704"` mean the same. The hardware profile is what `init` detected; change it only if planning for another machine. ```hcl resource "model" "qwen35_27b" { source { registry = "hugging_face" reference = "unsloth/Qwen3.5-27B-GGUF" } architecture = "qwen35" modalities = ["text"] artifact { format = "gguf" quantization = "q4_k_m" } context_length = 262144 n_layers = 64 n_kv_layers = 16 n_kv_heads = 4 head_dim = 256 variant { quantization = "q4_k_m" file = "Qwen3.5-27B-Q4_K_M.gguf" size = "16740812704B" } } resource "hardware_profile" "local_dev" { provider = "local_apple" accelerator { kind = "apple_silicon" model = "m4_pro" count = 1 memory = "48GiB" } memory = "48GiB" } resource "deployment" "qwen35_27b_local" { model = model.qwen35_27b.id hardware = hardware_profile.local_dev.id runtime = "llama_cpp" llama_cpp { context_length = 262144 port = 8000 n_gpu_layers = -1 extra_args = ["--n-predict", "65536"] } } ``` -------------------------------- ### Install vLLM with pip install vllm Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/troubleshooting.mdx Install vLLM into the environment whose PATH runs amicu apply. The error 'vllm not found on PATH' indicates it is missing. ```bash pip install vllm ``` -------------------------------- ### Hetzner GPU hardware profile in HCL Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/providers/hetzner.mdx Example hardware_profile resource for Hetzner with a GPU accelerator. Running amicu apply against this profile fails before anything starts; use amicu validate and amicu plan to check it today. ```hcl resource "hardware_profile" "hetzner_gpu" { provider = "hetzner" region = "fsn1" accelerator { kind = "gpu" model = "rtx-4000-ada-20gb" count = 1 memory = "20GiB" } memory = "64GiB" } ``` -------------------------------- ### Install llama.cpp on macOS with brew install llama.cpp Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/troubleshooting.mdx Install llama.cpp so that llama-server is on the PATH of the shell running amicu apply. The error 'llama-server not found on PATH' indicates it is missing. ```bash brew install llama.cpp ``` -------------------------------- ### Start amicu-server with non-owning role in production Source: https://github.com/andypalmi/amicu/blob/main/README.md Starts the amicu-server in production mode using a separate, non-owning role (amicu_app) that lacks SUPERUSER and BYPASSRLS privileges. On boot, it verifies no pending migrations and refuses to start if the connected role would bypass row-level security, including inherited privileges. ```bash DATABASE_URL=postgres://amicu_app:...@host/amicu AMICU_ENV=production amicu-server ``` -------------------------------- ### AWS hardware_profile example Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/providers/aws.mdx Example hardware profile for an AWS GPU instance in eu-central-1 with an L40S accelerator. Running `amicu apply` against this profile fails; use `amicu validate` and `amicu plan` instead. ```hcl resource "hardware_profile" "aws_gpu" { provider = "aws" region = "eu-central-1" accelerator { kind = "gpu" model = "l40s" count = 1 memory = "48GiB" } memory = "32GiB" } ``` -------------------------------- ### Nebius hardware_profile configuration example Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/providers/nebius.mdx Example HCL configuration for a Nebius hardware profile using the `hardware_profile` resource. It specifies the provider as "nebius", region "eu-north1", an H100 GPU accelerator, and host memory. Running `amicu apply` against this profile fails; use `amicu validate` and `amicu plan` instead. ```hcl resource "hardware_profile" "nebius_gpu" { provider = "nebius" region = "eu-north1" accelerator { kind = "gpu" model = "h100-sxm-80gb" count = 1 memory = "80GiB" } memory = "200GiB" } ``` -------------------------------- ### Start Postgres and set DATABASE_URL for development Source: https://github.com/andypalmi/amicu/blob/main/README.md Brings up the bundled Postgres container and sets the DATABASE_URL environment variable for local development or self-hosting. The connection string uses the amicu_app role, which is a dedicated non-superuser role provisioned by the init script. Avoid connecting as the superuser to ensure row-level security remains effective. ```bash docker compose up -d postgres export DATABASE_URL=postgres://amicu_app:amicu_app@localhost:5432/amicu ``` -------------------------------- ### Azure GPU hardware profile configuration Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/providers/azure.mdx Example hardware_profile resource for Azure using a GPU accelerator. Running amicu apply against this profile fails; use amicu validate and amicu plan instead. ```hcl resource "hardware_profile" "azure_gpu" { provider = "azure" region = "germanywestcentral" accelerator { kind = "gpu" model = "a100-pcie-80gb" count = 1 memory = "80GiB" } memory = "220GiB" } ``` -------------------------------- ### Test Modal endpoint with curl Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/quickstart.mdx Ready-to-copy curl command printed after apply finishes. Requires both Modal proxy credentials and the CHAT_API_KEY. A 503 during cold start is normal. ```bash curl "$URL/v1/chat/completions" \ -H "Authorization: Bearer $CHAT_API_KEY" \ -H "Modal-Key: $MODAL_PROXY_TOKEN_ID" \ -H "Modal-Secret: $MODAL_PROXY_TOKEN_SECRET" \ -H "Content-Type: application/json" \ -d '{"model": "RedHatAI/Qwen3.5-9B-FP8-dynamic", "messages": [{"role": "user", "content": "Hello"}]}' ``` -------------------------------- ### JSON output example for orphans command Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/operate/orphans.mdx Example JSON output from the 'orphans' command when using '--output json'. It includes tracked resources with 'tracked: true' and provides fields like 'sources', 'resources', and 'note'. The 'note' field repeats the scope warning that not tracked does not mean orphaned. ```json { "version": "v1", "sources": [ { "name": "modal", "status": "ok" }, { "name": "launchd", "status": "skipped", "detail": "not macOS" } ], "resources": [ { "kind": "launchd_job", "identity": "io.amicu.llama.1a2b3c4d.chat", "state": "loaded, not running", "tracked": false, "ownership": "this_project", "stop_command": "launchctl unload -w /Users/you/Library/LaunchAgents/io.amicu.llama.1a2b3c4d.chat.plist && rm /Users/you/Library/LaunchAgents/io.amicu.llama.1a2b3c4d.chat.plist" } ], "note": "..." } ``` -------------------------------- ### GCP hardware_profile configuration Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/providers/gcp.mdx Example hardware_profile resource for a GCP GPU instance in europe-west4 with an L4 accelerator. Running amicu apply against this profile fails; use amicu validate and amicu plan instead. ```hcl resource "hardware_profile" "gcp_gpu" { provider = "gcp" region = "europe-west4" accelerator { kind = "gpu" model = "l4" count = 1 memory = "24GiB" } memory = "32GiB" } ``` -------------------------------- ### HCL deployment with extra_args and env Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/configuration/deployment.mdx Example deployment resource using extra_args to pass --no-warmup and env to set GGML_CUDA_DISABLE_GRAPHS. Duplicate typed fields trigger AMICU-CAP-002; denylisted flags/variables trigger AMICU-CAP-003; non-empty extra_args gives AMICU-CAP-004 (info) that memory fit is unverified; secrets should go in api_key, not env (AMICU-POLICY-006). ```hcl resource "deployment" "tuned" { model = model.qwen3_8b.id hardware = hardware_profile.local_dev.id runtime = "llama_cpp" llama_cpp { context_length = 8192 port = 8001 n_gpu_layers = -1 extra_args = ["--no-warmup"] env { GGML_CUDA_DISABLE_GRAPHS = "1" } } } ``` -------------------------------- ### GET /v1/models Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/providers/modal.mdx Lists the models available on the Modal-hosted vLLM endpoint. Requires both the Modal proxy token and the deployment's API key. ```APIDOC ## GET /v1/models ### Description Lists the models available on the Modal-hosted vLLM endpoint. Requires both the Modal proxy token and the deployment's API key. ### Method GET ### Endpoint /v1/models ### Parameters #### Headers - **Authorization** (string) - Required - Bearer token with the deployment's API key (`$CHAT_API_KEY`). - **Modal-Key** (string) - Required - Modal proxy token ID (`$MODAL_PROXY_TOKEN_ID`). - **Modal-Secret** (string) - Required - Modal proxy token secret (`$MODAL_PROXY_TOKEN_SECRET`). ### Request Example ```bash curl "$URL/v1/models" \ -H "Authorization: Bearer $CHAT_API_KEY" \ -H "Modal-Key: $MODAL_PROXY_TOKEN_ID" \ -H "Modal-Secret: $MODAL_PROXY_TOKEN_SECRET" ``` ### Response #### Success Response (200) Returns a list of available models. #### Error Handling - **503** - Container is cold-starting; retry after it warms up. - **401/403** - Invalid credentials (gateway credentials without the API key are rejected). ``` -------------------------------- ### Example resource block in HCL Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/configuration/index.mdx Shows the structure of a `resource` block with nested blocks and attributes. The `resource` block uses two labels: kind and id. Nested blocks like `source`, `artifact`, and `variant` take no labels. Attributes use `name = value` syntax with quoted strings, lists in brackets, and bare numbers/booleans. ```hcl resource "model" "qwen3_8b" { source { registry = "hugging_face" reference = "Qwen/Qwen3.5-8B-Instruct" } architecture = "qwen3" modalities = ["text"] artifact { format = "gguf" quantization = "q4_k_m" } variant { quantization = "q4_k_m" file = "qwen3.5-8b-instruct-q4_k_m.gguf" size = "5GiB" } } ``` -------------------------------- ### credential resource example in HCL Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/configuration/credential.mdx Defines a credential resource named 'registry' with a token secret reference and an env block mapping EXTRA_VAR to a secret. All fields must use secret("NAME") syntax; literal values are rejected at parse time with AMICU-POLICY-004. ```hcl resource "credential" "registry" { token = secret("HF_TOKEN") env { EXTRA_VAR = secret("EXTRA_SECRET") } } ``` -------------------------------- ### OVHcloud hardware_profile HCL configuration Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/providers/ovhcloud.mdx Example HCL resource block for an OVHcloud GPU hardware profile. Uses provider "ovhcloud", region "GRA", an l40s GPU with 48GiB VRAM, and 128GiB host memory. Note that `amicu apply` is not supported yet; use `amicu validate` and `amicu plan` to check the configuration. ```hcl resource "hardware_profile" "ovh_gpu" { provider = "ovhcloud" region = "GRA" accelerator { kind = "gpu" model = "l40s" count = 1 memory = "48GiB" } memory = "128GiB" } ``` -------------------------------- ### Clone and build amicu from source Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/quickstart.mdx Clones the repository, builds the amicu-cli release binary, and adds it to PATH. Then verifies with --help. ```bash git clone https://github.com/andypalmi/amicu.git cd amicu cargo build --release -p amicu-cli export PATH="$PWD/target/release:$PATH" amicu --help ``` -------------------------------- ### Declare a hardware profile with the on_prem provider Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/providers/self-hosted.mdx Use the `on_prem` provider to declare a hardware profile with a GPU accelerator. This is the only provider `apply` accepts today; `self-hosted` is not yet supported. Run amicu on the host itself and execute `amicu apply` there. ```hcl resource "hardware_profile" "rack_gpu" { provider = "on_prem" accelerator { kind = "gpu" model = "l40s" count = 1 memory = "48GiB" } memory = "128GiB" } ``` -------------------------------- ### Clone and build amicu from source Source: https://github.com/andypalmi/amicu/blob/main/README.md Clones the repository and builds the amicu-cli binary in release mode. The resulting binary is at ./target/release/amicu. ```bash git clone https://github.com/andypalmi/amicu.git cd amicu cargo build --release -p amicu-cli # binary: ./target/release/amicu ``` -------------------------------- ### OpenAI Python SDK Client Initialization Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/providers/modal.mdx Shows how to initialize the OpenAI Python SDK client to interact with the Modal-hosted vLLM endpoint, including the required proxy headers. ```APIDOC ## OpenAI Python SDK Client Initialization ### Description Initializes the OpenAI Python SDK client to interact with the Modal-hosted vLLM endpoint. The client must include the Modal proxy headers in addition to the API key. ### Usage ```python client = OpenAI( base_url=f"{url}/v1", api_key=os.environ["CHAT_API_KEY"], default_headers={ "Modal-Key": os.environ["MODAL_PROXY_TOKEN_ID"], "Modal-Secret": os.environ["MODAL_PROXY_TOKEN_SECRET"], }, ) ``` ### Notes - The `base_url` is the endpoint URL plus `/v1`. - The `api_key` is the deployment's API key. - The `default_headers` must include `Modal-Key` and `Modal-Secret` for proxy authentication. - Modal's proxy rejects `Authorization: Bearer` as proxy credentials; use separate `Modal-Key` and `Modal-Secret` headers. ``` -------------------------------- ### Set endpoint key and apply local deployment (bash) Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/providers/local.mdx Exports a random 32-byte hex key as LOCAL_API_KEY, applies the amicu configuration, and tests the local endpoint with curl. The key is passed to the service as LLAMA_API_KEY (llama.cpp) or VLLM_API_KEY (vLLM) via a private file, never the command line. Without an api_key, the endpoint is loopback only and the anonymous request check is skipped. ```bash export LOCAL_API_KEY=$(openssl rand -hex 32) amicu apply curl http://127.0.0.1:8000/v1/models -H "Authorization: Bearer $LOCAL_API_KEY" ``` -------------------------------- ### llama.cpp deployment on Modal with GGUF model Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/providers/modal.mdx Defines a model, hardware profile, and deployment for running a GGUF Qwen3.5-9B on Modal with llama.cpp. A GGUF variant.file becomes -hf -hff , and variant.size must be an integer byte size string. Amicu appends --host 0.0.0.0, --no-mmproj (unless multimodal), and --metrics. Flags referring to local files and secret-bearing flags are rejected before any Modal call. ```hcl resource "model" "qwen35_9b_gguf" { source { registry = "hugging_face" reference = "unsloth/Qwen3.5-9B-GGUF" } architecture = "qwen3" modalities = ["text"] artifact { format = "gguf" quantization = "q6_k" } context_length = 32768 variant { quantization = "q6_k" file = "Qwen3.5-9B-UD-Q6_K_XL.gguf" size = "8350MiB" } } resource "hardware_profile" "modal_l4" { provider = "modal" accelerator { kind = "gpu" model = "l4" count = 1 memory = "24GiB" } memory = "32GiB" } resource "deployment" "qwen35_modal" { model = model.qwen35_9b_gguf.id hardware = hardware_profile.modal_l4.id runtime = "llama_cpp" api_key = secret("QWEN35_MODAL_API_KEY") llama_cpp { context_length = 32768 port = 8080 n_gpu_layers = -1 } } ``` -------------------------------- ### Define data_class and governance_rule in HCL Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/configuration/governance-rule.mdx Example HCL configuration that defines a data_class for confidential data with EU residency and a governance_rule that allows only the modal provider and EU regions. The rule references the data_class by its id. ```hcl resource "data_class" "company_confidential" { sensitivity = "confidential" residency = ["eu"] } resource "governance_rule" "eu_only" { description = "EU regions on one GPU provider only" effect = "allow" data_classes = [data_class.company_confidential.id] allowed_providers = ["modal"] allowed_regions = ["eu", "eu-west"] } ``` -------------------------------- ### Define a budget resource with tenant and monthly limit Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/configuration/budget.mdx Creates a tenant and a budget resource. The budget references the tenant, sets a monthly limit of 2000 EUR, and defines alert thresholds at 0.5, 0.8, and 1.0 fractions of the limit. ```hcl resource "tenant" "team_research" { display_name = "Research" } resource "budget" "research_monthly" { tenant = tenant.team_research.id limit { amount = 2000 currency = "EUR" } period = "monthly" alert_thresholds = [0.5, 0.8, 1.0] } ``` -------------------------------- ### Configure network volume and flashboot in runpod block Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/providers/runpod.mdx Use this HCL block in your amicu configuration to point at an existing RunPod network volume and enable flashboot. The volume must already exist; amicu never creates, resizes, or deletes it. Workers are placed only in the volume's data center, and the volume is mounted at /runpod-volume. ```hcl runpod { network_volume = "agv6w2qcg7" flashboot = true } ``` -------------------------------- ### vLLM deployment on Modal with Qwen model Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/providers/modal.mdx Defines a model, hardware profile, and deployment for running Qwen3.5-9B-FP8-dynamic on Modal with vLLM. Note that accelerator.count becomes Modal's GPU string (L4:2), tensor_parallel_size is not derived from count, and NCCL_P2P_DISABLE works around an intermittent NCCL error on GPUs without NVLink. Plain env values are baked into the image, so never put secrets there. ```hcl resource "model" "qwen_fp8" { source { registry = "hugging_face" reference = "RedHatAI/Qwen3.5-9B-FP8-dynamic" } architecture = "qwen3" modalities = ["text"] artifact { format = "safetensors" quantization = "fp8" } context_length = 262144 } resource "hardware_profile" "modal_2xl4" { provider = "modal" region = "eu-west" accelerator { kind = "gpu" model = "l4" count = 2 memory = "24GiB" } memory = "64GiB" } resource "deployment" "qwen_tp2" { model = model.qwen_fp8.id hardware = hardware_profile.modal_2xl4.id runtime = "vllm" api_key = secret("QWEN_TP2_API_KEY") vllm { context_length = 262144 port = 8000 tensor_parallel_size = 2 env { NCCL_P2P_DISABLE = "1" } } } ``` -------------------------------- ### Amicu CLI commands overview Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/index.mdx Lists the primary Amicu CLI commands: init, validate, plan, apply, and destroy, with brief comments on their purpose. The workflow mirrors Terraform's declarative configuration and state management. ```bash amicu init # scaffold .amicu/ and an empty amicu.hcl (add --example for a starter) amicu validate # structural, reference, capacity, and policy checks amicu plan # what apply would do, diffed against state amicu apply # start, update, or stop deployments after approval amicu destroy # stop deployments and remove them from state (--purge also deletes their logs) ``` -------------------------------- ### apply --output json Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/reference/cli.mdx Applies the plan and outputs only the resulting endpoint handles to stdout when `--output json` is used. The plan preview and approval prompt go to stderr. ```APIDOC ## apply --output json ### Description Applies the plan and outputs only the resulting endpoint handles to stdout when `--output json` is used. The plan preview and approval prompt go to stderr. ### Command `amicu apply --output json` ### Parameters #### Optional Flags - `--output json` (string) - Optional - Output the result as JSON. ### Response #### Success Response (200) stdout carries only the resulting endpoint handles. The plan preview and approval prompt go to stderr. ### Notes - If telemetry is enabled, `amicu apply` starts a small agent that uploads aggregate performance rollups. ``` -------------------------------- ### amicu modal metrics [--watch] [--interval N] Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/providers/modal.mdx Shows a runtime and hardware snapshot for a Modal app. Scrapes the runtime's /metrics endpoint through the app's Modal URL and needs the proxy token pair. A scaled-to-zero app is woken by the request, so the first call can be slow. For vLLM it shows request counts, token counts, KV cache usage, preemptions, and latency percentiles; for llama.cpp it shows request and token counters and tokens per second (latency percentiles are n/a). Tokens per second needs two scrapes, so use --watch. Per-container hardware metrics (utilization, memory, temperature, power) come from a read-only probe in each container; if it fails, they show n/a. ```APIDOC ## amicu modal metrics [--watch] [--interval N] ### Description Shows a runtime and hardware snapshot for a Modal app. Scrapes the runtime's /metrics endpoint through the app's Modal URL and needs the proxy token pair. A scaled-to-zero app is woken by the request, so the first call can be slow. For vLLM it shows request counts, token counts, KV cache usage, preemptions, and latency percentiles; for llama.cpp it shows request and token counters and tokens per second (latency percentiles are n/a). Tokens per second needs two scrapes, so use --watch. Per-container hardware metrics (utilization, memory, temperature, power) come from a read-only probe in each container; if it fails, they show n/a. ### Command `amicu modal metrics [--watch] [--interval N]` ### Parameters - `` (string) - Required - The app name recorded in state. - `--watch` (flag) - Optional - Continuously update metrics. - `--interval N` (integer) - Optional - Interval between updates when watching. ### Output - Runtime and hardware snapshot. - For vLLM: request counts, token counts, KV cache usage, preemptions, and latency percentiles. - For llama.cpp: request and token counters and tokens per second (latency percentiles are `n/a`). - Per-container hardware metrics: utilization, memory, temperature, power (or `n/a` if probe fails). ``` -------------------------------- ### Set CHAT_API_KEY and apply Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/security/secrets.mdx Generates a random hex key and exports it as CHAT_API_KEY, then runs amicu apply. The apply command reads the variable from the environment of the process that runs it. ```bash export CHAT_API_KEY=$(openssl rand -hex 32) amicu apply ``` -------------------------------- ### Set RunPod and Chat API Keys as Environment Variables Source: https://github.com/andypalmi/amicu/blob/main/README.md Required before running amicu apply for RunPod. RUNPOD_API_KEY is the management key for plan, apply, destroy, and amicu runpod commands. CHAT_API_KEY is a second RunPod key with api.runpod.ai access for Serverless endpoints. ```bash export RUNPOD_API_KEY=... # management key: plan, apply, destroy, amicu runpod export CHAT_API_KEY=... # Serverless: a second RunPod key with api.runpod.ai access ``` -------------------------------- ### llama.cpp deployment on local hardware Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/configuration/deployment.mdx Defines a deployment using the llama.cpp runtime on a local hardware profile. Sets context length, port, and GPU layers. ```hcl resource "deployment" "support_local" { model = model.qwen3_8b.id hardware = hardware_profile.local_dev.id runtime = "llama_cpp" llama_cpp { context_length = 8192 port = 8000 n_gpu_layers = -1 } } ``` -------------------------------- ### amicu command syntax Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/reference/cli.mdx Shows the general syntax for amicu commands. The --output flag is global and defaults to human. Run 'amicu --help' for the authoritative flag list. ```text amicu [--output human|json] ``` -------------------------------- ### Deployment with memory_check set to warn Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/configuration/deployment.mdx Shows how to set `memory_check = "warn"` on a deployment to turn memory rejection into a warning. The comment indicates additional fields are omitted. ```hcl resource "deployment" "chat" { memory_check = "warn" # ... } ``` -------------------------------- ### Run amicu destroy Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/quickstart.mdx Lists all deployments recorded in state and prompts for confirmation before stopping and removing them. Use `--target ` to destroy specific deployments, `--auto-approve` (alias `--yes`) to skip the prompt, and `--purge` to also delete host log files. On macOS and Linux, the service file (holding the endpoint API key) is deleted; on Windows, the scheduled task and its definition, launcher, pid, and environment files are deleted. Modal cache volumes are never deleted. ```bash amicu destroy ``` -------------------------------- ### amicu modal logs [--follow] [--since ] Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/providers/modal.mdx Retrieves logs for a Modal app. Without --follow, prints available logs and returns. With --follow, streams logs until the app ends or Ctrl-C is pressed. --since resumes just past a log entry id. ```APIDOC ## amicu modal logs [--follow] [--since ] ### Description Retrieves logs for a Modal app. Without --follow, prints available logs and returns. With --follow, streams logs until the app ends or Ctrl-C is pressed. --since resumes just past a log entry id. ### Command `amicu modal logs [--follow] [--since ]` ### Parameters - `` (string) - Required - The app name recorded in state. - `--follow` (flag) - Optional - Stream logs until the app ends or Ctrl-C is pressed. - `--since ` (string) - Optional - Resume just past a log entry id. ### Output Lines tagged `[stdout]`, `[stderr]`, or `[info]`. ### Errors - If the app is missing, prints `no deployment named ` and exits 1. ``` -------------------------------- ### amicu modal metrics Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/reference/cli.mdx Shows runtime and hardware metrics for a Modal app. Supports watching with a configurable interval. ```APIDOC ## amicu modal metrics ### Description Shows runtime and hardware metrics for a Modal app. Supports watching with a configurable interval. ### Command `amicu modal metrics [--watch] [--interval ]` ### Parameters #### Arguments - `` (string) - Required - Modal app name recorded in state, of the form `amicu---`; older apps are `amicu-` plus the deployment id. #### Options - `--watch` (flag) - Optional - Continuously prints metrics. - `--interval` (integer) - Optional - Interval in seconds between snapshots. Defaults to 5 and must be at least 1. ### Notes - Reads `MODAL_TOKEN_ID` and `MODAL_TOKEN_SECRET` from the environment. - Requires `MODAL_PROXY_TOKEN_ID` and `MODAL_PROXY_TOKEN_SECRET`. ### Example ```bash amicu modal metrics amicu-my-project-my-deployment-abc123 --watch --interval 10 ``` ``` -------------------------------- ### Run amicu orphans Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/operate/orphans.mdx Lists untracked amicu resources. The `--output json` flag outputs JSON. Run in the project directory; it reads `.amicu/state/state.json`. ```bash amicu orphans amicu orphans --output json ``` -------------------------------- ### amicu telemetry enable Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/reference/cli.mdx Records opt-in to sharing aggregate performance metrics. This command does not require a project and makes no network calls. ```APIDOC ## amicu telemetry enable ### Description Records opt-in to sharing aggregate performance metrics. This command does not require a project and makes no network calls. ### Command `amicu telemetry enable` ### Parameters None. ### Response No output on success. The choice is stored in `$XDG_CONFIG_HOME/amicu/telemetry.json` or `~/.config/amicu/telemetry.json` when `XDG_CONFIG_HOME` is not set. ``` -------------------------------- ### Export amicu skills for all targets Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/reference/agent-skills.mdx Run `amicu skill export` without `--target` to export for every target into each default directory, printing what was written where. The command works without a project. ```bash amicu skill export --target claude-code amicu skill export --target cursor amicu skill export --target windsurf amicu skill export --target generic --path ./agent-guidance ``` -------------------------------- ### Restore state.json from backup Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/operate/state-and-backends.mdx If state.json is corrupt or missing but state.json.bak is valid, amicu refuses to continue and names the backup. Restore it with this command. ```bash cp .amicu/state/state.json.bak .amicu/state/state.json ``` -------------------------------- ### Send a chat completion request with curl Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/quickstart.mdx Sends a chat completion request to the local deployment at `127.0.0.1:8000`. No API key header is needed because the deployment has no `api_key`. If the request fails, check the service log; a missing or wrong GGUF path is the usual cause. ```bash curl http://127.0.0.1:8000/v1/chat/completions \ -H "Content-Type: application/json" \ -d '{"model": "unsloth/Qwen3.5-27B-GGUF", "messages": [{"role": "user", "content": "Hello"}]}' ``` -------------------------------- ### OpenAI Python SDK client with Modal proxy headers Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/providers/modal.mdx Configure the OpenAI Python SDK to use the Modal endpoint with the deployment API key and the Modal proxy token headers. The proxy rejects Authorization Bearer as proxy credentials, so Modal-Key and Modal-Secret must be passed as separate headers. ```python client = OpenAI( base_url=f"{url}/v1", api_key=os.environ["CHAT_API_KEY"], default_headers={ "Modal-Key": os.environ["MODAL_PROXY_TOKEN_ID"], "Modal-Secret": os.environ["MODAL_PROXY_TOKEN_SECRET"], }, ) ``` -------------------------------- ### vLLM deployment on Modal with model and hardware profile Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/configuration/deployment.mdx Defines a model, hardware profile, and deployment for a vLLM runtime on a remote GPU provider (Modal). Includes an API key, autoscaling limits, and vLLM settings. ```hcl resource "model" "chat_prod" { source { registry = "hugging_face" reference = "Qwen/Qwen3-8B" } architecture = "qwen3" modalities = ["text"] artifact { format = "safetensors" } context_length = 32768 } resource "hardware_profile" "gpu_a100" { provider = "modal" region = "eu-west" accelerator { kind = "gpu" model = "a100-sxm4-80gb" count = 2 memory = "80GiB" } memory = "64GiB" } resource "deployment" "chat_prod" { model = model.chat_prod.id hardware = hardware_profile.gpu_a100.id runtime = "vllm" api_key = secret("CHAT_API_KEY") vllm { context_length = 32768 port = 8000 tensor_parallel_size = 2 gpu_memory_utilization = 0.90 } scaling { min_replicas = 0 max_replicas = 1 scaledown_window = "15m" } } ``` -------------------------------- ### amicu runpod metrics Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/reference/cli.mdx Shows runtime metrics for a RunPod deployment, scraped through the RunPod gateway. Supports watching and waking a scaled-to-zero endpoint. ```APIDOC ## amicu runpod metrics ### Description Shows runtime metrics for a RunPod deployment, scraped through the RunPod gateway. Supports watching and waking a scaled-to-zero endpoint. ### Command `amicu runpod metrics [--watch] [--interval ] [--wake]` ### Parameters #### Arguments - `` (string) - Required - Deployment name recorded in the project's state. #### Options - `--watch` (flag) - Optional - Prints a new snapshot every `--interval` seconds and keeps the endpoint warm (and billed) while it runs. - `--interval` (integer) - Optional - Interval in seconds between snapshots. Defaults to 5, at least 1. - `--wake` (flag) - Optional - Allows the request to start a billed worker for a scaled-to-zero endpoint. A pod is always on, so `--wake` does not apply. ### Notes - Reads `RUNPOD_API_KEY` from the environment. - Uses the deployment's `api_key` for scraping. - Hardware metrics are not available on RunPod. - The load balancer answers from one worker of its choosing, so with several workers the figures describe one of them. ### Example ```bash amicu runpod metrics my-deployment --watch --interval 10 ``` ``` -------------------------------- ### Export RunPod management and endpoint keys Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/providers/runpod.mdx Exports the RunPod management key and the endpoint key as environment variables. The management key is used for plan/apply refresh, apply, destroy, and amicu runpod. The endpoint key must be a separate RunPod API key with api.runpod.ai access, as amicu refuses a deployment whose api_key is the management key. ```bash export RUNPOD_API_KEY=... # management key export CHAT_API_KEY=... # endpoint key ``` -------------------------------- ### Stop instances manually on Linux Source: https://github.com/andypalmi/amicu/blob/main/web/apps/web/content/docs/operate/state-and-backends.mdx Stop each instance by hand on Linux when state is lost or corrupt with no usable backup. ```bash systemctl --user disable --now