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 GetMappedContent

From Leeroopedia
Knowledge Sources
Domains LLM Observability, Response Normalization, Data Pipeline
Last Updated 2026-02-14 00:00 GMT

Overview

Concrete orchestrator for dispatching to provider-specific mappers and producing a unified MappedLLMRequest, provided by the llm-mapper package.

Description

getMappedContent is the main entry point for the LLM response normalization pipeline. Given a MapperType and a HeliconeRequest, it looks up the corresponding mapper function from the MAPPERS registry, invokes it with the request/response bodies, and assembles a complete MappedLLMRequest including the parsed LlmSchema, preview text, raw bodies, and Helicone metadata. The result is then sanitized to ensure message content types are consistent strings and preview text is truncated.

A convenience wrapper heliconeRequestToMappedContent chains mapper type detection (via getMapperTypeFromHeliconeRequest) with getMappedContent for one-step normalization.

Usage

Use getMappedContent when you already have a MapperType determined. Use heliconeRequestToMappedContent when you want the full detection-and-parsing pipeline in one call.

Code Reference

Source Location

  • Repository: Helicone
  • File: packages/llm-mapper/utils/getMappedContent.ts

Signature

export const getMappedContent = ({
  mapperType,
  heliconeRequest,
}: {
  mapperType: MapperType;
  heliconeRequest: HeliconeRequest;
}): MappedLLMRequest
export const heliconeRequestToMappedContent = (
  heliconeRequest: HeliconeRequest
): MappedLLMRequest

Import

import { getMappedContent, heliconeRequestToMappedContent } from "@helicone-package/llm-mapper/utils/getMappedContent";

Mapper Registry

The MAPPERS record maps each MapperType to a provider-specific mapper function:

MapperType Mapper Function Source Module
"ai-gateway-chat" mapOpenAIRequest mappers/openai/chat
"ai-gateway-responses" mapOpenAIResponse mappers/openai/responses
"openai-chat" mapOpenAIRequest mappers/openai/chat
"openai-response" mapOpenAIResponse mappers/openai/responses
"anthropic-chat" mapAnthropicRequest mappers/anthropic/chat
"gemini-chat" mapGeminiPro mappers/gemini/chat
"llama-chat" mapLlamaRequest mappers/llama/chat
"vercel-chat" mapVercelRequest mappers/vercel/chat
"black-forest-labs-image" mapBlackForestLabsImage mappers/black-forest-labs/image
"openai-assistant" mapOpenAIAssistant mappers/openai/assistant
"openai-image" mapDalleRequest mappers/openai/dalle
"openai-moderation" mapOpenAIModeration mappers/openai/moderation
"openai-embedding" mapOpenAIEmbedding mappers/openai/embedding
"openai-instruct" mapOpenAIInstructRequest mappers/openai/instruct
"openai-realtime" mapRealtimeRequest mappers/openai/realtime
"vector-db" mapVectorDB mappers/vector-db
"tool" mapTool mappers/tool
"data" mapData mappers/data
"unknown" mapOpenAIRequest mappers/openai/chat (fallback)

I/O Contract

Inputs

Name Type Required Description
mapperType MapperType Yes The detected mapper type string identifying which provider-specific mapper to use
heliconeRequest HeliconeRequest Yes Full Helicone request object containing request_body, response_body, response_status, model, provider, and all metadata fields (tokens, cost, latency, feedback, etc.)

Outputs

Name Type Description
(return) MappedLLMRequest Unified normalized object containing: _type (MapperType), id (request ID), schema (LlmSchema with normalized request/response), preview (truncated text + lazy full-text accessors), model, raw (original request/response bodies), heliconeMetadata (tokens, cost, latency, status, feedback, scores, etc.)

MappedLLMRequest Structure

type MappedLLMRequest = {
  _type: MapperType;
  id: string;
  schema: LlmSchema;       // { request: LLMRequestBody, response?: LLMResponseBody }
  preview: LLMPreview;      // { request: string, response: string, concatenatedMessages: Message[], fullRequestText(), fullResponseText() }
  model: string;
  raw: {
    request: any;
    response: any;
  };
  heliconeMetadata: HeliconeMetadata;
};

Usage Examples

Basic Usage

import { getMappedContent } from "@helicone-package/llm-mapper/utils/getMappedContent";
import { getMapperType } from "@helicone-package/llm-mapper/utils/getMapperType";

// Step 1: Detect mapper type
const mapperType = getMapperType({
  model: heliconeRequest.model,
  provider: heliconeRequest.provider,
});

// Step 2: Parse and normalize
const mapped = getMappedContent({ mapperType, heliconeRequest });

// Access normalized schema
console.log(mapped.schema.request.messages);   // Message[]
console.log(mapped.schema.response?.messages);  // Message[]
console.log(mapped.heliconeMetadata.cost);      // number
console.log(mapped.preview.request);            // truncated string (max 1000 chars)

One-Step Convenience

import { heliconeRequestToMappedContent } from "@helicone-package/llm-mapper/utils/getMappedContent";

// Combines detection + parsing in one call
const mapped = heliconeRequestToMappedContent(heliconeRequest);

Related Pages

Implements Principle

Page Connections

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