curl --request POST \
--url https://{tenant}.earnie.dev/v1/projects/{projectId}/model-uploads \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"filename": "<string>",
"size_bytes": 2,
"head_sha256": "<string>"
}
'import requests
url = "https://{tenant}.earnie.dev/v1/projects/{projectId}/model-uploads"
payload = {
"filename": "<string>",
"size_bytes": 2,
"head_sha256": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({filename: '<string>', size_bytes: 2, head_sha256: '<string>'})
};
fetch('https://{tenant}.earnie.dev/v1/projects/{projectId}/model-uploads', 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://{tenant}.earnie.dev/v1/projects/{projectId}/model-uploads",
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([
'filename' => '<string>',
'size_bytes' => 2,
'head_sha256' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://{tenant}.earnie.dev/v1/projects/{projectId}/model-uploads"
payload := strings.NewReader("{\n \"filename\": \"<string>\",\n \"size_bytes\": 2,\n \"head_sha256\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{tenant}.earnie.dev/v1/projects/{projectId}/model-uploads")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"filename\": \"<string>\",\n \"size_bytes\": 2,\n \"head_sha256\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{tenant}.earnie.dev/v1/projects/{projectId}/model-uploads")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"filename\": \"<string>\",\n \"size_bytes\": 2,\n \"head_sha256\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"filename": "<string>",
"size_bytes": 123,
"offset": 1,
"expires_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"model_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"filename": "<string>",
"size_bytes": 123,
"offset": 1,
"expires_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"model_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}{
"code": "<string>",
"message": "<string>"
}{
"code": "<string>",
"message": "<string>"
}{
"code": "<string>",
"message": "<string>",
"max_size_bytes": 123
}{
"code": "<string>",
"message": "<string>"
}{
"code": "<string>",
"message": "<string>"
}Declare a model upload, or resume the one in flight
Starts an upload of one model file or snapshot tar. The size cap is checked before any row or byte exists. Declaring the same file again (same size and head digest) while its upload is in flight answers that upload with 200 and its offset: that is how an upload resumes after a reload. Send the bytes with PUT /v1/projects/{projectId}/model-uploads/{uploadId}.
curl --request POST \
--url https://{tenant}.earnie.dev/v1/projects/{projectId}/model-uploads \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"filename": "<string>",
"size_bytes": 2,
"head_sha256": "<string>"
}
'import requests
url = "https://{tenant}.earnie.dev/v1/projects/{projectId}/model-uploads"
payload = {
"filename": "<string>",
"size_bytes": 2,
"head_sha256": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({filename: '<string>', size_bytes: 2, head_sha256: '<string>'})
};
fetch('https://{tenant}.earnie.dev/v1/projects/{projectId}/model-uploads', 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://{tenant}.earnie.dev/v1/projects/{projectId}/model-uploads",
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([
'filename' => '<string>',
'size_bytes' => 2,
'head_sha256' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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://{tenant}.earnie.dev/v1/projects/{projectId}/model-uploads"
payload := strings.NewReader("{\n \"filename\": \"<string>\",\n \"size_bytes\": 2,\n \"head_sha256\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{tenant}.earnie.dev/v1/projects/{projectId}/model-uploads")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"filename\": \"<string>\",\n \"size_bytes\": 2,\n \"head_sha256\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{tenant}.earnie.dev/v1/projects/{projectId}/model-uploads")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"filename\": \"<string>\",\n \"size_bytes\": 2,\n \"head_sha256\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"filename": "<string>",
"size_bytes": 123,
"offset": 1,
"expires_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"model_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"filename": "<string>",
"size_bytes": 123,
"offset": 1,
"expires_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"model_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}{
"code": "<string>",
"message": "<string>"
}{
"code": "<string>",
"message": "<string>"
}{
"code": "<string>",
"message": "<string>",
"max_size_bytes": 123
}{
"code": "<string>",
"message": "<string>"
}{
"code": "<string>",
"message": "<string>"
}Authorizations
An Earnie API key, sent as Authorization: Bearer sk_earnie_.... Create one under Settings > API keys. The key's scopes decide which operations it may call.
Path Parameters
Body
The file's name. A model weights file (.safetensors, .gguf, .bin, .pt, .pth, .onnx, .tflite, .mlmodel, .h5, .keras, .pb, .pkl), or a Hugging Face snapshot as .tar, .tar.gz or .tgz.
The exact size of the file. Every window names it as its total.
x >= 1Lowercase hex SHA-256 of the first min(16 MiB, size_bytes) bytes. With the size it is the resume key: declaring the same file again while its upload is in flight answers that upload and its offset.
^[0-9a-f]{64}$Response
The upload of this file already in flight, at its offset.
Bytes the server holds. The next window starts here.
x >= 0When an upload that receives no more bytes is discarded. Every accepted window moves it forward.
The Model the bytes sealed into, once the last window landed. When the same bytes were uploaded before, this is the existing Model.