API referenceInstance API
GUIDE & REFERENCE

Machine Learning

Every registered machine learning instance operation, with source-derived inputs, outputs, access policy, and errors.

This reference covers 9 HTTP operations registered by the Akasha daemon. Call these paths on your instance base URL. See authentication, errors, and coverage before integrating.

MethodPathOperation
POST/v1/ml/models/loadMl models load
POST/v1/ml/models/unloadMl models unload
GET/v1/ml/modelsMl models list
POST/v1/ml/metricsMl metrics
POST/v1/ml/embedMl embed
POST/v1/ml/generateMl generate
POST/v1/ml/tokenizers/loadMl tokenizer load
POST/v1/ml/train/supervisedMl train supervised http
POST/v1/ml/train/hrmMl train hrm http

POST /v1/ml/models/load

Ml models load

AvailabilitySource contract
Registrationconfig.enable_ml
Runtime serviceNo prefix-level service check; handler dependencies still apply.
Handler dependenciesSee handler source and return expressions.

Access: Daemon authentication and capability namespace authority; memory-domain permissions apply where mapped.

Request

JsonLoadModelRequest

FieldRust typeRequired on inputNotes
nameStringYes
model_typeStringYes
frameworkStringYes
pathOption<String>No; optional or defaulted
data_b64Option<String>No; optional or defaulted
struct LoadModelRequest {
    name: String,
    model_type: String,
    framework: String,
    path: Option<String>,
    data_b64: Option<String>,
}

Response

Declared return: Result<impl IntoResponse, DaemonError>

The following are the exact JSON construction expressions in the handler. Values such as rows, result, and delegated types are runtime values, not literal example payloads.

serde_json::json!({"id": id})
serde_json::json!({"id": id})

Errors and validation

Directly referenced error variants: InvalidRequest. Middleware and delegated services can return additional errors described in the shared error reference.

Source: akasha-daemon/src/main.rs:2650. Registration: akasha-daemon/src/main.rs:4556.

POST /v1/ml/models/unload

Ml models unload

AvailabilitySource contract
Registrationconfig.enable_ml
Runtime serviceNo prefix-level service check; handler dependencies still apply.
Handler dependenciesSee handler source and return expressions.

Access: Daemon authentication and capability namespace authority; memory-domain permissions apply where mapped.

Request

JsonUnloadModelRequest

FieldRust typeRequired on inputNotes
idStringYes
struct UnloadModelRequest {
    id: String,
}

Response

Declared return: Result<impl IntoResponse, DaemonError>

The following are the exact JSON construction expressions in the handler. Values such as rows, result, and delegated types are runtime values, not literal example payloads.

serde_json::json!({"ok": true})

Errors and validation

Directly referenced error variants: InvalidRequest. Middleware and delegated services can return additional errors described in the shared error reference.

Source: akasha-daemon/src/main.rs:2685. Registration: akasha-daemon/src/main.rs:4557.

GET /v1/ml/models

Ml models list

AvailabilitySource contract
Registrationconfig.enable_ml
Runtime serviceNo prefix-level service check; handler dependencies still apply.
Handler dependenciesSee handler source and return expressions.

Access: Daemon authentication and capability namespace authority; memory-domain permissions apply where mapped.

Request

No typed JSON, query, or path extractor is declared in the handler signature. Headers or request objects may still be consumed; the signature below is authoritative.

Response

Declared return: Result<impl IntoResponse, DaemonError>

The following are the exact JSON construction expressions in the handler. Values such as rows, result, and delegated types are runtime values, not literal example payloads.

serde_json::json!({"models": db.ml_list_loaded_models()}),

Errors and validation

Directly referenced error variants: none in the handler body. Middleware and delegated services can return additional errors described in the shared error reference.

Source: akasha-daemon/src/main.rs:2697. Registration: akasha-daemon/src/main.rs:4558.

POST /v1/ml/metrics

Ml metrics

AvailabilitySource contract
Registrationconfig.enable_ml
Runtime serviceNo prefix-level service check; handler dependencies still apply.
Handler dependenciesSee handler source and return expressions.

