🚀 Socket Launch Week Day 4:Socket MCP Adds Org Alerts, Threat Feed Review, and Package Inspection.Learn more
Sign In

@tokenlens/fetch

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tokenlens/fetch

Typed client for models.dev to fetch model catalogs with friendly errors.

latest
Source
npmnpm
Version
1.3.0
Version published
Weekly downloads
500K
31.06%
Maintainers
1
Weekly downloads
 
Created
Source

@tokenlens/fetch

npm version npm downloads License: MIT TypeScript

TokenLens overview

Tiny typed client for https://models.dev/api.json with friendly error codes.

Install

  • npm: npm i @tokenlens/fetch
  • pnpm: pnpm add @tokenlens/fetch
  • yarn: yarn add @tokenlens/fetch

API

  • fetchModels({ provider?, model?, fetch?, signal?, baseUrl? })
  • getModelMeta(providers, ...)

Usage

import { fetchModels, getModelMeta, FetchModelsError } from '@tokenlens/fetch';

const catalog = await fetchModels();
const openai = await fetchModels({ provider: 'openai' });
const gpt4o = await fetchModels({ provider: 'openai', model: 'gpt-4o' });

// Pick raw metadata directly from the fetched catalog
const prov = getModelMeta({ providers: catalog, provider: 'openai' });
const model = getModelMeta({ providers: catalog, id: 'openai:gpt-4o' });

try {
  await fetchModels();
} catch (err) {
  if (err instanceof FetchModelsError) {
    // 'UNAVAILABLE' | 'NETWORK' | 'HTTP' | 'PARSE'
    console.error(err.code, err.status, err.message);
  }
}

License MIT

Keywords

ai

FAQs

Package last updated on 19 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts