> ## Documentation Index
> Fetch the complete documentation index at: https://docs.berri.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Create App

> Connect to a single or multiple data sources and spin up chatGPT apps for each of them

Here's a link to a replit showing how to create an app: [https://replit.com/@krrishdholakia/BerriAPIQuizlet?v=1](https://replit.com/@krrishdholakia/BerriAPIQuizlet?v=1)

### Query

<ParamField body="user_email" type="string">
  Pass in your email, this will map the app you create to your account.
</ParamField>

<ParamField body="data_source" type="string">
  You can either send a **single data source**: a single file (`.pdf`, `.zip`, `.pptx`, `.docx`, `.txt`) or a website/API URL.

  ```python theme={null}
  import requests

  url = "https://api.berri.ai/create_app"

  data = {"template_id": template_id, "user_email": "krrish@berri.ai"}

  files = {'data_source': open('quizlet_wa_test_1.pdf', 'rb')}

  response = requests.post(url, files=files, data=data)
  ```

  Or **multiple data sources**: a list of strings or website URLs.

  ```python theme={null}
  import requests
  import json

  tmp_list = ["hello world", "https://stripe.com/docs/india-accept-international-payments#TransactionPurposeCode"]

  url = "https://api.berri.ai/create_app"
  data = {"user_email": "krrish@berri.ai", "data_source": json.dumps(tmp_list)}
  response = requests.post(url, data=data)
  response.text
  ```

  Additionally, you can also send in metadata for each data source.

  ```python theme={null}
  import requests
  import json

  api_endpoint = "https://api.berri.ai/create_app"

  data_source = [{"chunk": "hello", "chunk_metadata": "test_metadata"}, {"chunk": "hey there", "chunk_metadata": "test_metadata_2"}]

  data = {
    "user_email": "krrish@berri.ai",
    "data_source": json.dumps(data_source)
  }

  response = requests.post(api_endpoint, data=data)

  print(response.text)
  ```
</ParamField>

<ParamField body="template_id" type="string" optional>
  The app configuration you sent to /create\_template is now stored as a
  template. This is it's unique id. Use it to automatically spin up chatGPT apps
  with that exact configuration.
</ParamField>

<ParamField body="prompt" type="string" optional>
  Optional - use this to help specify how you want your output to be. This will
  override the prompt you set in your template if this field is set eg. You are
  an AI customer support bot for Substack blog posts
</ParamField>

<ParamField body="plugin_name" type="string" optional>
  OpenAI Plugin Parameter Use this Parameter to set the name for your plugin ex.
  resume knowledge
</ParamField>

<ParamField body="plugin_description" type="string" optional>
  OpenAI Plugin Parameter Use this Parameter to set a model description for your
  plugin ex. Plugin for querying data about Ishaan's resume
</ParamField>

### Response

<ResponseField name="api_endpoint" type="string">
  This will return an api endpoint which you can use to query your app.
</ResponseField>

<ResponseField name="website_endpoint" type="string">
  This will return a website endpoint which you can use for quick prototyping.
</ResponseField>

<ResponseField name="instance_id" type="string">
  This will return the instance\_id, which you can specify when calling
  api.berri.ai/query
</ResponseField>

<ResponseField name="plugin_yaml" type="string">
  OpenAI Plugin Field: This is the auto created openapi.yaml file for your berri
  More info here: [https://platform.openai.com/docs/plugins/examples](https://platform.openai.com/docs/plugins/examples)
</ResponseField>

<ResponseField name="plugin_manifest" type="string">
  OpenAI Plugin Field: This is the auto created ai-plugin.json file for your
  berri More info here: [https://platform.openai.com/docs/plugins/examples](https://platform.openai.com/docs/plugins/examples)
</ResponseField>

<RequestExample>
  ```bash curl theme={null}
  curl -X POST \
    https://api.berri.ai/create_app \
    -H 'Content-Type: multipart/form-data' \
    -F template_id=9a5f0111-4e8b-428d-8fda-863773fe41cd \
    -F user_email=krrish@berri.ai \
    -F data_source=@/Users/krrishdholakia/Downloads/quizlet_wa_test_1.pdf
  ```

  ```python python theme={null}
  import requests

  template_id = "9a5f0111-4e8b-428d-8fda-863773fe41cd"

  url = "https://api.berri.ai/create_app"

  data = {"template_id": template_id, "user_email": "krrish@berri.ai"}

  files = {'data_source': open('quizlet_wa_test_1.pdf', 'rb')}

  response = requests.post(url, files=files, data=data)

  print(response.text)

  api_endpoint = response.json()["api_endpoint"]
  ```

  ```javascript javascript theme={null}
  const request = require("request");

  const template_id = "9a5f0111-4e8b-428d-8fda-863773fe41cd";

  const url = "https://api.berri.ai/create_app";

  const data = {
    template_id: template_id,
    user_email: "krrish@berri.ai",
  };

  const files = {
    data_source: fs.createReadStream("quizlet_wa_test_1.pdf"),
  };

  const response = request.post(
    { url: url, formData: { data, files } },
    function (err, httpResponse, body) {
      if (err) {
        return console.error("upload failed:", err);
      }
      console.log("Upload successful!  Server responded with:", body);
    }
  );

  const api_endpoint = JSON.parse(body)["api_endpoint"];
  ```

  ```javascript node.js theme={null}
  const request = require("request");
  const fs = require("fs");

  const options = {
    method: "POST",
    url: "https://api.berri.ai/create_app",
    headers: {
      "Content-Type": "multipart/form-data",
    },
    formData: {
      template_id: "9a5f0111-4e8b-428d-8fda-863773fe41cd",
      user_email: "krrish@berri.ai",
      data_source: {
        value: fs.createReadStream("quizlet_wa_test_1.pdf"),
        options: {
          filename: "quizlet_wa_test_1.pdf",
          contentType: "application/pdf",
        },
      },
    },
  };

  request(options, function (error, response, body) {
    if (error) throw new Error(error);

    console.log(body);
  });
  ```

  ```javascript next.js theme={null}
  var formdata = new FormData();
  formdata.append("data_source", props.fileContent);
  formdata.append("user_email", props.email);
  formdata.append("template_id", "12fc2341-a89d-4726-bc43-e5cbf634de32");
  console.log(formdata);
  var requestOptions = {
    method: "POST",
    body: formdata,
    redirect: "follow",
  };
  fetch(create_instance_endpoint, requestOptions)
    .then((response) => response.json())
    .then((result) => {
      console.log("Create app result");
      console.log(result);
      console.log(result["website_endpoint"]);
    })
    .catch((error) => {
      console.log("error", error);
    });
  ```
</RequestExample>
