> ## 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.

# FineTuning

> Finetune your instance by providing it context and correct answer

### Fine-tune

This endpoint is used to finetune an instance by passing
in the required information as parameters in the request.

Request Body
The request body should contain a list of JSON objects, with each object containing both context and correct\_response attributes. The structure of the request body should be as follows:

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

<ParamField body="instance_id" type="string">
  The instance\_id you received after calling create\_app
</ParamField>

<ParamField body="data" type="string" default="[]" required>
  The request body should contain a list of JSON objects, with each object containing both context
  and correct\_response attributes. The structure of the request body should be as follows:

  ```
    [
        {
            "context": "In what year did Neil Armstrong land on the moon?",
            "correct_response": "1969"
        },
        {    "context": "Who is the author of the book 'To Kill a Mockingbird'?",
            "correct_response": "Harper Lee"
        },
        {    "context": "What is the capital of France?",
            "correct_response": "Paris"
        }
    ]
  ```
</ParamField>

### Response

<ResponseField name="status" type="string">
  A string indicating the status of the request. This will be "success" if the
  request was successful and the feedback was stored
</ResponseField>

<ResponseField name="api_endpoint" type="string">
  Your api endpoint of the finetuned instance
</ResponseField>

<RequestExample>
  ```python python theme={null}
  import requests
  import json

  payload = [{
  "context": "In what year did Neil Armstrong land on the moon?",
  "correct_response": "1969"
  }, {
  "context": "Who is the author of the book 'To Kill a Mockingbird'?",
  "correct_response": "Harper Lee"
  }, {
  "context": "What is the capital of France?",
  "correct_response": "Paris"
  }]

  url = "https://api.berri.ai/finetune_instance"
  args = {
  "user_email": "krrish@berri.ai",
  "instance_id": "7156c47f-2f70-4c81-a622-5dc21ef716d2"
  }
  headers = {'Content-Type': 'application/json'}
  data = json.dumps(payload)
  response = requests.post(url, params=args, headers=headers, data=data)
  print(response.text)

  ```

  ```php php theme={null}
  <?php

      $payload = array(
          array(
              "context" => "In what year did Neil Armstrong land on the moon?",
              "correct_response" => "1969"
          ),
          array(
              "context" => "Who is the author of the book 'To Kill a Mockingbird'?",
              "correct_response" => "Harper Lee"
          ),
          array(
              "context" => "What is the capital of France?",
              "correct_response" => "Paris"
          )
      );

      $url = "https://api.berri.ai/finetune_instance";
      $args = array(
          "user_email" => "krrishdholakia@gmail.com",
          "instance_id" => "6eaa6359-7d27-4083-98d0-989c9d05930c"
      );
      $headers = array('Content-Type' => 'application/json');
      $data = json_encode($payload);
      $options = array(
          'http' => array(
              'header'  => "Content-Type: application/json\r\n",
              'method'  => 'POST',
              'content' => $data
          )
      );
      $context = stream_context_create($options);
      $response = file_get_contents($url . '?' . http_build_query($args), false, $context);
      echo $response;

  ?>
  ```
</RequestExample>
