# Models and prices

Source: https://docs.sociaro.com/jobs/models/

Discover asynchronous models, read their input schemas and estimate a specific job before submitting it.

## The model list

`GET /v2/models` returns the models exposed by the Jobs API to your organisation.

cURL

```bash
curl https://api.sociaro.com/v2/models -H "Authorization: Bearer $SOCIARO_API_KEY"
```

Python

```python
# Requires Python 3 and requests (pip install requests).
import os
import requests

response = requests.get(
    'https://api.sociaro.com/v2/models',
    headers={
        'Authorization': 'Bearer ' + os.environ['SOCIARO_API_KEY'],
    },
    timeout=120,
)
response.raise_for_status()
print(response.text)
```

JavaScript

```javascript
// Run as an .mjs file with Node.js 22 or later.

const response = await fetch("https://api.sociaro.com/v2/models", {
  headers: {
    "Authorization": "Bearer " + process.env.SOCIARO_API_KEY,
  },
});
if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
console.log(await response.text());
```

| Field | Use |
| --- | --- |
| `id` | Send as `model` on submit or estimate. |
| `name`, `description` | Display name and summary. |
| `type`, `media`, `output_types` | Task classification, medium and supported output types. |
| `async`, `max_output_count`, `max_runtime_sec` | Execution mode and model limits. |
| `input_schema` | Supported input fields, types, constraints and required values. |
| `preview_image_url` | Preview URL or `null`. |
| `pricing` | Organisation-specific rates, when available. |
| `prompt_enhance` | Accepted enhancement modes, when supported. |

### `type`

Use the task classification to group models. Handle unknown values as `other`.

| Type | Input and output |
| --- | --- |
| `text-to-video` | Prompt → video. |
| `image-to-video` | First frame → video. |
| `reference-to-video` | Prompt and reference media → video. |
| `video-to-video` | Source video → edited or regenerated video. |
| `video-upscale` | Source video → higher-resolution video. |
| `avatar-video` | Portrait and audio or script → talking avatar. |
| `omni-video` | Multiple video input modes, selected by the input fields. |
| `text-to-image` | Prompt → image. |
| `image-to-image` | Source image and prompt → new image. |
| `image-edit` | Source image → edited image. |
| `vectorize` | Raster image → vector file. |

### `preview_image_url`

Use the returned URL for the model preview. A value of `null` means no preview is available.

### `input_schema`

