# Language Models

## List Language Models

<mark style="color:green;">`GET`</mark> `/llm/list`

Provides a JSON array of currently available language models

**Headers**

| Name         | Value              |
| ------------ | ------------------ |
| Content-Type | `application/json` |

**Response**

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

```json
[
  "mixtral-8x7b",
  "mistral-7b",
  "dolphin-2.6-mixtral-8x7b",
  "nous-mixtral-8x7b",
  "llama-2-70b",
  "llama-2-13b",
  "llama-2-7b",
  "codellama-70b",
  "codellama-34b",
  "airoboros",
  "airoboros-l2-70b-gpt4",
  "pygmalion-13b-4bit-128g",
  "lzlv-70b",
  "gemma-7b-it",
  "llava-1.5-7b",
  "gpt-3.5-turbo",
  "gpt-3.5-turbo-16k",
  "gpt-4",
  "gpt-4-turbo",
  "gemini-pro"
]
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Endpoint Unavailable"
}
```

{% endtab %}
{% endtabs %}

## Using a LLM

<mark style="color:blue;">`POST`</mark> `/llm/:model`

Calls a model for a response

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Body**

<table><thead><tr><th>Name</th><th width="156">Type</th><th>Description</th><th>Default</th></tr></thead><tbody><tr><td><code>messages</code></td><td>message[]</td><td>Name of the user</td><td><code>none</code></td></tr><tr><td><code>temperature</code></td><td>number</td><td>LLM Temperature</td><td>0.7</td></tr><tr><td><code>max_tokens</code></td><td>number</td><td>Max response tokens</td><td>1024</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}
{% code fullWidth="false" %}

```json
{
  "answer": "Hello! How may I assist you?"
}
```

{% endcode %}
{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}

{% tab title="500" %}

```json
{
  "error": "Error during generation (LLM)"
}
```

{% endtab %}
{% endtabs %}

**Example**

{% code title="example.js" overflow="wrap" lineNumbers="true" %}

```javascript
const res = await fetch('https://synapselabs.onrender.com/llm/mistral-7b', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer <your_api_key>'
  },
  body: JSON.stringify({
    messages: [{
      "role": "user",
      "content": "Tell me a random fact!"
    }],
  }),
});

const data = await res.json();
console.log(data) // {"answer":"Did you know..."}
```

{% endcode %}
