Training Jobs
Create training job
Creates a training job with the specified configuration.
POST
/
v1
/
training_projects
/
{training_project_id}
/
jobs
cURL
curl --request POST \
--url https://api.baseten.co/v1/training_projects/{training_project_id}/jobs \
--header "Authorization: Bearer $BASETEN_API_KEY" \
--data '{
"training_job": {
"image": {
"base_image": "hello-world",
"docker_auth": null
},
"compute": {
"node_count": 1,
"cpu_count": 1,
"memory": "2Gi",
"accelerator": {
"accelerator": "H100",
"count": 2
},
"availability_model": "spot"
},
"runtime": {
"start_commands": [
"python main.py"
],
"environment_variables": {
"API_KEY": "your_api_key_here",
"PATH": "/usr/bin"
},
"enable_cache": true,
"cache_config": {
"enable_legacy_hf_mount": true,
"enabled": true,
"mount_base_path": "/root/.cache",
"require_cache_affinity": true
},
"checkpointing_config": {
"enabled": true,
"checkpoint_path": "/mnt/ckpts",
"volume_size_gib": 10
},
"load_checkpoint_config": null
},
"name": "gpt-oss-job",
"truss_user_env": null,
"interactive_session": null,
"weights": [
{
"allow_patterns": null,
"auth": null,
"auth_secret_name": null,
"ignore_patterns": null,
"mount_location": "/app/models/base",
"source": "hf://meta-llama/Llama-3-8B@main"
}
],
"enable_baseten_workdir": false,
"priority": 0
}
}'import requests
import os
API_KEY = os.environ.get("BASETEN_API_KEY", "<YOUR_API_KEY>")
url = "https://api.baseten.co/v1/training_projects/{training_project_id}/jobs"
headers = {"Authorization": f"Bearer {API_KEY}"}
response = requests.request(
"POST",
url,
headers=headers,
json={'training_job': {'image': {'base_image': 'hello-world', 'docker_auth': None}, 'compute': {'node_count': 1, 'cpu_count': 1, 'memory': '2Gi', 'accelerator': {'accelerator': 'H100', 'count': 2}, 'availability_model': 'spot'}, 'runtime': {'start_commands': ['python main.py'], 'environment_variables': {'API_KEY': 'your_api_key_here', 'PATH': '/usr/bin'}, 'enable_cache': True, 'cache_config': {'enable_legacy_hf_mount': True, 'enabled': True, 'mount_base_path': '/root/.cache', 'require_cache_affinity': True}, 'checkpointing_config': {'enabled': True, 'checkpoint_path': '/mnt/ckpts', 'volume_size_gib': 10}, 'load_checkpoint_config': None}, 'name': 'gpt-oss-job', 'truss_user_env': None, 'interactive_session': None, 'weights': [{'allow_patterns': None, 'auth': None, 'auth_secret_name': None, 'ignore_patterns': None, 'mount_location': '/app/models/base', 'source': 'hf://meta-llama/Llama-3-8B@main'}], 'enable_baseten_workdir': False, 'priority': 0}}
)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
training_job: {
image: {
base_image: '<string>',
docker_auth: {
registry: '<string>',
gcp_service_account_json_docker_auth: {service_account_json_secret_ref: {name: '<string>'}},
aws_iam_docker_auth: {
access_key_secret_ref: {name: '<string>'},
secret_access_key_secret_ref: {name: '<string>'}
},
aws_oidc_docker_auth: {role_arn: '<string>', region: '<string>'},
gcp_oidc_docker_auth: {service_account: '<string>', workload_identity_provider: '<string>'},
registry_secret_docker_auth: {secret_ref: {name: '<string>'}}
}
},
compute: {
node_count: 1,
cpu_count: 1,
memory: '2Gi',
accelerator: {accelerator: 'H100', count: 2},
availability_model: 'dedicated'
},
runtime: {
start_commands: ['<string>'],
environment_variables: {},
artifacts: [{s3_bucket: '<string>', s3_key: '<string>'}],
enable_cache: true,
cache_config: {
enable_legacy_hf_mount: true,
enabled: true,
mount_base_path: '/root/.cache',
require_cache_affinity: true
},
checkpointing_config: {enabled: false, checkpoint_path: '/mnt/ckpts', volume_size_gib: 10},
load_checkpoint_config: {
enabled: false,
download_folder: '/tmp/loaded_checkpoints',
checkpoints: [
{project_name: '<string>', job_id: '<string>', typ: 'baseten_latest_checkpoint'}
]
}
},
name: 'gpt-oss-job',
truss_user_env: {
truss_client_version: '<string>',
python_version: '<string>',
pydantic_version: '<string>',
mypy_version: '<string>',
is_library_deployment: false,
is_frontend_deployment: false,
git_info: {
latest_commit_sha: '<string>',
latest_tag: '<string>',
commits_since_tag: 123,
has_uncommitted_changes: true
}
},
interactive_session: {
trigger: 'on_demand',
timeout_minutes: 480,
session_provider: 'vs_code',
auth_provider: 'github'
},
weights: [
{
source: '<string>',
mount_location: '<string>',
allow_patterns: ['*.safetensors', 'config.json'],
ignore_patterns: ['*.bin', '*.h5'],
auth_secret_name: 'hf_token',
auth: {auth_method: 'CUSTOM_SECRET', auth_secret_name: 'hf_token'}
}
],
enable_baseten_workdir: false,
priority: 0
}
})
};
fetch('https://api.baseten.co/v1/training_projects/{training_project_id}/jobs', 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/training_projects/{training_project_id}/jobs",
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([
'training_job' => [
'image' => [
'base_image' => '<string>',
'docker_auth' => [
'registry' => '<string>',
'gcp_service_account_json_docker_auth' => [
'service_account_json_secret_ref' => [
'name' => '<string>'
]
],
'aws_iam_docker_auth' => [
'access_key_secret_ref' => [
'name' => '<string>'
],
'secret_access_key_secret_ref' => [
'name' => '<string>'
]
],
'aws_oidc_docker_auth' => [
'role_arn' => '<string>',
'region' => '<string>'
],
'gcp_oidc_docker_auth' => [
'service_account' => '<string>',
'workload_identity_provider' => '<string>'
],
'registry_secret_docker_auth' => [
'secret_ref' => [
'name' => '<string>'
]
]
]
],
'compute' => [
'node_count' => 1,
'cpu_count' => 1,
'memory' => '2Gi',
'accelerator' => [
'accelerator' => 'H100',
'count' => 2
],
'availability_model' => 'dedicated'
],
'runtime' => [
'start_commands' => [
'<string>'
],
'environment_variables' => [
],
'artifacts' => [
[
's3_bucket' => '<string>',
's3_key' => '<string>'
]
],
'enable_cache' => true,
'cache_config' => [
'enable_legacy_hf_mount' => true,
'enabled' => true,
'mount_base_path' => '/root/.cache',
'require_cache_affinity' => true
],
'checkpointing_config' => [
'enabled' => false,
'checkpoint_path' => '/mnt/ckpts',
'volume_size_gib' => 10
],
'load_checkpoint_config' => [
'enabled' => false,
'download_folder' => '/tmp/loaded_checkpoints',
'checkpoints' => [
[
'project_name' => '<string>',
'job_id' => '<string>',
'typ' => 'baseten_latest_checkpoint'
]
]
]
],
'name' => 'gpt-oss-job',
'truss_user_env' => [
'truss_client_version' => '<string>',
'python_version' => '<string>',
'pydantic_version' => '<string>',
'mypy_version' => '<string>',
'is_library_deployment' => false,
'is_frontend_deployment' => false,
'git_info' => [
'latest_commit_sha' => '<string>',
'latest_tag' => '<string>',
'commits_since_tag' => 123,
'has_uncommitted_changes' => true
]
],
'interactive_session' => [
'trigger' => 'on_demand',
'timeout_minutes' => 480,
'session_provider' => 'vs_code',
'auth_provider' => 'github'
],
'weights' => [
[
'source' => '<string>',
'mount_location' => '<string>',
'allow_patterns' => [
'*.safetensors',
'config.json'
],
'ignore_patterns' => [
'*.bin',
'*.h5'
],
'auth_secret_name' => 'hf_token',
'auth' => [
'auth_method' => 'CUSTOM_SECRET',
'auth_secret_name' => 'hf_token'
]
]
],
'enable_baseten_workdir' => false,
'priority' => 0
]
]),
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/training_projects/{training_project_id}/jobs"
payload := strings.NewReader("{\n \"training_job\": {\n \"image\": {\n \"base_image\": \"<string>\",\n \"docker_auth\": {\n \"registry\": \"<string>\",\n \"gcp_service_account_json_docker_auth\": {\n \"service_account_json_secret_ref\": {\n \"name\": \"<string>\"\n }\n },\n \"aws_iam_docker_auth\": {\n \"access_key_secret_ref\": {\n \"name\": \"<string>\"\n },\n \"secret_access_key_secret_ref\": {\n \"name\": \"<string>\"\n }\n },\n \"aws_oidc_docker_auth\": {\n \"role_arn\": \"<string>\",\n \"region\": \"<string>\"\n },\n \"gcp_oidc_docker_auth\": {\n \"service_account\": \"<string>\",\n \"workload_identity_provider\": \"<string>\"\n },\n \"registry_secret_docker_auth\": {\n \"secret_ref\": {\n \"name\": \"<string>\"\n }\n }\n }\n },\n \"compute\": {\n \"node_count\": 1,\n \"cpu_count\": 1,\n \"memory\": \"2Gi\",\n \"accelerator\": {\n \"accelerator\": \"H100\",\n \"count\": 2\n },\n \"availability_model\": \"dedicated\"\n },\n \"runtime\": {\n \"start_commands\": [\n \"<string>\"\n ],\n \"environment_variables\": {},\n \"artifacts\": [\n {\n \"s3_bucket\": \"<string>\",\n \"s3_key\": \"<string>\"\n }\n ],\n \"enable_cache\": true,\n \"cache_config\": {\n \"enable_legacy_hf_mount\": true,\n \"enabled\": true,\n \"mount_base_path\": \"/root/.cache\",\n \"require_cache_affinity\": true\n },\n \"checkpointing_config\": {\n \"enabled\": false,\n \"checkpoint_path\": \"/mnt/ckpts\",\n \"volume_size_gib\": 10\n },\n \"load_checkpoint_config\": {\n \"enabled\": false,\n \"download_folder\": \"/tmp/loaded_checkpoints\",\n \"checkpoints\": [\n {\n \"project_name\": \"<string>\",\n \"job_id\": \"<string>\",\n \"typ\": \"baseten_latest_checkpoint\"\n }\n ]\n }\n },\n \"name\": \"gpt-oss-job\",\n \"truss_user_env\": {\n \"truss_client_version\": \"<string>\",\n \"python_version\": \"<string>\",\n \"pydantic_version\": \"<string>\",\n \"mypy_version\": \"<string>\",\n \"is_library_deployment\": false,\n \"is_frontend_deployment\": false,\n \"git_info\": {\n \"latest_commit_sha\": \"<string>\",\n \"latest_tag\": \"<string>\",\n \"commits_since_tag\": 123,\n \"has_uncommitted_changes\": true\n }\n },\n \"interactive_session\": {\n \"trigger\": \"on_demand\",\n \"timeout_minutes\": 480,\n \"session_provider\": \"vs_code\",\n \"auth_provider\": \"github\"\n },\n \"weights\": [\n {\n \"source\": \"<string>\",\n \"mount_location\": \"<string>\",\n \"allow_patterns\": [\n \"*.safetensors\",\n \"config.json\"\n ],\n \"ignore_patterns\": [\n \"*.bin\",\n \"*.h5\"\n ],\n \"auth_secret_name\": \"hf_token\",\n \"auth\": {\n \"auth_method\": \"CUSTOM_SECRET\",\n \"auth_secret_name\": \"hf_token\"\n }\n }\n ],\n \"enable_baseten_workdir\": false,\n \"priority\": 0\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/training_projects/{training_project_id}/jobs")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"training_job\": {\n \"image\": {\n \"base_image\": \"<string>\",\n \"docker_auth\": {\n \"registry\": \"<string>\",\n \"gcp_service_account_json_docker_auth\": {\n \"service_account_json_secret_ref\": {\n \"name\": \"<string>\"\n }\n },\n \"aws_iam_docker_auth\": {\n \"access_key_secret_ref\": {\n \"name\": \"<string>\"\n },\n \"secret_access_key_secret_ref\": {\n \"name\": \"<string>\"\n }\n },\n \"aws_oidc_docker_auth\": {\n \"role_arn\": \"<string>\",\n \"region\": \"<string>\"\n },\n \"gcp_oidc_docker_auth\": {\n \"service_account\": \"<string>\",\n \"workload_identity_provider\": \"<string>\"\n },\n \"registry_secret_docker_auth\": {\n \"secret_ref\": {\n \"name\": \"<string>\"\n }\n }\n }\n },\n \"compute\": {\n \"node_count\": 1,\n \"cpu_count\": 1,\n \"memory\": \"2Gi\",\n \"accelerator\": {\n \"accelerator\": \"H100\",\n \"count\": 2\n },\n \"availability_model\": \"dedicated\"\n },\n \"runtime\": {\n \"start_commands\": [\n \"<string>\"\n ],\n \"environment_variables\": {},\n \"artifacts\": [\n {\n \"s3_bucket\": \"<string>\",\n \"s3_key\": \"<string>\"\n }\n ],\n \"enable_cache\": true,\n \"cache_config\": {\n \"enable_legacy_hf_mount\": true,\n \"enabled\": true,\n \"mount_base_path\": \"/root/.cache\",\n \"require_cache_affinity\": true\n },\n \"checkpointing_config\": {\n \"enabled\": false,\n \"checkpoint_path\": \"/mnt/ckpts\",\n \"volume_size_gib\": 10\n },\n \"load_checkpoint_config\": {\n \"enabled\": false,\n \"download_folder\": \"/tmp/loaded_checkpoints\",\n \"checkpoints\": [\n {\n \"project_name\": \"<string>\",\n \"job_id\": \"<string>\",\n \"typ\": \"baseten_latest_checkpoint\"\n }\n ]\n }\n },\n \"name\": \"gpt-oss-job\",\n \"truss_user_env\": {\n \"truss_client_version\": \"<string>\",\n \"python_version\": \"<string>\",\n \"pydantic_version\": \"<string>\",\n \"mypy_version\": \"<string>\",\n \"is_library_deployment\": false,\n \"is_frontend_deployment\": false,\n \"git_info\": {\n \"latest_commit_sha\": \"<string>\",\n \"latest_tag\": \"<string>\",\n \"commits_since_tag\": 123,\n \"has_uncommitted_changes\": true\n }\n },\n \"interactive_session\": {\n \"trigger\": \"on_demand\",\n \"timeout_minutes\": 480,\n \"session_provider\": \"vs_code\",\n \"auth_provider\": \"github\"\n },\n \"weights\": [\n {\n \"source\": \"<string>\",\n \"mount_location\": \"<string>\",\n \"allow_patterns\": [\n \"*.safetensors\",\n \"config.json\"\n ],\n \"ignore_patterns\": [\n \"*.bin\",\n \"*.h5\"\n ],\n \"auth_secret_name\": \"hf_token\",\n \"auth\": {\n \"auth_method\": \"CUSTOM_SECRET\",\n \"auth_secret_name\": \"hf_token\"\n }\n }\n ],\n \"enable_baseten_workdir\": false,\n \"priority\": 0\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.baseten.co/v1/training_projects/{training_project_id}/jobs")
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 \"training_job\": {\n \"image\": {\n \"base_image\": \"<string>\",\n \"docker_auth\": {\n \"registry\": \"<string>\",\n \"gcp_service_account_json_docker_auth\": {\n \"service_account_json_secret_ref\": {\n \"name\": \"<string>\"\n }\n },\n \"aws_iam_docker_auth\": {\n \"access_key_secret_ref\": {\n \"name\": \"<string>\"\n },\n \"secret_access_key_secret_ref\": {\n \"name\": \"<string>\"\n }\n },\n \"aws_oidc_docker_auth\": {\n \"role_arn\": \"<string>\",\n \"region\": \"<string>\"\n },\n \"gcp_oidc_docker_auth\": {\n \"service_account\": \"<string>\",\n \"workload_identity_provider\": \"<string>\"\n },\n \"registry_secret_docker_auth\": {\n \"secret_ref\": {\n \"name\": \"<string>\"\n }\n }\n }\n },\n \"compute\": {\n \"node_count\": 1,\n \"cpu_count\": 1,\n \"memory\": \"2Gi\",\n \"accelerator\": {\n \"accelerator\": \"H100\",\n \"count\": 2\n },\n \"availability_model\": \"dedicated\"\n },\n \"runtime\": {\n \"start_commands\": [\n \"<string>\"\n ],\n \"environment_variables\": {},\n \"artifacts\": [\n {\n \"s3_bucket\": \"<string>\",\n \"s3_key\": \"<string>\"\n }\n ],\n \"enable_cache\": true,\n \"cache_config\": {\n \"enable_legacy_hf_mount\": true,\n \"enabled\": true,\n \"mount_base_path\": \"/root/.cache\",\n \"require_cache_affinity\": true\n },\n \"checkpointing_config\": {\n \"enabled\": false,\n \"checkpoint_path\": \"/mnt/ckpts\",\n \"volume_size_gib\": 10\n },\n \"load_checkpoint_config\": {\n \"enabled\": false,\n \"download_folder\": \"/tmp/loaded_checkpoints\",\n \"checkpoints\": [\n {\n \"project_name\": \"<string>\",\n \"job_id\": \"<string>\",\n \"typ\": \"baseten_latest_checkpoint\"\n }\n ]\n }\n },\n \"name\": \"gpt-oss-job\",\n \"truss_user_env\": {\n \"truss_client_version\": \"<string>\",\n \"python_version\": \"<string>\",\n \"pydantic_version\": \"<string>\",\n \"mypy_version\": \"<string>\",\n \"is_library_deployment\": false,\n \"is_frontend_deployment\": false,\n \"git_info\": {\n \"latest_commit_sha\": \"<string>\",\n \"latest_tag\": \"<string>\",\n \"commits_since_tag\": 123,\n \"has_uncommitted_changes\": true\n }\n },\n \"interactive_session\": {\n \"trigger\": \"on_demand\",\n \"timeout_minutes\": 480,\n \"session_provider\": \"vs_code\",\n \"auth_provider\": \"github\"\n },\n \"weights\": [\n {\n \"source\": \"<string>\",\n \"mount_location\": \"<string>\",\n \"allow_patterns\": [\n \"*.safetensors\",\n \"config.json\"\n ],\n \"ignore_patterns\": [\n \"*.bin\",\n \"*.h5\"\n ],\n \"auth_secret_name\": \"hf_token\",\n \"auth\": {\n \"auth_method\": \"CUSTOM_SECRET\",\n \"auth_secret_name\": \"hf_token\"\n }\n }\n ],\n \"enable_baseten_workdir\": false,\n \"priority\": 0\n }\n}"
response = http.request(request)
puts response.read_body{
"training_job": {
"id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"current_status": "<string>",
"instance_type": {
"id": "<string>",
"name": "<string>",
"memory_limit_mib": 123,
"millicpu_limit": 123,
"gpu_count": 123,
"gpu_type": "<string>",
"gpu_memory_limit_mib": 123
},
"updated_at": "2023-11-07T05:31:56Z",
"training_project_id": "<string>",
"training_project": {
"id": "<string>",
"name": "<string>"
},
"error_message": "<string>",
"name": "gpt-oss-job",
"priority": 0,
"availability_model": "dedicated",
"user": {
"email": "<string>"
}
}
}Authorizations
Send Authorization: Bearer <api_key>. The legacy Authorization: Api-Key <api_key> scheme is also accepted.
Path Parameters
Body
application/json
A request to create a training job.
The training job to create.
Show child attributes
Show child attributes
Response
200 - application/json
A response to creating a training job.
The created training job.
Show child attributes
Show child attributes
Was this page helpful?
Previous
Loops API referenceHTTP routes for Loops sessions, runs, samplers, checkpoints, and deployments.
Next
⌘I
cURL
curl --request POST \
--url https://api.baseten.co/v1/training_projects/{training_project_id}/jobs \
--header "Authorization: Bearer $BASETEN_API_KEY" \
--data '{
"training_job": {
"image": {
"base_image": "hello-world",
"docker_auth": null
},
"compute": {
"node_count": 1,
"cpu_count": 1,
"memory": "2Gi",
"accelerator": {
"accelerator": "H100",
"count": 2
},
"availability_model": "spot"
},
"runtime": {
"start_commands": [
"python main.py"
],
"environment_variables": {
"API_KEY": "your_api_key_here",
"PATH": "/usr/bin"
},
"enable_cache": true,
"cache_config": {
"enable_legacy_hf_mount": true,
"enabled": true,
"mount_base_path": "/root/.cache",
"require_cache_affinity": true
},
"checkpointing_config": {
"enabled": true,
"checkpoint_path": "/mnt/ckpts",
"volume_size_gib": 10
},
"load_checkpoint_config": null
},
"name": "gpt-oss-job",
"truss_user_env": null,
"interactive_session": null,
"weights": [
{
"allow_patterns": null,
"auth": null,
"auth_secret_name": null,
"ignore_patterns": null,
"mount_location": "/app/models/base",
"source": "hf://meta-llama/Llama-3-8B@main"
}
],
"enable_baseten_workdir": false,
"priority": 0
}
}'import requests
import os
API_KEY = os.environ.get("BASETEN_API_KEY", "<YOUR_API_KEY>")
url = "https://api.baseten.co/v1/training_projects/{training_project_id}/jobs"
headers = {"Authorization": f"Bearer {API_KEY}"}
response = requests.request(
"POST",
url,
headers=headers,
json={'training_job': {'image': {'base_image': 'hello-world', 'docker_auth': None}, 'compute': {'node_count': 1, 'cpu_count': 1, 'memory': '2Gi', 'accelerator': {'accelerator': 'H100', 'count': 2}, 'availability_model': 'spot'}, 'runtime': {'start_commands': ['python main.py'], 'environment_variables': {'API_KEY': 'your_api_key_here', 'PATH': '/usr/bin'}, 'enable_cache': True, 'cache_config': {'enable_legacy_hf_mount': True, 'enabled': True, 'mount_base_path': '/root/.cache', 'require_cache_affinity': True}, 'checkpointing_config': {'enabled': True, 'checkpoint_path': '/mnt/ckpts', 'volume_size_gib': 10}, 'load_checkpoint_config': None}, 'name': 'gpt-oss-job', 'truss_user_env': None, 'interactive_session': None, 'weights': [{'allow_patterns': None, 'auth': None, 'auth_secret_name': None, 'ignore_patterns': None, 'mount_location': '/app/models/base', 'source': 'hf://meta-llama/Llama-3-8B@main'}], 'enable_baseten_workdir': False, 'priority': 0}}
)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
training_job: {
image: {
base_image: '<string>',
docker_auth: {
registry: '<string>',
gcp_service_account_json_docker_auth: {service_account_json_secret_ref: {name: '<string>'}},
aws_iam_docker_auth: {
access_key_secret_ref: {name: '<string>'},
secret_access_key_secret_ref: {name: '<string>'}
},
aws_oidc_docker_auth: {role_arn: '<string>', region: '<string>'},
gcp_oidc_docker_auth: {service_account: '<string>', workload_identity_provider: '<string>'},
registry_secret_docker_auth: {secret_ref: {name: '<string>'}}
}
},
compute: {
node_count: 1,
cpu_count: 1,
memory: '2Gi',
accelerator: {accelerator: 'H100', count: 2},
availability_model: 'dedicated'
},
runtime: {
start_commands: ['<string>'],
environment_variables: {},
artifacts: [{s3_bucket: '<string>', s3_key: '<string>'}],
enable_cache: true,
cache_config: {
enable_legacy_hf_mount: true,
enabled: true,
mount_base_path: '/root/.cache',
require_cache_affinity: true
},
checkpointing_config: {enabled: false, checkpoint_path: '/mnt/ckpts', volume_size_gib: 10},
load_checkpoint_config: {
enabled: false,
download_folder: '/tmp/loaded_checkpoints',
checkpoints: [
{project_name: '<string>', job_id: '<string>', typ: 'baseten_latest_checkpoint'}
]
}
},
name: 'gpt-oss-job',
truss_user_env: {
truss_client_version: '<string>',
python_version: '<string>',
pydantic_version: '<string>',
mypy_version: '<string>',
is_library_deployment: false,
is_frontend_deployment: false,
git_info: {
latest_commit_sha: '<string>',
latest_tag: '<string>',
commits_since_tag: 123,
has_uncommitted_changes: true
}
},
interactive_session: {
trigger: 'on_demand',
timeout_minutes: 480,
session_provider: 'vs_code',
auth_provider: 'github'
},
weights: [
{
source: '<string>',
mount_location: '<string>',
allow_patterns: ['*.safetensors', 'config.json'],
ignore_patterns: ['*.bin', '*.h5'],
auth_secret_name: 'hf_token',
auth: {auth_method: 'CUSTOM_SECRET', auth_secret_name: 'hf_token'}
}
],
enable_baseten_workdir: false,
priority: 0
}
})
};
fetch('https://api.baseten.co/v1/training_projects/{training_project_id}/jobs', 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/training_projects/{training_project_id}/jobs",
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([
'training_job' => [
'image' => [
'base_image' => '<string>',
'docker_auth' => [
'registry' => '<string>',
'gcp_service_account_json_docker_auth' => [
'service_account_json_secret_ref' => [
'name' => '<string>'
]
],
'aws_iam_docker_auth' => [
'access_key_secret_ref' => [
'name' => '<string>'
],
'secret_access_key_secret_ref' => [
'name' => '<string>'
]
],
'aws_oidc_docker_auth' => [
'role_arn' => '<string>',
'region' => '<string>'
],
'gcp_oidc_docker_auth' => [
'service_account' => '<string>',
'workload_identity_provider' => '<string>'
],
'registry_secret_docker_auth' => [
'secret_ref' => [
'name' => '<string>'
]
]
]
],
'compute' => [
'node_count' => 1,
'cpu_count' => 1,
'memory' => '2Gi',
'accelerator' => [
'accelerator' => 'H100',
'count' => 2
],
'availability_model' => 'dedicated'
],
'runtime' => [
'start_commands' => [
'<string>'
],
'environment_variables' => [
],
'artifacts' => [
[
's3_bucket' => '<string>',
's3_key' => '<string>'
]
],
'enable_cache' => true,
'cache_config' => [
'enable_legacy_hf_mount' => true,
'enabled' => true,
'mount_base_path' => '/root/.cache',
'require_cache_affinity' => true
],
'checkpointing_config' => [
'enabled' => false,
'checkpoint_path' => '/mnt/ckpts',
'volume_size_gib' => 10
],
'load_checkpoint_config' => [
'enabled' => false,
'download_folder' => '/tmp/loaded_checkpoints',
'checkpoints' => [
[
'project_name' => '<string>',
'job_id' => '<string>',
'typ' => 'baseten_latest_checkpoint'
]
]
]
],
'name' => 'gpt-oss-job',
'truss_user_env' => [
'truss_client_version' => '<string>',
'python_version' => '<string>',
'pydantic_version' => '<string>',
'mypy_version' => '<string>',
'is_library_deployment' => false,
'is_frontend_deployment' => false,
'git_info' => [
'latest_commit_sha' => '<string>',
'latest_tag' => '<string>',
'commits_since_tag' => 123,
'has_uncommitted_changes' => true
]
],
'interactive_session' => [
'trigger' => 'on_demand',
'timeout_minutes' => 480,
'session_provider' => 'vs_code',
'auth_provider' => 'github'
],
'weights' => [
[
'source' => '<string>',
'mount_location' => '<string>',
'allow_patterns' => [
'*.safetensors',
'config.json'
],
'ignore_patterns' => [
'*.bin',
'*.h5'
],
'auth_secret_name' => 'hf_token',
'auth' => [
'auth_method' => 'CUSTOM_SECRET',
'auth_secret_name' => 'hf_token'
]
]
],
'enable_baseten_workdir' => false,
'priority' => 0
]
]),
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/training_projects/{training_project_id}/jobs"
payload := strings.NewReader("{\n \"training_job\": {\n \"image\": {\n \"base_image\": \"<string>\",\n \"docker_auth\": {\n \"registry\": \"<string>\",\n \"gcp_service_account_json_docker_auth\": {\n \"service_account_json_secret_ref\": {\n \"name\": \"<string>\"\n }\n },\n \"aws_iam_docker_auth\": {\n \"access_key_secret_ref\": {\n \"name\": \"<string>\"\n },\n \"secret_access_key_secret_ref\": {\n \"name\": \"<string>\"\n }\n },\n \"aws_oidc_docker_auth\": {\n \"role_arn\": \"<string>\",\n \"region\": \"<string>\"\n },\n \"gcp_oidc_docker_auth\": {\n \"service_account\": \"<string>\",\n \"workload_identity_provider\": \"<string>\"\n },\n \"registry_secret_docker_auth\": {\n \"secret_ref\": {\n \"name\": \"<string>\"\n }\n }\n }\n },\n \"compute\": {\n \"node_count\": 1,\n \"cpu_count\": 1,\n \"memory\": \"2Gi\",\n \"accelerator\": {\n \"accelerator\": \"H100\",\n \"count\": 2\n },\n \"availability_model\": \"dedicated\"\n },\n \"runtime\": {\n \"start_commands\": [\n \"<string>\"\n ],\n \"environment_variables\": {},\n \"artifacts\": [\n {\n \"s3_bucket\": \"<string>\",\n \"s3_key\": \"<string>\"\n }\n ],\n \"enable_cache\": true,\n \"cache_config\": {\n \"enable_legacy_hf_mount\": true,\n \"enabled\": true,\n \"mount_base_path\": \"/root/.cache\",\n \"require_cache_affinity\": true\n },\n \"checkpointing_config\": {\n \"enabled\": false,\n \"checkpoint_path\": \"/mnt/ckpts\",\n \"volume_size_gib\": 10\n },\n \"load_checkpoint_config\": {\n \"enabled\": false,\n \"download_folder\": \"/tmp/loaded_checkpoints\",\n \"checkpoints\": [\n {\n \"project_name\": \"<string>\",\n \"job_id\": \"<string>\",\n \"typ\": \"baseten_latest_checkpoint\"\n }\n ]\n }\n },\n \"name\": \"gpt-oss-job\",\n \"truss_user_env\": {\n \"truss_client_version\": \"<string>\",\n \"python_version\": \"<string>\",\n \"pydantic_version\": \"<string>\",\n \"mypy_version\": \"<string>\",\n \"is_library_deployment\": false,\n \"is_frontend_deployment\": false,\n \"git_info\": {\n \"latest_commit_sha\": \"<string>\",\n \"latest_tag\": \"<string>\",\n \"commits_since_tag\": 123,\n \"has_uncommitted_changes\": true\n }\n },\n \"interactive_session\": {\n \"trigger\": \"on_demand\",\n \"timeout_minutes\": 480,\n \"session_provider\": \"vs_code\",\n \"auth_provider\": \"github\"\n },\n \"weights\": [\n {\n \"source\": \"<string>\",\n \"mount_location\": \"<string>\",\n \"allow_patterns\": [\n \"*.safetensors\",\n \"config.json\"\n ],\n \"ignore_patterns\": [\n \"*.bin\",\n \"*.h5\"\n ],\n \"auth_secret_name\": \"hf_token\",\n \"auth\": {\n \"auth_method\": \"CUSTOM_SECRET\",\n \"auth_secret_name\": \"hf_token\"\n }\n }\n ],\n \"enable_baseten_workdir\": false,\n \"priority\": 0\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/training_projects/{training_project_id}/jobs")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"training_job\": {\n \"image\": {\n \"base_image\": \"<string>\",\n \"docker_auth\": {\n \"registry\": \"<string>\",\n \"gcp_service_account_json_docker_auth\": {\n \"service_account_json_secret_ref\": {\n \"name\": \"<string>\"\n }\n },\n \"aws_iam_docker_auth\": {\n \"access_key_secret_ref\": {\n \"name\": \"<string>\"\n },\n \"secret_access_key_secret_ref\": {\n \"name\": \"<string>\"\n }\n },\n \"aws_oidc_docker_auth\": {\n \"role_arn\": \"<string>\",\n \"region\": \"<string>\"\n },\n \"gcp_oidc_docker_auth\": {\n \"service_account\": \"<string>\",\n \"workload_identity_provider\": \"<string>\"\n },\n \"registry_secret_docker_auth\": {\n \"secret_ref\": {\n \"name\": \"<string>\"\n }\n }\n }\n },\n \"compute\": {\n \"node_count\": 1,\n \"cpu_count\": 1,\n \"memory\": \"2Gi\",\n \"accelerator\": {\n \"accelerator\": \"H100\",\n \"count\": 2\n },\n \"availability_model\": \"dedicated\"\n },\n \"runtime\": {\n \"start_commands\": [\n \"<string>\"\n ],\n \"environment_variables\": {},\n \"artifacts\": [\n {\n \"s3_bucket\": \"<string>\",\n \"s3_key\": \"<string>\"\n }\n ],\n \"enable_cache\": true,\n \"cache_config\": {\n \"enable_legacy_hf_mount\": true,\n \"enabled\": true,\n \"mount_base_path\": \"/root/.cache\",\n \"require_cache_affinity\": true\n },\n \"checkpointing_config\": {\n \"enabled\": false,\n \"checkpoint_path\": \"/mnt/ckpts\",\n \"volume_size_gib\": 10\n },\n \"load_checkpoint_config\": {\n \"enabled\": false,\n \"download_folder\": \"/tmp/loaded_checkpoints\",\n \"checkpoints\": [\n {\n \"project_name\": \"<string>\",\n \"job_id\": \"<string>\",\n \"typ\": \"baseten_latest_checkpoint\"\n }\n ]\n }\n },\n \"name\": \"gpt-oss-job\",\n \"truss_user_env\": {\n \"truss_client_version\": \"<string>\",\n \"python_version\": \"<string>\",\n \"pydantic_version\": \"<string>\",\n \"mypy_version\": \"<string>\",\n \"is_library_deployment\": false,\n \"is_frontend_deployment\": false,\n \"git_info\": {\n \"latest_commit_sha\": \"<string>\",\n \"latest_tag\": \"<string>\",\n \"commits_since_tag\": 123,\n \"has_uncommitted_changes\": true\n }\n },\n \"interactive_session\": {\n \"trigger\": \"on_demand\",\n \"timeout_minutes\": 480,\n \"session_provider\": \"vs_code\",\n \"auth_provider\": \"github\"\n },\n \"weights\": [\n {\n \"source\": \"<string>\",\n \"mount_location\": \"<string>\",\n \"allow_patterns\": [\n \"*.safetensors\",\n \"config.json\"\n ],\n \"ignore_patterns\": [\n \"*.bin\",\n \"*.h5\"\n ],\n \"auth_secret_name\": \"hf_token\",\n \"auth\": {\n \"auth_method\": \"CUSTOM_SECRET\",\n \"auth_secret_name\": \"hf_token\"\n }\n }\n ],\n \"enable_baseten_workdir\": false,\n \"priority\": 0\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.baseten.co/v1/training_projects/{training_project_id}/jobs")
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 \"training_job\": {\n \"image\": {\n \"base_image\": \"<string>\",\n \"docker_auth\": {\n \"registry\": \"<string>\",\n \"gcp_service_account_json_docker_auth\": {\n \"service_account_json_secret_ref\": {\n \"name\": \"<string>\"\n }\n },\n \"aws_iam_docker_auth\": {\n \"access_key_secret_ref\": {\n \"name\": \"<string>\"\n },\n \"secret_access_key_secret_ref\": {\n \"name\": \"<string>\"\n }\n },\n \"aws_oidc_docker_auth\": {\n \"role_arn\": \"<string>\",\n \"region\": \"<string>\"\n },\n \"gcp_oidc_docker_auth\": {\n \"service_account\": \"<string>\",\n \"workload_identity_provider\": \"<string>\"\n },\n \"registry_secret_docker_auth\": {\n \"secret_ref\": {\n \"name\": \"<string>\"\n }\n }\n }\n },\n \"compute\": {\n \"node_count\": 1,\n \"cpu_count\": 1,\n \"memory\": \"2Gi\",\n \"accelerator\": {\n \"accelerator\": \"H100\",\n \"count\": 2\n },\n \"availability_model\": \"dedicated\"\n },\n \"runtime\": {\n \"start_commands\": [\n \"<string>\"\n ],\n \"environment_variables\": {},\n \"artifacts\": [\n {\n \"s3_bucket\": \"<string>\",\n \"s3_key\": \"<string>\"\n }\n ],\n \"enable_cache\": true,\n \"cache_config\": {\n \"enable_legacy_hf_mount\": true,\n \"enabled\": true,\n \"mount_base_path\": \"/root/.cache\",\n \"require_cache_affinity\": true\n },\n \"checkpointing_config\": {\n \"enabled\": false,\n \"checkpoint_path\": \"/mnt/ckpts\",\n \"volume_size_gib\": 10\n },\n \"load_checkpoint_config\": {\n \"enabled\": false,\n \"download_folder\": \"/tmp/loaded_checkpoints\",\n \"checkpoints\": [\n {\n \"project_name\": \"<string>\",\n \"job_id\": \"<string>\",\n \"typ\": \"baseten_latest_checkpoint\"\n }\n ]\n }\n },\n \"name\": \"gpt-oss-job\",\n \"truss_user_env\": {\n \"truss_client_version\": \"<string>\",\n \"python_version\": \"<string>\",\n \"pydantic_version\": \"<string>\",\n \"mypy_version\": \"<string>\",\n \"is_library_deployment\": false,\n \"is_frontend_deployment\": false,\n \"git_info\": {\n \"latest_commit_sha\": \"<string>\",\n \"latest_tag\": \"<string>\",\n \"commits_since_tag\": 123,\n \"has_uncommitted_changes\": true\n }\n },\n \"interactive_session\": {\n \"trigger\": \"on_demand\",\n \"timeout_minutes\": 480,\n \"session_provider\": \"vs_code\",\n \"auth_provider\": \"github\"\n },\n \"weights\": [\n {\n \"source\": \"<string>\",\n \"mount_location\": \"<string>\",\n \"allow_patterns\": [\n \"*.safetensors\",\n \"config.json\"\n ],\n \"ignore_patterns\": [\n \"*.bin\",\n \"*.h5\"\n ],\n \"auth_secret_name\": \"hf_token\",\n \"auth\": {\n \"auth_method\": \"CUSTOM_SECRET\",\n \"auth_secret_name\": \"hf_token\"\n }\n }\n ],\n \"enable_baseten_workdir\": false,\n \"priority\": 0\n }\n}"
response = http.request(request)
puts response.read_body{
"training_job": {
"id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"current_status": "<string>",
"instance_type": {
"id": "<string>",
"name": "<string>",
"memory_limit_mib": 123,
"millicpu_limit": 123,
"gpu_count": 123,
"gpu_type": "<string>",
"gpu_memory_limit_mib": 123
},
"updated_at": "2023-11-07T05:31:56Z",
"training_project_id": "<string>",
"training_project": {
"id": "<string>",
"name": "<string>"
},
"error_message": "<string>",
"name": "gpt-oss-job",
"priority": 0,
"availability_model": "dedicated",
"user": {
"email": "<string>"
}
}
}