Skip to content
Create a key

Paste a key to use it in the examples on these pages. The key stays in this browser tab. These pages never send it anywhere.

Estimate the credits of an analysis or a build

estimate_analysisPOST/v1/projects/{projectId}/analyze/estimateBeta

Estimate the credits of an analysis, a build or the preparation of an edit, and who would pay them, without starting anything.

Beta. This endpoint is supported and can gain new fields. If a change would break your code, we tell you before it takes effect and list it in the changelog.

About

Call it before analyze_project (POST /v1/projects/{projectId}/analyze), before the build of a split screen, streamer or Reddit story project, or before preparing a Vibe Editing project, to show the price and to check that the account can pay it. It refuses for the same reasons the start would (no source video, settings still to choose, a video that no longer exists), so a project it accepts is ready to start, and the price it gives is the one the start charges. The price of an analysis depends only on the length of the source video, never on the settings: when the user only wants the price of an Auto Clip project with settings still to choose, choose them with update_project (PATCH /v1/projects/{projectId}) (get_setting_options (GET /v1/reference/setting-options) lists the values) and estimate again, and tell the user they can change them before analyze_project. payer says who would pay now: the plan or the API bonus. When the same work is already running, creditsToCharge is 0, runningJobId is its job, payer is null and enough is true, even when planRequired is true. Fake text projects have no price here: their story and voices use the daily fake text allowance. Nothing is charged or changed.

Example use

A nightly script goes through the projects in its queue one at a time. It estimates each one and starts the analysis only when enough is true. The projects it cannot pay for wait for the next night.

Endpoint

Code
POST https://api.gpt-video.com/v1/projects/{projectId}/analyze/estimate
  • Scope clips:read.
  • Rate limit 120 requests a minute for each key and 240 for each account, shared by every read call. See rate limits.
  • No Idempotency-Key.

Parameters

Path

NameTypeRequiredDescription
projectIdstringRequiredThe project id. It starts with prj_. Matches ^prj_[0-9a-f]{20}$.

Request

Price an analysis before starting it.

Request example
curl -X POST "https://api.gpt-video.com/v1/projects/prj_7c2e9a4f1b3d4e8096a5/analyze/estimate" \
  -H "Authorization: Bearer $GPT_VIDEO_API_KEY"
