Skip to content

feat: xAI Grok Imagine image and video providers; FLUX.2 models on the BFL provider - #16

Merged
blackflame007 merged 1 commit into
litellm_internal_stagingfrom
litellm_xai_media_provider
Jul 26, 2026
Merged

feat: xAI Grok Imagine image and video providers; FLUX.2 models on the BFL provider#16
blackflame007 merged 1 commit into
litellm_internal_stagingfrom
litellm_xai_media_provider

Conversation

@blackflame007

Copy link
Copy Markdown

Relevant issues

Linear ticket

Pre-Submission checklist

  • I have added meaningful tests
  • My PR passes all CI/CD checks (e.g., lint, format, unit tests)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to 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

@blackflame007
blackflame007 merged commit 5a4729d into litellm_internal_staging Jul 26, 2026
73 of 77 checks passed
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.

1 participant