# `LLMDB.Sources.ModelsDev`
[🔗](https://github.com/agentjido/llm_db/blob/main/lib/llm_db/sources/models_dev.ex#L1)

Remote source for models.dev metadata (https://models.dev/api.json).

- `pull/1` fetches data via Req and caches locally
- `load/1` reads from cached file (no network call)

## Options

- `:url` - API endpoint (default: "https://models.dev/api.json")
- `:req_opts` - Additional Req options for testing (e.g., `[plug: test_plug]`)

## Configuration

Cache directory can be configured in application config:

    config :llm_db,
      models_dev_cache_dir: "priv/llm_db/remote"

Default: `"priv/llm_db/remote"`

## Usage

    # Pull remote data and cache
    mix llm_db.pull

    # Load from cache
    {:ok, data} = ModelsDev.load(%{})

# `transform`

Transforms models.dev JSON format to canonical Zoi format.

## Input Format (models.dev)

```json
{
  "provider_id": {
    "id": "provider_id",
    "name": "Provider Name",
    "models": {
      "model_id": {
        "id": "model_id",
        "name": "Model Name",
        "limit": {"context": 128000, "output": 16384},
        "cost": {"input": 2.50, "output": 10.00},
        ...
      }
    }
  }
}
```

## Output Format (Canonical Zoi)

```elixir
%{
  "provider_id" => %{
    id: :provider_id,
    name: "Provider Name",
    models: [
      %{
        id: "model_id",
        provider: :provider_id,
        name: "Model Name",
        limits: %{context: 128000, output: 16384},
        cost: %{input: 2.50, output: 10.00},
        ...
      }
    ]
  }
}
```

Main transformations:
- Convert provider string IDs to atom keys
- Convert models map to models list
- Add provider field to each model
- Transform field names (limit → limits, etc.)
- Atomize known field keys

---

*Consult [api-reference.md](api-reference.md) for complete listing*
