# New model workflow

Complete main-skill preflight and [connections](connections.md) first. For an imported draft, start at step 2 with its `resourceId`; do not create it again.

Follow the [main entry](../SKILL.md) form-first rule for missing model fields, family selection, and any needed test or publication confirmation.

## 1. Prepare and create

```bash
openany seller schema --type model --application APPLICATION_ID -j
openany seller models create --application APPLICATION_ID --file model.json --operation TASK-model-create-1 -j
```

Prepare `model.json` against the current schema: `price` and `routes`, using the supplier's actual model identity, capabilities, quote, currency, service endpoints, mappings, and route choices. Prices are decimal strings with at most six fractional digits; token prices use the existing per-million-token unit. Bind routes to owned connection IDs and required connection revisions. Never copy response-only ownership, activation, or publication fields into a write payload. Record the returned `price.id` as `MODEL_ID`.

`price.model` is the supplier's service model ID. `routes[0].publicModel` is the OpenAny route model ID used in client requests. These may differ: for example, `price.model: "vendor-chat-v2"` and `routes[0].publicModel: "my-chat"`. Saving derives the route's service model from `price.model`; do not add a third writable identity. Editing either ID does not rename the other. Manage one route per model.

### Non-token pricing

When `price.billingUnit` is `request`, `image`, `second`, or `minute`, put the quoted price per one billing unit in `price.actualPrompt` and set `price.actualCompletion` to the decimal string `"0"`. Do not put the unit price in the completion field or copy it into both fields. For example, USD 0.05 per image uses `currency: "USD"`, `billingType: "per_image"`, `billingUnit: "image"`, `actualPrompt: "0.050000"`, and `actualCompletion: "0"` inside `price`.

For website v2 imports, `inputPrice` maps to `price.actualPrompt` and `outputPrice` maps to `price.actualCompletion`. Non-token pricing requires `outputPrice: "0"` and `priceUnitQuantity: "1"`; token pricing uses `priceUnitQuantity: "1000000"`. Keep prices in the declared currency and unit without rescaling.

### Model fields and family selection

Collect the current website fields, including the display name (`price.modelName`) and model family. A new public model needs an existing family selected by the user; use `routes[].familyId`, not API `categories` or the supplier application's `primary_category`. An already assigned family is read-only: preserve it and do not send a new assignment. Do not guess a family UUID or infer one from the model name. The current CLI exposes family options through model import preview (`items[].families`); for a single new model, a one-item import preview can supply those options. Then fill the selected family in the same draft or bindings. If options cannot be obtained, report the missing capability and ask the user to select through the console.

Do not turn optional schema properties or template placeholders into extra required questions. In an update, retain existing routes and use `expectedVersion`; when `pricingEditable` is false, omit pricing fields instead of asking the user to re-enter them. A cURL example is required by the model import contract, not automatically by every model write. Keep the import and single-model schemas separate.

If the live CLI schema disagrees with the current website fields (for example, missing `modelName` or `familyId`, or disallowing an authorized published-model edit), report the exact field and contract mismatch. Do not silently drop user input, invent replacement fields, remove unrelated safety checks, or claim a skill change fixes the backend schema. Preserve the prepared data and resolve the interface mismatch before the affected write.

### Credential-free examples

Keep placeholder headers such as `-H "Authorization: Bearer $OPENANY_API_KEY"` or `-H "Authorization: Bearer YOUR_API_KEY"` in model cURL examples (`price.curlExample` or `models[].requestCurlExample`). Enter real credentials through the secure connection. If the CLI returns `SECRET_IN_DOCUMENT`, use the reported `field` to locate the credential and replace it with a placeholder in the example.

## 2. Read the saved configuration

```bash
openany seller models get --application APPLICATION_ID --id MODEL_ID -j
```

Save `version`, `price.id`, and each route's `id`, `connectionId`, and `connectionRevision`. Use saved route IDs, not array indices or local import item IDs. Read `price.servicePath` to choose the authorized endpoint. If this is a draft-only task, report the draft ID and stop here.

## 3. Verify every route

First reuse a known passed, non-stale receipt only after checking all identity and version fields below against the current saved resource and connection. For a known running or unknown verification, query/reconcile it first. Run one authorized verification only when no current passed or unresolved verification remains. The get command below is conditional: use it only for an unfinished result or missing matching fields, not after a complete matching terminal result. Do not repeat tests or add fixed waits to obtain the same receipt.


For each route, create a separate non-secret verification file with these fields:

| Verification input | Source |
| --- | --- |
| `expectedVersion` | Saved model `version` |
| `routeId` | Saved `routes[].id` for this route |
| `expectedConnectionRevision` | That route's current `connectionRevision`; recheck the connection if needed |
| `endpointIndex` | Zero-based index of the selected endpoint in `price.servicePath` |
| `request` | Authorized test request (`path`, `query`, `headers`, `body` as applicable), without credentials |

```bash
openany seller models verify --application APPLICATION_ID --id MODEL_ID --file route-verification.json --operation TASK-model-route1-test-1 -j
openany seller models get --application APPLICATION_ID --id MODEL_ID --verification-id VERIFICATION_ID -j
```

`--file PATH` and `--input 'JSON'` are alternative input modes; choose exactly one. Verification does not require a file specifically. Both modes accept the same JSON object, for example:

```json
{
  "expectedVersion": "SAVED_MODEL_VERSION",
  "routeId": "SAVED_ROUTE_ID",
  "expectedConnectionRevision": 1,
  "endpointIndex": 0,
  "request": {
    "path": {},
    "query": {},
    "headers": { "Content-Type": "application/json" },
    "body": {
      "messages": [{ "role": "user", "content": "Ping test" }],
      "max_tokens": 5
    }
  }
}
```

Replace the version, route ID, revision, endpoint index and test body with the saved configuration and authorized test inputs. For models, `request.path` must be an empty object `{}` when supplied, never `"/v1/chat/completions"` or a nonempty parameter map. The actual URL path comes from `price.servicePath[endpointIndex]`. A string fails backend JSON decoding before URL construction or a service call; the CLI now rejects it locally. API path parameter objects are a separate contract. A generic 400 alone is not evidence that CLI permissions are insufficient or that verification requires the web UI.

Record the verification response `id` before querying it. Use a distinct operation/file for each route. A usable receipt has `state: "passed"`, is not stale, and matches this `modelId`, `modelVersion`, `routeId`, `connectionId`, and `connectionRevision`. Testing may incur costs; obey the authorized scope and budget. Query an unfinished known receipt within the task deadline instead of repeating verify. For unknown outcomes, follow [recovery](reviews.md).

## 4. Publish

Supplier admission must be complete (`live`). Individual resources do not need human review. Prepare `publication.json` from the saved resource:

`expectedVersion` and `verificationIds` containing the current successful receipt for every saved route.

```bash
openany seller models publish --application APPLICATION_ID --id MODEL_ID --file publication.json --operation TASK-model-publish-1 -j
openany seller models get --application APPLICATION_ID --id MODEL_ID -j
```

Report activation separately from runtime synchronization. Missing or stale verification and revision conflicts require inspection, never guessed version replacement. For unpublication, use `unpublish` with `expectedVersion`.

## Correct a resource

Read the resource and prepare a schema-valid configuration using the current version and connection revisions. No review withdrawal is required. For an authorized edit:

```bash
openany seller models update --application APPLICATION_ID --id MODEL_ID --file model-update.json --operation TASK-model-update-2 -j
```

Read back and reverify changed configuration as required. Reconcile uncertain writes before any further mutation.
