⌘K

Spark Asset Create Group Intl

spark_asset_create_group_intl

Create an international asset group and retrieve its ID for asset creation.

API Notes

spark_asset_create_group_intl creates a platform task through the unified generation API; model parameters belong in input[0].params

spark_asset_create_group_intl returns type: "text" content with a JSON-encoded text string; parse it to read Result

spark_asset_create_group_intl uses international asset resources; use the international models for subsequent operations and do not assume domestic and international IDs are interchangeable

spark_asset_create_group_intl returns the group’s ID in the parsed Result.Id; use it as GroupId, not as a platform task_id

Authentication

authorization string required

All APIs require authentication via Bearer Token.

Get API Key:

Visit API Key Management Page to get your API Key.

Usage:

Add to request header:

Authorization: Bearer YOUR_API_KEY

Parameters

model string required

Customer-facing model ID

Value: spark_asset_create_group_intl


input array required

Provide one object containing params; all parameters below belong in input[0].params


Name string required

Custom asset group name

Maximum length: 64 characters


GroupType string

Asset group type; optional and omitted in the basic example

Options: AIGC


ProjectName string

Omit or use the default project; the subsequent query examples use the default project and do not establish a complete query flow for other projects

Default: default


Polling

Since result generation takes time, you need to poll the task status after creating the task.

The initial response only returns information such as the task ID and initial status. The final result must be obtained by polling the task status endpoint using the task ID.

See the examples on the right for polling requests and responses.

A create response with status: "completed" only indicates that creation completed. Use the returned id to query the same platform task, and parse results when the task query returns completed with output

Task query statusAction
in_progressContinue querying the same task_id
completedParse the result’s text
failedRead error.code and error.message

Response Format

The success example on the right shows relevant fields only; actual results may include additional metadata. text remains a JSON-encoded string and must not be read as an already parsed object

FieldTypeDescription
idstringPlatform task ID used for task queries
output[].content[].typestringtext
output[].content[].textstringJSON-encoded string; parse to access Result
output[].content[].urlstringEmpty string, not an asset download URL
usage.coststringCost in USD, currently 0
errorobjectError details when a task fails
metadataobjectTask timing and other metadata, when returned

Parse the result

const content = task.output.flatMap(item => item.content ?? [])
  .find(item => item.type === "text");
const result = JSON.parse(content.text).Result;
const groupId = result.Id;

Pass the parsed Result.Id as GroupId when creating an asset; do not use it as the task query’s task_id

Complete Workflow

Create group → Create asset → Query asset

Use a platform task_id to query its task, the group’s Result.Id as GroupId, and the asset’s Result.Id as the asset query’s Id; these identifiers are not interchangeable

This default-project example runs the three models in sequence, reusing each task ID for polling. Replace the API key and placeholder image URL before running

const baseURL = "https://cloud.vtrix.ai";
const apiKey = "YOUR_API_KEY";

async function runAssetModel(model, params) {
  const createdResponse = await fetch(`${baseURL}/model/v1/generation`, {
    method: "POST",
    headers: {
      Authorization: `Bearer ${apiKey}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ model, input: [{ params }] }),
  });
  const created = await createdResponse.json();
  if (!createdResponse.ok || created.error || !created.id) {
    throw new Error(JSON.stringify(created));
  }

  const deadline = Date.now() + 10 * 60 * 1000;
  while (Date.now() < deadline) {
    const response = await fetch(
      `${baseURL}/model/v1/generation/task/${encodeURIComponent(created.id)}`,
      { headers: { Authorization: `Bearer ${apiKey}` } },
    );
    const task = await response.json();
    if (!response.ok || task.status === "failed") {
      throw new Error(JSON.stringify(task.error ?? task));
    }
    if (task.status === "completed" && task.output) {
      const text = task.output.flatMap(item => item.content ?? [])
        .find(item => item.type === "text")?.text;
      if (typeof text !== "string") throw new Error("Missing asset result");
      return JSON.parse(text).Result;
    }
    await new Promise(resolve => setTimeout(resolve, 2000));
  }
  throw new Error(`Polling timed out; query the same task: ${created.id}`);
}

const group = await runAssetModel("spark_asset_create_group_intl", {
  Name: "my-assets",
  ProjectName: "default",
});
const asset = await runAssetModel("spark_asset_create_intl", {
  GroupId: group.Id,
  Name: "reference",
  AssetType: "Image",
  URL: "https://example.com/reference.jpg",
});
const ready = await runAssetModel("spark_asset_get_intl", { Id: asset.Id });
if (ready.Status !== "Active") throw new Error("Asset is not ready");
console.log(ready.Id, ready.URL);

Pricing

This asset model is currently free, with usage.cost: "0" in successful responses. Group creation, asset creation, and asset queries are all free; subsequent image or video generation has separate pricing

Error Handling

Read error.code and error.message for failed tasks. Check parameters, URL accessibility, and asset or group IDs; the wrapper does not guarantee the underlying API’s specific error code. Use the same international asset models throughout the default-project workflow