# Create an LLM session record

```{raw} html
<div class="mo-api-page-show-toc" aria-hidden="true"></div>
```

Save a separate session record for the current user. This request does not call a model.


```http
POST https://api.moi.matrixorigin.cn/v5/workspaces/{workspace_id}/llm/sessions
```

## Before you call this API

Set `BASE_URL` to the product API prefix `https://api.moi.matrixorigin.cn/v5`. For private deployments, use the corresponding product API URL.

[Configure Workspace identity and variables in the same environment](objects.md#request-prerequisites).

## Request

:::::::{div} mo-api-tabs
::::::{tab-set}
:::::{tab-item} Request example

```bash
curl --request POST \
  "$BASE_URL/workspaces/$WORKSPACE_ID/llm/sessions" \
  --header "X-API-Key: $MOI_KEY" \
  --header "X-Workspace-ID: $WORKSPACE_ID" \
  --header "Content-Type: application/json" \
  --data-raw '{"title":"临时会话","source":"moi","config":"{}"}'
```

:::::
:::::{tab-item} Parameters

| Parameter | Location | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `workspace_id` | Path | string | Yes | Target Workspace, matching X-Workspace-ID. |
| `title` | Body | string | No | Session title; omission/null is saved as an empty string. |
| `source` | Body | string | No | Application source identifier, an open string. Omission/null becomes empty. |
| `config` | Body | string | No | Configuration stored as text. Serialize JSON configuration to a string first. |

The server generates the ID. No business request_id idempotency parameter is provided. For unknown creation outcomes, read the session list first to avoid immediate duplicate creation.

:::::
::::::
:::::::

## Successful response

:::::::{div} mo-api-tabs mo-api-response-tabs
::::::{tab-set}
:::::{tab-item} Response example

```json
{
  "code": 0,
  "data": {
    "id": 41,
    "title": "临时会话",
    "source": "moi",
    "user_id": "user-example",
    "config": "{}",
    "created_at": 1794445200,
    "updated_at": 1794445200
  }
}
```

:::::
:::::{tab-item} Fields

| Field | Type | Description |
| --- | --- | --- |
| `code` | integer | 0 on success; HTTP status is 201. |
| `data` | object | [Session record](objects.md#session-object). |

:::::
::::::
:::::::

## Error responses

[Error formats and read scope](objects.md#error-contract) explains differing identity, parameter, resource-read, and storage-failure outcomes.
