Skip to main content
POST
/
v1
/
models
/
{model_id}
/
deployments
cURL
curl --request POST \
--url https://api.baseten.co/v1/models/{model_id}/deployments \
--header "Authorization: Bearer $BASETEN_API_KEY" \
--data '{
  "source": null
}'
import requests
import os
API_KEY = os.environ.get("BASETEN_API_KEY", "<YOUR_API_KEY>")
url = "https://api.baseten.co/v1/models/{model_id}/deployments"

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

response = requests.request(
"POST",
url,
headers=headers,
json={'source': None}
)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
source: {
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
},
s3_key: '<string>',
kind: 'model_archive'
}
})
};

fetch('https://api.baseten.co/v1/models/{model_id}/deployments', 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/models/{model_id}/deployments",
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([
'source' => [
'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
],
's3_key' => '<string>',
'kind' => 'model_archive'
]
]),
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/models/{model_id}/deployments"

payload := strings.NewReader("{\n \"source\": {\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 \"s3_key\": \"<string>\",\n \"kind\": \"model_archive\"\n }\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/models/{model_id}/deployments")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"source\": {\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 \"s3_key\": \"<string>\",\n \"kind\": \"model_archive\"\n }\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.baseten.co/v1/models/{model_id}/deployments")

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 \"source\": {\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 \"s3_key\": \"<string>\",\n \"kind\": \"model_archive\"\n }\n}"

response = http.request(request)
puts response.read_body
{
  "model": {
    "id": "<string>",
    "created_at": "2023-11-07T05:31:56Z",
    "name": "<string>",
    "deployments_count": 123,
    "production_deployment_id": "<string>",
    "development_deployment_id": "<string>",
    "instance_type_name": "<string>",
    "team_name": "<string>"
  },
  "deployment": {
    "id": "<string>",
    "created_at": "2023-11-07T05:31:56Z",
    "name": "<string>",
    "model_id": "<string>",
    "is_production": true,
    "is_development": true,
    "active_replica_count": 123,
    "autoscaling_settings": {
      "min_replica": 123,
      "max_replica": 123,
      "autoscaling_window": 123,
      "scale_down_delay": 123,
      "concurrency_target": 123,
      "target_utilization_percentage": 123,
      "target_in_flight_tokens": 123,
      "max_scale_down_rate": 123
    },
    "instance_type_name": "<string>",
    "environment": "<string>",
    "labels": {}
  }
}

Authorizations

Authorization
string
header
required

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

Path Parameters

model_id
string
required

Body

application/json

Body for adding a deployment to an existing model via POST /v1/models/{model_id}/deployments.

source
Source · object
required

Where the new deployment is created from.

Response

200 - application/json

A newly created deployment and its model.

model
ModelV1 · object
required

The model the deployment belongs to. May have been created by this call.

deployment
DeploymentV1 · object
required

The newly created deployment.