Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Sep 22, 2025

Summary

This PR adds support for the Grok-4 Fast model, prioritizing OpenRouter integration where it's currently available for free.

Changes

  • ✨ Added grok-4-fast to xAI models configuration with 256K context window and image support
  • 💰 Configured free pricing to reflect current OpenRouter promotion
  • 🔧 Added special handling in OpenRouter fetcher to override pricing during free promotion period
  • ✅ Added comprehensive test coverage for both xAI and OpenRouter implementations
  • 📝 Added TODO comments for future pricing updates and direct xAI API support

Testing

  • All existing tests pass
  • New tests added for:
    • xAI handler with grok-4-fast model
    • OpenRouter parser with free pricing override

Notes

  • The model is currently free on OpenRouter as part of a promotion
  • Direct xAI API support can be added in a follow-up PR (lower priority as noted in the issue)
  • Pricing will need to be updated when the OpenRouter promotion ends

Fixes #8217

Checklist

  • Code follows project conventions
  • Tests added and passing
  • Linting and type checks pass
  • Implementation reviewed with 85% confidence score

Important

Add support for Grok-4 Fast model with free pricing via OpenRouter, including configuration and test updates.

  • Behavior:
    • Added grok-4-fast to xaiModels in xai.ts with 256K context window and image support.
    • Configured free pricing for grok-4-fast in openrouter.ts during OpenRouter promotion.
  • Testing:
    • Added tests in xai.spec.ts for grok-4-fast model handling and free pricing verification.
    • Added tests in openrouter.spec.ts for grok-4-fast pricing override.
  • Misc:
    • Added TODOs for future pricing updates and direct xAI API support in xai.ts.

This description was created by Ellipsis for 606cd8b. You can customize this summary. It will automatically update as commits are pushed.

- Added grok-4-fast to xAI models configuration with free pricing
- Added special handling in OpenRouter fetcher to override pricing for free promotion
- Added tests for the new model in both xAI and OpenRouter test suites
- Model supports 256K context window and image inputs

Fixes #8217
@roomote roomote bot requested review from cte, jr and mrubens as code owners September 22, 2025 16:38
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Sep 22, 2025
@dosubot dosubot bot added the enhancement New feature or request label Sep 22, 2025
Copy link
Contributor Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

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

Reviewing my own code again. It's like proofreading your own typos - you never see them until it's in production.

contextWindow: 256000,
supportsImages: true,
supportsPromptCache: true,
inputPrice: 0.0, // Currently free on OpenRouter
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pricing maintenance concern: This hardcodes free pricing (0.0) for grok-4-fast, but OpenRouter also overrides it to free. When the promotion ends, you'll need to update prices in both places. Consider either:

  • Removing the hardcoded free pricing here and letting OpenRouter handle the override
  • Adding a more prominent warning about the dual maintenance requirement

cacheReadsPrice: 0.0,
description: "xAI's Grok-4 Fast model with 256K context window - currently free on OpenRouter",
// TODO: Update pricing when OpenRouter promotion ends
// TODO: Add direct xAI API support for this model (lower priority)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

API support validation: The TODO mentions "Add direct xAI API support for this model (lower priority)" but the code assumes it already works with the xAI handler. Consider adding validation or clearer documentation about whether the xAI API actually supports grok-4-fast yet.

Copy link
Contributor

Choose a reason for hiding this comment

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

missing grok-4-fast-reasoning?

modelInfo.maxTokens = 32768
}

// Set xai/grok-4-fast model configuration (currently free on OpenRouter)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Consider adding timeline reference: The comment mentions "currently free on OpenRouter" but doesn't indicate when this might change. Consider adding a date or reference link to track when to revisit the pricing.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Sep 22, 2025
@daniel-lxs
Copy link
Member

The changes to the openrouter provider are unnecessary

@daniel-lxs daniel-lxs closed this Sep 23, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Sep 23, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Sep 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

[ENHANCEMENT] Support for Grok 4 Fast via OpenRouter - while the model is still free to use! - and directly as well

5 participants