Update a provider - Barndoor Documentation

Update a provider

cURL

curl --request PUT \
  --url https://app.barndoor.ai/api/llm-gateway/admin/providers/{id} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '\n{\n  "name": "<string>",\n  "base_url": "<string>",\n  "auth_type": "api_key",\n  "api_key": "<string>",\n  "credentials": {},\n  "enabled": true,\n  "settings": {},\n  "connection_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",\n  "request_timeout_secs": 1800,\n  "stream_idle_timeout_secs": 900\n}\n'

Python

import requests

url = "https://app.barndoor.ai/api/llm-gateway/admin/providers/{id}"

payload = {
    "name": "<string>",
    "base_url": "<string>",
    "auth_type": "api_key",
    "api_key": "<string>",
    "credentials": {},
    "enabled": True,
    "settings": {},
    "connection_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "request_timeout_secs": 1800,
    "stream_idle_timeout_secs": 900
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.text)

JavaScript

const options = {
  method: 'PUT',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    name: '<string>',
    base_url: '<string>',
    auth_type: 'api_key',
    api_key: '<string>',
    credentials: {},
    enabled: true,
    settings: {},
    connection_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
    request_timeout_secs: 1800,
    stream_idle_timeout_secs: 900
  })
};

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

PHP

<?php

$curl = curl_init();

curl_setopt_array($curl, [\
  CURLOPT_URL => "https://app.barndoor.ai/api/llm-gateway/admin/providers/{id}",\
  CURLOPT_RETURNTRANSFER => true,\
  CURLOPT_ENCODING => "",\
  CURLOPT_MAXREDIRS => 10,\
  CURLOPT_TIMEOUT => 30,\
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\
  CURLOPT_CUSTOMREQUEST => "PUT",\
  CURLOPT_POSTFIELDS => json_encode([\
    'name' => '<string>',\
    'base_url' => '<string>',\
    'auth_type' => 'api_key',\
    'api_key' => '<string>',\
    'credentials' => [\
\
    ],\
    'enabled' => true,\
    'settings' => [\
\
    ],\
    'connection_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',\
    'request_timeout_secs' => 1800,\
    'stream_idle_timeout_secs' => 900\
  ]),\
  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

package main

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

func main() {

url := "https://app.barndoor.ai/api/llm-gateway/admin/providers/{id}"

payload := strings.NewReader("{\n  \"name\": \"<string>\",\n  \"base_url\": \"<string>\",\n  \"auth_type\": \"api_key\",\n  \"api_key\": \"<string>\",\n  \"credentials\": {},\n  \"enabled\": true,\n  \"settings\": {},\n  \"connection_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n  \"request_timeout_secs\": 1800,\n  \"stream_idle_timeout_secs\": 900\n}")

req, _ := http.NewRequest("PUT", 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))
}

Response Examples

Success Response

{
  "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "org_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "name": "OpenAI Production (US)",
  "model_provider": "openai",
  "auth_type": "api_key",
  "base_url": "<string>",
  "enabled": true,
  "settings": {},
  "catalog_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "connection_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "request_timeout_secs": 1800,
  "stream_idle_timeout_secs": 900,
  "catalog_slug": "<string>"
}

Error Response

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