{"id":50312262,"url":"https://github.com/basisoasis/llm-intel","last_synced_at":"2026-06-07T13:00:34.791Z","repository":{"id":359623829,"uuid":"1161482870","full_name":"basisoasis/llm-intel","owner":"basisoasis","description":"Source model capabilities and pricing from OpenRouter for cost-aware development without hardcoded data tables","archived":false,"fork":false,"pushed_at":"2026-05-28T20:49:09.000Z","size":471,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-05-28T22:00:16.744Z","etag":null,"topics":["ai","cost-estimation","llm","model-info","openrouter","pricing","token-cost"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/basisoasis.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-19T06:45:05.000Z","updated_at":"2026-05-28T20:32:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"71d8fdc3-072a-470a-97fb-5db573025af1","html_url":"https://github.com/basisoasis/llm-intel","commit_stats":null,"previous_names":["basisoasis/llm-intel"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/basisoasis/llm-intel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basisoasis%2Fllm-intel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basisoasis%2Fllm-intel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basisoasis%2Fllm-intel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basisoasis%2Fllm-intel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/basisoasis","download_url":"https://codeload.github.com/basisoasis/llm-intel/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basisoasis%2Fllm-intel/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34022032,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-07T02:00:07.652Z","response_time":124,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","cost-estimation","llm","model-info","openrouter","pricing","token-cost"],"created_at":"2026-05-28T22:00:15.154Z","updated_at":"2026-06-07T13:00:34.708Z","avatar_url":"https://github.com/basisoasis.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"./docs/public/favicon.svg\" width=\"48\" /\u003e\n\n# llm-intel\n\nModel intelligence for every LLM.\n\n**llm-intel** sources model metadata and pricing from [OpenRouter](https://openrouter.ai), so you can look up capabilities and calculate token costs without maintaining your own data tables.\n\n## Features\n\n- Look up any model's capabilities, context window, and pricing by ID\n- Calculate token costs with exact precision (powered by `bignumber.js`)\n- Two purpose-built APIs: a **server client** (fetches from OpenRouter) and a **browser client** (reads pre-fetched JSON)\n- Three-tier caching: memory -\u003e disk -\u003e network\n- Full TypeScript support with generated `ModelId` types\n\n\u003e **[View Demo →](https://basisoasis.github.io/llm-intel/)**\n\n## Installation\n\n```bash\n# npm\nnpm install @basisoasis/llm-intel\n\n# pnpm\npnpm add @basisoasis/llm-intel\n\n# yarn\nyarn add @basisoasis/llm-intel\n\n# bun\nbun add @basisoasis/llm-intel\n```\n\n## Usage\n\n### Server (`LLMIntel`)\n\nUse this in Node.js / server-side environments. It fetches model data from OpenRouter, with disk and memory caching built in.\n\n```typescript\nimport { LLMIntel } from \"@basisoasis/llm-intel\";\n\n// Instantiate a provider client\nconst client = await LLMIntel.create({ provider: 'openrouter' });\n\n// Resolve a model by ID\nconst model = await client.getModel(\n  'anthropic/claude-4.6-sonnet-20260217'\n);\n\nif (!model) throw new Error('Model not found!');\n\nconst cost = client.calculateCost(model, {\n  inputTokens: 20_000,\n  outputTokens: 1700,\n});\n\nconsole.log(client.formatCostResult(cost));\n/* {\n  inputCost: \"$0.06\",\n  outputCost: \"$0.03\",\n  cacheReadCost: null,\n  cacheWriteCost: null,\n  imageCost: null,\n  requestCost: null,\n  totalCost: \"$0.09\",\n  currency: \"USD\",\n  warnings: [],\n} */\n```\n\n### Standalone function\n\nFor one-off lookups without instantiating a client:\n\n```typescript\nimport { getModelInfo } from \"@basisoasis/llm-intel\";\n\nconst result = await getModelInfo(\"anthropic/claude-3-5-sonnet\", {\n  provider: \"openrouter\",\n  apiKey: process.env.OPENROUTER_API_KEY,\n});\n```\n\n### Browser / SPA (`LLMIntelClient`)\n\nUse this when you already have the model JSON (e.g. fetched server-side and passed to a SPA, or bundled at build time). No API key required.\n\n```typescript\nimport { LLMIntelClient } from \"@basisoasis/llm-intel/client\";\n\n// Hydrate from a URL your server exposes\nconst client = new LLMIntelClient({\n  models: \"/api/models\", // returns ModelsResult JSON\n  cacheTtl: 5 * 60 * 1000, // 5 minutes\n});\n\n// Or hydrate statically from a pre-loaded array\nconst client = new LLMIntelClient({ models: modelDataArray });\n\nconst model = await client.getModel(\"google/gemini-2.5-pro\");\nif (!model) throw new Error('Model not found!');\n\nconst cost = client.calculateCost(model, {\n  inputTokens: 2000,\n  outputTokens: 800,\n});\n\nconsole.log(client.formatCost(cost.inputCost));  // $0.0025\nconsole.log(client.formatCost(cost.outputCost)); // $0.008\nconsole.log(client.formatCost(cost.totalCost));  // $0.01\n```\n\n## API Reference\n\n### `LLMIntel` (server)\n\n| Method                                           | Description                                                    |\n| ------------------------------------------------ | -------------------------------------------------------------- |\n| `LLMIntel.create(opts)`                          | Creates a validated client instance. Validates config upfront. |\n| `client.getModels()`                             | Returns all available models (`ModelsResult`).                 |\n| `client.getModel(modelId)`                       | Returns a single model by ID, or `null` if not found.          |\n| `client.calculateCost(model, tokens, currency?)` | Calculates prompt/completion/total cost.                       |\n| `client.formatCost(amount, currency?)`           | Formats a `BigNumber` as a currency string (e.g. `\"$5.12\"`).   |\n| `client.formatCostResult(result)`                | Formats all line items in a `CostResult` to strings.           |\n\n### `LLMIntelClient` (browser)\n\nSame `getModel`, `getModels`, `calculateCost`, `formatCost`, and `formatCostResult` methods. Takes either a URL or a pre-loaded `ModelData[]` array.\n\n### `getModelInfo(modelId, opts)` (standalone)\n\nFetches a single model without creating a client. Useful for serverless functions or scripts.\n\n## Caching\n\n`LLMIntel` uses a three-tier cache:\n\n1. **Memory:** fastest; per-instance, invalidated by TTL\n2. **Disk:** survives process restarts\n3. **Network:** fetches fresh data from OpenRouter\n\nConfigure the TTL via `cacheTtl` in milliseconds (default: `86_400_000` — 24 hours).\n\n`LLMIntelClient` uses memory caching only (no disk access in the browser).\n\n## Configuration\n\nAll options are optional — the library falls back to environment variables and then built-in defaults.\n\n```typescript\nLLMIntel.create({\n  provider: \"openrouter\",\n  openRouterApiKey: process.env.LLM_INTEL_OPEN_ROUTER_API_KEY,\n  cacheTtl: 86_400_000,\n  cacheDir: \".cache\",\n});\n```\n\n| Option             | Env var                         | Default                 | Description                                                             |\n| ------------------ | ------------------------------- | ----------------------- | ----------------------------------------------------------------------- |\n| `provider`         | `LLM_INTEL_PROVIDER`            | `\"openrouter\"`          | Data source to use. See [Providers](#providers).                        |\n| `openRouterApiKey` | `LLM_INTEL_OPEN_ROUTER_API_KEY` | —                       | Your OpenRouter API key. Required when using the `openrouter` provider. |\n| `cacheTtl`         | `LLM_INTEL_CACHE_TTL`           | `86_400_000` (24 hours) | How long cached model data is considered fresh, in milliseconds.        |\n| `cacheDir`         | `LLM_INTEL_CACHE_DIR`           | `{cwd}/.cache`          | Directory used for disk caching.                                        |\n\n## Providers\n\nCurrently, **OpenRouter** is the only supported provider. The library has been designed with a provider abstraction layer, so support for additional data sources can be added in the future without breaking changes to the public API.\n\n| Provider   | Status       |\n| ---------- | ------------ |\n| OpenRouter | ✅ Supported |\n| Others     | 🗓 Planned   |\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasisoasis%2Fllm-intel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbasisoasis%2Fllm-intel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasisoasis%2Fllm-intel/lists"}