Skip to main content
POST
/
v1
/
loops
/
samplers
cURL
curl --request POST \
--url https://api.baseten.co/v1/loops/samplers \
--header "Authorization: Bearer $BASETEN_API_KEY" \
--data '{
  "session_id": null,
  "base_model": null,
  "max_seq_length": null,
  "model_path": "bt://loops:k4q95w5/sampler_weights/step-100",
  "reuse_from_session_id": null
}'
import requests
import os
API_KEY = os.environ.get("BASETEN_API_KEY", "<YOUR_API_KEY>")
url = "https://api.baseten.co/v1/loops/samplers"

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

response = requests.request(
"POST",
url,
headers=headers,
json={'session_id': None, 'base_model': None, 'max_seq_length': None, 'model_path': 'bt://loops:k4q95w5/sampler_weights/step-100', 'reuse_from_session_id': None}
)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
session_id: '<string>',
base_model: '<string>',
max_seq_length: 123,
model_path: 'bt://loops:k4q95w5/sampler_weights/step-100',
reuse_from_session_id: '<string>'
})
};

fetch('https://api.baseten.co/v1/loops/samplers', 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/loops/samplers",
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([
'session_id' => '<string>',
'base_model' => '<string>',
'max_seq_length' => 123,
'model_path' => 'bt://loops:k4q95w5/sampler_weights/step-100',
'reuse_from_session_id' => '<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://api.baseten.co/v1/loops/samplers"

payload := strings.NewReader("{\n \"session_id\": \"<string>\",\n \"base_model\": \"<string>\",\n \"max_seq_length\": 123,\n \"model_path\": \"bt://loops:k4q95w5/sampler_weights/step-100\",\n \"reuse_from_session_id\": \"<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://api.baseten.co/v1/loops/samplers")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"session_id\": \"<string>\",\n \"base_model\": \"<string>\",\n \"max_seq_length\": 123,\n \"model_path\": \"bt://loops:k4q95w5/sampler_weights/step-100\",\n \"reuse_from_session_id\": \"<string>\"\n}")
.asString();
require 'uri'
require 'net/http'

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

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 \"session_id\": \"<string>\",\n \"base_model\": \"<string>\",\n \"max_seq_length\": 123,\n \"model_path\": \"bt://loops:k4q95w5/sampler_weights/step-100\",\n \"reuse_from_session_id\": \"<string>\"\n}"

response = http.request(request)
puts response.read_body
{
  "sampler": {
    "id": "<string>",
    "base_url": "<string>",
    "base_model": "<string>",
    "created_at": "2023-11-07T05:31:56Z",
    "model_id": "<string>",
    "deployment_id": "<string>",
    "status": {}
  }
}

Authorizations

Authorization
string
header
required

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

Body

application/json
session_id
string
required

ID of the Loops session this sampler belongs to.

base_model
string
required

Base model ID for standalone samplers (e.g., for baselines).

max_seq_length
integer | null

Maximum prompt length (in tokens) the sampler must handle. Set this to the longest prompt you plan to send. Omit to use the default for the base model.

model_path
string | null

Optional bt:// URI of an existing sampler-target checkpoint to load weights from on startup. Form: bt://loops:<run_id>/sampler_weights/<checkpoint_name>.

Example:

"bt://loops:k4q95w5/sampler_weights/step-100"

reuse_from_session_id
string | null

Optional Loops session ID whose deployment should be reused for this sampler. Same best-effort semantics as the run endpoint.

Response

200 - application/json
sampler
LoopsSamplerV1 · object
required