Upload bytes to an upload session
curl --request PUT \
--url https://api.varg.ai/v2/files/upload/{session_id} \
--header 'Content-Type: application/octet-stream' \
--data '<string>'import requests
url = "https://api.varg.ai/v2/files/upload/{session_id}"
payload = "<string>"
headers = {"Content-Type": "application/octet-stream"}
response = requests.put(url, data=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'Content-Type': 'application/octet-stream'},
body: '<string>'
};
fetch('https://api.varg.ai/v2/files/upload/{session_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.varg.ai/v2/files/upload/{session_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => "<string>",
CURLOPT_HTTPHEADER => [
"Content-Type: application/octet-stream"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.varg.ai/v2/files/upload/{session_id}"
payload := strings.NewReader("<string>")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Content-Type", "application/octet-stream")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api.varg.ai/v2/files/upload/{session_id}")
.header("Content-Type", "application/octet-stream")
.body("<string>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.varg.ai/v2/files/upload/{session_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Content-Type"] = 'application/octet-stream'
request.body = "<string>"
response = http.request(request)
puts response.read_body{
"ok": true,
"public_url": "https://s3.varg.ai/files/acc_x/file_abc123.mp4",
"size": 48234112,
"media_type": "video/mp4",
"file_id": "file_abc123",
"registered": true
}{
"error": {
"code": "model_not_found",
"message": "Unknown model: flux-shnell",
"details": "<unknown>"
}
}{
"error": {
"code": "model_not_found",
"message": "Unknown model: flux-shnell",
"details": "<unknown>"
}
}{
"error": {
"code": "model_not_found",
"message": "Unknown model: flux-shnell",
"details": "<unknown>"
}
}{
"error": {
"code": "model_not_found",
"message": "Unknown model: flux-shnell",
"details": "<unknown>"
}
}Files
Upload bytes to an upload session
Second step of the large-file flow started by POST /files/upload-session.
Send the raw file bytes as the request body (not multipart) with the
Content-Type from the session. Maximum size is 200 MB. A session
accepts one upload and expires after 1 hour.
This endpoint needs no API key: the unguessable session_id is the
credential, and CORS allows any origin so browser widgets can call it.
The file is registered in your account automatically; registered is
false only if registration failed after the bytes were stored, in
which case call POST /files/import with public_url.
PUT
/
files
/
upload
/
{session_id}
Upload bytes to an upload session
curl --request PUT \
--url https://api.varg.ai/v2/files/upload/{session_id} \
--header 'Content-Type: application/octet-stream' \
--data '<string>'import requests
url = "https://api.varg.ai/v2/files/upload/{session_id}"
payload = "<string>"
headers = {"Content-Type": "application/octet-stream"}
response = requests.put(url, data=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'Content-Type': 'application/octet-stream'},
body: '<string>'
};
fetch('https://api.varg.ai/v2/files/upload/{session_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.varg.ai/v2/files/upload/{session_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => "<string>",
CURLOPT_HTTPHEADER => [
"Content-Type: application/octet-stream"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.varg.ai/v2/files/upload/{session_id}"
payload := strings.NewReader("<string>")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Content-Type", "application/octet-stream")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api.varg.ai/v2/files/upload/{session_id}")
.header("Content-Type", "application/octet-stream")
.body("<string>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.varg.ai/v2/files/upload/{session_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Content-Type"] = 'application/octet-stream'
request.body = "<string>"
response = http.request(request)
puts response.read_body{
"ok": true,
"public_url": "https://s3.varg.ai/files/acc_x/file_abc123.mp4",
"size": 48234112,
"media_type": "video/mp4",
"file_id": "file_abc123",
"registered": true
}{
"error": {
"code": "model_not_found",
"message": "Unknown model: flux-shnell",
"details": "<unknown>"
}
}{
"error": {
"code": "model_not_found",
"message": "Unknown model: flux-shnell",
"details": "<unknown>"
}
}{
"error": {
"code": "model_not_found",
"message": "Unknown model: flux-shnell",
"details": "<unknown>"
}
}{
"error": {
"code": "model_not_found",
"message": "Unknown model: flux-shnell",
"details": "<unknown>"
}
}Path Parameters
The session_id from POST /files/upload-session
Body
application/octet-stream*/*
The body is of type file.
Was this page helpful?