Skip to content

feat: add grok imagine as image generation#1516

Open
lmariscal wants to merge 1 commit into0xPlaygrounds:mainfrom
lmariscal:leo/wtmntzprplwp
Open

feat: add grok imagine as image generation#1516
lmariscal wants to merge 1 commit into0xPlaygrounds:mainfrom
lmariscal:leo/wtmntzprplwp

Conversation

@lmariscal
Copy link

@lmariscal lmariscal commented Mar 14, 2026

Summary

  • Add image generation support for xAI's Grok Imagine API (grok-imagine-image and grok-imagine-image-pro models)
  • Implement ImageGenerationModel trait for the xAI provider, following the same pattern as OpenAI's implementation
  • xAI uses aspect_ratio and resolution instead of pixel-based size, so these are passed via additional_params (defaults to "1:1" aspect ratio)

Changes

  • rig-core/src/providers/xai/image_generation.rs — New module implementing the ImageGenerationModel trait for xAI
  • rig-core/src/providers/xai/mod.rs — Register and re-export the image_generation module (behind image feature flag)
  • rig-core/src/providers/xai/client.rs — Change ImageGeneration = Nothing to Capable<ImageGenerationModel<H>>
  • rig-core/examples/xai_image_generation.rs — Example demonstrating usage with custom resolution and aspect ratio

Test plan

  • cargo clippy --example xai_image_generation --features image passes
  • cargo test --lib -p rig-core passes
  • Example runs successfully and produces a valid image

Fixes #1517

@lmariscal lmariscal changed the title add grok imagine as image generation feat: add grok imagine as image generation Mar 14, 2026
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.

feat: add grok imagine as image generation

1 participant