Skip to content

feat: implement dynamic model cost resolver via models.dev API#28

Open
ganimalqudhaifi wants to merge 4 commits into
anthonyhaussman:mainfrom
ganimalqudhaifi:feat/dynamic-pricing
Open

feat: implement dynamic model cost resolver via models.dev API#28
ganimalqudhaifi wants to merge 4 commits into
anthonyhaussman:mainfrom
ganimalqudhaifi:feat/dynamic-pricing

Conversation

@ganimalqudhaifi

Copy link
Copy Markdown

This PR introduces a dynamic pricing fetcher that automatically retrieves the latest model costs from the models.dev API registry.

Key Improvements:

  • Zero Hardcoding: Eliminates the need to manually hardcode and update prices for Google, Anthropic, and OpenAI models inside the plugin.
  • Dynamic Provider Mapping: Automatically maps OpenCode model IDs to their respective providers in the API registry.
  • Smart Caching: Responses are securely cached in the OS tmpdir with a 24-hour TTL to ensure CLI boot times remain instant without unnecessary network overhead.
  • Conflict-Free: Designed to be completely modular and will seamlessly merge alongside other pending PRs (e.g., model capabilities alignment).

@anthonyhaussman anthonyhaussman left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thorough code review performed. Several critical and high severity issues were found related to blocking network requests on CLI boot and shared cache permissions. Please see the line-specific comments for detailed feedback.

Comment thread src/plugin/pricing.ts Outdated
Comment thread src/plugin/pricing.ts Outdated
Comment thread src/plugin.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants