Skip to main content
POST
/
v1
/
models
/
{model_id}
/
environments
cURL
curl --request POST \
--url https://api.baseten.co/v1/models/{model_id}/environments \
--header "Authorization: Bearer $BASETEN_API_KEY" \
--data '{
  "name": "staging",
  "autoscaling_settings": {
    "autoscaling_window": 800,
    "concurrency_target": 3,
    "max_replica": 2,
    "max_scale_down_rate": null,
    "min_replica": 1,
    "scale_down_delay": 60,
    "target_in_flight_tokens": null,
    "target_utilization_percentage": null
  },
  "promotion_settings": {
    "promotion_cleanup_strategy": null,
    "ramp_up_duration_seconds": 600,
    "ramp_up_while_promoting": true,
    "redeploy_on_promotion": true,
    "rolling_deploy": true,
    "rolling_deploy_config": 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}/environments"

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

response = requests.request(
    "POST",
    url,
    headers=headers,
    json={'name': 'staging', 'autoscaling_settings': {'autoscaling_window': 800, 'concurrency_target': 3, 'max_replica': 2, 'max_scale_down_rate': None, 'min_replica': 1, 'scale_down_delay': 60, 'target_in_flight_tokens': None, 'target_utilization_percentage': None}, 'promotion_settings': {'promotion_cleanup_strategy': None, 'ramp_up_duration_seconds': 600, 'ramp_up_while_promoting': True, 'redeploy_on_promotion': True, 'rolling_deploy': True, 'rolling_deploy_config': None}}
)

print(response.text)
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    name: '<string>',
    autoscaling_settings: {
      autoscaling_window: 800,
      concurrency_target: 3,
      max_replica: 2,
      max_scale_down_rate: null,
      min_replica: 1,
      scale_down_delay: 60,
      target_in_flight_tokens: null,
      target_utilization_percentage: null
    },
    promotion_settings: {
      promotion_cleanup_strategy: null,
      ramp_up_duration_seconds: 600,
      ramp_up_while_promoting: true,
      redeploy_on_promotion: true,
      rolling_deploy: true,
      rolling_deploy_config: null
    }
  })
};

fetch('https://api.baseten.co/v1/models/{model_id}/environments', 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}/environments",
  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([
    'name' => '<string>',
    'autoscaling_settings' => [
        'autoscaling_window' => 800,
        'concurrency_target' => 3,
        'max_replica' => 2,
        'max_scale_down_rate' => null,
        'min_replica' => 1,
        'scale_down_delay' => 60,
        'target_in_flight_tokens' => null,
        'target_utilization_percentage' => null
    ],
    'promotion_settings' => [
        'promotion_cleanup_strategy' => null,
        'ramp_up_duration_seconds' => 600,
        'ramp_up_while_promoting' => true,
        'redeploy_on_promotion' => true,
        'rolling_deploy' => true,
        'rolling_deploy_config' => null
    ]
  ]),
  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}/environments"

	payload := strings.NewReader("{\n  \"name\": \"<string>\",\n  \"autoscaling_settings\": {\n    \"autoscaling_window\": 800,\n    \"concurrency_target\": 3,\n    \"max_replica\": 2,\n    \"max_scale_down_rate\": null,\n    \"min_replica\": 1,\n    \"scale_down_delay\": 60,\n    \"target_in_flight_tokens\": null,\n    \"target_utilization_percentage\": null\n  },\n  \"promotion_settings\": {\n    \"promotion_cleanup_strategy\": null,\n    \"ramp_up_duration_seconds\": 600,\n    \"ramp_up_while_promoting\": true,\n    \"redeploy_on_promotion\": true,\n    \"rolling_deploy\": true,\n    \"rolling_deploy_config\": null\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}/environments")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"<string>\",\n  \"autoscaling_settings\": {\n    \"autoscaling_window\": 800,\n    \"concurrency_target\": 3,\n    \"max_replica\": 2,\n    \"max_scale_down_rate\": null,\n    \"min_replica\": 1,\n    \"scale_down_delay\": 60,\n    \"target_in_flight_tokens\": null,\n    \"target_utilization_percentage\": null\n  },\n  \"promotion_settings\": {\n    \"promotion_cleanup_strategy\": null,\n    \"ramp_up_duration_seconds\": 600,\n    \"ramp_up_while_promoting\": true,\n    \"redeploy_on_promotion\": true,\n    \"rolling_deploy\": true,\n    \"rolling_deploy_config\": null\n  }\n}")
  .asString();
require 'uri'
require 'net/http'

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

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  \"name\": \"<string>\",\n  \"autoscaling_settings\": {\n    \"autoscaling_window\": 800,\n    \"concurrency_target\": 3,\n    \"max_replica\": 2,\n    \"max_scale_down_rate\": null,\n    \"min_replica\": 1,\n    \"scale_down_delay\": 60,\n    \"target_in_flight_tokens\": null,\n    \"target_utilization_percentage\": null\n  },\n  \"promotion_settings\": {\n    \"promotion_cleanup_strategy\": null,\n    \"ramp_up_duration_seconds\": 600,\n    \"ramp_up_while_promoting\": true,\n    \"redeploy_on_promotion\": true,\n    \"rolling_deploy\": true,\n    \"rolling_deploy_config\": null\n  }\n}"

response = http.request(request)
puts response.read_body
{
  "name": "<string>",
  "created_at": "2023-11-07T05:31:56Z",
  "model_id": "<string>",
  "current_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": {}
  },
  "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
  },
  "promotion_settings": {
    "redeploy_on_promotion": true,
    "rolling_deploy": true,
    "promotion_cleanup_strategy": "SCALE_TO_ZERO",
    "rolling_deploy_config": {
      "rolling_deploy_strategy": "REPLICA",
      "max_surge_percent": 25,
      "max_unavailable_percent": 0,
      "stabilization_time_seconds": 0,
      "replica_overhead_percent": 0
    },
    "ramp_up_while_promoting": true,
    "ramp_up_duration_seconds": 600
  },
  "instance_type": {
    "id": "<string>",
    "name": "<string>",
    "memory_limit_mib": 123,
    "millicpu_limit": 123,
    "gpu_count": 123,
    "gpu_type": "<string>",
    "gpu_memory_limit_mib": 123
  },
  "candidate_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": {}
  },
  "in_progress_promotion": {
    "percent_traffic_to_new_version": 123,
    "error_message": "<string>",
    "rolling_deploy": true
  }
}

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

A request to create an environment.

name
string
required

Name of the environment

Example:

"staging"

autoscaling_settings
UpdateAutoscalingSettingsV1 · object | null

Autoscaling settings for the environment

Example:
{
  "autoscaling_window": 800,
  "concurrency_target": 3,
  "max_replica": 2,
  "max_scale_down_rate": null,
  "min_replica": 1,
  "scale_down_delay": 60,
  "target_in_flight_tokens": null,
  "target_utilization_percentage": null
}
promotion_settings
UpdatePromotionSettingsV1 · object | null

Promotion settings for the environment

Example:
{
  "promotion_cleanup_strategy": null,
  "ramp_up_duration_seconds": 600,
  "ramp_up_while_promoting": true,
  "redeploy_on_promotion": true,
  "rolling_deploy": true,
  "rolling_deploy_config": null
}

Response

200 - application/json

Environment for oracles.

name
string
required

Name of the environment

created_at
string<date-time>
required

Time the environment was created in ISO 8601 format

model_id
string
required

Unique identifier of the model

current_deployment
DeploymentV1 · object | null
required

Current deployment of the environment

autoscaling_settings
AutoscalingSettingsV1 · object
required

Autoscaling settings for the environment

promotion_settings
PromotionSettingsV1 · object
required

Promotion settings for the environment

instance_type
InstanceTypeV1 · object
required

Instance type for the environment

candidate_deployment
DeploymentV1 · object | null

Candidate deployment being promoted to the environment, if a promotion is in progress

in_progress_promotion
InProgressPromotionV1 · object | null

Details of the in-progress promotion, if any