> ## Documentation Index
> Fetch the complete documentation index at: https://developers.meshapi.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Models with providers (v2)

> GET /v2/models returns the model catalog with every provider that can serve each model, at that provider's own price and capabilities.

`GET /v2/models` is the model catalog with the providers filled in. It returns the same array as [`GET /v1/models`](https://developers.meshapi.ai/docs/reference/models#listing-available-models), and each model carries one extra field, `providers`: every provider that can serve it, each at its own price and with its own capabilities.

| Endpoint | Returns |
| - | - |
| `GET /v2/models` | Every enabled model, each with its `providers` array |
| `GET /v2/models/{model_id}` | One model with its `providers` array |

Full request and response schemas, with an interactive explorer, are in the **API Reference** tab: [List models with their providers](https://developers.meshapi.ai/api/models/list-models-with-their-providers.md) and [Get a model with its providers](https://developers.meshapi.ai/api/models/get-a-model-with-its-providers.md). This page is the guide.

> [!NOTE]
>
> `/v2/models` is a second shape for the catalog, not a new version of the API. `/v1/models` is not deprecated and keeps working unchanged, every other endpoint stays under `/v1`, and the [`X-Mesh-Version` header](https://developers.meshapi.ai/docs/reference/api-versioning) applies to `/v2/models` exactly as it does everywhere else.

## When to use it

| You want | Call |
| - | - |
| The list of models and the price a bare model ID bills at | `GET /v1/models` |
| The providers of one model | `GET /v1/models/{model_id}/providers` or `GET /v2/models/{model_id}` |
| Every model with every provider's price, in one response | `GET /v2/models` |
| The catalog without a key | `GET /v1/public/models` (there is no keyless `/v2` route) |

Reach for `/v2/models` when you are building a model picker, a price comparison, or a capability matrix and would otherwise call `/providers` once per model. If you only need model IDs and headline prices, `/v1/models` is a much smaller response.

## Listing models

```bash theme={null}
curl https://api.meshapi.ai/v2/models \
  -H "Authorization: Bearer rsk_YOUR_KEY"
```

The response is a JSON array. There is no envelope and no pagination: one call returns the whole catalog your key may use.

```json theme={null}
[
  {
    "id": "anthropic/claude-sonnet-4.5",
    "name": "Claude Sonnet 4.5",
    "brand": "anthropic",
    "model_type": "text",
    "context_length": 200000,
    "is_free": false,
    "input_modalities": ["text", "image"],
    "output_modalities": ["text"],
    "supports_tools": true,
    "supports_structured_output": true,
    "pricing": {
      "pricing_unit": "per_1m_tokens",
      "prompt_usd_per_1m": "3.00000000",
      "completion_usd_per_1m": "15.00000000",
      "cache_read_input_usd_per_1m": "0.30000000",
      "discount_pct": null
    },
    "providers": [
      {
        "provider": "anthropic",
        "display_name": "Anthropic",
        "is_free": false,
        "context_window": 200000,
        "supports_tools": true,
        "supports_structured_output": true,
        "pricing": {
          "pricing_unit": "per_1m_tokens",
          "prompt_usd_per_1m": "3.00000000",
          "completion_usd_per_1m": "15.00000000",
          "cache_read_input_usd_per_1m": "0.30000000",
          "discount_pct": null
        }
      },
      {
        "provider": "bedrock",
        "display_name": "Amazon Bedrock",
        "is_free": false,
        "context_window": 200000,
        "supports_tools": true,
        "supports_structured_output": true,
        "pricing": {
          "pricing_unit": "per_1m_tokens",
          "prompt_usd_per_1m": "3.00000000",
          "completion_usd_per_1m": "15.00000000",
          "cache_read_input_usd_per_1m": "0.30000000",
          "discount_pct": null
        }
      }
    ]
  }
]
```

The example is trimmed. A real model object has every field described under [Model capabilities](https://developers.meshapi.ai/docs/reference/models.md#model-capabilities), and a real `pricing` object has a field for every billing dimension, `null` where the model does not bill for it.

### Query parameters

| Parameter | Type | Description |
| - | - | - |
| `free` | boolean | `true` = free models only, `false` = paid only, omit = all |
| `type` | string | Filter by model type: `text`, `embedding`, `image`, `audio`, `video`, `evaluation`. `tts` and `stt` models cannot be selected with this filter; read `model_type` instead. Any other value is a `422` |
| `provider` | string | Only models this provider can serve, e.g. `openai`, `vertex`, `bedrock` (`amazon-bedrock` and `azure-foundry` are accepted as aliases). Every provider of a matching model is still listed |

> [!WARNING]
>
> `provider` does not behave the way it does on `/v1/models`. There it **re-prices** each model at that provider's rate. On `/v2/models` it only **selects** models: the top-level `pricing` stays the price a bare model ID bills at, and the provider's own rate is its row in `providers`. If you move a `?provider=` query from `/v1` to `/v2`, read the price from the row, not from the top level.

An unknown provider slug is not an error: it returns an empty array.

## Getting one model

```bash theme={null}
curl https://api.meshapi.ai/v2/models/anthropic/claude-sonnet-4.5 \
  -H "Authorization: Bearer rsk_YOUR_KEY"
```

The model ID goes in the path as it is, slash included. The response is a single object, identical to that model's entry in the list.

## The response

### Model fields

Everything outside `providers` is the `/v1/models` object, field for field. Code written against `/v1/models` reads a `/v2/models` response without changes. See [Model capabilities](https://developers.meshapi.ai/docs/reference/models.md#model-capabilities) for the full field list.

The top-level `pricing` is the price a request with a bare model ID bills at. It is the same value `/v1/models` returns, so the two endpoints never disagree on a model's headline price.

### Provider rows

Each entry in `providers` describes the model as one provider serves it.

| Field | Type | Meaning |
| - | - | - |
| `provider` | string | The provider slug, e.g. `openai`, `bedrock`, `vertex`, `azure_foundry`. The same slug the `provider` filter and [BYOK](https://developers.meshapi.ai/docs/capabilities/byok.md) use |
| `display_name` | string \| null | A human-readable name for the provider |
| `icon_url` / `icon_url_dark` | string \| null | Provider logos for light and dark backgrounds |
| `is_free` | boolean | Whether this provider serves the model at \$0 |
| `pricing` | object | This provider's rates, in the same shape as the model's `pricing`. See [Pricing](https://developers.meshapi.ai/docs/getting-started/pricing.md) for the units |
| `context_window` | integer \| null | The context window this provider offers for the model |
| `standard_context_threshold` | integer \| null | The prompt size above which this provider's long-context pricing applies; `null` means no long-context tier |
| `max_prompt_chars` | integer \| null | Longest prompt this provider accepts; `null` means no limit is recorded, not that there is none |
| `supports_*` | boolean | The same capability flags as on the model, as this provider supports them: tools, structured output, thinking, batching, flex, realtime, the Responses and Chat Completions APIs, and the video input flags |
| `supports_generate_audio` | boolean \| null | Whether this provider can generate an audio track for a video model |
| `video_options` | object \| null | The video sizes, durations and other options this provider accepts, for video models |

Three rules hold for every response:

* **Rows are alphabetical by `provider`.** Position carries no meaning.
* **The default provider is not marked.** Which provider serves a bare model ID is a routing decision Mesh can change at any time, and requests can [fall back](https://developers.meshapi.ai/docs/platform/retry-and-fallback.md) to another provider. Do not infer the default from the rows, and do not build on a specific provider serving a request.
* **Only active providers are listed.** A provider that is switched off for a model does not appear.

### Capabilities can differ by provider

The model-level flags describe the model as a bare model ID is served. A provider row can differ: one provider may offer a longer context window, the flex tier or structured output where another does not. When a capability matters to you, read it from the row.

### Prices can differ by provider

Providers set their own rates, so two rows of the same model can carry different prices. The top-level `pricing` is the rate a bare model ID bills at, which is one provider's rate; it is not an average or a minimum of the rows.

### Discounts

If your account has a discount, it is applied to each row separately, the same way it is applied when a request is billed. A discount scoped to one provider appears on that provider's row only.

* `pricing.discount_pct` is the percentage off, or `null` when no discount applies to that row.
* `pricing.discounted` holds the same rates with the discount applied. It is part of API version `2026-09` and later, on the model's `pricing` and on every provider row. A request that resolves to `2026-08` (no header and no version pinned on the key, or an explicit `2026-08`) does not receive it. See [API versioning](https://developers.meshapi.ai/docs/reference/api-versioning.md).

```bash theme={null}
curl https://api.meshapi.ai/v2/models/anthropic/claude-sonnet-4.5 \
  -H "Authorization: Bearer rsk_YOUR_KEY" \
  -H "X-Mesh-Version: 2026-09"
```

### An empty `providers` array

A model can come back with `"providers": []`. It means no provider is listed for the model right now. A newly added provider can take up to a minute to appear, so do not treat an empty array as permanent, and do not drop the model from a cached list on the strength of one response.

## Authentication and access

Both routes take an `rsk_` API key, the same credential as `/v1/models`. A key restricted to specific scopes needs `models:read`. See [Authentication](https://developers.meshapi.ai/docs/getting-started/authentication.md).

The response is scoped to the caller:

* **Model allow-lists apply.** A model your organization, team or key is not permitted to use is left out of the list, and requesting it by ID returns `403`. See [Model allow-lists](https://developers.meshapi.ai/docs/getting-started/api-keys.md#model-allow-lists).
* **Prices are yours.** Discounts on your account are reflected in every row, so two accounts can see different `discount_pct` values for the same model.

## Errors

| Status | Code | When |
| - | - | - |
| `401` | `unauthorized` | The key is missing or invalid |
| `403` | `forbidden` | The key is scoped and lacks `models:read` |
| `403` | `model_excluded` | `GET /v2/models/{model_id}` for a model a model policy that applies to you does not allow |
| `403` | `model_brand_unknown` | `GET /v2/models/{model_id}` when a policy allows models by brand and no brand is recorded for this one |
| `404` | `not_found` | `GET /v2/models/{model_id}` for a model that does not exist or is not enabled |
| `422` | `validation_error` | A query parameter has a value outside its allowed set, e.g. `?type=tts` |
| `503` | `model_catalog_unavailable` | The catalog could not be read. Safe to retry |
| `503` | `model_policy_unavailable` | A model policy that applies to you could not be evaluated yet. Safe to retry |

On a failed catalog read `/v2/models` answers `503`, where `/v1/models` returns an empty array. A `200` from `/v2/models` is therefore always a real answer: you will not be handed a partial list. See [Errors](https://developers.meshapi.ai/docs/reference/errors.md) for the error body format.

## Response size and caching

The list carries every provider row of every model, so it is several times the size of `/v1/models` and runs to megabytes. A few habits keep that cheap:

* **Cache it.** Prices and providers change rarely. Fetch the list on a schedule and serve your UI from your own copy instead of calling it per page view.
* **Filter on the server.** `?type=text` or `?provider=bedrock` returns a fraction of the full list.
* **Ask for one model** with `GET /v2/models/{model_id}` when that is all you need.
* **Use `/v1/models`** when you do not need the provider rows.

The catalog is live, but not instant: a change to a model, a price or a provider can take a few minutes to reach the response.

## Examples

### Cheapest provider for a model

```python Python theme={null}
import os
import requests

resp = requests.get(
    "https://api.meshapi.ai/v2/models/anthropic/claude-sonnet-4.5",
    headers={"Authorization": f"Bearer {os.environ['MESH_API_KEY']}"},
    timeout=30,
)
resp.raise_for_status()
model = resp.json()

priced = [
    p for p in model["providers"]
    if p["pricing"]["prompt_usd_per_1m"] is not None
]
if priced:
    cheapest = min(priced, key=lambda p: float(p["pricing"]["prompt_usd_per_1m"]))
    print(cheapest["provider"], cheapest["pricing"]["prompt_usd_per_1m"])
```

```javascript Node.js theme={null}
const resp = await fetch(
  "https://api.meshapi.ai/v2/models/anthropic/claude-sonnet-4.5",
  { headers: { Authorization: `Bearer ${process.env.MESH_API_KEY}` } },
);
if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
const model = await resp.json();

const priced = model.providers.filter(
  (p) => p.pricing.prompt_usd_per_1m !== null,
);
if (priced.length) {
  const cheapest = priced.reduce((a, b) =>
    Number(a.pricing.prompt_usd_per_1m) <= Number(b.pricing.prompt_usd_per_1m) ? a : b,
  );
  console.log(cheapest.provider, cheapest.pricing.prompt_usd_per_1m);
}
```

Prices are strings, so convert before comparing. A row whose rate is `null` does not bill per token: check `pricing.pricing_unit` before treating it as free. A model can have no token-priced row at all, which is why both examples check before picking.

### Which providers support a capability

```python Python theme={null}
import os
import requests

resp = requests.get(
    "https://api.meshapi.ai/v2/models",
    params={"type": "text"},
    headers={"Authorization": f"Bearer {os.environ['MESH_API_KEY']}"},
    timeout=60,
)
resp.raise_for_status()

for model in resp.json():
    structured = [
        p["provider"] for p in model["providers"] if p["supports_structured_output"]
    ]
    if structured:
        print(model["id"], structured)
```

### Models one provider can serve

```bash theme={null}
curl "https://api.meshapi.ai/v2/models?provider=bedrock" \
  -H "Authorization: Bearer rsk_YOUR_KEY"
```

Each returned model still lists all of its providers. To read Bedrock's own price, take the row where `provider` is `bedrock`.

## Moving from `/v1/models`

| | `GET /v1/models` | `GET /v2/models` |
| - | - | - |
| Top-level shape | Array of models | Array of models |
| Model fields | — | Identical, plus `providers` |
| Top-level `pricing` | Price a bare model ID bills at | The same |
| Provider prices | One call per model to `/providers` | In every model's `providers` |
| `?provider=` | Re-prices each model at that provider | Selects models; prices unchanged |
| Catalog read fails | `200` with an empty array | `503` |
| Keyless variant | `/v1/public/models` | None |

Nothing forces a move. Switch when the nested rows save you calls; stay on `/v1/models` otherwise.

## Related

* [Models](https://developers.meshapi.ai/docs/reference/models.md) — model IDs, capabilities, and choosing a model
* [Pricing](https://developers.meshapi.ai/docs/getting-started/pricing.md) — how the pricing units work
* [Retry and fallback](https://developers.meshapi.ai/docs/platform/retry-and-fallback.md) — how a request moves between providers
* [BYOK](https://developers.meshapi.ai/docs/capabilities/byok.md) — serving a model from your own provider account
* [API versioning](https://developers.meshapi.ai/docs/reference/api-versioning.md) — pinning a dated version


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.