Skip to main content
POST
/
v4
/
knowledge-bases
Python
import os
from scale_gp import SGPClient

client = SGPClient(
    api_key=os.environ.get("SGP_API_KEY"),  # This is the default and can be omitted
)
create_knowledge_base_response = client.knowledge_bases.create(
    embedding_config={
        "model_deployment_id": "model_deployment_id",
        "type": "models_api",
    },
    knowledge_base_name="knowledge_base_name",
)
print(create_knowledge_base_response.knowledge_base_id)
package main

import (
"context"
"fmt"

"github.com/stainless-sdks/sgp-go"
"github.com/stainless-sdks/sgp-go/option"
)

func main() {
client := sgp.NewClient(
option.WithAPIKey("My API Key"),
)
createKnowledgeBaseResponse, err := client.KnowledgeBases.New(context.TODO(), sgp.KnowledgeBaseNewParams{
EmbeddingConfig: sgp.F[sgp.KnowledgeBaseNewParamsEmbeddingConfigUnion](sgp.KnowledgeBaseNewParamsEmbeddingConfigEmbeddingConfigModelsAPI{
ModelDeploymentID: sgp.F("model_deployment_id"),
Type: sgp.F(sgp.KnowledgeBaseNewParamsEmbeddingConfigEmbeddingConfigModelsAPITypeModelsAPI),
}),
KnowledgeBaseName: sgp.F("knowledge_base_name"),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", createKnowledgeBaseResponse.KnowledgeBaseID)
}
curl --request POST \
--url https://api.egp.scale.com/v4/knowledge-bases \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"embedding_config": {
"type": "<string>",
"model_deployment_id": "<string>"
},
"knowledge_base_name": "<string>",
"account_id": "<string>",
"metadata": {}
}
'
const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
embedding_config: {type: '<string>', model_deployment_id: '<string>'},
knowledge_base_name: '<string>',
account_id: '<string>',
metadata: {}
})
};

fetch('https://api.egp.scale.com/v4/knowledge-bases', 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.egp.scale.com/v4/knowledge-bases",
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([
'embedding_config' => [
'type' => '<string>',
'model_deployment_id' => '<string>'
],
'knowledge_base_name' => '<string>',
'account_id' => '<string>',
'metadata' => [

]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
HttpResponse<String> response = Unirest.post("https://api.egp.scale.com/v4/knowledge-bases")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"embedding_config\": {\n \"type\": \"<string>\",\n \"model_deployment_id\": \"<string>\"\n },\n \"knowledge_base_name\": \"<string>\",\n \"account_id\": \"<string>\",\n \"metadata\": {}\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.egp.scale.com/v4/knowledge-bases")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"embedding_config\": {\n \"type\": \"<string>\",\n \"model_deployment_id\": \"<string>\"\n },\n \"knowledge_base_name\": \"<string>\",\n \"account_id\": \"<string>\",\n \"metadata\": {}\n}"

response = http.request(request)
puts response.read_body
{
  "knowledge_base_id": "<string>"
}
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}

Authorizations

x-api-key
string
header
required

Headers

x-selected-account-id
string | null

Body

application/json
embedding_config
EmbeddingConfigModelsAPI · object
required

The configuration of the embedding

knowledge_base_name
string
required

A unique name for the knowledge base

account_id
string

Account to create knowledge base in. If you have access to more than one account, you must specify an account_id

metadata
Metadata · object

Metadata associated with the knowledge base

kb_index_configuration
KBIndexConfiguration · object

Configuration for metadata schema in the knowledge base, including field definitions and index settings

Response

Successful Response

knowledge_base_id
string
required

The unique ID of the created knowledge base