Implementation:Helicone Helicone Provider URL Pattern Matching
| Knowledge Sources | |
|---|---|
| Domains | LLM Observability, Provider Routing, Cost Calculation |
| Last Updated | 2026-02-14 00:00 GMT |
Overview
Concrete provider registry array that maps LLM API URL patterns to provider names and cost tables, provided by the @helicone/cost package.
Description
The providers array in packages/cost/providers/mappings.ts is the central registry for identifying LLM providers by their API URLs. Each entry contains a pattern (RegExp), a provider (ProviderName string), an optional costs array of ModelRow[] entries, and an optional modelDetails map. The array currently contains entries for over 30 providers including OpenAI, Anthropic, Azure, Google, AWS Bedrock, Groq, Mistral, DeepSeek, xAI, Fireworks, Perplexity, OpenRouter, and many more.
Key design details:
- URL patterns use anchored regex (e.g.,
/^https:\/\/api\.openai\.com/) to prevent false matches. - OpenAI's pattern supports regional data residency variants (
us.api.openai.com). - Azure's pattern handles multiple domain suffixes (
openai.azure.com,azure-api.net,cognitiveservices.azure.com,services.ai.azure.com). - AWS Bedrock URLs match two entries -- "AWS" (with both Bedrock and Nova costs) and "BEDROCK" (with only Bedrock costs).
- Providers without cost data (LOCAL, HELICONE proxies, CLOUDFLARE, OPENPIPE, CHUTES, CEREBRAS, CANOPYWAVE) have empty or absent
costsarrays. - The module exports
defaultProvider(OpenAI),allCosts(flattened cost array),approvedDomains(all patterns), andmodelNames(all model identifiers).
Usage
Use this registry when you need to:
- Identify which provider a given URL belongs to.
- Retrieve cost tables for a specific provider.
- Validate that a target URL belongs to a known LLM API domain.
Code Reference
Source Location
- Repository: Helicone
- File:
packages/cost/providers/mappings.ts(lines 141-329)
Signature
export const providers: {
pattern: RegExp;
provider: ProviderName;
costs?: ModelRow[];
modelDetails?: ModelDetailsMap;
}[];
Import
import { providers } from "@helicone/cost";
// or directly:
import { providers, ProviderName } from "@helicone/cost/providers/mappings";
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| (array lookup) | string (URL to test) |
Yes | The target LLM API URL to match against provider patterns |
Outputs
| Name | Type | Description |
|---|---|---|
| pattern | RegExp |
Regular expression matching the provider's API URL(s) |
| provider | ProviderName |
Provider identifier string (e.g., "OPENAI", "ANTHROPIC", "GOOGLE", "AWS", "BEDROCK") |
| costs | ModelRow[] ¦ undefined |
Array of model cost definitions for this provider, if available |
| modelDetails | ModelDetailsMap ¦ undefined |
Map of model metadata (capabilities, benchmarks, etc.) for supported providers |
ProviderName Values
The ProviderName type is a union of 34 string literals:
type ProviderName =
| "OPENAI" | "ANTHROPIC" | "AZURE" | "LOCAL" | "HELICONE"
| "AMDBARTEK" | "ANYSCALE" | "CLOUDFLARE" | "2YFV" | "TOGETHER"
| "LEMONFOX" | "FIREWORKS" | "PERPLEXITY" | "GOOGLE" | "OPENROUTER"
| "WISDOMINANUTSHELL" | "GROQ" | "COHERE" | "MISTRAL" | "DEEPINFRA"
| "QSTASH" | "FIRECRAWL" | "AWS" | "BEDROCK" | "DEEPSEEK" | "X"
| "AVIAN" | "NEBIUS" | "NOVITA" | "OPENPIPE" | "CHUTES" | "LLAMA"
| "NVIDIA" | "VERCEL" | "CEREBRAS" | "BASETEN" | "CANOPYWAVE";
Usage Examples
Basic Usage
import { providers } from "@helicone/cost";
const targetUrl = "https://api.anthropic.com/v1/messages";
const matched = providers.find((p) => p.pattern.test(targetUrl));
if (matched) {
console.log("Provider:", matched.provider);
// "ANTHROPIC"
console.log("Has costs:", !!matched.costs);
// true
console.log("Model count:", matched.costs?.length);
}
Using Default Provider
import { providers, defaultProvider } from "@helicone/cost/providers/mappings";
const url = "https://my-custom-llm.example.com/v1/chat";
const matched = providers.find((p) => p.pattern.test(url));
// Fall back to OpenAI cost table if no match
const costTable = matched?.costs ?? defaultProvider.costs;
Domain Validation
import { approvedDomains } from "@helicone/cost/providers/mappings";
function isApprovedDomain(url: string): boolean {
return approvedDomains.some((pattern) => pattern.test(url));
}