### Narev Router Skill - Example Agent Prompts Source: https://context7.com/narevai/skills/llms.txt These examples demonstrate how agent prompts are routed by the `narev` skill to the appropriate Narev Cloud documentation paths or specific skills. ```text # Example agent prompts that invoke the narev router: "Which Narev skill should I use for billing middleware?" → Routes to: /sdk/ai-billing/index "How do I set up usage-based billing concepts?" → Routes to: /platform/concepts/usage-based-billing "Show me the Polar billing integration." → Routes to: /platform/billing/overview "How do I use the routing API?" → Routes to: /platform/routing/introduction "What is Narev Self-Hosted?" → Routes to: /narev-oss/index # The router also checks package.json for @ai-billing/core and # @ai-billing/ to select the correct major-version SDK docs. ``` -------------------------------- ### Install Agent Skills Source: https://github.com/narevai/skills/blob/main/README.md Use this command to add Narev Skills to your Agent Skills environment. ```bash npx skills add narevai/skills ``` -------------------------------- ### Manual Installation for Claude Code Source: https://github.com/narevai/skills/blob/main/README.md Clone the Narev Skills repository into your local Claude skills directory for manual integration. ```bash git clone https://github.com/narevai/skills ~/.claude/skills/narev ``` -------------------------------- ### Install Codex Plugin Source: https://github.com/narevai/skills/blob/main/README.md Add Narev Skills as a plugin to Codex. After installation, restart Codex and enable the skill from the plugins section. ```bash codex plugin marketplace add narevai/skills ``` -------------------------------- ### Anthropic Plugin Marketplace Format Source: https://github.com/narevai/skills/blob/main/CLAUDE.md Example of the `.claude-plugin/marketplace.json` file, which lists Narev skills for the Anthropic plugin system. It shows how to group skills under 'narev' and 'pricing' plugins. ```json .claude-plugin/marketplace.json — Anthropic plugin format. The **narev** plugin lists the router (`skills/core/narev/`); the **pricing** plugin lists the two pricing skills under `skills/pricing/`. ``` -------------------------------- ### Codex Marketplace Registry Source: https://github.com/narevai/skills/blob/main/AGENTS.md Details the Codex marketplace registry configuration for installing the Narev skills plugin from a Git URL. ```json .agents/plugins/marketplace.json — Codex marketplace registry for installing the plugin from the Git URL. ``` -------------------------------- ### Get Available Model Pricing Information Source: https://context7.com/narevai/skills/llms.txt Retrieves a list of available models and their pricing details, useful for identifying correct model IDs and subproviders. ```APIDOC ## GET /api/models/pricing ### Description Fetches a list of models and their associated pricing information, including subprovider details for multi-host models. ### Method GET ### Endpoint https://www.narev.ai/api/models/pricing ### Parameters #### Query Parameters - **model_id** (string) - Optional - Filters the results to a specific model ID. ### Response #### Success Response (200) - **data** (array) - A list of model pricing objects. - Each object contains details like `modelId`, `provider`, `subprovider`, and pricing information. ### Response Example ```json [ { "modelId": "llama-3.1-70b", "provider": "meta", "subprovider": "together", "pricing": { "input": 0.0000006, "output": 0.0000006, "request": null, "inputCacheRead": 0.0000003, "inputCacheWrite": null, "internalReasoning": null, "webSearch": null } } // ... more models ] ``` ``` -------------------------------- ### CI Workflow for Scheduled Pricing Refresh Source: https://context7.com/narevai/skills/llms.txt Automates the refresh of LLM pricing snapshots every Monday. It checks out code, sets up Node.js, installs dependencies, runs a pricing update script, and opens a pull request if changes are detected. ```yaml # .github/workflows/update-pricing.yml name: Refresh LLM Pricing on: schedule: - cron: "0 6 * * 1" # Every Monday at 06:00 UTC workflow_dispatch: jobs: update: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 20 - run: pnpm install - run: pnpm tsx scripts/update-pricing.ts # Non-zero exit on HTTP error causes the job to fail visibly - name: Open PR if pricing changed uses: peter-evans/create-pull-request@v6 with: commit-message: "chore: refresh LLM pricing snapshot" title: "chore: refresh LLM pricing snapshot" body: "Auto-generated by the weekly pricing refresh workflow." branch: chore/refresh-pricing ``` -------------------------------- ### Calculate Claude Sonnet 4 Cost Source: https://context7.com/narevai/skills/llms.txt This example demonstrates calculating the cost for an Anthropic Claude Sonnet 4 model call. Always include all required fields in the usage object. ```bash curl -X POST 'https://www.narev.ai/api/models/pricing/calculate' \ -H 'Content-Type: application/json' \ -d '{ "modelId": "claude-sonnet-4-5", "provider": "anthropic", "usage": { "promptTokens": 1200, "completionTokens": 400, "cacheReadTokens": 0, "cacheWriteTokens": 0, "reasoningTokens": 0 } }' ``` -------------------------------- ### List LLM Model Pricing with cURL Source: https://github.com/narevai/skills/blob/main/skills/pricing/narev-lookup-llm-pricing/SKILL.md Use this command to fetch a list of LLM models and their pricing details from the Narev API. You can filter results by model ID and provider. Ensure you have cURL installed. ```bash curl -G 'https://www.narev.ai/api/models/pricing' \ --data-urlencode 'model_id=gpt-4o' \ --data-urlencode 'provider=openai' ``` -------------------------------- ### Handle Pricing API Errors Source: https://context7.com/narevai/skills/llms.txt Examples of common error responses from the Narev Pricing API, including usage validation failures, enterprise-only models, and not found errors. Always provide zero for unused usage fields. ```bash # 400 Bad Request — usage validation failure # Cause: missing required integer fields in usage object # Fix: pass 0 for all unused fields, never null or omit # Bad body: { "usage": { "promptTokens": 100, "completionTokens": 50 } } # Good body: { "usage": { "promptTokens": 100, "completionTokens": 50, # "cacheReadTokens": 0, "cacheWriteTokens": 0, # "reasoningTokens": 0 } } ``` ```bash # 402 Payment Required — enterprise-only model # Response: { "error": "...", "pricing": null } # Action: contact Narev for enterprise access; do not invent rates ``` ```bash # 404 Not Found — no public pricing for this modelId + provider combo # Action: GET /api/models/pricing to verify correct IDs and subprovider; # for multi-host models (llama, etc.) subprovider is required ``` ```bash # subprovider resolution example for llama-3.1-70b: curl -G 'https://www.narev.ai/api/models/pricing' \ --data-urlencode 'model_id=llama-3.1-70b' # → inspect data[].subprovider to find "bedrock", "openrouter", "together", etc. # → then POST calculate with the correct subprovider value ``` -------------------------------- ### TypeScript Snapshot Script for Pricing Registry Source: https://context7.com/narevai/skills/llms.txt Fetches full catalog pricing data from the narev.ai API and writes it to src/pricing.json. Handles pagination and converts USD per token to per-million-token rates. Use this script to keep pricing information up-to-date. ```typescript // scripts/update-pricing.ts // Run: pnpm tsx scripts/update-pricing.ts // Fetches full catalog and writes pricing.json with per-million-token rates. interface PricingEntry { inputPerMTok: number; outputPerMTok: number; cacheReadPerMTok?: number; cacheWritePerMTok?: number; requestFlat?: number; discount?: number; } async function fetchAllPricing(provider?: string): Promise> { const registry: Record = {}; let page = 1; const limit = 1000; while (true) { const params = new URLSearchParams({ page: String(page), limit: String(limit) }); if (provider) params.set("provider", provider); const res = await fetch(`https://www.narev.ai/api/models/pricing?${params}`); if (!res.ok) { console.error(`HTTP ${res.status}`); process.exit(1); // Non-zero exit so CI fails visibly } const { data, meta } = await res.json(); for (const row of data) { if (!row.pricing) continue; // Skip enterprise-only (null pricing) // Key as "provider/model_id" to avoid last-write-wins for shared model IDs const key = `${row.provider}/${row.model_id}`; // API returns USD per token; multiply by 1_000_000 for per-million units registry[key] = { inputPerMTok: (row.pricing.price_prompt ?? 0) * 1_000_000, outputPerMTok: (row.pricing.price_completion ?? 0) * 1_000_000, cacheReadPerMTok: row.pricing.price_input_cache_read ? row.pricing.price_input_cache_read * 1_000_000 : undefined, cacheWritePerMTok: row.pricing.price_input_cache_write ? row.pricing.price_input_cache_write * 1_000_000 : undefined, requestFlat: row.pricing.pricing_request ?? undefined, discount: row.pricing.pricing_discount ?? undefined, }; } if (page >= meta.total_pages) break; page++; } return registry; } const registry = await fetchAllPricing(); // or pass "openai" / "anthropic" for partial refresh const banner = "// AUTO-GENERATED by scripts/update-pricing.ts — do not edit manually\n"; await Bun.write("src/pricing.json", JSON.stringify(registry, null, 2)); console.log(`Wrote ${Object.keys(registry).length} entries to src/pricing.json`); ``` -------------------------------- ### Python Snapshot Script for Pricing Registry Source: https://context7.com/narevai/skills/llms.txt Fetches pricing data from the narev.ai API and writes it to src/pricing.json. This script handles pagination and converts USD per token to per-million-token rates. It's useful for maintaining an up-to-date pricing registry. ```python # scripts/update_pricing.py # Run: uv run python scripts/update_pricing.py # Writes src/pricing.json with per-million-token rates. import json, sys from pathlib import Path import httpx def fetch_all_pricing(provider: str | None = None) -> dict: registry = {} page, limit = 1, 1000 while True: params = {"page": page, "limit": limit} if provider: params["provider"] = provider r = httpx.get("https://www.narev.ai/api/models/pricing", params=params) if r.status_code != 200: print(f"HTTP {r.status_code}: {r.text}", file=sys.stderr) sys.exit(1) # Non-zero exit so CI fails visibly body = r.json() data, meta = body["data"], body["meta"] for row in data: if not row.get("pricing"): continue # Skip null pricing (enterprise-only) # Namespace key to avoid collisions across providers key = f"{row['provider']}/{row['model_id']}" p = row["pricing"] # API is USD per token → multiply by 1_000_000 for per-million units registry[key] = { "inputPerMTok": (p.get("price_prompt") or 0) * 1_000_000, "outputPerMTok": (p.get("price_completion") or 0) * 1_000_000, **({"cacheReadPerMTok": p["price_input_cache_read"] * 1_000_000} if p.get("price_input_cache_read") else {}), **({"cacheWritePerMTok": p["price_input_cache_write"] * 1_000_000} if p.get("price_input_cache_write") else {}), **({"requestFlat": p["pricing_request"]} if p.get("pricing_request") else {}), **({"discount": p["pricing_discount"]} if p.get("pricing_discount") else {}), } if page >= meta["total_pages"]: break page += 1 return registry registry = fetch_all_pricing() # Pass "openai" or "anthropic" for scoped refresh Path("src/pricing.json").write_text( "// AUTO-GENERATED — do not edit manually\n" + json.dumps(registry, indent=2) ) print(f"Wrote {len(registry)} entries to src/pricing.json") ``` -------------------------------- ### List LLM Pricing with Filters (Narev API) Source: https://context7.com/narevai/skills/llms.txt Use this `curl` command to query the Narev Pricing API for specific models and providers. Authentication is not required. Rates are returned in USD per token. ```bash # List pricing for gpt-4o on OpenAI curl -G 'https://www.narev.ai/api/models/pricing' \ --data-urlencode 'model_id=gpt-4o' \ --data-urlencode 'provider=openai' ``` ```json # Example response: # { # "data": [ # { # "model_id": "gpt-4o", # "provider": "openai", # "subprovider": "OpenAI", # "pricing": { # "price_prompt": 0.0000025, # "price_completion": 0.00001, # "price_input_cache_read": 0.00000125, # "price_input_cache_write": null, # "price_internal_reasoning": null, # "pricing_request": null, # "price_web_search": null, # "pricing_discount": 0 # } # } # ], # "meta": { "page": 1, "limit": 100, "total": 1, "total_pages": 1 } # } # Convert to USD per million tokens for display: # input: 0.0000025 * 1_000_000 = $2.50 / 1M tokens # output: 0.00001 * 1_000_000 = $10.00 / 1M tokens ``` ```bash # List all providers for a multi-host model (subprovider matters) curl -G 'https://www.narev.ai/api/models/pricing' \ --data-urlencode 'model_id=llama-3.1-70b' ``` ```bash # Paginate the full catalog curl -G 'https://www.narev.ai/api/models/pricing' \ --data-urlencode 'limit=1000' \ --data-urlencode 'page=2' ``` -------------------------------- ### Create Offline Price Resolver with Snapshot Source: https://context7.com/narevai/skills/llms.txt Integrates a pricing snapshot into `@ai-billing/core` for offline billing, avoiding runtime HTTP calls to Narev. Ensure the pricing map uses USD per token, not per million. ```typescript // src/billing/price-resolver.ts // After running the snapshot script, use createObjectPriceResolver // for offline billing — no runtime HTTP call to Narev. // NOTE: SDK ModelPricing expects USD per token (NOT per million). Do not // apply the 1_000_000 multiplier when building this map. import { createObjectPriceResolver, type ModelPricing } from "@ai-billing/core"; // Map from Narev API (snake_case, USD/token) → SDK (camelCase, USD/token) async function buildPricingMap(): Promise> { const res = await fetch("https://www.narev.ai/api/models/pricing?limit=1000"); if (!res.ok) process.exit(1); const { data } = await res.json(); const map: Record = {}; for (const row of data) { if (!row.pricing) continue; const p = row.pricing; map[`${row.provider}/${row.model_id}`] = { promptTokens: p.price_prompt ?? 0, completionTokens: p.price_completion ?? 0, inputCacheReadTokens: p.price_input_cache_read ?? 0, inputCacheWriteTokens: p.price_input_cache_write ?? 0, internalReasoningTokens: p.price_internal_reasoning ?? 0, request: p.pricing_request ?? 0, webSearch: p.price_web_search ?? 0, discount: p.pricing_discount ?? 0, }; } return map; } export const priceResolver = createObjectPriceResolver(await buildPricingMap()); // Usage in app: // import { priceResolver } from "./billing/price-resolver"; // const billing = createBilling({ priceResolver, destination: myDestination }); ``` -------------------------------- ### Create Object Price Resolver with Local Pricing Data Source: https://github.com/narevai/skills/blob/main/skills/pricing/narev-update-llm-pricing/SKILL.md Use this pattern when your application already uses the Narev SDK and you have pricing data in a local object. Ensure the pricing data is in USD per token, not per million tokens. ```typescript import { createObjectPriceResolver } from "@ai-billing/core"; import { pricing } from "./pricing"; export const priceResolver = createObjectPriceResolver(pricing); ``` -------------------------------- ### Narev Skills Directory Structure Source: https://github.com/narevai/skills/blob/main/CLAUDE.md Illustrates the standard directory layout for Narev AI agent skills, separating core routing logic from pricing-specific functionalities. ```tree skills/ ├── core/ │ └── narev/ # router — when to use which skill or doc path └── pricing/ ├── narev-lookup-llm-pricing/ # Pricing API reference (GET catalog, POST calculate) └── narev-update-llm-pricing/ # Snapshot / pin rates into the repo ``` -------------------------------- ### Calculate Model Pricing Source: https://context7.com/narevai/skills/llms.txt This endpoint calculates the cost for a given model usage based on prompt tokens, completion tokens, and other usage parameters. It supports various providers like OpenAI and Anthropic. ```APIDOC ## POST /api/models/pricing/calculate ### Description Calculates the cost for a specified model usage, including prompt tokens, completion tokens, and cache usage. ### Method POST ### Endpoint https://www.narev.ai/api/models/pricing/calculate ### Parameters #### Request Body - **modelId** (string) - Required - The identifier of the model. - **provider** (string) - Required - The provider of the model (e.g., "openai", "anthropic"). - **subprovider** (string) - Optional - The subprovider for multi-host models (e.g., "bedrock", "openrouter"). - **usage** (object) - Required - An object containing token usage details. - **promptTokens** (integer) - Required - The number of prompt tokens used. - **completionTokens** (integer) - Required - The number of completion tokens used. - **cacheReadTokens** (integer) - Required - The number of cache read tokens used. - **cacheWriteTokens** (integer) - Required - The number of cache write tokens used. - **reasoningTokens** (integer) - Required - The number of reasoning tokens used. ### Request Example ```json { "modelId": "gpt-4o", "provider": "openai", "subprovider": "OpenAI", "usage": { "promptTokens": 1000, "completionTokens": 500, "cacheReadTokens": 0, "cacheWriteTokens": 0, "reasoningTokens": 0 } } ``` ### Response #### Success Response (200) - **pricing** (object) - Contains pricing details per usage type. - **input** (number) - Cost per input token. - **output** (number) - Cost per output token. - **request** (number | null) - Cost per request. - **inputCacheRead** (number) - Cost per input cache read token. - **inputCacheWrite** (number | null) - Cost per input cache write token. - **internalReasoning** (number | null) - Cost per internal reasoning token. - **webSearch** (number | null) - Cost per web search token. - **costBreakdown** (object) - **total** (number) - The total calculated cost. - **usage** (object) - Echoes the usage object from the request. #### Response Example ```json { "pricing": { "input": 0.0000025, "output": 0.00001, "request": null, "inputCacheRead": 0.00000125, "inputCacheWrite": null, "internalReasoning": null, "webSearch": null }, "costBreakdown": { "total": 0.0000075 }, "usage": { "promptTokens": 1000, "completionTokens": 500, "cacheReadTokens": 0, "cacheWriteTokens": 0, "reasoningTokens": 0 } } ``` ``` -------------------------------- ### narev-lookup-llm-pricing: List Model Pricing Source: https://context7.com/narevai/skills/llms.txt Retrieves the pricing catalog for LLM models with optional filters for model ID and provider. Supports pagination and returns pricing details per token. ```APIDOC ## GET /api/models/pricing — List the model catalog ### Description Retrieves the pricing catalog with optional filters. Supports pagination (`page`, `limit` up to 1000). Each entry contains `model_id`, `provider`, `subprovider`, and a `pricing` object with per-token rates. ### Method GET ### Endpoint /api/models/pricing ### Parameters #### Query Parameters - **model_id** (string) - Optional - The ID of the model to filter by. - **provider** (string) - Optional - The provider of the model to filter by. - **subprovider** (string) - Optional - The subprovider of the model to filter by, required when the model is hosted by multiple vendors. - **limit** (integer) - Optional - The maximum number of results to return (default 100, max 1000). - **page** (integer) - Optional - The page number for pagination. ### Request Example ```bash # List pricing for gpt-4o on OpenAI curl -G 'https://www.narev.ai/api/models/pricing' \ --data-urlencode 'model_id=gpt-4o' \ --data-urlencode 'provider=openai' # List all providers for a multi-host model (subprovider matters) curl -G 'https://www.narev.ai/api/models/pricing' \ --data-urlencode 'model_id=llama-3.1-70b' # Paginate the full catalog curl -G 'https://www.narev.ai/api/models/pricing' \ --data-urlencode 'limit=1000' \ --data-urlencode 'page=2' ``` ### Response #### Success Response (200) - **data** (array) - An array of pricing objects. - **model_id** (string) - The ID of the model. - **provider** (string) - The provider of the model. - **subprovider** (string) - The subprovider of the model. - **pricing** (object) - An object containing per-token rates. - **price_prompt** (number) - The price for prompt tokens. - **price_completion** (number) - The price for completion tokens. - **price_input_cache_read** (number) - The price for input cache read. - **price_input_cache_write** (number | null) - The price for input cache write. - **price_internal_reasoning** (number | null) - The price for internal reasoning. - **pricing_request** (number | null) - The price for pricing requests. - **price_web_search** (number | null) - The price for web search. - **pricing_discount** (number) - The pricing discount. - **meta** (object) - Metadata for pagination. - **page** (integer) - The current page number. - **limit** (integer) - The number of results per page. - **total** (integer) - The total number of results. - **total_pages** (integer) - The total number of pages. ### Response Example ```json { "data": [ { "model_id": "gpt-4o", "provider": "openai", "subprovider": "OpenAI", "pricing": { "price_prompt": 0.0000025, "price_completion": 0.00001, "price_input_cache_read": 0.00000125, "price_input_cache_write": null, "price_internal_reasoning": null, "pricing_request": null, "price_web_search": null, "pricing_discount": 0 } } ], "meta": { "page": 1, "limit": 100, "total": 1, "total_pages": 1 } } ``` ``` -------------------------------- ### List LLM Pricing Catalog Source: https://github.com/narevai/skills/blob/main/skills/pricing/narev-lookup-llm-pricing/SKILL.md Retrieves a paginated list of available LLM models and their pricing details. Supports filtering by model ID, provider, and search terms. ```APIDOC ## GET /api/models/pricing ### Description Lists the catalog of LLM models and their associated pricing information. This endpoint is paginated and can be filtered by various parameters. ### Method GET ### Endpoint https://www.narev.ai/api/models/pricing ### Parameters #### Query Parameters - **model_id** (string) - Optional - Filter by specific model ID. - **search** (string) - Optional - Perform a general search across models. - **provider** (string) - Optional - Filter by the model provider (e.g., 'openai'). - **subprovider** (string) - Optional - Filter by a specific subprovider. - **sort_by** (string) - Optional - Field to sort the results by (`model_id`, `provider`, or `subprovider`). - **order** (string) - Optional - Order of sorting (`asc` or `desc`). - **page** (integer) - Optional - Page number for pagination (default: 1). - **limit** (integer) - Optional - Number of results per page (max: 1000, default: 100). ### Response #### Success Response (200) - **data** (array) - An array of `ModelPricingEntry` objects. - **model_id** (string) - The ID of the model. - **provider** (string) - The provider of the model. - **subprovider** (string) - The subprovider of the model. - **pricing** (object) - Pricing details for the model. - **price_prompt** (number) - USD per input token. - **price_completion** (number) - USD per output token. - **price_input_cache_read** (number) - USD per cached input token. - **price_input_cache_write** (number) - USD per cached input token. - **price_internal_reasoning** (number) - USD per reasoning output token. - **pricing_request** (number) - Flat USD per request. - **price_web_search** (number) - USD per web-search invocation. - **pricing_discount** (number) - Fractional discount (0-1). - **price_image** (number) - USD per image unit (if applicable). - **price_image_output** (number) - USD per output image unit (if applicable). - **price_audio** (number) - USD per audio unit (if applicable). - **price_audio_output** (number) - USD per output audio unit (if applicable). - **price_input_audio_cache** (number) - USD per input audio cache unit (if applicable). - **meta** (object) - Pagination metadata. - **page** (integer) - Current page number. - **limit** (integer) - Results per page. - **total** (integer) - Total number of results. - **total_pages** (integer) - Total number of pages. ### Request Example ```bash curl -G 'https://www.narev.ai/api/models/pricing' \ --data-urlencode 'model_id=gpt-4o' \ --data-urlencode 'provider=openai' ``` ``` -------------------------------- ### Calculate LLM Call Cost with cURL Source: https://github.com/narevai/skills/blob/main/skills/pricing/narev-lookup-llm-pricing/SKILL.md Use this cURL command to send a POST request to the Narev pricing calculation endpoint. Ensure all required usage fields are provided as integers, using 0 for unused categories. ```bash curl -X POST 'https://www.narev.ai/api/models/pricing/calculate' \ -H 'Content-Type: application/json' \ -d '{ "modelId": "gpt-4o", "provider": "openai", "subprovider": "OpenAI", "usage": { "promptTokens": 1000, "completionTokens": 500, "cacheReadTokens": 0, "cacheWriteTokens": 0, "reasoningTokens": 0 } }' ``` -------------------------------- ### Codex Plugin Manifest Source: https://github.com/narevai/skills/blob/main/AGENTS.md Specifies the Codex plugin manifest for bundling Narev skills, with the 'skills' entry point directing to the './skills/' directory. ```json .codex-plugin/plugin.json — Codex plugin manifest for the bundle (`skills` entry point at `./skills/`). ``` -------------------------------- ### narev-lookup-llm-pricing: Calculate Call Cost Source: https://context7.com/narevai/skills/llms.txt Computes the exact USD cost for a single LLM call based on provided token usage. Requires all five usage fields and the subprovider if applicable. ```APIDOC ## POST /api/models/pricing/calculate — Calculate USD cost for one call ### Description Computes the exact USD cost for a single LLM call given token usage. All five `usage` integer fields are required — pass `0` for unused categories (never `null` or omit them). `subprovider` is required when the model is served by multiple hosts. ### Method POST ### Endpoint /api/models/pricing/calculate ### Parameters #### Request Body - **usage** (object) - Required - An object containing token usage for different categories. - **prompt_tokens** (integer) - Required - The number of prompt tokens used. - **completion_tokens** (integer) - Required - The number of completion tokens used. - **input_cache_read_tokens** (integer) - Required - The number of input cache read tokens used. - **input_cache_write_tokens** (integer) - Required - The number of input cache write tokens used. - **internal_reasoning_tokens** (integer) - Required - The number of internal reasoning tokens used. - **model_id** (string) - Required - The ID of the model used. - **provider** (string) - Required - The provider of the model. - **subprovider** (string) - Optional - The subprovider of the model, required when the model is hosted by multiple vendors. ### Request Example ```json { "usage": { "prompt_tokens": 1000, "completion_tokens": 500, "input_cache_read_tokens": 200, "input_cache_write_tokens": 0, "internal_reasoning_tokens": 0 }, "model_id": "gpt-4o", "provider": "openai", "subprovider": "OpenAI" } ``` ### Response #### Success Response (200) - **total_cost_usd** (number) - The total cost of the call in USD. #### Response Example ```json { "total_cost_usd": 0.00000425 } ``` ``` -------------------------------- ### Calculate LLM Call Cost Source: https://github.com/narevai/skills/blob/main/skills/pricing/narev-lookup-llm-pricing/SKILL.md Computes the estimated USD cost for a single LLM API call based on the model, provider, and usage details. ```APIDOC ## POST /api/models/pricing/calculate ### Description Calculates the estimated USD cost for a single LLM API call. You need to provide the model ID, provider, and a breakdown of token usage. ### Method POST ### Endpoint https://www.narev.ai/api/models/pricing/calculate ### Parameters #### Request Body - **modelId** (string) - Required - The ID of the model to use. - **provider** (string) - Required - The provider of the model (e.g., 'openai'). - **subprovider** (string) - Required - The subprovider, especially when a model is served by multiple providers (e.g., 'bedrock', 'openrouter'). - **usage** (object) - Required - An object detailing token usage. - **promptTokens** (integer) - Required - Number of input tokens. - **completionTokens** (integer) - Required - Number of output tokens. - **cacheReadTokens** (integer) - Required - Number of cached input tokens read. - **cacheWriteTokens** (integer) - Required - Number of cached input tokens written. - **reasoningTokens** (integer) - Required - Number of reasoning output tokens. - **webSearchCount** (integer) - Optional - Number of web searches performed. - **isByok** (boolean) - Optional - Indicates if Bring Your Own Key is used. ### Request Example ```json { "modelId": "claude-3-sonnet-20240229", "provider": "anthropic", "subprovider": "bedrock", "usage": { "promptTokens": 1000, "completionTokens": 500, "cacheReadTokens": 0, "cacheWriteTokens": 0, "reasoningTokens": 100 }, "webSearchCount": 1, "isByok": false } ``` ### Response #### Success Response (200) - **estimatedCostUsd** (number) - The calculated cost in USD for the API call. #### Response Example ```json { "estimatedCostUsd": 0.0012345 } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.