Back to home

DEVELOPER DOCUMENTATION

ScalingTensor API documentation

Use one API key to call every model in the catalog. Media models run as asynchronous jobs that you submit and poll; the chat endpoint is synchronous.

Browse model marketplace

01

Generate your first media job

Create an API key in the Console, then submit a job for a media model from the catalog. The example uses sonilo/text-to-music. Save data.jobId from the response and poll the result endpoint every few seconds until status is completed or failed; the completed result contains the output URL.

cURL
# 1. Submit a job. The response contains data.jobId.
curl -X POST https://restapi.scalingtensor.com/api/media/generate \
  -H "Content-Type: application/json" \
  -H "apiKey: YOUR_API_KEY" \
  -d '{
    "model": "sonilo/text-to-music",
    "params": {
      "prompt": "lofi hiphop beat with warm vinyl texture",
      "duration": 20,
      "variants_num": 1
    }
  }'

# 2. Poll with that jobId until data.status is completed or failed.
curl "https://restapi.scalingtensor.com/api/media/result?jobId=YOUR_JOB_ID" \
  -H "apiKey: YOUR_API_KEY"

02

Fundamentals

Base URL

Use the production API root below. Requests and responses use JSON. Media generation currently accepts JSON URLs only; binary uploads are not supported.

BASE URL
https://restapi.scalingtensor.com

Authentication

Except for the model list, chat and media calls require the key created in the Console in the apiKey request header. Do not use Authorization or expose keys in browser code.

HEADERS
Content-Type: application/json
apiKey: YOUR_API_KEY

Response envelope

Every endpoint returns the same envelope. A request is successful only when code is 0; an HTTP success alone does not indicate business success. time and Long identifiers may be serialized as strings.

JSON
{
  "code": 0,
  "data": { ... },
  "msg": "Success",
  "time": "1788483942311",
  "requestId": "",
  "success": true
}

03

API Reference

POST/api/chat/completion

Create a chat completion

This endpoint is synchronous and works with catalog models whose type is chat; replace YOUR_CHAT_MODEL_ID with one of their slugs. messages are passed to the active model adapter. The current controller accepts only model and messages as top-level fields.

FieldTypeRequiredDescription
modelstringYesSlug of an enabled chat model
messagesobject[]YesMessage array; each item normally includes role and content
cURL
curl -X POST https://restapi.scalingtensor.com/api/chat/completion \
  -H "Content-Type: application/json" \
  -H "apiKey: YOUR_API_KEY" \
  -d '{
    "model": "YOUR_CHAT_MODEL_ID",
    "messages": [
      {"role": "user", "content": "Hello!"}
    ]
  }'

Response data

FieldTypeDescription
contentstringGenerated model text
tokensInintegerActual input token count
tokensOutintegerActual output token count
costMicrosint64/stringActual cost in microdollars (USD 1 = 1,000,000 microdollars)
JSON
{
  "code": 0,
  "data": {
    "content": "Hello! How can I help?",
    "tokensIn": 8,
    "tokensOut": 7,
    "costMicros": "6"
  },
  "msg": "Success"
}
POST/api/media/generate

Submit a media job

Media generation is asynchronous. Save the returned jobId and poll the result endpoint. params are forwarded according to the model provider, so available fields depend on the selected model.

FieldTypeRequiredDescription
modelstringYesSlug of an enabled media model
paramsobjectYesModel parameter object; cannot be null
cURL
curl -X POST https://restapi.scalingtensor.com/api/media/generate \
  -H "Content-Type: application/json" \
  -H "apiKey: YOUR_API_KEY" \
  -d '{
    "model": "sonilo/text-to-music",
    "params": {
      "prompt": "Warm ambient music for a product demo",
      "duration": 30,
      "variants_num": 1
    }
  }'

Response data

FieldTypeDescription
jobIdint64/stringScalingTensor job ID used to retrieve the result
statusstringInitial status, normally pending
JSON
{
  "code": 0,
  "data": { "jobId": "724958320123", "status": "pending" },
  "msg": "Success"
}
GET/api/media/result

Retrieve a media result

Poll with the jobId returned during submission. A job can only be read by the user that owns the API key used to create it. Poll every 2–5 seconds until completed or failed.

FieldTypeRequiredDescription
apiKeyheaderYesA valid API key for the account that created the job
jobIdquery / int64YesjobId returned by media submission
cURL
curl "https://restapi.scalingtensor.com/api/media/result?jobId=724958320123" \
  -H "apiKey: YOUR_API_KEY"

Job statuses

FieldDescription
pendingQueued or processing; continue polling
completedCompleted; resultData contains the provider result and output URL
failedFailed; stop polling. Precharged fixed cost is refunded according to service logic
JSON
{
  "code": 0,
  "data": {
    "status": "completed",
    "resultData": {
      "status": "completed",
      "output_url": "https://.../result.mp3"
    }
  },
  "msg": "Success"
}

04

Common media parameters

params differ by model. Each model page lists its accepted parameters (Input Schema) and an example request. The Sonilo parameters below are validated before a job is accepted.

Modelparams fields and constraints
sonilo/text-to-musicprompt (1–2,000 chars), duration (integer, 5–360 seconds); optional segments, output_format, variants_num (1–10)
sonilo/text-to-sfxprompt (1–2,000 chars), duration (integer, 1–180 seconds); optional audio_format: wav/mp3/aac/flac
sonilo/video-to-musicvideo_url (public direct HTTP(S) video URL); optional prompt, segments, preserve_speech, isolate_vocals, output_format, ducking, variants_num, stems, prompt_influence, lyrics
sonilo/video-to-sfxvideo_url; optional prompt (up to 2,000 chars), audio_format, segments (1–30 contiguous items with start, end, prompt)
sonilo/dubbingvideo_url; optional languages (unique language-code array), ducking (boolean)
video_url must be a public, direct HTTP(S) URL without redirects and contain readable video. The JSON endpoint does not support binary video uploads.

05

Error handling

Business errors use the same response envelope. Check code before reading data. Common codes are listed below.

codeDescription
0Success
3Rate limited
5Internal server error
1000General business error
1001Invalid parameters
1003Model/job not found, or job belongs to another user
1008Invalid or revoked API key
1009Insufficient wallet balance
1012Video is too large to inspect
1013Could not determine a positive video duration

Security and retry guidance

  • Keep API keys on your server or in a secure secret manager.
  • Decide carefully whether to retry chat calls to avoid duplicate charges.
  • After a media submission succeeds, do not resubmit; store jobId and poll it.
  • Use exponential backoff only for rate limits, network failures, and server errors.