# Model count

`GET /v1/models/count` answers how many models are on sale, as one number.

## Request

Send it with an API key. The one field goes in the address, after `?`. The
[models guide](/docs/models) shows how a model is named and picked.

| 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 counted when it answers in any of them, so the count
matches the length of what [All models](/docs/reference/models) lists for the same value.

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

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

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

print(count)
```

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

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

console.log(data.count);
```

```go
package main

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

const address = "https://opendunes.com/v1/models/count?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 {
			Count int `json:"count"`
		} `json:"data"`
	}
	if err := json.NewDecoder(res.Body).Decode(&body); err != nil {
		panic(err)
	}
	fmt.Println(body.Data.Count)
}
```

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

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

## Response

`200 OK`.

| Field | Holds |
|---|---|
| `data` | the count |
| `count` | in `data`: how many models are on sale in the output types you asked for. A type no model answers in counts `0` |

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