const res = await fetch("https://api.gpt-video.com/v1/projects/prj_7c2e9a4f1b3d4e8096a5/analyze/estimate", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.GPT_VIDEO_API_KEY}`,
  },
});
const data = await res.json();
console.log(data);
import os

import requests

r = requests.post(
    "https://api.gpt-video.com/v1/projects/prj_7c2e9a4f1b3d4e8096a5/analyze/estimate",
    headers={
        "Authorization": f"Bearer {os.environ['GPT_VIDEO_API_KEY']}",
    },
)
data = r.json()
print(data)
{
  "method": "tools/call",
  "params": {
    "name": "estimate_analysis",
    "arguments": {
      "projectId": "prj_7c2e9a4f1b3d4e8096a5"
    }
  }
}

Response

A successful call answers HTTP 200.

Fields to check

NameTypeDescription
estimate.runningJobIdstring or nullThe job of the analysis or build already running on the project; null when none is.

Response example

HTTP 200
{
  "estimate": {
    "credits": 30,
    "creditsToCharge": 30,
    "sourceDurationSec": 1800,
    "runningJobId": null,
    "creditsAvailable": 640,
    "planRequired": false,
    "enough": true,
    "payer": "plan",
    "bonusRemaining": null
  }
}
All response fields
NameTypeRequiredDescription
estimateobjectRequired
estimate.creditsintegerRequiredThe price of a new analysis, build or preparation of this project, in credits.
estimate.creditsToChargeintegerRequiredWhat the start would charge now: the price, or 0 when the same work is already running.
estimate.sourceDurationSecnumberRequiredThe length of video the price is computed on, in seconds: the source, or the main and the background video of a split screen together. 0 when the price does not depend on a video, as for a Reddit story.
estimate.runningJobIdstring or nullRequiredThe job of the analysis or build already running on the project; null when none is.
estimate.creditsAvailableintegerRequiredThe credits of the plan the account can spend now: what is left of the plan this month plus top-up credits. Through the API they can be spent only on the Creator and Studio plans. The API bonus is not in it: see payer and bonusRemaining.
estimate.planRequiredbooleanRequiredtrue when the account must choose a plan in the GPT-Video app before it can spend its credits. While the API bonus is active, a call through the API spends it even when planRequired is true. It does not say whether the API may spend the plan credits: only the Creator and Studio plans can.
estimate.enoughbooleanRequiredtrue when the start would not be refused for credits or plan, that is when payer is not null. Always true while the same work is running, because that job is returned and nothing is charged.
estimate.payerstring or nullRequiredWho would pay the start now: plan is the credits of the account's plan, api_bonus is the API bonus. null when the start would be refused for credits or plan, and when the same work is already running and nothing would be charged. One of plan, api_bonus.
estimate.bonusRemaininginteger or nullRequiredThe credits left in the API bonus, 0 once it is used up, expired or cancelled; null when the account never had one.
More examples

An analysis already running costs nothing

POST /v1/projects/prj_7c2e9a4f1b3d4e8096a5/analyze/estimate

HTTP 200
{
  "estimate": {
    "credits": 30,
    "creditsToCharge": 0,
    "sourceDurationSec": 1800,
    "runningJobId": "job_6c1e8b4a2f0d4a97e3b5",
    "creditsAvailable": 640,
    "planRequired": false,
    "enough": true,
    "payer": null,
    "bonusRemaining": null
  }
}

Price the build of a split screen video

POST /v1/projects/prj_9cf6ba9cd17fd89cf513/analyze/estimate

HTTP 200
{
  "estimate": {
    "credits": 31,
    "creditsToCharge": 31,
    "sourceDurationSec": 1860,
    "runningJobId": null,
    "creditsAvailable": 640,
    "planRequired": false,
    "enough": true,
    "payer": "plan",
    "bonusRemaining": null
  }
}

Price the build of a Reddit story

POST /v1/projects/prj_b71ffef7c27c5ea1cc87/analyze/estimate

HTTP 200
{
  "estimate": {
    "credits": 1,
    "creditsToCharge": 1,
    "sourceDurationSec": 0,
    "runningJobId": null,
    "creditsAvailable": 640,
    "planRequired": false,
    "enough": true,
    "payer": "plan",
    "bonusRemaining": null
  }
}

A project without a source video

POST /v1/projects/prj_1d8b6e0c47a24f93b1c2/analyze/estimate

HTTP 422
{
  "error": {
    "code": "SOURCE_MISSING",
    "message": "Upload or import a source video before starting the analysis.",
    "hint": "A project's video cannot be changed through the API. Upload the video, then create a new project with its asset id as sourceAssetId.",
    "requestId": "req_b4e0a7c3d9f14a62c8e5d1b7"
  }
}

Errors

CodeStatusWhenWhat to do
NOT_FOUND404See the error reference.Change the request, then send it again.
CONFLICT409The project is a fake text project, which has no price here, or an Auto Clip project with settings still to choose or to fix. The message says what to change.Read the resource again, then decide. Do not send the same request again.
SOURCE_MISSING422A project without a source videoChange the request, then send it again.

Every call can also answer these errors. VALIDATION_FAILED, UNKNOWN_PARAMETER, UNAUTHORIZED, SCOPE_MISSING, PAYLOAD_TOO_LARGE, RATE_LIMITED, INTERNAL, UNAVAILABLE.

Cost

No credits are used.

Questions

Does an estimate reserve the credits?

No. Nothing is reserved: the credits are charged when the analysis or the build starts, at the price it reports then.

Why is creditsToCharge 0 when credits is not?

The same work is already running on the project. The start would return that job and charge nothing; credits is the price of a new one.

Who pays when the account has the API bonus?

payer says it. Through the API the bonus pays first while it covers the whole price, and on the Creator and Studio plans the plan pays otherwise. On any other plan a price the bonus cannot cover is refused. The bonus never pays part of a price, and a price is never split between the two.

View as Markdown