Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Helicone Helicone Unified Types

From Leeroopedia
Knowledge Sources
Domains Type System, Provider Integration, Model Registry
Last Updated 2026-02-14 06:32 GMT

Overview

The core type definitions for Helicone's unified model/provider mapping system, defining the type hierarchy from creators to providers to individual model configurations.

Description

The unified/types.ts module provides the foundational type system for the unified model layer that powers the Helicone playground and provider routing. It defines:

  • Creator: A union type of model creators ("OpenAI" | "Anthropic" | "Google" | "Meta" | "DeepSeek")
  • Provider: A union type of API providers ("OPENAI" | "AZURE" | "ANTHROPIC" | "BEDROCK" | "GOOGLE_GEMINI" | "GOOGLE_VERTEXAI" | "OPENROUTER" | "DEEPSEEK")
  • ProviderConfig: Connection details including base URL, auth header format, default endpoint, default body mapper, required env vars, and optional static headers
  • TokenCost: Per-token pricing with fields for input, output, input/output audio, and cache read/write costs
  • Parameters: Model-level or provider-level settings including max tokens, reasoning effort, custom endpoint, and extensible key-value pairs
  • ProviderModel: A specific model implementation on a specific provider, with optional token costs and parameters
  • ModelConfig: A model with default costs, default parameters, and a list of provider implementations
  • ModelProviderMapping: Maps model names to their configurations
  • CreatorModelMapping: The top-level type mapping each creator to their model configurations

Usage

Import these types when working with the unified model system, provider configurations, cost calculations, or the playground model selection UI.

Code Reference

Source Location

Signature

import { MapperName, PathMapper } from "../../llm-mapper/path-mapper";
import { LLMRequestBody } from "../../llm-mapper/types";

export type Creator = "OpenAI" | "Anthropic" | "Google" | "Meta" | "DeepSeek";

export type Provider =
  | "OPENAI" | "AZURE" | "ANTHROPIC" | "BEDROCK"
  | "GOOGLE_GEMINI" | "GOOGLE_VERTEXAI" | "OPENROUTER" | "DEEPSEEK";

export interface ProviderConfig {
  baseUrl: string;
  authHeaderConfig: { headerName: string; valuePrefix?: string; };
  defaultEndpoint: string;
  defaultMapper: MapperName;
  envVars: string[];
  defaultHeaders?: Record<string, string>;
}

export interface TokenCost {
  input: number;
  output: number;
  input_audio?: number;
  output_audio?: number;
  input_cache_write?: number;
  input_cache_read?: number;
}

export interface Parameters {
  max_tokens?: number;
  reasoning_effort?: "low" | "medium" | "high";
  endpoint?: string;
  mapper?: PathMapper<unknown, LLMRequestBody>;
  [key: string]: any;
}

export interface ProviderModel {
  provider: Provider;
  modelString: string;
  tokenCost?: TokenCost;
  parameters?: Parameters;
}

export interface ModelConfig {
  defaultTokenCost?: TokenCost;
  defaultParameters?: Parameters;
  providers: ProviderModel[];
}

export interface ModelProviderMapping {
  [modelName: string]: ModelConfig;
}

export type CreatorModelMapping = Record<Creator, ModelProviderMapping>;

Import

import {
  Creator,
  Provider,
  ProviderConfig,
  TokenCost,
  Parameters,
  ProviderModel,
  ModelConfig,
  ModelProviderMapping,
  CreatorModelMapping,
} from "@helicone/cost/unified/types";

I/O Contract

Type Purpose Key Fields
Creator Model creator/author "Anthropic" | "Google" | "Meta" | "DeepSeek"
Provider API endpoint provider "AZURE" | "ANTHROPIC" | ...
ProviderConfig Provider connection details baseUrl, authHeaderConfig, defaultEndpoint, defaultMapper, envVars
TokenCost Per-token pricing input, output, input_audio, output_audio, input_cache_write, input_cache_read
Parameters Model/provider settings max_tokens, reasoning_effort, endpoint, mapper, extensible
ProviderModel Model on a specific provider provider, modelString, tokenCost, parameters
ModelConfig Full model configuration defaultTokenCost, defaultParameters, providers: ProviderModel[]
ModelProviderMapping Model name to config map [modelName: string]: ModelConfig
CreatorModelMapping Creator to models map Record<Creator, ModelProviderMapping>

Usage Examples

import {
  Creator,
  Provider,
  ModelConfig,
  TokenCost,
  CreatorModelMapping,
} from "@helicone/cost/unified/types";

// Define a model configuration
const gpt4Config: ModelConfig = {
  defaultTokenCost: {
    input: 0.00003,
    output: 0.00006,
  },
  defaultParameters: {
    max_tokens: 4096,
  },
  providers: [
    {
      provider: "OPENAI",
      modelString: "gpt-4",
    },
    {
      provider: "AZURE",
      modelString: "gpt-4",
      parameters: {
        endpoint: "/chat/completions?api-version=2024-10-21",
      },
    },
  ],
};

// Type-safe creator check
const creator: Creator = "OpenAI";
const provider: Provider = "AZURE";

// Build a full mapping
const mapping: CreatorModelMapping = {
  OpenAI: { "gpt-4": gpt4Config },
  Anthropic: { /* ... */ },
  Google: { /* ... */ },
  Meta: { /* ... */ },
  DeepSeek: { /* ... */ },
};

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment