Module Proto.Model

Claude AI model identifiers for protocol encoding.

This module provides type-safe model identifiers with JSON encoding/decoding support via Jsont. Use polymorphic variants for known models with a custom escape hatch for future or unknown models.

type t = [
  1. | `Sonnet_4_5
    (*

    claude-sonnet-4-5 - Most recent Sonnet model

    *)
  2. | `Sonnet_4
    (*

    claude-sonnet-4 - Sonnet 4 model

    *)
  3. | `Sonnet_3_5
    (*

    claude-sonnet-3-5 - Sonnet 3.5 model

    *)
  4. | `Opus_4_5
    (*

    claude-opus-4-5 - Most recent Opus model

    *)
  5. | `Opus_4_1
    (*

    claude-opus-4-1 - Opus 4.1 model

    *)
  6. | `Opus_4
    (*

    claude-opus-4 - Opus 4 model for complex tasks

    *)
  7. | `Haiku_4
    (*

    claude-haiku-4 - Fast, cost-effective Haiku model

    *)
  8. | `Custom of string
    (*

    Custom model string for future/unknown models

    *)
]

The type of Claude models.

val to_string : t -> string

to_string t converts a model to its string representation.

Examples:

  • `Sonnet_4_5 becomes "claude-sonnet-4-5"
  • `Opus_4_5 becomes "claude-opus-4-5"
  • `Opus_4 becomes "claude-opus-4"
  • `Custom "my-model" becomes "my-model"
val of_string : string -> t

of_string s parses a model string into a typed model.

Known model strings are converted to their typed variants. Unknown strings become `Custom s.

Examples:

  • "claude-sonnet-4-5" becomes `Sonnet_4_5
  • "future-model" becomes `Custom "future-model"
val jsont : t Jsont.t

jsont is the Jsont codec for model identifiers.

This codec maps between the typed model representation and JSON strings. It uses of_string for decoding and to_string for encoding.