Unified model mapping utilities for OpenAI and Claude models.
This module provides a single source of truth for all model mappings,
consolidating OpenAI→Claude mappings and Claude alias resolution.
map_model_to_claude
map_model_to_claude(model_name)
Map any model name to its canonical Claude model name.
This function handles:
- OpenAI model names → Claude equivalents
- Claude aliases → canonical Claude names
- Pattern matching for versioned models
- Pass-through for unknown models
Parameters:
Name |
Type |
Description |
Default |
model_name
|
str
|
Model identifier (OpenAI, Claude, or alias)
|
required
|
Returns:
Type |
Description |
str
|
Canonical Claude model identifier
|
Source code in ccproxy/utils/model_mapping.py
| def map_model_to_claude(model_name: str) -> str:
"""Map any model name to its canonical Claude model name.
This function handles:
- OpenAI model names → Claude equivalents
- Claude aliases → canonical Claude names
- Pattern matching for versioned models
- Pass-through for unknown models
Args:
model_name: Model identifier (OpenAI, Claude, or alias)
Returns:
Canonical Claude model identifier
"""
# Direct mapping first (handles both OpenAI and Claude aliases)
claude_model = MODEL_MAPPING.get(model_name)
if claude_model:
return claude_model
# Pattern matching for versioned OpenAI models
if model_name.startswith("gpt-4o-mini"):
return "claude-3-5-haiku-latest"
elif model_name.startswith("gpt-4o") or model_name.startswith("gpt-4"):
return "claude-3-7-sonnet-20250219"
elif model_name.startswith("gpt-3.5"):
return "claude-3-5-haiku-latest"
elif (
model_name.startswith("o1")
or model_name.startswith("gpt-5")
or model_name.startswith("o3")
or model_name.startswith("gpt")
):
return "claude-sonnet-4-20250514"
# If it's already a Claude model, pass through unchanged
if model_name.startswith("claude-"):
return model_name
# For unknown models, pass through unchanged
return model_name
|
get_openai_to_claude_mapping
get_openai_to_claude_mapping()
Get mapping of OpenAI models to Claude models.
Returns:
Type |
Description |
dict[str, str]
|
Dictionary mapping OpenAI model names to Claude model names
|
Source code in ccproxy/utils/model_mapping.py
| def get_openai_to_claude_mapping() -> dict[str, str]:
"""Get mapping of OpenAI models to Claude models.
Returns:
Dictionary mapping OpenAI model names to Claude model names
"""
return {k: v for k, v in MODEL_MAPPING.items() if not k.startswith("claude-")}
|
get_claude_aliases_mapping
get_claude_aliases_mapping()
Get mapping of Claude aliases to canonical Claude names.
Returns:
Type |
Description |
dict[str, str]
|
Dictionary mapping Claude aliases to canonical model names
|
Source code in ccproxy/utils/model_mapping.py
| def get_claude_aliases_mapping() -> dict[str, str]:
"""Get mapping of Claude aliases to canonical Claude names.
Returns:
Dictionary mapping Claude aliases to canonical model names
"""
return {k: v for k, v in MODEL_MAPPING.items() if k.startswith("claude-")}
|
get_supported_claude_models
get_supported_claude_models()
Get list of supported canonical Claude models.
Returns:
Type |
Description |
list[str]
|
Sorted list of unique canonical Claude model names
|
Source code in ccproxy/utils/model_mapping.py
| def get_supported_claude_models() -> list[str]:
"""Get list of supported canonical Claude models.
Returns:
Sorted list of unique canonical Claude model names
"""
return sorted(set(MODEL_MAPPING.values()))
|
is_openai_model
is_openai_model(model_name)
Check if a model name is an OpenAI model.
Parameters:
Name |
Type |
Description |
Default |
model_name
|
str
|
Model identifier to check
|
required
|
Returns:
Type |
Description |
bool
|
True if the model is an OpenAI model, False otherwise
|
Source code in ccproxy/utils/model_mapping.py
| def is_openai_model(model_name: str) -> bool:
"""Check if a model name is an OpenAI model.
Args:
model_name: Model identifier to check
Returns:
True if the model is an OpenAI model, False otherwise
"""
return (
model_name.startswith(("gpt-", "o1", "o3", "text-davinci"))
or model_name in get_openai_to_claude_mapping()
)
|
is_claude_model
is_claude_model(model_name)
Check if a model name is a Claude model (canonical or alias).
Parameters:
Name |
Type |
Description |
Default |
model_name
|
str
|
Model identifier to check
|
required
|
Returns:
Type |
Description |
bool
|
True if the model is a Claude model, False otherwise
|
Source code in ccproxy/utils/model_mapping.py
| def is_claude_model(model_name: str) -> bool:
"""Check if a model name is a Claude model (canonical or alias).
Args:
model_name: Model identifier to check
Returns:
True if the model is a Claude model, False otherwise
"""
return (
model_name.startswith("claude-") or model_name in get_claude_aliases_mapping()
)
|
map_openai_model_to_claude
map_openai_model_to_claude(openai_model)
Legacy alias for map_model_to_claude().
Parameters:
Name |
Type |
Description |
Default |
openai_model
|
str
|
|
required
|
Returns:
Source code in ccproxy/utils/model_mapping.py
| def map_openai_model_to_claude(openai_model: str) -> str:
"""Legacy alias for map_model_to_claude().
Args:
openai_model: OpenAI model identifier
Returns:
Claude model identifier
"""
return map_model_to_claude(openai_model)
|
get_canonical_model_name
get_canonical_model_name(model_name)
Legacy alias for map_model_to_claude().
Parameters:
Name |
Type |
Description |
Default |
model_name
|
str
|
Model name (possibly an alias)
|
required
|
Returns:
Source code in ccproxy/utils/model_mapping.py
| def get_canonical_model_name(model_name: str) -> str:
"""Legacy alias for map_model_to_claude().
Args:
model_name: Model name (possibly an alias)
Returns:
Canonical model name
"""
return map_model_to_claude(model_name)
|