> ## Documentation Index
> Fetch the complete documentation index at: https://docs.archetypeai.app/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Start with /introduction/getting-started. Use the Inference API's Direct Query endpoint (POST /api/inference/query) with the newton-c-2.6 or newton-fusion-1.0 model (text, image, and video reasoning) or the omega-embedding encoder (time-series embeddings). ATAI_API_ENDPOINT is the base URL https://platform.u1.archetypeai.app with no version path; every endpoint path begins with /api. Pages whose descriptions are marked (Archived) document the legacy Lens runtime — do not use them for new projects.

# Cancel Model Session

> Close one of your sessions on a platform-hosted model

Requires [version 2.0.1](https://docs.archetypeai.app/release-notes/2.0.x.md#v2-0-1) or later of the Archetype platform.

## Overview

This endpoint closes a running session. The session ends as `cancelled`, and its place under your
organization's limit for the model frees up at once.

## Request

**session\_id** `string` *required*

Session `ses_` ID.

## Response

Returns `200` with the [session object](https://docs.archetypeai.app/api-reference/inference/sessions/get-session.md#response), now
`cancelled`.

```bash cURL theme={"system"}
curl -X POST "$ATAI_API_ENDPOINT/inference/sessions/ses_01jcx4m8t2vq6xn3r7k5hbzw9e/cancel" \
  -H "Authorization: Bearer $ATAI_API_KEY"
```

```python Python theme={"system"}
import os
import requests

base_url = os.environ["ATAI_API_ENDPOINT"]
api_key = os.environ["ATAI_API_KEY"]

response = requests.post(
    f"{base_url}/inference/sessions/ses_01jcx4m8t2vq6xn3r7k5hbzw9e/cancel",
    headers={"Authorization": f"Bearer {api_key}"},
)

if response.ok:
    print(response.json()["status"])
else:
    print(f"Error: {response.json()['errors']}")
```

```javascript JavaScript theme={"system"}
const response = await fetch(
  `${process.env.ATAI_API_ENDPOINT}/inference/sessions/ses_01jcx4m8t2vq6xn3r7k5hbzw9e/cancel`,
  {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.ATAI_API_KEY}`
    }
  }
);

const body = await response.json();
if (response.ok) {
  console.log(body.status);
} else {
  console.error('Error:', body.errors);
}
```

```json 200 - Session cancelled theme={"system"}
{
  "id": "ses_01jcx4m8t2vq6xn3r7k5hbzw9e",
  "model": "omega-embedding",
  "status": "cancelled",
  "values": {"window_size": 1024, "step_size": 512},
  "error": null,
  "created_at": "2026-11-11T09:12:44Z",
  "started_at": "2026-11-11T09:12:51Z",
  "completed_at": "2026-11-11T09:40:02Z"
}
```

## Important Notes

> [!NOTE]
>
> * `404` means the session doesn't exist or isn't visible to you.
> * `409` means the session has already ended, which can happen on its own, for example when it expires.
> * The call can take up to 15 seconds while the session's in-flight work winds down. The cancel stands
>   even if that can't be confirmed.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.