Skip to content

For AI agents: every API docs page in one plain-text file is at /docs/llms-full.txt, and the documentation index is at /llms.txt. This page is available as Markdown at https://diffio.ai/docs/api-reference/create-project.md, and every docs URL returns Markdown when requested with Accept: text/markdown.

Create a project

Creates a project for one audio or video recording and returns pre-built multipart upload instructions (upload.requests). Pass generation to queue the first restore immediately so it starts automatically as soon as the upload is ready.

POST https://api.diffio.ai/v2/projects

  • Key scope: projects:write
  • Auth header:Authorization: Bearer <apiKey>
  • Body: JSON
  1. POST /projects
  2. uploads/start
  3. uploads/parts
  4. uploads/complete
  5. upload/complete
The HTTP upload sequence, call by call
  1. POST/projectsid and upload
  2. POSTupload.requests.start.urluploadId
  3. PUTupload.requests.part.url (one per part)etag per part
  4. POSTupload.requests.complete.urlsizeBytes, etag
  5. POST/projects/{project_id}/upload/completeoptional; status preparing or ready

Every edge call: Authorization: Bearer {upload_token}Parts ≤ 32 MiB (part_size_bytes, numbered from 1)

Request

Send a JSON object naming the recording (file_name) and optional file size, MIME type, metadata, or initial generation.

Headers

FieldTypeRequiredDescription
#Diffio-End-UserstringRequired: NoOptional end-user identifier (up to 128 characters). Assigns the new project to end_user and scopes Idempotency-Key to that end user.
#Idempotency-KeystringRequired: NoOptional key (up to 255 characters) for safe retries. Repeating the same request returns the original project; changing any body field returns 409 (idempotency_key_conflict).

Body fields

FieldTypeRequiredDescription
#file_namestringRequired: YesRecording filename with a supported audio or video extension.
#content_typestringRequired: NoRecording MIME type (for example audio/mpeg or video/mp4); defaults to application/octet-stream when omitted.
#size_bytesintegerRequired: NoFile size in bytes when known, from 0 up to 2147483648 (2 GB).
#metadataobjectRequired: NoOptional string-to-string map saved on the project (up to 50 keys; each key up to 40 characters, each value up to 500 characters).
#generationobjectRequired: NoOptional initial restore to queue immediately (latest_generation); requires generations:write scope in addition to projects:write.Fields below
generation 3 fields
FieldTypeRequiredDescription
#generation.modelstringRequired: YesModel ID from GET /models, such as diffio-flash or diffio-pro.
#generation.samplingobjectRequired: NoOptional advanced sampling overrides object.
#generation.labelstringRequired: NoOptional caller-defined name for the generation (up to 120 characters).

Request

import os
from diffio import DiffioClient

key = os.environ["DIFFIO_API_KEY"]
client = DiffioClient(api_key=key)

project = client.projects.create(
    file_name="interview.mp3",
    content_type="audio/mpeg",
    size_bytes=510957,
    metadata={"order_id": "1042"},
    end_user="customer-mwe8tm1g",
    idempotency_key="v2docs-a-mwe8tm1g",
)

Response

Returns the new project (status: "awaiting_upload") with signed multipart upload instructions valid for 24 hours.

Success: 201Created.

Response fields

