Preview a smart-model decision - Barndoor Documentation

Preview a smart-model decision

cURL

curl --request POST \
  --url https://app.barndoor.ai/api/llm-gateway/admin/smart-models/preview \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model_alias": "<string>",
  "determiner_model_alias": "<string>",
  "slots": [
    { 
      "model_alias": "<string>",
      "label": "<string>"
    }
  ],
  "text": "<string>",
  "description": "<string>",
  "enabled": true,
  "context_breakpoints": [
    123
  ],
  "determiner_input_max_chars": 123,
  "default_slot_on_failure": 123,
  "endpoint": "/v1/chat/completions",
  "requires_tools": false,
  "requires_vision": false,
  "token_count": 123
}
'

Python Code

import requests

url = "https://app.barndoor.ai/api/llm-gateway/admin/smart-models/preview"

payload = {
    "model_alias": "<string>",
    "determiner_model_alias": "<string>",
    "slots": [
        {
            "model_alias": "<string>",
            "label": "<string>"
        }
    ],
    "text": "<string>",
    "description": "<string>",
    "enabled": True,
    "context_breakpoints": [123],
    "determiner_input_max_chars": 123,
    "default_slot_on_failure": 123,
    "endpoint": "/v1/chat/completions",
    "requires_tools": False,
    "requires_vision": False,
    "token_count": 123
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)

JavaScript Code

const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    model_alias: '<string>',
    determiner_model_alias: '<string>',
    slots: [{model_alias: '<string>', label: '<string>'}],
    text: '<string>',
    description: '<string>',
    enabled: true,
    context_breakpoints: [123],
    determiner_input_max_chars: 123,
    default_slot_on_failure: 123,
    endpoint: '/v1/chat/completions',
    requires_tools: false,
    requires_vision: false,
    token_count: 123
  })
};

fetch('https://app.barndoor.ai/api/llm-gateway/admin/smart-models/preview', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));

PHP Code

<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://app.barndoor.ai/api/llm-gateway/admin/smart-models/preview",
  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([
    'model_alias' => '<string>',
    'determiner_model_alias' => '<string>',
    'slots' => [
        [
                'model_alias' => '<string>',
                'label' => '<string>'
        ]
    ],
    'text' => '<string>',
    'description' => '<string>',
    'enabled' => true,
    'context_breakpoints' => [
        123
    ],
    'determiner_input_max_chars' => 123,
    'default_slot_on_failure' => 123,
    'endpoint' => '/v1/chat/completions',
    'requires_tools' => false,
    'requires_vision' => false,
    'token_count' => 123
  ]),
  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;
}
?>

Go Code

package main

import (
    "fmt"
    "strings"
    "net/http"
    "io"
)

func main() {

url := "https://app.barndoor.ai/api/llm-gateway/admin/smart-models/preview"

payload := strings.NewReader("{\n  \"model_alias\": \"<string>\",\n  \"determiner_model_alias\": \"<string>\",\n  \"slots\": [\n    {\n      \"model_alias\": \"<string>\",\n      \"label\": \"<string>\"\n    }\n  ],\n  \"text\": \"<string>\",\n  \"description\": \"<string>\",\n  \"enabled\": true,\n  \"context_breakpoints\": [123],\n  \"determiner_input_max_chars\": 123,\n  \"default_slot_on_failure\": 123,\n  \"endpoint\": \"/v1/chat/completions\",\n  \"requires_tools\": false,\n  \"requires_vision\": false,\n  \"token_count\": 123}\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))
}

Sample Responses

Successful Response

{
  "target_model_alias": "<string>",
  "decision": {}
}

Error Response

{
  "error": "BadRequest",
  "message": "request_timeout_secs must be between 1 and 3600"
}

Authorizations

Body

Response