<span id="产品模型调用公共对象"></span>

# Product model invocation common objects

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

Product model invocation uses workspace and product identity. Genesis inference, backend administration, and Worker execution follow separate contracts.

<span id="prepare"></span>

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

## Before you call this API

Obtain the product API base URL, credentials, and workspace ID in one environment. Examples use `$BASE_URL`, `$MOI_KEY`, and `$WORKSPACE_ID`. `BASE_URL` already includes its product prefix; do not append `/v1`. Workspace models/endpoints must meet applicable access, configuration, and online conditions.

Production deployment version is unconfirmed. Regular product identities pass through the current gateway; task credentials and system Worker identities are not interchangeable user authentication methods.

(budget)=
<span id="上下文预检查"></span>

## Context preflight

| `moi_context_budget` field | Type | Condition |
| --- | --- | --- |
| `status` | string | `checked` or `unknown`. |
| `input_tokens` | integer | Measured input token count when checked. |
| `context_window` | integer | Model context window when checked. |
| `reserved_output_tokens` | integer | Reserved output when checked; positive max_completion_tokens takes precedence, otherwise max_tokens. |
| `reason` | string | May be adapter_unsupported when unknown. |

The checker determines whether output reservation, template input, and extension fields can be measured. if_supported does not guarantee all backends bypass measurement errors. unknown does not mean sufficient budget.

<span id="errors"></span>

<span id="错误与计费"></span>

## Errors and billing

Regular product errors from both endpoints use numeric `code` and `message`, optionally `details`. Do not reuse root backend administration string `code/msg`. Identity/permission layers may reject first; inspect actual HTTP status and machine fields.

Billing admission rejection may include `details.reason`, string `details.retryable`, and optional `details.action`. Handle402,403, dependency unavailability, and other statuses as returned. Model usage, successful requests, and final settlement differ. A service_slot query parameter cannot grant quota or privileges.

Streaming chat can return JSON errors before committing the response. After commitment, HTTP status cannot change; consume SSE error events and connection termination. SDK StreamResponse and CLI streaming deliver bytes only; applications must interpret business errors in the stream.

Complete credential signatures, Service Slots, quota charging, and accounting recovery still require live-environment retesting.