Access: Daemon authentication and capability namespace authority; memory-domain permissions apply where mapped.

Request

JsonMlMetricsRequest

FieldRust typeRequired on inputNotes
model_idStringYes
struct MlMetricsRequest {
    model_id: String,
}

Response

Declared return: Result<impl IntoResponse, DaemonError>

The following are the exact JSON construction expressions in the handler. Values such as rows, result, and delegated types are runtime values, not literal example payloads.

serde_json::json!({"metrics": m})

Errors and validation

Directly referenced error variants: InvalidRequest. Middleware and delegated services can return additional errors described in the shared error reference.

Source: akasha-daemon/src/main.rs:2712. Registration: akasha-daemon/src/main.rs:4559.

POST /v1/ml/embed

Ml embed

AvailabilitySource contract
Registrationconfig.enable_ml
Runtime serviceNo prefix-level service check; handler dependencies still apply.
Handler dependenciesSee handler source and return expressions.

Access: Daemon authentication and capability namespace authority; memory-domain permissions apply where mapped.

Request

JsonEmbedRequest

FieldRust typeRequired on inputNotes
textStringYes
chunkboolNo; optional or defaultedWhen true, long text is automatically chunked and each chunk is embedded separately. The response contains a vectors array instead of a single vector. Serde: default
chunkingOption<chunking::ChunkingConfig>No; optional or defaultedOptional per-request chunking overrides.
struct EmbedRequest {
    text: String,
    /// When true, long text is automatically chunked and each chunk is
    /// embedded separately.  The response contains a `vectors` array instead
    /// of a single `vector`.
    #[serde(default)]
    chunk: bool,
    /// Optional per-request chunking overrides.
    chunking: Option<chunking::ChunkingConfig>,
}

Response

Declared return: Result<impl IntoResponse, DaemonError>

The following are the exact JSON construction expressions in the handler. Values such as rows, result, and delegated types are runtime values, not literal example payloads.

serde_json::json!({"vector": v, "chunks": 1})
serde_json::json!({
            "vectors": vectors,
            "chunks": chunks.len(),
        })
serde_json::json!({"vector": v})

Errors and validation

Directly referenced error variants: InvalidRequest. Middleware and delegated services can return additional errors described in the shared error reference.

Source: akasha-daemon/src/main.rs:2737. Registration: akasha-daemon/src/main.rs:4560.

POST /v1/ml/generate

Ml generate

AvailabilitySource contract
Registrationconfig.enable_ml
Runtime serviceNo prefix-level service check; handler dependencies still apply.
Handler dependenciesSee handler source and return expressions.

Access: Daemon authentication and capability namespace authority; memory-domain permissions apply where mapped.

Request

JsonMlGenerateRequest

FieldRust typeRequired on inputNotes
model_idStringYes
promptStringYes
max_tokensOption<usize>No; optional or defaulted
temperatureOption<f32>No; optional or defaulted
struct MlGenerateRequest {
    model_id: String,
    prompt: String,
    max_tokens: Option<usize>,
    temperature: Option<f32>,
}

Response

Declared return: Result<impl IntoResponse, DaemonError>

The following are the exact JSON construction expressions in the handler. Values such as rows, result, and delegated types are runtime values, not literal example payloads.

serde_json::json!({"text": text})

Errors and validation

Directly referenced error variants: InvalidRequest, ServiceDisabled. Middleware and delegated services can return additional errors described in the shared error reference.

Source: akasha-daemon/src/main.rs:2829. Registration: akasha-daemon/src/main.rs:4561.

POST /v1/ml/tokenizers/load

Ml tokenizer load

AvailabilitySource contract
Registrationconfig.enable_ml
Runtime serviceNo prefix-level service check; handler dependencies still apply.
Handler dependenciesSee handler source and return expressions.

Access: Daemon authentication and capability namespace authority; memory-domain permissions apply where mapped.

Request

JsonMlTokenizerLoadReq

