Skip to content

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

Merged
anthonyhaussman merged 3 commits into
anthonyhaussman:mainfrom
ganimalqudhaifi:feat/dynamic-pricing
Jul 26, 2026
Merged

feat: implement dynamic model cost resolver via models.dev API#28
anthonyhaussman merged 3 commits into
anthonyhaussman:mainfrom
ganimalqudhaifi:feat/dynamic-pricing

Conversation

@ganimalqudhaifi

Copy link
Copy Markdown
Contributor

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
@anthonyhaussman
anthonyhaussman merged commit 95f1ccf into anthonyhaussman:main Jul 26, 2026
2 checks passed
@ganimalqudhaifi
ganimalqudhaifi deleted the feat/dynamic-pricing branch July 26, 2026 13:33
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