diff --git a/CHANGELOG.md b/CHANGELOG.md
index ea17fe4..df9d292 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -28,9 +28,21 @@ step 1 (Hugging Face downloader) is released as a minor version.
traceback), followed by the last lines of output.
- A deployment's vLLM data type replaces the runtime's `--dtype` instead of repeating the flag.
- Models and runtimes used by a deployment can't be deleted until the deployment is.
+- **API keys** (Settings → API keys): add generated or own keys, show and copy them again later.
+ A deployment with "Require an API key" accepts any of them (`LLAMA_API_KEY`, `VLLM_API_KEY` or
+ `--api-key` for several vLLM keys); the values are masked in the shown command and in the log, and
+ Kaname's own "Try it" chat sends one. Key changes apply when a deployment restarts.
+- **Deploy from the library:** a "Deploy" button in the library and on the model page opens a new
+ deployment with the model and a fitting runtime preselected. The library and the model page link
+ to the deployments that use a model.
+- Deployment form reorganized: launch options in groups (General, Context, Performance, KV cache,
+ Resources, Extra arguments) with each field's flag next to its label, the command in its own step,
+ and extra arguments as flag/value rows with "+ Add argument" (also in the runtime form).
### Fixed
+- Dropdowns were unreadable in dark mode (white option list with light text): native controls now
+ follow the theme.
- Image pulls showed "Starting · 0 B" until they finished: the worker's progress updates were never
written (Drizzle queries only run when awaited).
diff --git a/drizzle/0012_api_keys.sql b/drizzle/0012_api_keys.sql
new file mode 100644
index 0000000..3d1f5d1
--- /dev/null
+++ b/drizzle/0012_api_keys.sql
@@ -0,0 +1,8 @@
+CREATE TABLE `api_keys` (
+ `id` text PRIMARY KEY NOT NULL,
+ `name` text NOT NULL,
+ `key` text NOT NULL,
+ `created_at` integer NOT NULL
+);
+--> statement-breakpoint
+CREATE UNIQUE INDEX `api_keys_key_unique` ON `api_keys` (`key`);
\ No newline at end of file
diff --git a/drizzle/meta/0012_snapshot.json b/drizzle/meta/0012_snapshot.json
new file mode 100644
index 0000000..9039a2e
--- /dev/null
+++ b/drizzle/meta/0012_snapshot.json
@@ -0,0 +1,1523 @@
+{
+ "version": "6",
+ "dialect": "sqlite",
+ "id": "0d459c4f-2846-4f48-a248-25ef06279cb6",
+ "prevId": "4d24a2c4-682c-4a99-946f-ceb7fd1d1bae",
+ "tables": {
+ "api_keys": {
+ "name": "api_keys",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "api_keys_key_unique": {
+ "name": "api_keys_key_unique",
+ "columns": [
+ "key"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "deployment_logs": {
+ "name": "deployment_logs",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "deployment_id": {
+ "name": "deployment_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "ts": {
+ "name": "ts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "stream": {
+ "name": "stream",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "line": {
+ "name": "line",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "deployment_logs_idx": {
+ "name": "deployment_logs_idx",
+ "columns": [
+ "deployment_id",
+ "id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "deployment_logs_deployment_id_deployments_id_fk": {
+ "name": "deployment_logs_deployment_id_deployments_id_fk",
+ "tableFrom": "deployment_logs",
+ "tableTo": "deployments",
+ "columnsFrom": [
+ "deployment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "deployments": {
+ "name": "deployments",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "runtime_id": {
+ "name": "runtime_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "model_id": {
+ "name": "model_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "options": {
+ "name": "options",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "cpus": {
+ "name": "cpus",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "memory_mb": {
+ "name": "memory_mb",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "host_port": {
+ "name": "host_port",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "desired_state": {
+ "name": "desired_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'stopped'"
+ },
+ "state": {
+ "name": "state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'stopped'"
+ },
+ "delete_requested_at": {
+ "name": "delete_requested_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "container_id": {
+ "name": "container_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "container_name": {
+ "name": "container_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "command": {
+ "name": "command",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "image_id": {
+ "name": "image_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "ready_at": {
+ "name": "ready_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "stopped_at": {
+ "name": "stopped_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "exit_code": {
+ "name": "exit_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "error": {
+ "name": "error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "stats": {
+ "name": "stats",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "deployments_runtime_id_runtimes_id_fk": {
+ "name": "deployments_runtime_id_runtimes_id_fk",
+ "tableFrom": "deployments",
+ "tableTo": "runtimes",
+ "columnsFrom": [
+ "runtime_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "deployments_model_id_models_id_fk": {
+ "name": "deployments_model_id_models_id_fk",
+ "tableFrom": "deployments",
+ "tableTo": "models",
+ "columnsFrom": [
+ "model_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "job_files": {
+ "name": "job_files",
+ "columns": {
+ "job_id": {
+ "name": "job_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "model_file_id": {
+ "name": "model_file_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "expected_bytes": {
+ "name": "expected_bytes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "done_bytes": {
+ "name": "done_bytes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "state": {
+ "name": "state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'pending'"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "job_files_job_id_jobs_id_fk": {
+ "name": "job_files_job_id_jobs_id_fk",
+ "tableFrom": "job_files",
+ "tableTo": "jobs",
+ "columnsFrom": [
+ "job_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "job_files_model_file_id_model_files_id_fk": {
+ "name": "job_files_model_file_id_model_files_id_fk",
+ "tableFrom": "job_files",
+ "tableTo": "model_files",
+ "columnsFrom": [
+ "model_file_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "job_files_job_id_model_file_id_pk": {
+ "columns": [
+ "job_id",
+ "model_file_id"
+ ],
+ "name": "job_files_job_id_model_file_id_pk"
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "job_logs": {
+ "name": "job_logs",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": true
+ },
+ "job_id": {
+ "name": "job_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "ts": {
+ "name": "ts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "stream": {
+ "name": "stream",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "line": {
+ "name": "line",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "job_logs_job_idx": {
+ "name": "job_logs_job_idx",
+ "columns": [
+ "job_id",
+ "id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "job_logs_job_id_jobs_id_fk": {
+ "name": "job_logs_job_id_jobs_id_fk",
+ "tableFrom": "job_logs",
+ "tableTo": "jobs",
+ "columnsFrom": [
+ "job_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "jobs": {
+ "name": "jobs",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "model_id": {
+ "name": "model_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "purpose": {
+ "name": "purpose",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "target_sha": {
+ "name": "target_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "state": {
+ "name": "state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'queued'"
+ },
+ "attempt": {
+ "name": "attempt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "total_bytes": {
+ "name": "total_bytes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "done_bytes": {
+ "name": "done_bytes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "speed_bps": {
+ "name": "speed_bps",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "eta_seconds": {
+ "name": "eta_seconds",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "exit_code": {
+ "name": "exit_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "error_code": {
+ "name": "error_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "result": {
+ "name": "result",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "cancel_requested_at": {
+ "name": "cancel_requested_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "finished_at": {
+ "name": "finished_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "jobs_state_idx": {
+ "name": "jobs_state_idx",
+ "columns": [
+ "state"
+ ],
+ "isUnique": false
+ },
+ "jobs_model_idx": {
+ "name": "jobs_model_idx",
+ "columns": [
+ "model_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "jobs_model_id_models_id_fk": {
+ "name": "jobs_model_id_models_id_fk",
+ "tableFrom": "jobs",
+ "tableTo": "models",
+ "columnsFrom": [
+ "model_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "local_folders": {
+ "name": "local_folders",
+ "columns": {
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "files": {
+ "name": "files",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "file_count": {
+ "name": "file_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "total_bytes": {
+ "name": "total_bytes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "commit": {
+ "name": "commit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "scanned_at": {
+ "name": "scanned_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "model_files": {
+ "name": "model_files",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "model_id": {
+ "name": "model_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "size": {
+ "name": "size",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "blob_oid": {
+ "name": "blob_oid",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "lfs_sha256": {
+ "name": "lfs_sha256",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "selected": {
+ "name": "selected",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "state": {
+ "name": "state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'pending'"
+ },
+ "checked_at": {
+ "name": "checked_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "model_files_model_path_uq": {
+ "name": "model_files_model_path_uq",
+ "columns": [
+ "model_id",
+ "path"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "model_files_model_id_models_id_fk": {
+ "name": "model_files_model_id_models_id_fk",
+ "tableFrom": "model_files",
+ "tableTo": "models",
+ "columnsFrom": [
+ "model_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "model_revisions": {
+ "name": "model_revisions",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "model_id": {
+ "name": "model_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "sha": {
+ "name": "sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "pinned_at": {
+ "name": "pinned_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "superseded_at": {
+ "name": "superseded_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "model_revisions_model_idx": {
+ "name": "model_revisions_model_idx",
+ "columns": [
+ "model_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "model_revisions_model_id_models_id_fk": {
+ "name": "model_revisions_model_id_models_id_fk",
+ "tableFrom": "model_revisions",
+ "tableTo": "models",
+ "columnsFrom": [
+ "model_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "model_tags": {
+ "name": "model_tags",
+ "columns": {
+ "model_id": {
+ "name": "model_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "tag_id": {
+ "name": "tag_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "model_tags_tag_idx": {
+ "name": "model_tags_tag_idx",
+ "columns": [
+ "tag_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "model_tags_model_id_models_id_fk": {
+ "name": "model_tags_model_id_models_id_fk",
+ "tableFrom": "model_tags",
+ "tableTo": "models",
+ "columnsFrom": [
+ "model_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "model_tags_tag_id_tags_id_fk": {
+ "name": "model_tags_tag_id_tags_id_fk",
+ "tableFrom": "model_tags",
+ "tableTo": "tags",
+ "columnsFrom": [
+ "tag_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "model_tags_model_id_tag_id_pk": {
+ "columns": [
+ "model_id",
+ "tag_id"
+ ],
+ "name": "model_tags_model_id_tag_id_pk"
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "models": {
+ "name": "models",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "repo_type": {
+ "name": "repo_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'model'"
+ },
+ "repo_id": {
+ "name": "repo_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "tracked_revision": {
+ "name": "tracked_revision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'main'"
+ },
+ "pinned_sha": {
+ "name": "pinned_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "local_path": {
+ "name": "local_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "include_patterns": {
+ "name": "include_patterns",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'[]'"
+ },
+ "exclude_patterns": {
+ "name": "exclude_patterns",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'[]'"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'pending'"
+ },
+ "remote_sha": {
+ "name": "remote_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "last_checked_at": {
+ "name": "last_checked_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "last_check_error": {
+ "name": "last_check_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "hub_state": {
+ "name": "hub_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "hub_missing_since": {
+ "name": "hub_missing_since",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "update_diff": {
+ "name": "update_diff",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "last_verified_at": {
+ "name": "last_verified_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "downloaded_at": {
+ "name": "downloaded_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "base_models": {
+ "name": "base_models",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "base_relation": {
+ "name": "base_relation",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "author_avatar_url": {
+ "name": "author_avatar_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "architecture": {
+ "name": "architecture",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "pipeline_tag": {
+ "name": "pipeline_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "license": {
+ "name": "license",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "hub_tags": {
+ "name": "hub_tags",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "metadata_fetched_at": {
+ "name": "metadata_fetched_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "models_repo_uq": {
+ "name": "models_repo_uq",
+ "columns": [
+ "repo_type",
+ "repo_id"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "runtimes": {
+ "name": "runtimes",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "engine": {
+ "name": "engine",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "image": {
+ "name": "image",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "env": {
+ "name": "env",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'{}'"
+ },
+ "extra_args": {
+ "name": "extra_args",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'[]'"
+ },
+ "devices": {
+ "name": "devices",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'[]'"
+ },
+ "shm_size_mb": {
+ "name": "shm_size_mb",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "numa_tuning": {
+ "name": "numa_tuning",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "preset": {
+ "name": "preset",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "image_state": {
+ "name": "image_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'unknown'"
+ },
+ "image_id": {
+ "name": "image_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "image_size": {
+ "name": "image_size",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "image_created": {
+ "name": "image_created",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "pull_requested_at": {
+ "name": "pull_requested_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "pull_started_at": {
+ "name": "pull_started_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "pull_progress": {
+ "name": "pull_progress",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "pull_error": {
+ "name": "pull_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "image_checked_at": {
+ "name": "image_checked_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "settings": {
+ "name": "settings",
+ "columns": {
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "tags": {
+ "name": "tags",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "tags_slug_uq": {
+ "name": "tags_slug_uq",
+ "columns": [
+ "slug"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ },
+ "worker_state": {
+ "name": "worker_state",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "instance_id": {
+ "name": "instance_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "pid": {
+ "name": "pid",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "hf_version": {
+ "name": "hf_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "models_dir_free_bytes": {
+ "name": "models_dir_free_bytes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "models_dir_total_bytes": {
+ "name": "models_dir_total_bytes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "heartbeat_at": {
+ "name": "heartbeat_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "scan_requested_at": {
+ "name": "scan_requested_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "docker": {
+ "name": "docker",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "checkConstraints": {}
+ }
+ },
+ "views": {},
+ "enums": {},
+ "_meta": {
+ "schemas": {},
+ "tables": {},
+ "columns": {}
+ },
+ "internal": {
+ "indexes": {}
+ }
+}
\ No newline at end of file
diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json
index d902789..fc21ded 100644
--- a/drizzle/meta/_journal.json
+++ b/drizzle/meta/_journal.json
@@ -85,6 +85,13 @@
"when": 1791278463453,
"tag": "0011_deployments",
"breakpoints": true
+ },
+ {
+ "idx": 12,
+ "version": "6",
+ "when": 1791281615301,
+ "tag": "0012_api_keys",
+ "breakpoints": true
}
]
}
\ No newline at end of file
diff --git a/src/app/(app)/[org]/[repo]/page.tsx b/src/app/(app)/[org]/[repo]/page.tsx
index 9b19642..57c4326 100644
--- a/src/app/(app)/[org]/[repo]/page.tsx
+++ b/src/app/(app)/[org]/[repo]/page.tsx
@@ -9,6 +9,8 @@ import {
LanguagesIcon,
ListChecksIcon,
MessagesSquareIcon,
+ PlusIcon,
+ RocketIcon,
ScaleIcon,
SparklesIcon,
TriangleAlertIcon,
@@ -17,12 +19,14 @@ import type { Metadata } from "next";
import Link from "next/link";
import { notFound, redirect } from "next/navigation";
import { CopyButton } from "@/components/copy-button";
+import { DeploymentStateBadge } from "@/components/deployment-state";
import { HubStateBadge } from "@/components/hub-state-badge";
import { LocalTime } from "@/components/local-time";
import { ModelStatusBadge } from "@/components/model-status-badge";
import { buttonVariants } from "@/components/ui/button";
import { cn } from "@/lib/utils";
import { formatBytes, shortSha } from "@/lib/format";
+import { deploymentsByModel, listDeployableModels } from "@/lib/deployments";
import { fetchModelCard } from "@/lib/hub/client";
import { modelFamilies } from "@/lib/hub/metadata";
import { listModelJobs } from "@/lib/jobs";
@@ -97,13 +101,17 @@ export default async function ModelPage({ params, searchParams }: PageProps<"/[o
const hubTags = model.hubTags ?? [];
const hubMissing = model.hubState === "repo_missing" || model.hubState === "commit_missing";
- const [tags, related, card, worker, recentJobs] = await Promise.all([
+ const [tags, related, card, worker, recentJobs, byModel, deployable] = await Promise.all([
modelTagList(model.id),
relatedModels(model.id, baseModels),
tab === "card" ? fetchModelCard(model.repoId, model.pinnedSha).catch(() => undefined) : Promise.resolve(undefined),
getWorkerStatus(),
listModelJobs(model.id, 1),
+ deploymentsByModel(),
+ listDeployableModels(),
]);
+ const modelDeployments = byModel.get(model.id) ?? [];
+ const canDeploy = deployable.some((m) => m.id === model.id);
const update =
!hubMissing && model.updateDiff && model.updateDiff.sha === model.remoteSha && model.remoteSha !== model.pinnedSha
? model.updateDiff
@@ -143,6 +151,15 @@ export default async function ModelPage({ params, searchParams }: PageProps<"/[o
)}
+ {canDeploy && (
+
+
+ Deploy
+
+ )}
+ {(modelDeployments.length > 0 || canDeploy) && (
+
+
+ {modelDeployments.length === 0 ? (
+
Not deployed yet.
+ ) : (
+ modelDeployments.map((d) => (
+
+
+ {d.name}
+ {d.runtimeName}
+
+
+
+ ))
+ )}
+ {canDeploy && (
+
+
+ New deployment
+
+ )}
+
+
+ )}
+
- Selection
diff --git a/src/app/(app)/deployments/[id]/deployment-detail.tsx b/src/app/(app)/deployments/[id]/deployment-detail.tsx
index d6a575a..4fb51ab 100644
--- a/src/app/(app)/deployments/[id]/deployment-detail.tsx
+++ b/src/app/(app)/deployments/[id]/deployment-detail.tsx
@@ -3,7 +3,7 @@
import { ExternalLinkIcon, PencilIcon, PlayIcon, SendIcon, SquareIcon, Trash2Icon } from "lucide-react";
import Link from "next/link";
import { useRouter } from "next/navigation";
-import { useEffect, useRef, useState, useSyncExternalStore } from "react";
+import { useEffect, useRef, useState } from "react";
import { CopyButton } from "@/components/copy-button";
import { DeploymentStateBadge } from "@/components/deployment-state";
import { LocalTime } from "@/components/local-time";
@@ -21,6 +21,7 @@ import {
import { Button, buttonVariants } from "@/components/ui/button";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Progress } from "@/components/ui/progress";
+import { useHostname, webUiUrl } from "@/hooks/use-hostname";
import { ENGINE_PORT } from "@/lib/deploy-command";
import type { DeploymentRow } from "@/lib/deployments";
import { formatBytes, percent } from "@/lib/format";
@@ -67,15 +68,9 @@ export function DeploymentDetail({ initial }: { initial: Deployment }) {
const startingSecs = d.state === "starting" && d.startedAt ? Math.max(0, (now - new Date(d.startedAt).getTime()) / 1000) : null;
const port = ENGINE_PORT[d.engine];
const internal = d.containerName ? `http://${d.containerName}:${port}/v1` : null;
- // The browser's host name (null while rendering on the server, so hydration matches).
- const hostname = useSyncExternalStore(
- () => () => {},
- () => window.location.hostname,
- () => null,
- );
+ const hostname = useHostname();
const published = d.hostPort && hostname ? `http://${hostname}:${d.hostPort}/v1` : null;
- // llama-server's built-in chat UI, served at / on the same port.
- const webUi = d.engine === "llama.cpp" && d.options.webui !== false && d.hostPort && hostname ? `http://${hostname}:${d.hostPort}/` : null;
+ const webUi = webUiUrl(d, hostname);
return (
@@ -218,6 +213,16 @@ export function DeploymentDetail({ initial }: { initial: Deployment }) {
)}
OpenAI-compatible; model name {d.repoId}.
+ {d.options.requireApiKey && (
+ <>
+ {" "}
+ Requires one of the{" "}
+
+ API keys
+ {" "}
+ as Authorization: Bearer.
+ >
+ )}
diff --git a/src/app/(app)/deployments/deployment-form.tsx b/src/app/(app)/deployments/deployment-form.tsx
index 667830b..6a591db 100644
--- a/src/app/(app)/deployments/deployment-form.tsx
+++ b/src/app/(app)/deployments/deployment-form.tsx
@@ -1,19 +1,23 @@
"use client";
-import { BoxesIcon, CheckIcon, CpuIcon, SearchIcon } from "lucide-react";
+import { BoxesIcon, CheckIcon, SearchIcon, TerminalIcon } from "lucide-react";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { toast } from "sonner";
+import { ArgsEditor } from "@/components/args-editor";
import { CopyButton } from "@/components/copy-button";
import { FileRoleBadge } from "@/components/labels";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
+import { Checkbox } from "@/components/ui/checkbox";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
+import { NativeSelect } from "@/components/ui/native-select";
import type { DeploymentOptions, RuntimeEngine } from "@/lib/db/schema";
import type { ModelCandidates } from "@/lib/deploy-candidates";
-import { buildCommand, ENGINE_PORT, estimateMemoryMb, renderCommand } from "@/lib/deploy-command";
+import { API_KEY_PLACEHOLDER, buildCommand, ENGINE_PORT, estimateMemoryMb, renderCommand } from "@/lib/deploy-command";
+import { argsToRows, rowsToArgs } from "@/lib/extra-args";
import { formatBytes } from "@/lib/format";
import { quantGroup } from "@/lib/selection";
import { cn } from "@/lib/utils";
@@ -42,8 +46,6 @@ export type FormInitial = {
const CONTEXT_PRESETS = [2048, 4096, 8192, 16384, 32768];
const KV_TYPES = ["f16", "q8_0", "q4_0"];
-const selectClass =
- "h-8 w-full rounded-lg border border-input bg-transparent px-2.5 text-sm outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 dark:bg-input/30";
const intOrNull = (s: string) => (s.trim() === "" ? null : Math.max(0, Math.round(Number(s)))) || null;
const numOrNull = (s: string) => (s.trim() === "" ? null : Number(s)) || null;
@@ -63,10 +65,41 @@ function Section({ step, title, description, children }: { step: number; title:
);
}
-function Field({ label, hint, children, htmlFor }: { label: string; hint?: React.ReactNode; children: React.ReactNode; htmlFor?: string }) {
+/** A titled block of related options inside the launch options card. */
+function Group({ title, description, children }: { title: string; description?: string; children: React.ReactNode }) {
return (
-
-
+
+
+
{title}
+ {description &&
{description}
}
+
+
{children}
+
+ );
+}
+
+/** `flag`: the command-line flag the field sets, shown next to the label. */
+function Field({
+ label,
+ flag,
+ hint,
+ children,
+ htmlFor,
+ wide,
+}: {
+ label: string;
+ flag?: string;
+ hint?: React.ReactNode;
+ children: React.ReactNode;
+ htmlFor?: string;
+ wide?: boolean;
+}) {
+ return (
+
+
+
+ {flag && {flag}}
+
{children}
{hint &&
{hint}
}
@@ -78,11 +111,13 @@ export function DeploymentForm({
runtimes,
models,
host,
+ apiKeyCount,
initial,
}: {
runtimes: FormRuntime[];
models: FormModel[];
host: FormHost;
+ apiKeyCount: number;
initial?: FormInitial;
}) {
const router = useRouter();
@@ -109,12 +144,13 @@ export function DeploymentForm({
const [cacheTypeV, setCacheTypeV] = useState(o?.cacheTypeV ?? "");
const [flashAttn, setFlashAttn] = useState(o?.flashAttn ?? "");
const [webui, setWebui] = useState(o?.webui !== false);
+ const [requireApiKey, setRequireApiKey] = useState(!!o?.requireApiKey);
const [batchSize, setBatchSize] = useState(o?.batchSize != null ? String(o.batchSize) : "");
const [ubatchSize, setUbatchSize] = useState(o?.ubatchSize != null ? String(o.ubatchSize) : "");
const [dtype, setDtype] = useState(o?.dtype ?? "");
const [maxNumSeqs, setMaxNumSeqs] = useState(o?.maxNumSeqs != null ? String(o.maxNumSeqs) : "");
const [kvCacheGb, setKvCacheGb] = useState(o?.kvCacheGb != null ? String(o.kvCacheGb) : "");
- const [extraArgs, setExtraArgs] = useState((o?.extraArgs ?? []).join("\n"));
+ const [argRows, setArgRows] = useState(() => argsToRows(o?.extraArgs ?? []));
const [cpus, setCpus] = useState(initial?.cpus != null ? String(initial.cpus) : "");
const [memoryMb, setMemoryMb] = useState(initial?.memoryMb != null ? String(initial.memoryMb) : "");
const [memoryTouched, setMemoryTouched] = useState(!!initial?.memoryMb);
@@ -144,13 +180,11 @@ export function DeploymentForm({
cacheTypeV: engine === "llama.cpp" && cacheTypeV ? cacheTypeV : null,
flashAttn: engine === "llama.cpp" && flashAttn ? (flashAttn as "auto" | "on" | "off") : null,
webui: engine === "llama.cpp" ? webui : null,
+ requireApiKey,
dtype: engine === "vllm" && dtype ? dtype : null,
maxNumSeqs: engine === "vllm" ? intOrNull(maxNumSeqs) : null,
kvCacheGb: engine === "vllm" ? numOrNull(kvCacheGb) : null,
- extraArgs: extraArgs
- .split("\n")
- .map((a) => a.trim())
- .filter(Boolean),
+ extraArgs: rowsToArgs(argRows),
};
const fileBytes = model
@@ -163,7 +197,13 @@ export function DeploymentForm({
const estimate = model ? estimateMemoryMb(fileBytes, options.contextSize, engine, options.kvCacheGb) : null;
const memory = memoryTouched ? intOrNull(memoryMb) : estimate;
const preview =
- runtime && model ? renderCommand(runtime.image, buildCommand({ engine, options, model, runtime: { env: runtime.env, extraArgs: runtime.extraArgs } })) : null;
+ runtime && model ? renderCommand(runtime.image, buildCommand({
+ engine,
+ options,
+ model,
+ runtime: { env: runtime.env, extraArgs: runtime.extraArgs },
+ apiKeys: Array.from({ length: apiKeyCount }, () => API_KEY_PLACEHOLDER),
+ })) : null;
const noBf16 = host && !host.cpuFeatures.includes("avx512_bf16");
async function submit(start: boolean) {
@@ -302,7 +342,7 @@ export function DeploymentForm({
{model && engine === "llama.cpp" && (
-
+
{model.candidates.gguf.map((g) => (
-
-
+
-
+
)}
@@ -358,106 +399,152 @@ export function DeploymentForm({
{runtime && model && (
-
+
setName(e.target.value)} maxLength={80} />
-
-
+
+ )}
+
{engine === "llama.cpp" ? (
-
-
+
+
setThreads(e.target.value.replace(/\D/g, ""))} inputMode="numeric" placeholder="auto" />
-
-
- {[
- [cacheTypeK, setCacheTypeK],
- [cacheTypeV, setCacheTypeV],
- ].map(([value, set], i) => (
-
- ))}
-
-
-
-
+
- :${hostPort}/` : "Needs a host port to open it (below).") : "--no-webui"}>
-
+
+ setBatchSize(e.target.value.replace(/\D/g, ""))} inputMode="numeric" placeholder="2048" />
-
-
- setBatchSize(e.target.value.replace(/\D/g, ""))} inputMode="numeric" placeholder="2048" aria-label="Batch size" />
- setUbatchSize(e.target.value.replace(/\D/g, ""))} inputMode="numeric" placeholder="512" aria-label="Micro-batch size" />
-
+
+ setUbatchSize(e.target.value.replace(/\D/g, ""))} inputMode="numeric" placeholder="512" />
-
+
) : (
-
+
-
+
-
- setKvCacheGb(e.target.value.replace(/[^\d.]/g, ""))} inputMode="decimal" placeholder={runtime.env.VLLM_CPU_KVCACHE_SPACE ?? "4"} />
-
-
-
-
-
+
)}
-
+
-
-
+
+
+
+
+ )}
+ {runtime && model && (
+
{preview && (
-
-
-
+
+
+
+ {preview}
+
+
-
{preview}
)}
-
);
diff --git a/src/app/(app)/deployments/form-data.ts b/src/app/(app)/deployments/form-data.ts
index 43a4508..6de1078 100644
--- a/src/app/(app)/deployments/form-data.ts
+++ b/src/app/(app)/deployments/form-data.ts
@@ -1,14 +1,16 @@
import "server-only";
+import { listApiKeys } from "@/lib/api-keys";
import { listDeployableModels } from "@/lib/deployments";
import { getDockerInfo, listRuntimes } from "@/lib/runtimes";
import type { FormHost, FormModel, FormRuntime } from "./deployment-form";
-/** Everything the deployment form needs: runtimes, servable models, host facts. */
-export async function formData(): Promise<{ runtimes: FormRuntime[]; models: FormModel[]; host: FormHost }> {
- const [runtimes, models, docker] = await Promise.all([listRuntimes(), listDeployableModels(), getDockerInfo()]);
+/** Everything the deployment form needs: runtimes, servable models, host facts, API key count. */
+export async function formData(): Promise<{ runtimes: FormRuntime[]; models: FormModel[]; host: FormHost; apiKeyCount: number }> {
+ const [runtimes, models, docker, keys] = await Promise.all([listRuntimes(), listDeployableModels(), getDockerInfo(), listApiKeys()]);
return {
runtimes: runtimes.map((r) => ({ id: r.id, name: r.name, engine: r.engine, image: r.image, imageState: r.imageState, env: r.env, extraArgs: r.extraArgs })),
models,
host: docker ? { cpus: docker.cpus, memoryBytes: docker.memoryBytes, cpuFeatures: docker.cpuFeatures } : null,
+ apiKeyCount: keys.length,
};
}
diff --git a/src/app/(app)/deployments/new/page.tsx b/src/app/(app)/deployments/new/page.tsx
index 5d14168..4c951dd 100644
--- a/src/app/(app)/deployments/new/page.tsx
+++ b/src/app/(app)/deployments/new/page.tsx
@@ -1,16 +1,19 @@
import type { Metadata } from "next";
+import { deployPreset } from "@/lib/deployments";
import { DeploymentForm } from "../deployment-form";
import { formData } from "../form-data";
export const dynamic = "force-dynamic";
export const metadata: Metadata = { title: "New deployment" };
-export default async function NewDeploymentPage() {
- const data = await formData();
+/** `?model=
` (the library's "Deploy") preselects the model and a runtime that can serve it. */
+export default async function NewDeploymentPage({ searchParams }: PageProps<"/deployments/new">) {
+ const { model } = await searchParams;
+ const [data, preset] = await Promise.all([formData(), typeof model === "string" ? deployPreset(model) : null]);
return (
New deployment
-
+
);
}
diff --git a/src/app/(app)/library-view.tsx b/src/app/(app)/library-view.tsx
index 25c94d6..0e698af 100644
--- a/src/app/(app)/library-view.tsx
+++ b/src/app/(app)/library-view.tsx
@@ -1,6 +1,6 @@
"use client";
-import { SearchIcon, XIcon } from "lucide-react";
+import { RocketIcon, SearchIcon, XIcon } from "lucide-react";
import Link from "next/link";
import { usePathname, useRouter, useSearchParams } from "next/navigation";
import { useMemo, useState } from "react";
@@ -10,7 +10,7 @@ import { HUB_STATE_LABEL, HubStateBadge } from "@/components/hub-state-badge";
import { MODEL_STATUS, ModelStatusBadge } from "@/components/model-status-badge";
import { TagBadge, TagDot } from "@/components/tag-badge";
import { Badge } from "@/components/ui/badge";
-import { Button } from "@/components/ui/button";
+import { Button, buttonVariants } from "@/components/ui/button";
import { Card, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
@@ -19,6 +19,7 @@ import type { ModelStatus } from "@/lib/db/schema";
import { formatBytes, shortSha } from "@/lib/format";
import type { JobSnapshot } from "@/lib/jobs";
import type { LibraryRow } from "@/lib/library";
+import { cn } from "@/lib/utils";
import {
EMPTY_FILTERS,
type Facet,
@@ -180,6 +181,9 @@ export function LibraryView({ rows }: { rows: LibraryRow[] }) {
Pinned
Downloaded
Status
+
+ Deploy
+
@@ -195,6 +199,23 @@ export function LibraryView({ rows }: { rows: LibraryRow[] }) {
{base && base !== r.repoId &&
base {base}}
{r.architecture &&
{r.architecture}}
+ {r.deployments.map((d) => (
+
+
+
{d.name}
+
+
+ ))}
{r.tags.map((t) => (
)}
+
+ {r.deployable && (
+
+
+ Deploy
+
+ )}
+
);
})}
diff --git a/src/app/(app)/settings/api-keys/api-key-settings.tsx b/src/app/(app)/settings/api-keys/api-key-settings.tsx
new file mode 100644
index 0000000..2204ae0
--- /dev/null
+++ b/src/app/(app)/settings/api-keys/api-key-settings.tsx
@@ -0,0 +1,172 @@
+"use client";
+
+import { EyeIcon, EyeOffIcon, KeyRoundIcon, PlusIcon, Trash2Icon } from "lucide-react";
+import { useRouter } from "next/navigation";
+import { useState } from "react";
+import { toast } from "sonner";
+import { CopyButton } from "@/components/copy-button";
+import { LocalTime } from "@/components/local-time";
+import {
+ AlertDialog,
+ AlertDialogAction,
+ AlertDialogCancel,
+ AlertDialogContent,
+ AlertDialogDescription,
+ AlertDialogFooter,
+ AlertDialogHeader,
+ AlertDialogTitle,
+ AlertDialogTrigger,
+} from "@/components/ui/alert-dialog";
+import { Button } from "@/components/ui/button";
+import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
+import { Input } from "@/components/ui/input";
+import type { ApiKeyRow } from "@/lib/api-keys";
+
+/** Keys that deployments with "Require an API key" accept. */
+export function ApiKeySettings({ keys }: { keys: ApiKeyRow[] }) {
+ const [created, setCreated] = useState<{ name: string; key: string } | null>(null);
+ return (
+
+
+ API keys
+
+ Deployments with “Require an API key” accept any of these keys as Authorization: Bearer <key>.
+ Changes apply when a deployment (re)starts.
+
+
+
+
+ {created && (
+
+
API key “{created.name}” added. You can show it again from the list.
+
+ {created.key}
+
+
+
+ )}
+ {keys.length === 0 ? (
+ No API keys yet.
+ ) : (
+
+ {keys.map((k) => (
+
+ ))}
+
+ )}
+
+
+ );
+}
+
+function NewKeyRow({ onCreated }: { onCreated: (k: { name: string; key: string }) => void }) {
+ const router = useRouter();
+ const [name, setName] = useState("");
+ const [key, setKey] = useState("");
+ const [busy, setBusy] = useState(false);
+
+ async function create(e: React.FormEvent) {
+ e.preventDefault();
+ if (!name.trim()) return;
+ setBusy(true);
+ try {
+ const res = await fetch("/api/api-keys", {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ name, key: key.trim() || undefined }),
+ });
+ const json = await res.json().catch(() => ({}));
+ if (!res.ok) {
+ toast.error(json.error?.message ?? `Could not add the key (${res.status})`);
+ return;
+ }
+ onCreated({ name: json.name, key: json.key });
+ setName("");
+ setKey("");
+ router.refresh();
+ } finally {
+ setBusy(false);
+ }
+ }
+
+ return (
+
+ );
+}
+
+function KeyRow({ apiKey }: { apiKey: ApiKeyRow }) {
+ const router = useRouter();
+ const [shown, setShown] = useState(null);
+
+ async function toggle() {
+ if (shown) return setShown(null);
+ const res = await fetch(`/api/api-keys/${apiKey.id}`, { cache: "no-store" });
+ const json = await res.json().catch(() => ({}));
+ if (!res.ok) toast.error(json.error?.message ?? `Could not load the key (${res.status})`);
+ else setShown(json.key);
+ }
+
+ async function remove() {
+ const res = await fetch(`/api/api-keys/${apiKey.id}`, { method: "DELETE" });
+ if (!res.ok) toast.error(`Could not delete (${res.status})`);
+ else toast.success(`API key "${apiKey.name}" deleted`);
+ router.refresh();
+ }
+
+ return (
+
+
+
{apiKey.name}
+ {shown ? (
+
+
+ {shown}
+
+
+
+ ) : (
+
{apiKey.hint}
+ )}
+
+ {shown ? : }
+
+
+
+
+
+ }>
+
+
+
+
+ Delete API key “{apiKey.name}”?
+ Clients using it are rejected once their deployments restart.
+
+
+ Cancel
+
+ Delete
+
+
+
+
+
+ );
+}
diff --git a/src/app/(app)/settings/api-keys/page.tsx b/src/app/(app)/settings/api-keys/page.tsx
new file mode 100644
index 0000000..c0e0c1e
--- /dev/null
+++ b/src/app/(app)/settings/api-keys/page.tsx
@@ -0,0 +1,10 @@
+import type { Metadata } from "next";
+import { listApiKeys } from "@/lib/api-keys";
+import { ApiKeySettings } from "./api-key-settings";
+
+export const dynamic = "force-dynamic";
+export const metadata: Metadata = { title: "API keys · Settings" };
+
+export default async function ApiKeySettingsPage() {
+ return ;
+}
diff --git a/src/app/(app)/settings/layout.tsx b/src/app/(app)/settings/layout.tsx
index 4f467d0..db2cbdf 100644
--- a/src/app/(app)/settings/layout.tsx
+++ b/src/app/(app)/settings/layout.tsx
@@ -1,4 +1,4 @@
-import { BoxesIcon, DownloadIcon, TagIcon, TagsIcon } from "lucide-react";
+import { BoxesIcon, DownloadIcon, KeyRoundIcon, TagIcon, TagsIcon } from "lucide-react";
import { SettingsNav } from "./settings-nav";
const SECTIONS = [
@@ -6,6 +6,7 @@ const SECTIONS = [
{ href: "/settings/tags", label: "Tags", icon: },
{ href: "/settings/downloads", label: "Downloads", icon: },
{ href: "/settings/runtimes", label: "Runtimes", icon: },
+ { href: "/settings/api-keys", label: "API keys", icon: },
];
export default function SettingsLayout({ children }: LayoutProps<"/settings">) {
diff --git a/src/app/(app)/settings/runtimes/runtime-form.tsx b/src/app/(app)/settings/runtimes/runtime-form.tsx
index 0dd351f..6090081 100644
--- a/src/app/(app)/settings/runtimes/runtime-form.tsx
+++ b/src/app/(app)/settings/runtimes/runtime-form.tsx
@@ -1,11 +1,13 @@
"use client";
import { useState } from "react";
+import { ArgsEditor } from "@/components/args-editor";
import { Button } from "@/components/ui/button";
import { Checkbox } from "@/components/ui/checkbox";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import type { RuntimeEngine } from "@/lib/db/schema";
+import { argsToRows, rowsToArgs } from "@/lib/extra-args";
import { formatEnvLines, parseEnvLines, type RuntimeInput, RuntimeValidationError, validateRuntime } from "@/lib/runtimes-shared";
import { cn } from "@/lib/utils";
@@ -34,7 +36,7 @@ export function RuntimeForm({
const [image, setImage] = useState(initial.image);
const [description, setDescription] = useState(initial.description ?? "");
const [envText, setEnvText] = useState(formatEnvLines(initial.env ?? {}));
- const [argsText, setArgsText] = useState((initial.extraArgs ?? []).join("\n"));
+ const [argRows, setArgRows] = useState(() => argsToRows(initial.extraArgs ?? []));
const [devicesText, setDevicesText] = useState((initial.devices ?? []).join(", "));
const [shm, setShm] = useState(initial.shmSizeMb != null ? String(initial.shmSizeMb) : "");
const [numa, setNuma] = useState(!!initial.numaTuning);
@@ -51,7 +53,7 @@ export function RuntimeForm({
image,
description,
env: parseEnvLines(envText),
- extraArgs: argsText.split("\n"),
+ extraArgs: rowsToArgs(argRows),
devices: devicesText.split(/[,\s]+/),
shmSizeMb: shm.trim() ? Number(shm) : null,
numaTuning: numa,
@@ -117,31 +119,22 @@ export function RuntimeForm({
setDescription(e.target.value)} maxLength={2000} />
-
-
-
+
+
+
+
+
Added to every deployment's command; a deployment can override them.
diff --git a/src/app/api/api-keys/[id]/route.ts b/src/app/api/api-keys/[id]/route.ts
new file mode 100644
index 0000000..1ec8887
--- /dev/null
+++ b/src/app/api/api-keys/[id]/route.ts
@@ -0,0 +1,29 @@
+import { NextResponse } from "next/server";
+import { withAuth } from "@/lib/api-auth";
+import { apiError, handleApiError } from "@/lib/api-errors";
+import { ApiKeyError, deleteApiKey, revealApiKey } from "@/lib/api-keys";
+
+export const dynamic = "force-dynamic";
+
+/** The key's value ("show key" in Settings). */
+export const GET = withAuth
>(async (_req, { params }) => {
+ const { id } = await params;
+ try {
+ return NextResponse.json({ key: await revealApiKey(id) }, { headers: { "Cache-Control": "no-store" } });
+ } catch (err) {
+ if (err instanceof ApiKeyError) return apiError(err.status, err.code, err.message);
+ return handleApiError(err);
+ }
+});
+
+/** Remove a key; running deployments keep accepting it until they restart. */
+export const DELETE = withAuth>(async (_req, { params }) => {
+ const { id } = await params;
+ try {
+ await deleteApiKey(id);
+ return new NextResponse(null, { status: 204 });
+ } catch (err) {
+ if (err instanceof ApiKeyError) return apiError(err.status, err.code, err.message);
+ return handleApiError(err);
+ }
+});
diff --git a/src/app/api/api-keys/route.ts b/src/app/api/api-keys/route.ts
new file mode 100644
index 0000000..b4bd39b
--- /dev/null
+++ b/src/app/api/api-keys/route.ts
@@ -0,0 +1,19 @@
+import { NextResponse } from "next/server";
+import { withAuth } from "@/lib/api-auth";
+import { apiError, handleApiError } from "@/lib/api-errors";
+import { ApiKeyBody, ApiKeyError, createApiKey, listApiKeys } from "@/lib/api-keys";
+
+export const dynamic = "force-dynamic";
+
+/** Keys without their values (only the last characters). */
+export const GET = withAuth(async () => NextResponse.json(await listApiKeys()));
+
+/** Add a key (generated when `key` is missing); the response carries the full key once. */
+export const POST = withAuth(async (req) => {
+ try {
+ return NextResponse.json(await createApiKey(ApiKeyBody.parse(await req.json())), { status: 201 });
+ } catch (err) {
+ if (err instanceof ApiKeyError) return apiError(err.status, err.code, err.message);
+ return handleApiError(err);
+ }
+});
diff --git a/src/app/api/deployments/[id]/chat/route.ts b/src/app/api/deployments/[id]/chat/route.ts
index d66c2eb..0d71a54 100644
--- a/src/app/api/deployments/[id]/chat/route.ts
+++ b/src/app/api/deployments/[id]/chat/route.ts
@@ -1,6 +1,7 @@
import { z } from "zod";
import { withAuth } from "@/lib/api-auth";
import { apiError, handleApiError } from "@/lib/api-errors";
+import { apiKeyValues } from "@/lib/api-keys";
import { ENGINE_PORT } from "@/lib/deploy-command";
import { getDeployment } from "@/lib/deployments";
@@ -21,9 +22,11 @@ export const POST = withAuth>(async (
if (!d) return apiError(404, "not_found", "Deployment not found.");
if (d.state !== "running" || !d.containerName) return apiError(409, "not_running", "The deployment isn't running.");
const { messages, maxTokens } = Body.parse(await req.json());
+ // Any key works; keys added after the deployment started aren't known to it yet, so prefer the oldest.
+ const [key] = d.options.requireApiKey ? await apiKeyValues() : [];
const upstream = await fetch(`http://${d.containerName}:${ENGINE_PORT[d.engine]}/v1/chat/completions`, {
method: "POST",
- headers: { "Content-Type": "application/json" },
+ headers: { "Content-Type": "application/json", ...(key ? { Authorization: `Bearer ${key}` } : {}) },
body: JSON.stringify({ model: d.repoId, messages, max_tokens: maxTokens, stream: true, stream_options: { include_usage: true } }),
signal: req.signal,
}).catch((err: Error) => {
@@ -31,6 +34,7 @@ export const POST = withAuth>(async (
});
if (!upstream.ok || !upstream.body) {
const text = await upstream.text().catch(() => "");
+ if (upstream.status === 401) return apiError(502, "upstream", "The model server rejected Kaname's API key. Restart the deployment to pick up changed keys.");
return apiError(502, "upstream", `The model server answered ${upstream.status}: ${text.slice(0, 500)}`);
}
return new Response(upstream.body, { headers: { "Content-Type": "text/event-stream", "Cache-Control": "no-store" } });
diff --git a/src/app/globals.css b/src/app/globals.css
index 7f5cd55..88ffb65 100644
--- a/src/app/globals.css
+++ b/src/app/globals.css
@@ -127,4 +127,11 @@
html {
@apply font-sans;
}
+ /* Native controls (select popups, scrollbars, date pickers) follow the theme. */
+ .dark {
+ color-scheme: dark;
+ }
+ option {
+ @apply bg-popover text-popover-foreground;
+ }
}
\ No newline at end of file
diff --git a/src/components/args-editor.tsx b/src/components/args-editor.tsx
new file mode 100644
index 0000000..09b1dd9
--- /dev/null
+++ b/src/components/args-editor.tsx
@@ -0,0 +1,56 @@
+"use client";
+
+import { PlusIcon, XIcon } from "lucide-react";
+import { Button } from "@/components/ui/button";
+import { Input } from "@/components/ui/input";
+import type { ArgRow } from "@/lib/extra-args";
+
+const GENERIC = { flag: "--flag", value: "value (optional)" };
+
+/** Extra command-line arguments as flag/value rows (controlled). `placeholder` is the first row's example. */
+export function ArgsEditor({
+ rows,
+ onChange,
+ placeholder = GENERIC,
+ addLabel = "Add argument",
+}: {
+ rows: ArgRow[];
+ onChange: (rows: ArgRow[]) => void;
+ placeholder?: { flag: string; value: string };
+ addLabel?: string;
+}) {
+ const set = (i: number, patch: Partial) => onChange(rows.map((r, j) => (j === i ? { ...r, ...patch } : r)));
+ const single = (s: string) => s.replace(/[\r\n]/g, "");
+
+ return (
+
+ );
+}
diff --git a/src/components/ui/native-select.tsx b/src/components/ui/native-select.tsx
new file mode 100644
index 0000000..eb217b1
--- /dev/null
+++ b/src/components/ui/native-select.tsx
@@ -0,0 +1,21 @@
+import { ChevronDownIcon } from "lucide-react";
+import * as React from "react";
+import { cn } from "@/lib/utils";
+
+/** A native