# Allowed models

`GET /v1/models/user` lists the models on sale that your settings allow the key to call, with
their prices in DA.

## Request

Send it with an API key. The settings read are the [guardrails](/docs/guardrails) assigned to
that key: a model a guardrail leaves out is not listed, and where several are assigned, their
model lists intersect. On a key with no guardrail, it lists what
[All models](/docs/reference/models) lists. The [models guide](/docs/models) shows how to pick a
model and read its ID.

Yacine gives Souk Bot's key a guardrail that allows two models. This route, on that key, lists
those two, and no other.

| Field | Needed | You send |
|---|---|---|
| `output_modalities` | no | `text` when left out · a list such as `image,audio` · `all` |

`output_modalities` takes `text`, `image`, `embeddings`, `audio`, `video`, `rerank`, `decisions`,
`speech` and `transcription`. A model is listed when it answers in any of them.

```python
import json
import os
import urllib.request

API_KEY = os.environ["OPENDUNES_API_KEY"]
ADDRESS = "https://opendunes.com/v1/models/user?output_modalities=all"

request = urllib.request.Request(
    ADDRESS,
    headers={"Authorization": "Bearer " + API_KEY},
)
with urllib.request.urlopen(request) as response:
    models = json.load(response)["data"]

for model in models:
    print(model["id"])
```

```javascript
const API_KEY = process.env.OPENDUNES_API_KEY;
const ADDRESS = "https://opendunes.com/v1/models/user?output_modalities=all";

const response = await fetch(ADDRESS, {
  headers: { Authorization: `Bearer ${API_KEY}` },
});
const { data } = await response.json();

for (const model of data) console.log(model.id);
```

```go
package main

import (
	"encoding/json"
	"fmt"
	"net/http"
	"os"
)

const address = "https://opendunes.com/v1/models/user?output_modalities=all"

func main() {
	apiKey := os.Getenv("OPENDUNES_API_KEY")

	req, err := http.NewRequest("GET", address, nil)
	if err != nil {
		panic(err)
	}
	req.Header.Set("Authorization", "Bearer "+apiKey)

	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()

	var body struct {
		Data []struct {
			ID string `json:"id"`
		} `json:"data"`
	}
	if err := json.NewDecoder(res.Body).Decode(&body); err != nil {
		panic(err)
	}
	for _, model := range body.Data {
		fmt.Println(model.ID)
	}
}
```

```bash cURL
ADDRESS="https://opendunes.com/v1/models/user?output_modalities=all"

curl "$ADDRESS" \
  -H "Authorization: Bearer $OPENDUNES_API_KEY"
```

## Response

`200 OK`.

| Field | Holds |
|---|---|
| `data` | every model the key may call, newest first; an empty list when its guardrails allow none on sale |
| `id` | in each: its ID, `lab/model`: the name a request sends |
| `pricing` | in each: its prices in DA, one per meter it has, each a string per unit of that meter, with `discount` beside them |

Each model carries every field [All models](/docs/reference/models) describes, in the same shape.

## What it cost

Free. Reading the catalogue is never charged.

## Errors

`error.code` carries the status, and `error.message` says why.

| Status | When |
|---|---|
| 401 | the key is missing, wrong, disabled or expired |
| 403 | the key answers only from the addresses set on it, and this request came from another |
