curl --request POST \
--url https://api.outerlayer.ai/v1/apps/{appId}/model-providers \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Outerlayer-App-Id: <api-key>' \
--data '
{
"key": "<string>",
"modelIds": [
"<string>"
],
"address": "<string>",
"name": "<string>",
"preset": "<string>"
}
'import requests
url = "https://api.outerlayer.ai/v1/apps/{appId}/model-providers"
payload = {
"key": "<string>",
"modelIds": ["<string>"],
"address": "<string>",
"name": "<string>",
"preset": "<string>"
}
headers = {
"X-Outerlayer-App-Id": "<api-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Outerlayer-App-Id': '<api-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
key: '<string>',
modelIds: ['<string>'],
address: '<string>',
name: '<string>',
preset: '<string>'
})
};
fetch('https://api.outerlayer.ai/v1/apps/{appId}/model-providers', 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.outerlayer.ai/v1/apps/{appId}/model-providers",
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([
'key' => '<string>',
'modelIds' => [
'<string>'
],
'address' => '<string>',
'name' => '<string>',
'preset' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-Outerlayer-App-Id: <api-key>"
],
]);
$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.outerlayer.ai/v1/apps/{appId}/model-providers"
payload := strings.NewReader("{\n \"key\": \"<string>\",\n \"modelIds\": [\n \"<string>\"\n ],\n \"address\": \"<string>\",\n \"name\": \"<string>\",\n \"preset\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Outerlayer-App-Id", "<api-key>")
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.outerlayer.ai/v1/apps/{appId}/model-providers")
.header("X-Outerlayer-App-Id", "<api-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"key\": \"<string>\",\n \"modelIds\": [\n \"<string>\"\n ],\n \"address\": \"<string>\",\n \"name\": \"<string>\",\n \"preset\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.outerlayer.ai/v1/apps/{appId}/model-providers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Outerlayer-App-Id"] = '<api-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"key\": \"<string>\",\n \"modelIds\": [\n \"<string>\"\n ],\n \"address\": \"<string>\",\n \"name\": \"<string>\",\n \"preset\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"address": "<string>",
"apiType": "<string>",
"host": "<string>",
"id": "<string>",
"kind": "preset",
"modelIds": [
"<string>"
],
"name": "<string>",
"setAt": "<string>",
"setBy": "<string>",
"variable": "<string>",
"verified": true
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}Add a model provider to the factory
Adds a preset (preset, with the model ids and the key) or a custom endpoint (name, address, the model ids and the key). The gateway tries the endpoint with one call and the key in the entry’s header, then stores the key in Supabase Vault as a build variable that is sent to the address. The call is {address}/key for OpenRouter and {address}/models for a custom endpoint. An endpoint that answers 401 or 403 is refused with model_endpoint_key_refused (422) and nothing is stored. The entry is stored with verified true only when OpenRouter accepts the key. A custom endpoint can serve its model list with no key, so its entry is stored with verified false when it answers 200. The same holds for an endpoint the gateway cannot reach, one that redirects, and one whose name resolves to a private address: the gateway follows no redirect and sends the key to no other host. An address that is not https or not public, a list with no model id, an unknown preset or an address another variable already uses is refused with model_provider_invalid (422). A name another provider uses is refused with model_provider_name_taken (409). The key variable is named after the entry, such as ACME_GATEWAY_API_KEY, with a number added when the name is taken. Answers 403 model_providers_off, and stores nothing, unless the model_providers flag is on for the organization.
curl --request POST \
--url https://api.outerlayer.ai/v1/apps/{appId}/model-providers \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Outerlayer-App-Id: <api-key>' \
--data '
{
"key": "<string>",
"modelIds": [
"<string>"
],
"address": "<string>",
"name": "<string>",
"preset": "<string>"
}
'import requests
url = "https://api.outerlayer.ai/v1/apps/{appId}/model-providers"
payload = {
"key": "<string>",
"modelIds": ["<string>"],
"address": "<string>",
"name": "<string>",
"preset": "<string>"
}
headers = {
"X-Outerlayer-App-Id": "<api-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Outerlayer-App-Id': '<api-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
key: '<string>',
modelIds: ['<string>'],
address: '<string>',
name: '<string>',
preset: '<string>'
})
};
fetch('https://api.outerlayer.ai/v1/apps/{appId}/model-providers', 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.outerlayer.ai/v1/apps/{appId}/model-providers",
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([
'key' => '<string>',
'modelIds' => [
'<string>'
],
'address' => '<string>',
'name' => '<string>',
'preset' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-Outerlayer-App-Id: <api-key>"
],
]);
$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.outerlayer.ai/v1/apps/{appId}/model-providers"
payload := strings.NewReader("{\n \"key\": \"<string>\",\n \"modelIds\": [\n \"<string>\"\n ],\n \"address\": \"<string>\",\n \"name\": \"<string>\",\n \"preset\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Outerlayer-App-Id", "<api-key>")
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.outerlayer.ai/v1/apps/{appId}/model-providers")
.header("X-Outerlayer-App-Id", "<api-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"key\": \"<string>\",\n \"modelIds\": [\n \"<string>\"\n ],\n \"address\": \"<string>\",\n \"name\": \"<string>\",\n \"preset\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.outerlayer.ai/v1/apps/{appId}/model-providers")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Outerlayer-App-Id"] = '<api-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"key\": \"<string>\",\n \"modelIds\": [\n \"<string>\"\n ],\n \"address\": \"<string>\",\n \"name\": \"<string>\",\n \"preset\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"address": "<string>",
"apiType": "<string>",
"host": "<string>",
"id": "<string>",
"kind": "preset",
"modelIds": [
"<string>"
],
"name": "<string>",
"setAt": "<string>",
"setBy": "<string>",
"variable": "<string>",
"verified": true
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}