Skip to main content
POST
/
v1
/
prepare_model_upload
cURL
curl --request POST \
--url https://api.baseten.co/v1/prepare_model_upload \
--header "Authorization: Bearer $BASETEN_API_KEY" \
--data '{
  "deployment": {
    "config": null,
    "raw_config": null,
    "user_env": null,
    "environment_name": null,
    "deploy_timeout_minutes": null,
    "deployment_name": null,
    "labels": null
  },
  "name": null,
  "team_id": null,
  "model_id": null
}'
import requests
import os
API_KEY = os.environ.get("BASETEN_API_KEY", "<YOUR_API_KEY>")
url = "https://api.baseten.co/v1/prepare_model_upload"

headers = {"Authorization": f"Bearer {API_KEY}"}

response = requests.request(
"POST",
url,
headers=headers,
json={'deployment': {'config': None, 'raw_config': None, 'user_env': None, 'environment_name': None, 'deploy_timeout_minutes': None, 'deployment_name': None, 'labels': None}, 'name': None, 'team_id': None, 'model_id': None}
)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
deployment: {
config: {},
raw_config: '<string>',
user_env: {},
environment_name: '<string>',
preserve_env_instance_type: true,
deploy_timeout_minutes: 123,
deployment_name: '<string>',
labels: {},
is_development: false
},
name: '<string>',
team_id: '<string>',
model_id: '<string>',
dry_run: false
})
};

fetch('https://api.baseten.co/v1/prepare_model_upload', 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.baseten.co/v1/prepare_model_upload",
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([
'deployment' => [
'config' => [

],
'raw_config' => '<string>',
'user_env' => [

],
'environment_name' => '<string>',
'preserve_env_instance_type' => true,
'deploy_timeout_minutes' => 123,
'deployment_name' => '<string>',
'labels' => [

],
'is_development' => false
],
'name' => '<string>',
'team_id' => '<string>',
'model_id' => '<string>',
'dry_run' => false
]),
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://api.baseten.co/v1/prepare_model_upload"

payload := strings.NewReader("{\n \"deployment\": {\n \"config\": {},\n \"raw_config\": \"<string>\",\n \"user_env\": {},\n \"environment_name\": \"<string>\",\n \"preserve_env_instance_type\": true,\n \"deploy_timeout_minutes\": 123,\n \"deployment_name\": \"<string>\",\n \"labels\": {},\n \"is_development\": false\n },\n \"name\": \"<string>\",\n \"team_id\": \"<string>\",\n \"model_id\": \"<string>\",\n \"dry_run\": false\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://api.baseten.co/v1/prepare_model_upload")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"deployment\": {\n \"config\": {},\n \"raw_config\": \"<string>\",\n \"user_env\": {},\n \"environment_name\": \"<string>\",\n \"preserve_env_instance_type\": true,\n \"deploy_timeout_minutes\": 123,\n \"deployment_name\": \"<string>\",\n \"labels\": {},\n \"is_development\": false\n },\n \"name\": \"<string>\",\n \"team_id\": \"<string>\",\n \"model_id\": \"<string>\",\n \"dry_run\": false\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.baseten.co/v1/prepare_model_upload")

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 \"deployment\": {\n \"config\": {},\n \"raw_config\": \"<string>\",\n \"user_env\": {},\n \"environment_name\": \"<string>\",\n \"preserve_env_instance_type\": true,\n \"deploy_timeout_minutes\": 123,\n \"deployment_name\": \"<string>\",\n \"labels\": {},\n \"is_development\": false\n },\n \"name\": \"<string>\",\n \"team_id\": \"<string>\",\n \"model_id\": \"<string>\",\n \"dry_run\": false\n}"

response = http.request(request)
puts response.read_body
{
  "creds": {
    "aws_access_key_id": "<string>",
    "aws_secret_access_key": "<string>",
    "aws_session_token": "<string>"
  },
  "s3_bucket": "<string>",
  "s3_key": "<string>",
  "s3_region": "<string>"
}

Authorizations

Authorization
string
header
required

Send Authorization: Bearer <api_key>. The legacy Authorization: Api-Key <api_key> scheme is also accepted.

Body

application/json

Body for POST /v1/prepare_model_upload.

Validates the same payload the commit endpoint will validate, and on dry_run=false issues STS upload credentials. Exactly one of name or model_id is required: name validates the new-model path (POST /v1/models); model_id validates the add-deployment path (POST /v1/models/{model_id}/deployments).

deployment
DeploymentArchivePayloadV1 · object
required

Deployment-level payload, identical to the payload sent at commit.

name
string | null

Set to validate a new-model push. Exactly one of name or model_id is required.

team_id
string | null

Team the new model will belong to. Only valid when name is set; defaults to the organization's default team when omitted. Must not be set when model_id is set (the existing model already has a team).

model_id
string | null

Set to validate an add-deployment push to an existing model. Exactly one of name or model_id is required.

dry_run
boolean
default:false

If true, validate the payload only and do not issue upload credentials. The response sets creds, s3_bucket, and s3_key to null.

Response

200 - application/json

Response from POST /v1/prepare_model_upload.

On success with dry_run=false, returns STS upload credentials. On success with dry_run=true, creds, s3_bucket, and s3_key are null and only validation has run.

creds
AWSCredentialsV1 · object | null

STS credentials to upload the model archive.

s3_bucket
string | null

S3 bucket the credentials are scoped to.

s3_key
string | null

S3 key the credentials are scoped to. Pass this to POST /v1/models (in the model_archive source) once the upload completes.

s3_region
string | null

AWS region the S3 bucket resides in.