feat: model registry

Resolved 💬 2 comments Opened Apr 22, 2025 by chunterb Closed Aug 7, 2025

Summary

I am proposing a better way to handle model specific information. My opinion on the current approach is that it will create a snowball of one-off util methods to get model information, rather than just having a model config that serves as the single source of truth.

This will be a mutli-part PR that can be rolled out individually to make it easier to track. Part 1 has already been mocked out - just gathering feedback on if we think this is needed.

Part 1

  • Create the initial model info structure, starting with focus on context length management.
export const modelInfo = {
    "o1-pro-2025-03-19": {
        label: "O1 Pro (2025-03-19)",
        maxContextLength: 200000,
    },
    /// ... all other models to be supported
};

This will just effect the model-utils context window calculation. Right now it uses the model name to guess context - this will replace that with something along the lines of this

function maxTokensForModel(model: SupportedModelId): number {
  return openAiModelInfo[model].maxContextLength;
}

Part 2

This PR will focus on enhancing the current approach for pulling in models to choose from. The API only supports basic information like model IDs. Also, Codex is using ALL models that come from the OpenAI API... so things like computer-use-preview and whisper can be selected at this time (which obviously breaks).

Option 1
  • Continue to use the API, and filter out all models that we do not have a config for.
Option 2
  • Replace the API entirely with the model config from part 1.

Part 3

This PR will focus on changing out the string type being used for the model throughout the app with the new SupportedModelId type. This will essentially allow for static checking of supported models.

Future Enhancements

Having this config opens the door for other model-specific info in the future.

Some things that come to mind:

  • In/Out price tracking
  • Feature support (images, caching, etc)

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