Skip to content

ccproxy.models.detection

ccproxy.models.detection

Detection models for Claude Code CLI headers and system prompt extraction.

ClaudeCodeHeaders

Bases: BaseModel

Pydantic model for Claude CLI headers extraction with field aliases.

to_headers_dict

to_headers_dict()

Convert to headers dictionary for HTTP forwarding with proper case.

Source code in ccproxy/models/detection.py
def to_headers_dict(self) -> dict[str, str]:
    """Convert to headers dictionary for HTTP forwarding with proper case."""
    headers = {}

    # Map field names to proper HTTP header names
    header_mapping = {
        "anthropic_beta": "anthropic-beta",
        "anthropic_version": "anthropic-version",
        "anthropic_dangerous_direct_browser_access": "anthropic-dangerous-direct-browser-access",
        "x_app": "x-app",
        "user_agent": "User-Agent",
        "x_stainless_lang": "X-Stainless-Lang",
        "x_stainless_retry_count": "X-Stainless-Retry-Count",
        "x_stainless_timeout": "X-Stainless-Timeout",
        "x_stainless_package_version": "X-Stainless-Package-Version",
        "x_stainless_os": "X-Stainless-OS",
        "x_stainless_arch": "X-Stainless-Arch",
        "x_stainless_runtime": "X-Stainless-Runtime",
        "x_stainless_runtime_version": "X-Stainless-Runtime-Version",
    }

    for field_name, header_name in header_mapping.items():
        value = getattr(self, field_name, None)
        if value is not None:
            headers[header_name] = value

    return headers

SystemPromptData

Bases: BaseModel

Extracted system prompt information.

ClaudeCacheData

Bases: BaseModel

Cached Claude CLI detection data with version tracking.

CodexHeaders

Bases: BaseModel

Pydantic model for Codex CLI headers extraction with field aliases.

to_headers_dict

to_headers_dict()

Convert to headers dictionary for HTTP forwarding with proper case.

Source code in ccproxy/models/detection.py
def to_headers_dict(self) -> dict[str, str]:
    """Convert to headers dictionary for HTTP forwarding with proper case."""
    headers = {}

    # Map field names to proper HTTP header names
    header_mapping = {
        "session_id": "session_id",
        "originator": "originator",
        "openai_beta": "openai-beta",
        "version": "version",
        "chatgpt_account_id": "chatgpt-account-id",
    }

    for field_name, header_name in header_mapping.items():
        value = getattr(self, field_name, None)
        if value is not None and value != "":
            headers[header_name] = value

    return headers

CodexInstructionsData

Bases: BaseModel

Extracted Codex instructions information.

CodexCacheData

Bases: BaseModel

Cached Codex CLI detection data with version tracking.