Each model publishes a closed JSON Schema draft 2020-12. Read `required`, types, ranges, enum values and defaults for that model. An omitted default is unspecified. See [validation and input examples](https://docs.sociaro.com/jobs/inputs/index.md).

For `W*H` size strings, `x-min-pixels`, `x-max-pixels`, `x-min-aspect-ratio` and `x-max-aspect-ratio` express constraints on total area and width divided by height. Read the extensions that the model supplies.

File URL nodes may include `x-sociaro` constraints. For arrays, check `items`. For typed media parts, check their `url` property. The constraints describe provider limits. The provider can still reject a file during processing.

| Extension fields | Unit or meaning |
| --- | --- |
| `max_file_size` | Bytes per file. |
| `min_width`, `max_width`, `min_height`, `max_height` | Pixels per dimension. |
| `min_pixels`, `max_pixels` | Width × height, in pixels. |
| `min_aspect_ratio`, `max_aspect_ratio` | Width divided by height. |
| `min_duration`, `max_duration`, `max_total_duration` | Seconds per file or, for the total, across matching files. |
| `min_fps`, `max_fps` | Frames per second. |
| `max_count` | Matching files in a mixed array. Plain arrays use `maxItems`. |

### `pricing`

The authenticated catalogue returns current **organisation rates in USD**. The [public catalogue](https://docs.sociaro.com/models/index.md) shows public list rates. Use the estimate for a specific request and the completed job's `cost_usd` for the final charge.

`pricing.rows` contains display rows with the charge, options, price and any note. The current-price view sets `from` and `until` to `null`. `pricing.notes` contains model-specific billing rules. `pricing.components` provides one machine-readable component per row, in the same order.

Example component for a video rate:

```json
{"unit": "second", "of": "output_video", "usd": 0.126, "when": {"resolution": "720p", "audio": true}, "metered": "request"}
```

| Component | Interpretation |
| --- | --- |
| `unit`, `of`, `usd` | USD charged for one unit of the measured quantity. Units include `second`, `image`, `1M_tokens`, `megapixel`, `megapixel_second` and `job`. |
| `when` | Conditions for this rate. May refer to a request option, a derived property (e.g. input video present) or a result tier. An empty object matches all requests. |
| `metered` | `request` uses request parameters. `result` uses measured media or the generated result. |
| `free` | Number of initial units excluded from the charge. |
| `approx` | Informational equivalent of another component, excluded from the sum. |
| `floor` | Minimum applicable charge. Apply the row's conditions and scaling rules. |
| `round_up` | Round the measured quantity up to the next whole unit before multiplying by `usd`. |

For applicable billable components, multiply the rate by the measured quantity and sum the charges. A megapixel is 1,000,000 pixels. For megapixel-seconds, multiply the frame area in megapixels by output duration. A size tier, minimum charge or draft rate can change the result. Use the model's own notes or call the estimate endpoint for the total.

If organisation rates are temporarily unavailable, discovery returns `503 unavailable`. Retry later.

## Estimate

`POST /v2/jobs/estimate` accepts the same `model`, `input` and optional `output` as a submit. It requires a valid API key. The request creates no job, incurs no charge and reserves no funds. An `Idempotency-Key` header is ignored.

The maximum body size is 2,097,152 bytes. For larger inline media, supply an accessible file URL in an input that accepts URLs.

Example request and response for a five-second video. The returned amount uses the organisation's rate at request time:

cURL

```bash
curl https://api.sociaro.com/v2/jobs/estimate \
  -H "Authorization: Bearer $SOCIARO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
        "model": "kling/kling-3.0-t2v",
        "input": {"prompt": "a paper boat drifting down a rain-soaked street",
                  "settings": {"resolution": "720p", "duration": 5}}
      }'
```

Python

```python
# Requires Python 3 and requests (pip install requests).
import os
import requests

payload = {'model': 'kling/kling-3.0-t2v',
 'input': {'prompt': 'a paper boat drifting down a rain-soaked street',
           'settings': {'resolution': '720p', 'duration': 5}}}

response = requests.post(
    'https://api.sociaro.com/v2/jobs/estimate',
    headers={
        'Authorization': 'Bearer ' + os.environ['SOCIARO_API_KEY'],
        'Content-Type': 'application/json',
    },
    json=payload,
    timeout=120,
)
response.raise_for_status()
print(response.text)
```

JavaScript

```javascript
// Run as an .mjs file with Node.js 22 or later.

const payload = {
  "model": "kling/kling-3.0-t2v",
  "input": {
    "prompt": "a paper boat drifting down a rain-soaked street",
    "settings": {
      "resolution": "720p",
      "duration": 5
    }
  }
};

const response = await fetch("https://api.sociaro.com/v2/jobs/estimate", {
  method: "POST",
  headers: {
    "Authorization": "Bearer " + process.env.SOCIARO_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify(payload),
});
if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
console.log(await response.text());
```

```json
{"model": "kling/kling-3.0-t2v", "estimated_cost_usd": 0.42, "estimate_kind": "exact"}
```

`model` contains the requested ID. `estimated_cost_usd` is in USD. Prices can change between estimate and settlement. Prompt enhancement has no separate charge.

### `promo`

The response includes `promo` when the gateway can confirm that this organisation has free generations remaining for the model. `name` identifies the promotion, `free_left` is the remaining allowance and `period` is `day`, `week`, `month` or `total`. Calendar periods use UTC and weeks start on Monday.

Example response with a promotion:

```json
{"model": "sociaro/leda", "estimated_cost_usd": 0.03, "estimate_kind": "upper_bound",
 "promo": {"name": "Leda preview", "free_left": 3, "period": "day"}}
```

`estimated_cost_usd` is the applicable paid rate if the free allowance no longer applies. A promotion can change `exact` to `upper_bound`. If the gateway cannot read the usage count, it omits `promo` and returns an otherwise `exact` estimate as `upper_bound`. Free generations may still remain when `promo` is absent. An `approximate` estimate remains approximate.

### `estimate_kind`

Read this field for each request. At the quoted rates, it describes how the final charge relates to the estimate.

| Value | Meaning |
| --- | --- |
| `exact` | The final charge equals the estimate. |
| `upper_bound` | The final charge is equal to or below the estimate. |
| `approximate` | The final charge can be higher or lower, for example when it depends on a measured media duration. |

### What is checked

The gateway authenticates the key and validates the input. An estimate can succeed with an exhausted balance. A successful estimate does not reserve capacity, validate every provider resource or guarantee acceptance at submit.

### Other answers

| HTTP status | Meaning |
| --- | --- |
| `400 invalid_input` | Request fields fail validation. |
| `400 estimate_unavailable` | A required source measurement could not be read. Submitting the job is still possible. |
| `401`, `403`, `404` | Invalid key, unavailable organisation feature or unknown model/resource. |
| `413 request_too_large` | Body exceeds the estimate size limit. |
| `503 unavailable` | Pricing is temporarily unavailable. Retry later. |

Estimate responses omit `job_created`. A zero balance alone does not prevent an estimate.
