feat: xAI Grok Imagine image and video providers; FLUX.2 models on the BFL provider - #16
Merged
blackflame007 merged 1 commit intoJul 26, 2026
Conversation
blackflame007
merged commit Jul 26, 2026
5a4729d
into
litellm_internal_staging
73 of 77 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Relevant issues
Linear ticket
Pre-Submission checklist
@greptileaito re-request a review after pushing changes)Screenshots / Proof of Fix
Live proxy proof will follow once the platform config lands: the plan is a curl of POST /v1/images/generations with model xai/grok-imagine-image and a POST /v1/videos submit-poll-content cycle with xai/grok-imagine-video against the staging proxy, plus a black_forest_labs/flux-2-pro generation, all hitting the real provider APIs
Type
🆕 New Feature
Changes
Adds xAI media generation, which upstream v1.93.0 lacks entirely. xai/grok-imagine-image and xai/grok-imagine-image-quality ride a new XAIImageGenerationConfig on the OpenAI-compatible /v1/images/generations endpoint at api.x.ai, with size mapped to aspect_ratio and the native aspect_ratio and resolution (1k/2k) fields passed through. xai/grok-imagine-video and xai/grok-imagine-video-1.5 get a kling-style XAIVideoConfig for the async submit-poll flow: POST /v1/videos/generations returns request_id, GET /v1/videos/{request_id} reports pending/done/failed/expired, and the finished video.url is downloaded on the content call. The video id is provider-encoded for routing, usage.duration_seconds is set from the requested duration at create and from video.duration when done, so per-second cost metering works via output_cost_per_video_per_second
The Black Forest Labs provider's model-endpoint maps gain the FLUX.2 family (flux-2-pro, flux-2-max, flux-2-flex, flux-2-klein-9b, flux-2-klein-4b) for both generation and edit, matching the current hosted API at api.bfl.ai (verified against its openapi.json)
Cost wiring: an image_cost_calculator for xai in the image cost dispatch, plus model_prices entries for the two xai image models (0.02 and 0.05 per image), the two xai video models (0.05 and 0.08 per second) and the five FLUX.2 models, sourced from docs.x.ai and docs.bfl.ml pricing pages
Tests cover the full transformation surface for both new configs (URL and auth resolution, param mapping, request bodies, response and status mapping, id encode/decode, content URL extraction, registry dispatch) plus pricing presence for every new model entry; 212 pass in the touched directories