https://retellai.com/?utm_source=discord&utm_medium=seo logo
Im get 500 error using the api to create a new kno...
# ❓・ai-evy-support
d
@AI Evy Im get 500 error using the api to create a new knowledge base
a
Thanks for tagging me @Darin. I'll look through relevant sources and get back to you shortly.
​ To learn more, see the sources I considered: [[1] internal server error on create knowledge base by API](https://discord.com/channels/1186424376300679209/1391417148215136376) [[2] API knowledge base bug](https://discord.com/channels/1186424376300679209/1448946789385371668) [[3] Create Knowledge Base](https://docs.retellai.com/api-references/create-knowledge-base) [[4] Create Knowledge Base Through API](https://discord.com/channels/1186424376300679209/1442245748275019860) ​
### Answer A 500 error when creating a knowledge base via API is a known issue that has affected other users. [(1) ]() Here are a few things to check: 1. Use the SDK approach — The Knowledge Base API for create/add works best with the SDK: [(2) ]()
Copy code
javascript
import Retell from 'retell-sdk';
const client = new Retell({
  apiKey: 'YOUR_RETELL_API_KEY',
}) ;
async function main() {
  const knowledgeBaseResponse = await client.knowledgeBase.create({
    knowledge_base_name: "Sample KB",
    knowledge_base_texts: [
      {
        text: "Hello, how are you?",
        title: "Sample Question",
      },
    ],
    knowledge_base_urls: [
      "<https://www.retellai.com%22,>
      "<https://docs.retellai.com%22,>
    ],
    knowledge_base_files: [
      fs.createReadStream("../sample.txt") ,
    ],
  }) ;
  console.log(knowledgeBaseResponse.knowledge_base_id) ;
}
main() ;
[(3) ]() 2. Ensure correct data types: -
knowledge_base_name
must be a string (less than 40 characters) -
knowledge_base_texts
must be an array of objects with
text
and
title
properties , [(4) ]() -
knowledge_base_urls
must be valid URLs [(3) ]() 3. If using FormData directly, ensure the
knowledge_base_name
is properly formatted as a string. [(1) ]() If the issue persists, this may be a temporary server-side issue — the Retell team has worked on knowledge base issues previously.
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.