Upload a file
curl --request POST \
--url https://api.varg.ai/v2/files \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: <content-type>' \
--data '"<string>"'import requests
url = "https://api.varg.ai/v2/files"
payload = "<string>"
headers = {
"Content-Type": "<content-type>",
"Authorization": "Bearer <token>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': '<content-type>', Authorization: 'Bearer <token>'},
body: JSON.stringify('<string>')
};
fetch('https://api.varg.ai/v2/files', 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",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode('<string>'),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: <content-type>"
],
]);
$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"
payload := strings.NewReader("\"<string>\"")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "<content-type>")
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.varg.ai/v2/files")
.header("Content-Type", "<content-type>")
.header("Authorization", "Bearer <token>")
.body("\"<string>\"")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.varg.ai/v2/files")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = '<content-type>'
request["Authorization"] = 'Bearer <token>'
request.body = "\"<string>\""
response = http.request(request)
puts response.read_body{
"file_id": "<string>",
"url": "<string>",
"hash": "<string>",
"size": 123,
"media_type": "<string>",
"filename": "<string>",
"title": "<string>",
"subtitle": "<string>",
"metadata": {},
"deduplicated": 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>"
}
}Files
Upload a file
Upload a file as a raw binary body (max 200 MB). Set Content-Type to
the file’s media type; when it’s missing or generic, varg sniffs the
type from magic bytes.
Send X-Content-Hash: sha256:<hex> to enable deduplication — if your
account already has a file with the same content, the existing file is
returned instantly (deduplicated: true) without re-uploading. Use
GET /files/check?hash= to pre-check before sending bytes.
POST
/
files
Upload a file
curl --request POST \
--url https://api.varg.ai/v2/files \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: <content-type>' \
--data '"<string>"'import requests
url = "https://api.varg.ai/v2/files"
payload = "<string>"
headers = {
"Content-Type": "<content-type>",
"Authorization": "Bearer <token>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': '<content-type>', Authorization: 'Bearer <token>'},
body: JSON.stringify('<string>')
};
fetch('https://api.varg.ai/v2/files', 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",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode('<string>'),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: <content-type>"
],
]);
$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"
payload := strings.NewReader("\"<string>\"")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "<content-type>")
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.varg.ai/v2/files")
.header("Content-Type", "<content-type>")
.header("Authorization", "Bearer <token>")
.body("\"<string>\"")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.varg.ai/v2/files")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = '<content-type>'
request["Authorization"] = 'Bearer <token>'
request.body = "\"<string>\""
response = http.request(request)
puts response.read_body{
"file_id": "<string>",
"url": "<string>",
"hash": "<string>",
"size": 123,
"media_type": "<string>",
"filename": "<string>",
"title": "<string>",
"subtitle": "<string>",
"metadata": {},
"deduplicated": 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>"
}
}Authorizations
varg API key (varg_...). Get one at app.varg.ai
or run bunx vargai login. App sessions may alternatively send a
Supabase JWT.
Headers
sha256 hash of the bytes (with or without the sha256: prefix) for dedup
Original filename
Body
application/octet-stream
The body is of type file.
Was this page helpful?