<span id="工作区式大语言模型创建后端"></span>

# Create an LLM backend (workspace endpoint)

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

Save LLM backend configuration and get a new backend ID.


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

<span id="调用前准备"></span>

## Before you call this API

`BASE_URL` uses the product API prefix `https://api.moi.matrixorigin.cn/v5`. For a dedicated deployment, use its corresponding product API address.

[Configure identity, Workspace, and object permissions in the same environment](objects.md#prepare).

<span id="请求"></span>

## Request

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

```bash
curl --request POST \
  "$BASE_URL/workspaces/$WORKSPACE_ID/llm/backends" \
  --header "X-API-Key: $MOI_KEY" \
  --header "X-Workspace-ID: $WORKSPACE_ID" \
  --header "Content-Type: application/json" \
  --data-raw '{"name":"临时后端","type":0,"api_key_encrypted":"provider-key-example","models":["chat-example"]}'
```

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

| Parameter | Location | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `X-Workspace-ID` | Header | string | Yes | Workspace ID in the same environment. |
| `workspace_id` | Path | string | Yes | Workspace ID in the same environment. |
| `name` | Body | string | Yes | Nonempty name after trimming surrounding whitespace. |
| `type` | Body | integer | No | Numeric protocol 0–6, default 0; Embedding rejects 5. |
| `api_key_encrypted` | Body | string | No | Provider credentials. The field name does not establish their encryption state. |
| `models` | Body | array (array of strings) | No | Nonempty names without leading/trailing whitespace. The workspace API allows an empty set. |
| `timeout_seconds` | Body | integer | No | Positive seconds. Omitted/nonpositive values become 120. |
| `reasoning_control_protocol` | Body | integer | No | LLM only uses 0–5, default 0; Embedding ignores it. |
| `provider_origin` | Body | string | No | Only LLM accepts external_provider; Embedding does not use it. |
| `origin_ref` | Body | string | No | LLM provenance reference text. |
| `origin_version` | Body | string | No | LLM provenance version text. |

Requires Workspace model_backend.create. Save the returned id, then read details and endpoints. Configuration does not verify model connectivity or inference capability. Ordinary Workspace-level creation does not automatically create endpoints. DEV adapters have special internal behavior and are not a production integration method.

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

<span id="成功响应"></span>

## Successful response

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

```json
{
  "code": 0,
  "data": {
    "id": 12,
    "name": "临时后端",
    "timeout_seconds": 120,
    "models": [
      "chat-example"
    ],
    "created_at": 1794445200,
    "updated_at": 1794445200,
    "provider_origin": "external_provider",
    "api_key_encrypted": "provider-key-example"
  }
}
```

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

HTTP 201。

| Field | Type | Description |
| --- | --- | --- |
| `code` | integer | 0 on success. |
| `data` | object | [Actual objects for this protocol](objects.md#responses). |

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

<span id="错误响应"></span>

## Error response

[Errors and result confirmation](objects.md#errors) distinguishes the two protocols. Parse omitted fields, SDK zero values, and empty HTTP responses separately. Confirm writes using the corresponding read operation.