FieldTypePresentDescription
#idstringAlwaysUnique project identifier (UUID).
#objectstringAlwaysResource type, always "project".project
#statusstringAlwaysUpload and preparation state: awaiting_upload until bytes arrive, preparing while media is probed, ready when ready to restore, or failed.awaiting_uploadpreparingreadyfailed
#latest_generationobject | nullAlwaysNewest Generation object on this project, or null when no generation exists yet.
#uploadobject | nullAlwaysMultipart upload instructions for sending the file to the media edge, or null on an idempotent replay after the upload has arrived.Fields below
upload 11 fields
FieldTypePresentDescription
#upload.upload_session_idstringAlwaysUpload session identifier (api-{project_id}).
#upload.edge_base_urlstringAlwaysOrigin URL of the media upload edge (https://media.diffio.io).
#upload.upload_tokenstringAlwaysSigned bearer token sent as Authorization: Bearer <token> on every upload edge request.
#upload.part_size_bytesintegerAlwaysRequired byte length for every upload part except the last (33554432, 32 MiB).
#upload.max_bytesintegerAlwaysMaximum total upload size in bytes (2147483648, 2 GB).
#upload.expires_atstringAlwaysISO 8601 UTC timestamp when upload_token expires (24 hours after minting); renew via POST /projects/{project_id}/upload.
#upload.requestsobjectAlwaysPre-built HTTP request descriptors for the multipart upload (start, part, complete, abort).
#upload.requests.startobjectAlwaysDescriptor (method, url, headers, body, returns, description) called once first to obtain uploadId.
#upload.requests.partobjectAlwaysDescriptor called once per part (numbered from 1) with raw bytes as the PUT body; save each returned etag.
#upload.requests.completeobjectAlwaysDescriptor called once after all parts finish, sending uploadId and the ordered parts array (partNumber, etag).
#upload.requests.abortobjectAlwaysOptional descriptor to discard uploaded parts for an unfinished uploadId.
Other response fields15 fields
FieldTypePresentDescription
#file_namestring | nullAlwaysRecording filename as sent at creation, or null.
#content_typestring | nullAlwaysMIME type sent at creation (application/octet-stream when none was sent), or null.
#size_bytesinteger | nullAlwaysFile size in bytes: the uploaded byte count once the upload arrives, before that the size_bytes sent at creation; null when unknown.
#duration_secondsnumber | nullAlwaysRecording duration in seconds once status is ready, or null while awaiting upload or preparing.
#has_videobooleanAlwaysTrue when the recording has video: inferred from content_type or the file name until the upload is probed, then from the file itself.
#end_userstring | nullAlwaysEnd-user identifier from the Diffio-End-User header at creation, or null for account-level projects.
#metadataobjectAlwaysKey-value string map saved with the project ({} when none was supplied).
#generation_countintegerAlwaysTotal number of generations created for this project.
Show all 15 fields (7 more)
FieldTypePresentDescription
#video_preview_statusstring | nullAlwaysState of a video project's picture-only HLS stream (video_hls): preparing, ready, or failed; null for audio projects.preparingreadyfailed
#share_idstring | nullAlwaysPublic 17-character share identifier while a share is published, or null when unshared.
#created_atstring | nullAlwaysISO 8601 UTC timestamp when the project was created, or null.
#updated_atstring | nullAlwaysISO 8601 UTC timestamp when the project last changed, or null.
#errorobject | nullAlwaysFailure details when status is failed, or null otherwise.
#error.codestringAlwaysStable snake_case project failure code (media_processing_failed or project_failed).
#error.messagestringAlwaysHuman-readable explanation of why the upload could not be prepared.

Response 201Created.

Return codes

  • 201Created.Project created with multipart upload instructions (and queued latest_generation when generation was sent).
  • 400Bad request.
    Malformed JSON, or 4 more causes
    • Malformed JSON
    • Missing file_name
    • Invalid body field
    • Oversized header
    • Unknown generation.model
    invalid_jsonmissing_fieldinvalid_fieldinvalid_headerunknown_model
  • 402Payment required: see error.code for the billing problem.When generation is included and the account cannot pay for the first restore (checked at the 60-second minimum until the upload is probed); see the error codes below. insufficient_creditneeds_payment_methodpayment_failedusage_limit_reacheddetails
  • 403Forbidden: the key lacks permission.Key is inactive or lacks projects:write, or generations:write when generation is included. permission_denied
  • 409Conflict: see error.code for which one.Reused Idempotency-Key with different request fields. idempotency_key_conflictdetails
  • 413Payload too large.size_bytes exceeds the 2 GB (2,147,483,648 bytes) upload limit. upload_too_large
  • 415Client error.File extension or content_type is not a supported audio or video format. unsupported_media_type
  • 500Server error.Initial generation could not be started and nothing was charged, or server error. generation_start_failedinternal_error
  • 401Unauthorized: the API key is missing or invalid.405Client error.Same on every endpoint
    • 401Unauthorized: the API key is missing or invalid. Missing API key (code missing_api_key), or invalid API key (code invalid_api_key).
    • 405Client error. HTTP method not supported on this path; check the Allow header (code method_not_allowed).

Error codes

5 codes
StatusCodeMeaningAlso returned
402Payment required: see error.code for the billing problem.insufficient_creditYour API credit is used up, or cannot cover this file.estimated_cost_cents remaining_credit_cents
402Payment required: see error.code for the billing problem.needs_payment_methodCard billing accounts: no payment method, and the credit is used up or cannot cover this file.estimated_cost_cents remaining_credit_cents (when the credit was read)
402Payment required: see error.code for the billing problem.payment_failedA payment for API usage failed, or the last invoice of ended card billing is unpaid.details omitted
402Payment required: see error.code for the billing problem.usage_limit_reachedUnbilled usage reached $100; it is being charged now.details omitted
409Conflict: see error.code for which one.idempotency_key_conflictIdempotency-Key was already used with different request fields.details omitted

Example error response

Error response
{
  "error": {
    "code": "insufficient_credit",
    "message": "This file needs about $1.25 of API credit and your balance is $0.40. Add credit in the developer dashboard to continue.",
    "request_id": "f064e4099097414da3fb5b37684ab1bb",
    "details": {
      "estimated_cost_cents": 125,
      "remaining_credit_cents": 40
    }
  }
}

Notes

  • Upload the recording by executing upload.requests.start, upload.requests.part (32 MiB parts except the last), and upload.requests.complete, or call client.projects.upload(...) in the Python and Node.js SDKs.
  • Files can be up to 2 GB (2,147,483,648 bytes) with no media length limit.
  • After upload.requests.complete succeeds, the upload edge reports completion automatically within about 30 seconds; call Complete a project's upload to make readiness immediate.

Report an issue with this page