Skip to content

Cancel inference run

Viewing v2— current version

POST
/v2/workspaces/{workspace_id}/inferences/{inference_id}/cancel
curl --request POST \
--url https://api.app.layer.ai/api/v2/workspaces/:workspace_id/inferences/:inference_id/cancel \
--header 'Authorization: Bearer <token>'

Unchanged from v1. This endpoint’s documented request and response schemas are identical in v1 and v2 — change the /v1 prefix to /v2. Schema equality is not a promise about behaviour, so keep your usual smoke tests.

Request cancellation of an in-flight inference. Fire-and-forget: returns immediately after signalling the run to stop. Poll GET /workspaces/{workspace_id}/inferences/{inference_id} for the eventual CANCELLED status. A run that already COMPLETED can no longer be cancelled and returns INFERENCE_ALREADY_COMPLETE; the other terminal states are idempotent no-ops.

workspace_id
required
Workspace Id

Id of the workspace that owns the resource.

string format: uuid

Id of the workspace that owns the resource.

inference_id
required
Inference Id

Id of the generation.

string format: uuid

Id of the generation.

Successful Response

Media typeapplication/json
GetForgeRunOutput
object
inference_id
required
Inference Id

Unique identifier for this forge run.

string format: uuid
status
required
InferenceStatus

Current status: in_progress, complete, failed, cancelled, or deleted.

string
Allowed values: in_progress complete failed cancelled deleted
poll_interval_seconds
Any of:
integer
completed_at
Any of:
string format: date-time
outputs
Any of:
Array<object>
ForgeRunAsset
object
file_id
required
File Id

File ID for the generated asset.

string format: uuid
url
required
Url

Download URL for the asset.

string
content_type
required
Content Type

MIME type, e.g. image/png or video/mp4.

string
preview_url
Any of:
string
width
Any of:
integer
height
Any of:
integer
duration_seconds
Any of:
number
file_size_bytes
Any of:
integer
actual_price_creative_units
Any of:
number
error
Any of:
string
error_code
Any of:
string
Example
{
"status": "in_progress"
}

Unauthenticated — missing or invalid Bearer token.

Media typeapplication/problem+json
object
type
required
string
title
required
string
status
required
integer
detail
required
string
Example
{
"type": "https://api.layer.ai/errors/ERROR_CODE",
"title": "Error Title",
"status": 400,
"detail": "Human-readable description."
}

Forbidden — insufficient permissions.

Media typeapplication/problem+json
object
type
required
string
title
required
string
status
required
integer
detail
required
string
Example
{
"type": "https://api.layer.ai/errors/ERROR_CODE",
"title": "Error Title",
"status": 400,
"detail": "Human-readable description."
}

Resource not found.

Media typeapplication/problem+json
object
type
required
string
title
required
string
status
required
integer
detail
required
string
Example
{
"type": "https://api.layer.ai/errors/ERROR_CODE",
"title": "Error Title",
"status": 400,
"detail": "Human-readable description."
}

Invalid input parameters.

Media typeapplication/problem+json
object
type
required
string
title
required
string
status
required
integer
detail
required
string
Example
{
"type": "https://api.layer.ai/errors/ERROR_CODE",
"title": "Error Title",
"status": 400,
"detail": "Human-readable description."
}

Rate limited — too many concurrent requests.

Media typeapplication/problem+json
object
type
required
string
title
required
string
status
required
integer
detail
required
string
Example
{
"type": "https://api.layer.ai/errors/ERROR_CODE",
"title": "Error Title",
"status": 400,
"detail": "Human-readable description."
}

Internal server error.

Media typeapplication/problem+json
object
type
required
string
title
required
string
status
required
integer
detail
required
string
Example
{
"type": "https://api.layer.ai/errors/ERROR_CODE",
"title": "Error Title",
"status": 400,
"detail": "Human-readable description."
}