# Alli LLM App Market API

Kindly be advised that the utilization of the Alli App Market is not universally accessible to all clients. Should you express interest in utilizing our App Market, we recommend that you reach out to your designated account manager for further information and guidance.

## **Getting the API KEY**

**Please provide your API key in the request header `API-KEY`.** Your API key can be found in your dashboard [Settings menu](https://app.alli.ai/settings), under the General tab.

## Error Messages

Please read the error message you get if you don't get the response that you expected. For example, if you don't use the right HTTP method for the API, you'll get this type of error as response:

```
{“error”: “Method Not Allowed POST: /webapi/apps”}
```

If you don't include the inputs when running the LLM App for example, you'll get this type of error as a response:

```
{"errors": "internal error. Expecting value: line 1 column 1 (char 0)"}
```

## LLM App List Search

<mark style="color:blue;">`GET`</mark> `https://backend.alli.ai/webapi/apps`

App list search API allows you to see all single action and conversational apps within your project

#### Path Parameters

| Name      | Type    | Description                                                                                                                                                                                                   |
| --------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| published | boolean | <p>Choose whether to show only the apps that are published or not.</p><p></p><p><code>True</code> will show published apps.</p><p><code>False</code> will show drafts only.</p><p>Default shows all apps.</p> |
| user      | string  | User ID (Optional; if not provided, all apps will be fetched)                                                                                                                                                 |
| id        | string  | Specify an app ID. (Optional; if not provided, all apps will be fetched. Can be multiple id's, eg. id=abc\&id=bcd)                                                                                            |

#### Headers

| Name                                      | Type   | Description                                                                            |
| ----------------------------------------- | ------ | -------------------------------------------------------------------------------------- |
| API-KEY<mark style="color:red;">\*</mark> | string | Your Rest API key can be found in your dashboard Settings menu, under the General tab. |

{% tabs %}
{% tab title="200: OK " %}

{% endtab %}
{% endtabs %}

### Request Example

Please replace YOUR\_REST\_API\_KEY with your one in the example below. Please see [getting-api-key](#getting-the-api-key) section.&#x20;

```
curl --location 
'https://backend.alli.ai/webapi/apps?published=true' \
--header 'API-KEY: YOUR_REST_API_KEY'
```

### Response Example

```
{
  "result": [
    {
      "id": "TExNQXBwOjY1NTQxZGJhMWJjYjE2MmIxZjU4MGEyYg==",
      "name": "New Skill",
      "type": "skill",
      "description": null,
      "category": "OTHERS",
      "appFrom": "second_party"
    },
    {
      "id": "TExNQXBwOjY1NWFiOGZkNjlkZDAyNWI3MGUwNGY1ZA==",
      "name": "New Skill (1)",
      "type": "skill",
      "description": null,
      "category": "OTHERS",
      "appFrom": "second_party"
    },
    {
      "id": "TExNQXBwOjY1NDljOTM1MTkyNTExNGQzYTEyMThiOA==",
      "name": "New single action (1)",
      "type": "single_action",
      "description": "afafaf",
      "category": "IT",
      "appFrom": "second_party"
    },
    {
      "id": "TExNQXBwOjY1NTQ2MTNlOWZiZGI4MzA4ODBkYjNmYQ==",
      "name": "llm app v2",
      "type": "skill",
      "description": "dafafaf",
      "category": "GENERAL",
      "appFrom": "second_party"
    }
  ]
}
```

## Run LLM App

<mark style="color:green;">`POST`</mark> `https://backend.alli.ai/webapi/apps/:app_id/run`

Run LLM App API allows you to run the desired skill/conversational or single-action app.

#### Headers

| Name                                      | Type   | Description                                                                            |
| ----------------------------------------- | ------ | -------------------------------------------------------------------------------------- |
| API-KEY<mark style="color:red;">\*</mark> | string | Your Rest API key can be found in your dashboard Settings menu, under the General tab. |

#### Request Body

| Name   | Type   | Description                                                                                                                                                                                                                                                      |
| ------ | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| inputs | json   | <p>Input for use in a single action or conversational/skill.<br><br>Single action: Only the variable inputs used in the single action app are available.</p><p></p><p>Conversational/skill : Currently, only variables set as user variables can be used.</p>    |
| mode   | string | <p>Whether to output data as stream or sync. Current available values: <code>sync</code> OR <code>stream</code> (default=<code>sync</code>) </p><p></p><p>When in stream mode, .json strings with the same output format as sync are outputted as streaming.</p> |

{% tabs %}
{% tab title="200: OK " %}

{% endtab %}
{% endtabs %}

### Single Action Request Example

Please replace YOUR\_REST\_API\_KEY with your one in the example below. Please see [getting-api-key](#getting-the-api-key) section.&#x20;

```
curl -vv -X POST \
  'https://backend.alli.ai/webapi/apps/TExNQXBwOjY1NWVlYTMzY2IzMzQ1OTVkZjQwNzdhZg==/run' \
  --header 'Accept: */*' \
  --header 'API-KEY: YOUR_REST_API_KEY' \
  --header 'Content-Type: application/json' \
  --data-raw '{"inputs":{"input": "The Little Prince has sold approximately 140 million copies worldwide, making it one of the best-selling and most translated books ever published. To date, it has been translated into 301 languages and dialects. It was the first novel to be published in the United States. The story of the novel is interesting: Saint-Exupéry was in New York City, and while having dinner with his American publisher, Eugene Reynal, he doodled a child on a napkin. When Eugene Reynal saw the drawing, he suggested to Saint-Maximilien that it would be a good idea to write a children's book about the child before Christmas. (It is said that Eugène Reynal suggested it to relieve his stress.) The basic sketch of the Little Prince was based on a statue of the baby Jesus in Prague, Czech Republic. The narrator, a pilot, was also inspired by visions Saint-Exupéry himself experienced when he and his co-pilot crash-landed in the Sahara Desert in 1935 and were stranded for five days without a drop of water."}}'
```

### Single Action Response Example

```
{
  "result": {
    "id": "TExNQXBwOjY1NWVlYTMzY2IzMzQ1OTVkZjQwNzdhZg==",
    "name": "Summary Single-action App",
    "type": "single_action",
    "category": "General",
    "choices": [
      {
        "id": "U2luZ2xlQWN0aW9uOjY1NWVlZjQ4M2JhMTIzYzA3YWZmNWUzOQ==",
        "type": "llm",
        "message": "The Little Prince is one of the world's best-selling books, with over 140 million copies sold, and has been translated into 301 languages. The novel was first published in the United States and was the brainchild of publisher Eugene Reynal. The basic sketch of The Little Prince was inspired by the Baby Jesus statue in Prague, Czech Republic, and the pilot was inspired by Saint-Exupéry's own experiences in the Sahara Desert."
      }
    ]
  }
}
```

### Conversational/Skill Request Example

Currently, Skills that require user interaction in the middle of the app execution (e.g., asking the user to make a selection, enter a message, etc.) are not supported by the LLM App API. (However, launching an LLM node after uploading a document is an exception, as shown in the example below).

Please replace YOUR\_REST\_API\_KEY with your one in the example below. Please see [getting-api-key](#getting-the-api-key) section.&#x20;

```
curl -vv -X POST \
'https://backend.alli.ai/webapi/apps/TExNQXBwOjY1NWVlYTU1OTZlOWM1MjI4MDY2YjlhOQ==/run' \
--header 'Accept: */*' \
--header 'API-KEY: YOUR_REST_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{"inputs":{"usertest": ["S25vd2xlZGdlQmFzZTo2NTVlZjAzNmMxYzFmMDFiYmNmYjYxMWM="]}}'
```

### Conversational/Skill Response Example

```
{
  "result": {
    "id": "TExNQXBwOjY1NWVlYTU1OTZlOWM1MjI4MDY2YjlhOQ==",
    "name": "LLM App Skill",
    "type": "skill",
    "category": "General",
    "choices": [
      {
        "id": "Q2hhdDo2NTVlZjFhMGJiOWRkZjBhMWVkMzViNTE=",
        "type": "llm",
        "message": "{\"blocks\": [{\"key\": \"jeno\", \"type\": \"unstyled\", \"text\": \"A girl who loses her mother, but finds solace in the tree she plants on her mother's grave.\", \"depth\": 0, \"inlineStyleRanges\": [], \"entityRanges\": [], \"data\": {}}], \"entityMap\": {}}"
      }
    ]
  }
}
```

### Error Messages (cont.)

If you did not receive the expected response, please check the error message

| Status Code | Error Code | Name              | Message                                              | Description                                                                                      |
| ----------- | ---------- | ----------------- | ---------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
| 500         | 7000       | API Error         | Something went wrong                                 | The default message for API processing failures, received in the event of an unclassified error. |
| 403         | 7001       | Invalid API key   | API-KEY is not valid                                 | Number of cases where the API Key requested in the header is invalid                             |
| 403         | 7002       | Invalid JSON      | Cannot decode the requested JSON body                | Received if the requested JSON file is invalid and cannot be decoded                             |
| 400         | 7003       | Invalid parameter | Requested parameters are not valid. 'text' is empty. | Received if the requested parameter is invalid (e.g., requesting a reference with empty text)    |
| 403         | 7004       | Payment error     | Billing error                                        | Received general errors with payments (e.g., payment is past due, etc.)                          |
| 405         | -          | Wrong HTTP Method | -                                                    | Received if an invalid HTTP method was used                                                      |

### Error Response example

```
{
    "type": "APIError",
    "code": 7000,
    "message": "Something went wrong."
}
```
