# Inference

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

Source: https://docs.minds.sh/docs/api/instance/inference



This reference covers **12 HTTP operations** registered by the Akasha daemon. Call these paths on your instance base URL. See [authentication](/docs/api/instance/authentication), [errors](/docs/api/instance/errors), and [coverage](/docs/api/instance/coverage) before integrating.

| Method   | Path                                    | Operation                                                                   |
| -------- | --------------------------------------- | --------------------------------------------------------------------------- |
| `POST`   | `/v1/inference/:model_id`               | [Inference invoke](#post-v1-inference-model-id)                             |
| `GET`    | `/v1/inference/jobs/:job_id`            | [Inference job status](#get-v1-inference-jobs-job-id)                       |
| `GET`    | `/v1/inference/models`                  | [Inference list models](#get-v1-inference-models)                           |
| `POST`   | `/v1/inference/models`                  | [Inference register model](#post-v1-inference-models)                       |
| `GET`    | `/v1/inference/models/:model_id`        | [Inference get model](#get-v1-inference-models-model-id)                    |
| `DELETE` | `/v1/inference/models/:model_id`        | [Inference delete model](#delete-v1-inference-models-model-id)              |
| `PATCH`  | `/v1/inference/models/:model_id/status` | [Inference update model status](#patch-v1-inference-models-model-id-status) |
| `GET`    | `/v1/inference/backends/summary`        | [Inference backend summary](#get-v1-inference-backends-summary)             |
| `GET`    | `/v1/inference/jobs`                    | [Inference jobs snapshot](#get-v1-inference-jobs)                           |
| `GET`    | `/v1/inference/health`                  | [Inference health](#get-v1-inference-health)                                |
| `POST`   | `/v1/inference/jobs/:job_id/retry`      | [Inference retry job](#post-v1-inference-jobs-job-id-retry)                 |
| `POST`   | `/v1/inference/jobs/:job_id/cancel`     | [Inference cancel job](#post-v1-inference-jobs-job-id-cancel)               |

<a id="post-v1-inference-model-id" />

## POST `/v1/inference/:model_id` [#post-v1inferencemodel_id]

Inference invoke

| Availability         | Source contract                            |
| -------------------- | ------------------------------------------ |
| Registration         | `config.enable_inference`                  |
| Runtime service      | `inference`                                |
| Handler dependencies | See handler source and return expressions. |

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

### Request [#request]

**Path** — `String`

```json
{
  "type": "string"
}
```

**Json** — `UnifiedInferenceRequest`

| Field         | Rust type               | Required on input         | Notes            |
| ------------- | ----------------------- | ------------------------- | ---------------- |
| `tenant_id`   | `String`                | Yes                       |                  |
| `payloads`    | `Vec<InferencePayload>` | No; optional or defaulted | Serde: `default` |
| `config`      | `Option<Value>`         | No; optional or defaulted | Serde: `default` |
| `priority`    | `Option<u8>`            | No; optional or defaulted | Serde: `default` |
| `deadline_ms` | `Option<u64>`           | No; optional or defaulted | Serde: `default` |

```rust
struct UnifiedInferenceRequest {
    pub tenant_id: String,
    #[serde(default)]
    pub payloads: Vec<InferencePayload>,
    #[serde(default)]
    pub config: Option<Value>,
    #[serde(default)]
    pub priority: Option<u8>,
    #[serde(default)]
    pub deadline_ms: Option<u64>,
}
```

### Response [#response]

**Declared return:** `Result<Json<UnifiedInferenceApiResponse>, DaemonError>`

```rust
struct UnifiedInferenceApiResponse {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub job_id: Option<Uuid>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub result: Option<InferenceResultEnvelope>,
    pub backend: BackendKind,
    pub telemetry: BackendTelemetrySnapshot,
    pub metering: MeteringSnapshot,
}
```

### Errors and validation [#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.

<Accordions>
  <Accordion title="Inspect implementation">
    This exact source excerpt includes validation, defaults, delegated calls, and response assembly.

    ```rust
    async fn inference_invoke(
        State(state): State<AppState>,
        Path(model_id): Path<String>,
        Json(request): Json<UnifiedInferenceRequest>,
    ) -> Result<Json<UnifiedInferenceApiResponse>, DaemonError> {
        state.usage_emitter.emit_hrm_inference();
        let service = require_inference_service(&state)?;
        service
            .invoke(&model_id, request)
            .await
            .map(Json)
            .map_err(map_inference_error)
    }
    ```
  </Accordion>
</Accordions>

Source: `akasha-daemon/src/main.rs:5194`. Registration: `akasha-daemon/src/main.rs:5164`.

<a id="get-v1-inference-jobs-job-id" />

## GET `/v1/inference/jobs/:job_id` [#get-v1inferencejobsjob_id]

Inference job status

| Availability         | Source contract                            |
| -------------------- | ------------------------------------------ |
| Registration         | `config.enable_inference`                  |
| Runtime service      | `inference`                                |
| Handler dependencies | See handler source and return expressions. |

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

### Request [#request-1]

**Path** — `String`

```json
{
  "type": "string"
}
```

### Response [#response-1]

**Declared return:** `Result<Json<JobStatus>, DaemonError>`

```rust
enum JobStatus {
    Pending {
        queued_at: DateTime<Utc>,
    },
    Running {
        started_at: DateTime<Utc>,
    },
    Completed {
        finished_at: DateTime<Utc>,
        result: Box<InferenceResultEnvelope>,
    },
    Failed {
        finished_at: DateTime<Utc>,
        error: String,
    },
    Cancelled {
        finished_at: DateTime<Utc>,
    },
}
```

### Errors and validation [#errors-and-validation-1]

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

<Accordions>
  <Accordion title="Inspect implementation">
    This exact source excerpt includes validation, defaults, delegated calls, and response assembly.

    ```rust
    async fn inference_job_status(
        State(state): State<AppState>,
        Path(job_id): Path<String>,
    ) -> Result<Json<JobStatus>, DaemonError> {
        let service = require_inference_service(&state)?;
        let uuid = Uuid::parse_str(&job_id)
            .map_err(|_| DaemonError::InvalidRequest("invalid job id".into()))?;
        service
            .get_job_status(uuid)
            .await
            .map(Json)
            .map_err(map_inference_error)
    }
    ```
  </Accordion>
</Accordions>

Source: `akasha-daemon/src/main.rs:5208`. Registration: `akasha-daemon/src/main.rs:5165`.

<a id="get-v1-inference-models" />

## GET `/v1/inference/models` [#get-v1inferencemodels]

Inference list models

| Availability         | Source contract                            |
| -------------------- | ------------------------------------------ |
| Registration         | `config.enable_inference`                  |
| Runtime service      | `inference`                                |
| Handler dependencies | See handler source and return expressions. |

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

### Request [#request-2]

**Query** — `InferenceModelQuery`

| Field     | Rust type        | Required on input         | Notes |
| --------- | ---------------- | ------------------------- | ----- |
| `tenant`  | `Option<String>` | No; optional or defaulted |       |
| `backend` | `Option<String>` | No; optional or defaulted |       |
| `family`  | `Option<String>` | No; optional or defaulted |       |
| `status`  | `Option<String>` | No; optional or defaulted |       |
| `search`  | `Option<String>` | No; optional or defaulted |       |

```rust
struct InferenceModelQuery {
    tenant: Option<String>,
    backend: Option<String>,
    family: Option<String>,
    status: Option<String>,
    search: Option<String>,
}
```

### Response [#response-2]

**Declared return:** `Result<Json<InferenceModelListResponse>, 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.

```rust
InferenceModelListResponse {
        models: service.list_models(&filter),
    }
```

### Errors and validation [#errors-and-validation-2]

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

<Accordions>
  <Accordion title="Inspect implementation">
    This exact source excerpt includes validation, defaults, delegated calls, and response assembly.

    ```rust
    async fn inference_list_models(
        State(state): State<AppState>,
        Query(query): Query<InferenceModelQuery>,
    ) -> Result<Json<InferenceModelListResponse>, DaemonError> {
        let service = require_inference_service(&state)?;
        let filter = query.to_filter()?;
        Ok(Json(InferenceModelListResponse {
            models: service.list_models(&filter),
        }))
    }
    ```
  </Accordion>
</Accordions>

Source: `akasha-daemon/src/main.rs:5335`. Registration: `akasha-daemon/src/main.rs:5166`.

<a id="post-v1-inference-models" />

## POST `/v1/inference/models` [#post-v1inferencemodels]

Inference register model

| Availability         | Source contract                            |
| -------------------- | ------------------------------------------ |
| Registration         | `config.enable_inference`                  |
| Runtime service      | `inference`                                |
| Handler dependencies | See handler source and return expressions. |

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

### Request [#request-3]

**Json** — `RegisterModelRequest`

| Field            | Rust type             | Required on input         | Notes            |
| ---------------- | --------------------- | ------------------------- | ---------------- |
| `model_id`       | `String`              | Yes                       |                  |
| `tenant_id`      | `String`              | Yes                       |                  |
| `owner`          | `String`              | Yes                       |                  |
| `family`         | `ModelFamily`         | Yes                       |                  |
| `backend`        | `BackendKind`         | Yes                       |                  |
| `version`        | `String`              | Yes                       |                  |
| `adapter_id`     | `Option<String>`      | No; optional or defaulted | Serde: `default` |
| `hrm_entrypoint` | `Option<String>`      | No; optional or defaulted | Serde: `default` |
| `tags`           | `Vec<String>`         | No; optional or defaulted | Serde: `default` |
| `capabilities`   | `Vec<String>`         | No; optional or defaulted | Serde: `default` |
| `extra`          | `Value`               | No; optional or defaulted | Serde: `default` |
| `status`         | `Option<ModelStatus>` | No; optional or defaulted | Serde: `default` |

```rust
struct RegisterModelRequest {
    model_id: String,
    tenant_id: String,
    owner: String,
    family: ModelFamily,
    backend: BackendKind,
    version: String,
    #[serde(default)]
    adapter_id: Option<String>,
    #[serde(default)]
    hrm_entrypoint: Option<String>,
    #[serde(default)]
    tags: Vec<String>,
    #[serde(default)]
    capabilities: Vec<String>,
    #[serde(default)]
    extra: Value,
    #[serde(default)]
    status: Option<ModelStatus>,
}
```

### Response [#response-3]

**Declared return:** `Result<StatusCode, DaemonError>`

Serialization is delegated or the handler returns a raw response. Consult the exact handler below; the OpenAPI response intentionally remains unconstrained.

### Errors and validation [#errors-and-validation-3]

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

Explicit status constants: `CREATED`.

<Accordions>
  <Accordion title="Inspect implementation">
    This exact source excerpt includes validation, defaults, delegated calls, and response assembly.

    ```rust
    async fn inference_register_model(
        State(state): State<AppState>,
        Json(request): Json<RegisterModelRequest>,
    ) -> Result<StatusCode, DaemonError> {
        let service = require_inference_service(&state)?;
        let now = Utc::now();
        let metadata = ModelMetadata {
            model_id: request.model_id.clone(),
            tenant_id: request.tenant_id.clone(),
            family: request.family,
            backend: request.backend,
            adapter_id: request.adapter_id.clone(),
            version: request.version.clone(),
            hrm_entrypoint: request.hrm_entrypoint.clone(),
            tags: request.tags.clone(),
            owner: request.owner.clone(),
            created_at: now,
            updated_at: now,
            capabilities: request.capabilities.clone(),
            extra: request.extra.clone(),
            status: request.status.unwrap_or_default(),
        };
        service
            .register_model(metadata)
            .map_err(map_inference_error)?;
        Ok(StatusCode::CREATED)
    }
    ```
  </Accordion>
</Accordions>

Source: `akasha-daemon/src/main.rs:5295`. Registration: `akasha-daemon/src/main.rs:5166`.

<a id="get-v1-inference-models-model-id" />

## GET `/v1/inference/models/:model_id` [#get-v1inferencemodelsmodel_id]

Inference get model

| Availability         | Source contract                            |
| -------------------- | ------------------------------------------ |
| Registration         | `config.enable_inference`                  |
| Runtime service      | `inference`                                |
| Handler dependencies | See handler source and return expressions. |

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

### Request [#request-4]

**Path** — `String`

```json
{
  "type": "string"
}
```

### Response [#response-4]

**Declared return:** `Result<Json<ModelMetadata>, 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.

```rust
metadata
```

### Errors and validation [#errors-and-validation-4]

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

<Accordions>
  <Accordion title="Inspect implementation">
    This exact source excerpt includes validation, defaults, delegated calls, and response assembly.

    ```rust
    async fn inference_get_model(
        State(state): State<AppState>,
        Path(model_id): Path<String>,
    ) -> Result<Json<ModelMetadata>, DaemonError> {
        let service = require_inference_service(&state)?;
        let metadata = service
            .registry()
            .get(&model_id)
            .ok_or_else(|| DaemonError::InvalidRequest("model not found".into()))?;
        Ok(Json(metadata))
    }
    ```
  </Accordion>
</Accordions>

Source: `akasha-daemon/src/main.rs:5323`. Registration: `akasha-daemon/src/main.rs:5170`.

<a id="delete-v1-inference-models-model-id" />

## DELETE `/v1/inference/models/:model_id` [#delete-v1inferencemodelsmodel_id]

Inference delete model

| Availability         | Source contract                            |
| -------------------- | ------------------------------------------ |
| Registration         | `config.enable_inference`                  |
| Runtime service      | `inference`                                |
| Handler dependencies | See handler source and return expressions. |

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

### Request [#request-5]

**Path** — `String`

```json
{
  "type": "string"
}
```

### Response [#response-5]

**Declared return:** `Result<StatusCode, DaemonError>`

Serialization is delegated or the handler returns a raw response. Consult the exact handler below; the OpenAPI response intentionally remains unconstrained.

### Errors and validation [#errors-and-validation-5]

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

Explicit status constants: `NO_CONTENT`.

<Accordions>
  <Accordion title="Inspect implementation">
    This exact source excerpt includes validation, defaults, delegated calls, and response assembly.

    ```rust
    async fn inference_delete_model(
        State(state): State<AppState>,
        Path(model_id): Path<String>,
    ) -> Result<StatusCode, DaemonError> {
        let service = require_inference_service(&state)?;
        service
            .delete_model(&model_id)
            .map_err(map_inference_error)?;
        Ok(StatusCode::NO_CONTENT)
    }
    ```
  </Accordion>
</Accordions>

Source: `akasha-daemon/src/main.rs:5358`. Registration: `akasha-daemon/src/main.rs:5170`.

<a id="patch-v1-inference-models-model-id-status" />

## PATCH `/v1/inference/models/:model_id/status` [#patch-v1inferencemodelsmodel_idstatus]

Inference update model status

| Availability         | Source contract                            |
| -------------------- | ------------------------------------------ |
| Registration         | `config.enable_inference`                  |
| Runtime service      | `inference`                                |
| Handler dependencies | See handler source and return expressions. |

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

### Request [#request-6]

**Path** — `String`

```json
{
  "type": "string"
}
```

**Json** — `InferenceUpdateStatusRequest`

| Field    | Rust type     | Required on input | Notes |
| -------- | ------------- | ----------------- | ----- |
| `status` | `ModelStatus` | Yes               |       |

```rust
struct InferenceUpdateStatusRequest {
    status: ModelStatus,
}
```

### Response [#response-6]

**Declared return:** `Result<Json<ModelMetadata>, 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.

```rust
updated
```

### Errors and validation [#errors-and-validation-6]

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

<Accordions>
  <Accordion title="Inspect implementation">
    This exact source excerpt includes validation, defaults, delegated calls, and response assembly.

    ```rust
    async fn inference_update_model_status(
        State(state): State<AppState>,
        Path(model_id): Path<String>,
        Json(body): Json<InferenceUpdateStatusRequest>,
    ) -> Result<Json<ModelMetadata>, DaemonError> {
        let service = require_inference_service(&state)?;
        let updated = service
            .update_model_status(&model_id, body.status)
            .map_err(map_inference_error)?;
        Ok(Json(updated))
    }
    ```
  </Accordion>
</Accordions>

Source: `akasha-daemon/src/main.rs:5346`. Registration: `akasha-daemon/src/main.rs:5174`.

<a id="get-v1-inference-backends-summary" />

## GET `/v1/inference/backends/summary` [#get-v1inferencebackendssummary]

Inference backend summary

| Availability         | Source contract                            |
| -------------------- | ------------------------------------------ |
| Registration         | `config.enable_inference`                  |
| Runtime service      | `inference`                                |
| Handler dependencies | See handler source and return expressions. |

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

### Request [#request-7]

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 [#response-7]

**Declared return:** `Result<Json<Vec<BackendRuntimeReport>>, 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.

```rust
service.backend_reports()
```

### Errors and validation [#errors-and-validation-7]

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

<Accordions>
  <Accordion title="Inspect implementation">
    This exact source excerpt includes validation, defaults, delegated calls, and response assembly.

    ```rust
    async fn inference_backend_summary(
        State(state): State<AppState>,
    ) -> Result<Json<Vec<BackendRuntimeReport>>, DaemonError> {
        let service = require_inference_service(&state)?;
        Ok(Json(service.backend_reports()))
    }
    ```
  </Accordion>
</Accordions>

Source: `akasha-daemon/src/main.rs:5369`. Registration: `akasha-daemon/src/main.rs:5178`.

<a id="get-v1-inference-jobs" />

## GET `/v1/inference/jobs` [#get-v1inferencejobs]

Inference jobs snapshot

| Availability         | Source contract                            |
| -------------------- | ------------------------------------------ |
| Registration         | `config.enable_inference`                  |
| Runtime service      | `inference`                                |
| Handler dependencies | See handler source and return expressions. |

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

### Request [#request-8]

**Query** — `InferenceJobQuery`

| Field   | Rust type       | Required on input         | Notes |
| ------- | --------------- | ------------------------- | ----- |
| `limit` | `Option<usize>` | No; optional or defaulted |       |

```rust
struct InferenceJobQuery {
    limit: Option<usize>,
}
```

### Response [#response-8]

**Declared return:** `Result<Json<QueueSnapshot>, 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.

```rust
service.queue_snapshot(resolve_job_limit(query.limit))
```

### Errors and validation [#errors-and-validation-8]

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

<Accordions>
  <Accordion title="Inspect implementation">
    This exact source excerpt includes validation, defaults, delegated calls, and response assembly.

    ```rust
    async fn inference_jobs_snapshot(
        State(state): State<AppState>,
        Query(query): Query<InferenceJobQuery>,
    ) -> Result<Json<QueueSnapshot>, DaemonError> {
        let service = require_inference_service(&state)?;
        Ok(Json(service.queue_snapshot(resolve_job_limit(query.limit))))
    }
    ```
  </Accordion>
</Accordions>

Source: `akasha-daemon/src/main.rs:5376`. Registration: `akasha-daemon/src/main.rs:5182`.

<a id="get-v1-inference-health" />

## GET `/v1/inference/health` [#get-v1inferencehealth]

Inference health

| Availability         | Source contract                            |
| -------------------- | ------------------------------------------ |
| Registration         | `config.enable_inference`                  |
| Runtime service      | `inference`                                |
| Handler dependencies | See handler source and return expressions. |

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

### Request [#request-9]

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 [#response-9]

**Declared return:** `Result<impl IntoResponse, DaemonError>`

Serialization is delegated or the handler returns a raw response. Consult the exact handler below; the OpenAPI response intentionally remains unconstrained.

### Errors and validation [#errors-and-validation-9]

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

<Accordions>
  <Accordion title="Inspect implementation">
    This exact source excerpt includes validation, defaults, delegated calls, and response assembly.

    ```rust
    async fn inference_health(State(state): State<AppState>) -> Result<impl IntoResponse, DaemonError> {
        service_health_payload(&state, "inference").await
    }
    ```
  </Accordion>
</Accordions>

Source: `akasha-daemon/src/main.rs:10313`. Registration: `akasha-daemon/src/main.rs:5183`.

<a id="post-v1-inference-jobs-job-id-retry" />

## POST `/v1/inference/jobs/:job_id/retry` [#post-v1inferencejobsjob_idretry]

Inference retry job

| Availability         | Source contract                            |
| -------------------- | ------------------------------------------ |
| Registration         | `config.enable_inference`                  |
| Runtime service      | `inference`                                |
| Handler dependencies | See handler source and return expressions. |

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

### Request [#request-10]

**Path** — `String`

```json
{
  "type": "string"
}
```

### Response [#response-10]

**Declared return:** `Result<Json<UnifiedInferenceApiResponse>, DaemonError>`

```rust
struct UnifiedInferenceApiResponse {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub job_id: Option<Uuid>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub result: Option<InferenceResultEnvelope>,
    pub backend: BackendKind,
    pub telemetry: BackendTelemetrySnapshot,
    pub metering: MeteringSnapshot,
}
```

### Errors and validation [#errors-and-validation-10]

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

<Accordions>
  <Accordion title="Inspect implementation">
    This exact source excerpt includes validation, defaults, delegated calls, and response assembly.

    ```rust
    async fn inference_retry_job(
        State(state): State<AppState>,
        Path(job_id): Path<String>,
    ) -> Result<Json<UnifiedInferenceApiResponse>, DaemonError> {
        let service = require_inference_service(&state)?;
        let uuid = Uuid::parse_str(&job_id)
            .map_err(|_| DaemonError::InvalidRequest("invalid job id".into()))?;
        service
            .retry_job(uuid)
            .await
            .map(Json)
            .map_err(map_inference_error)
    }
    ```
  </Accordion>
</Accordions>

Source: `akasha-daemon/src/main.rs:5384`. Registration: `akasha-daemon/src/main.rs:5184`.

<a id="post-v1-inference-jobs-job-id-cancel" />

## POST `/v1/inference/jobs/:job_id/cancel` [#post-v1inferencejobsjob_idcancel]

Inference cancel job

| Availability         | Source contract                            |
| -------------------- | ------------------------------------------ |
| Registration         | `config.enable_inference`                  |
| Runtime service      | `inference`                                |
| Handler dependencies | See handler source and return expressions. |

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

### Request [#request-11]

**Path** — `String`

```json
{
  "type": "string"
}
```

### Response [#response-11]

**Declared return:** `Result<Json<JobStatus>, DaemonError>`

```rust
enum JobStatus {
    Pending {
        queued_at: DateTime<Utc>,
    },
    Running {
        started_at: DateTime<Utc>,
    },
    Completed {
        finished_at: DateTime<Utc>,
        result: Box<InferenceResultEnvelope>,
    },
    Failed {
        finished_at: DateTime<Utc>,
        error: String,
    },
    Cancelled {
        finished_at: DateTime<Utc>,
    },
}
```

### Errors and validation [#errors-and-validation-11]

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

<Accordions>
  <Accordion title="Inspect implementation">
    This exact source excerpt includes validation, defaults, delegated calls, and response assembly.

    ```rust
    async fn inference_cancel_job(
        State(state): State<AppState>,
        Path(job_id): Path<String>,
    ) -> Result<Json<JobStatus>, DaemonError> {
        let service = require_inference_service(&state)?;
        let uuid = Uuid::parse_str(&job_id)
            .map_err(|_| DaemonError::InvalidRequest("invalid job id".into()))?;
        service
            .cancel_job(uuid)
            .await
            .map(Json)
            .map_err(map_inference_error)
    }
    ```
  </Accordion>
</Accordions>

Source: `akasha-daemon/src/main.rs:5398`. Registration: `akasha-daemon/src/main.rs:5188`.