FieldRust typeRequired on inputNotes
model_idStringYes
struct MlTokenizerLoadReq {
    model_id: String,
}

Response

Declared return: Result<impl IntoResponse, DaemonError>

The following are the exact JSON construction expressions in the handler. Values such as rows, result, and delegated types are runtime values, not literal example payloads.

serde_json::json!({"ok": true})

Errors and validation

Directly referenced error variants: InvalidRequest. Middleware and delegated services can return additional errors described in the shared error reference.

Source: akasha-daemon/src/main.rs:2862. Registration: akasha-daemon/src/main.rs:4562.

POST /v1/ml/train/supervised

Ml train supervised http

AvailabilitySource contract
Registrationconfig.enable_ml
Runtime serviceNo prefix-level service check; handler dependencies still apply.
Handler dependenciesSee handler source and return expressions.

Access: Daemon authentication and capability namespace authority; memory-domain permissions apply where mapped.

Request

JsonMlTrainSupervisedReq

FieldRust typeRequired on inputNotes
model_nameStringYes
input_dimusizeYes
num_classesusizeYes
samplesVec<MlSupervisedSample>Yes
paramsMlTrainingParamsNo; optional or defaultedSerde: default
struct MlTrainSupervisedReq {
    model_name: String,
    input_dim: usize,
    num_classes: usize,
    samples: Vec<MlSupervisedSample>,
    #[serde(default)]
    params: MlTrainingParams,
}

Response

Declared return: Result<impl IntoResponse, DaemonError>

The following are the exact JSON construction expressions in the handler. Values such as rows, result, and delegated types are runtime values, not literal example payloads.

serde_json::json!({
        "model_id": info.id,
        "name": info.name,
        "version": info.version,
        "metrics": info.metrics,
    })

Errors and validation

Directly referenced error variants: InvalidRequest. Middleware and delegated services can return additional errors described in the shared error reference.

Source: akasha-daemon/src/main.rs:2972. Registration: akasha-daemon/src/main.rs:4563.

POST /v1/ml/train/hrm

Ml train hrm http

AvailabilitySource contract
Registrationconfig.enable_ml
Runtime serviceNo prefix-level service check; handler dependencies still apply.
Handler dependenciesCognitive

Access: Daemon authentication and capability namespace authority; memory-domain permissions apply where mapped.

Request

JsonMlTrainHrmReq

FieldRust typeRequired on inputNotes
domainStringYes
dataspaceStringYes
primitive_keyspaceStringYes
checkpoint_nameStringYes
reservoir_idOption<String>No; optional or defaultedSerde: default
epochsOption<usize>No; optional or defaultedSerde: default
batch_sizeOption<usize>No; optional or defaultedSerde: default
model_configserde_json::ValueYes
training_configserde_json::ValueYes
inputsOption<Vec<serde_json::Value>>No; optional or defaultedSerde: default
targetsOption<Vec<serde_json::Value>>No; optional or defaultedSerde: default
struct MlTrainHrmReq {
    domain: String,
    dataspace: String,
    primitive_keyspace: String,
    checkpoint_name: String,
    #[serde(default)]
    reservoir_id: Option<String>,
    #[serde(default)]
    epochs: Option<usize>,
    #[serde(default)]
    batch_size: Option<usize>,
    model_config: serde_json::Value,
    training_config: serde_json::Value,
    #[serde(default)]
    #[allow(dead_code)]
    inputs: Option<Vec<serde_json::Value>>,
    #[serde(default)]
    #[allow(dead_code)]
    targets: Option<Vec<serde_json::Value>>,
}

Response

Declared return: Result<impl IntoResponse, DaemonError>

The following are the exact JSON construction expressions in the handler. Values such as rows, result, and delegated types are runtime values, not literal example payloads.

serde_json::json!({"status": "ok"})

Errors and validation

Directly referenced error variants: InvalidRequest. Middleware and delegated services can return additional errors described in the shared error reference.

Source: akasha-daemon/src/main.rs:3025. Registration: akasha-daemon/src/main.rs:4564.

On this page