Skip to content

feat(fal_ai): add MiniMax H3 text-to-video and reference-to-video - #42286

Merged
kerry-berri merged 1 commit into
mainfrom
litellm_fal_ai_minimax_h3
Sep 21, 2026
Merged

kerry-berri merged 1 commit into
mainfrom
litellm_fal_ai_minimax_h3

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • MiniMax H3 (Hailuo 3) is live on fal.ai but LiteLLM has no entry for it
  • Routing it through the existing fal_ai video adapter silently drops size, so fal renders at its 2K default
  • Spend is logged as $0 because there is no pricing row
  • Reference-to-video is rejected by fal because the adapter sends image_url instead of reference_image_urls

How it solves it:

  • Adds fal_ai/minimax/h3/text-to-video and fal_ai/minimax/h3/reference-to-video to the cost map with per-resolution pricing
  • Adds output_cost_per_second_768p and output_cost_per_second_2k to typed model info, router params, and the dashboard types
  • Makes the fal_ai video adapter model-aware: H3 gets its own resolution vocabulary (480P, 768P, 2K, 4K), integer duration, reference_image_urls list, and a 2K default in usage; Seedance keeps its current behavior

User Flow

Before: a developer adds MiniMax H3 through fal_ai, asks for a 768P clip, and gets a 2K clip billed at $0

  1. Admin adds model: fal_ai/minimax/h3/text-to-video and model: fal_ai/minimax/h3/reference-to-video deployments to the proxy config and restarts
  2. Developer sends POST http://localhost:4000/v1/videos with {"model":"minimax-h3","prompt":"...","seconds":"6","size":"768P"}
  3. The 200 response has "size": null, "usage": {"video_resolution": "720p"}, and no x-litellm-response-cost header
  4. GET http://localhost:4000/v1/videos/{id}/content returns a 2544x1456 (2K) mp4, so they paid fal for 2K and the proxy logged $0
  5. Developer sends POST http://localhost:4000/v1/videos with {"model":"minimax-h3-reference","prompt":"...","seconds":"5","size":"480P","input_reference":"https://.../owl.png"}
  6. Status flips to completed, but GET .../content returns 500 fal.ai video result did not include a video URL because fal rejected the request with "At least one reference image, video, or audio must be provided"

After: the same requests produce the requested resolution, are billed correctly, and reference-to-video works

  1. Admin adds the same two deployments to the proxy config and restarts
  2. Developer sends the same POST http://localhost:4000/v1/videos with "size":"768P"
  3. The 200 response has "size": "768P", "usage": {"video_resolution": "768P"}, and x-litellm-response-cost: 0.36 (6 s at $0.06/s)
  4. GET http://localhost:4000/v1/videos/{id}/content returns a 1344x768 mp4
  5. Developer sends the same reference-to-video POST
  6. The 200 response has "size": "480P" and x-litellm-response-cost: 0.25, and GET .../content returns an 832x480 mp4

Relevant issues

Affected release

Linear ticket

Resolves LIT-8275

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*, make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • 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)

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

Shared setup. Both proxies run the same config against the real fal.ai API with LITELLM_LOCAL_MODEL_COST_MAP=True so the cost map on disk is the one under test. Before runs from a worktree at the merge base on port 4000, After runs from the PR tip on port 4001

model_list:
  - model_name: minimax-h3
    litellm_params:
      model: fal_ai/minimax/h3/text-to-video
      api_key: os.environ/FAL_AI_API_KEY
  - model_name: minimax-h3-reference
    litellm_params:
      model: fal_ai/minimax/h3/reference-to-video
      api_key: os.environ/FAL_AI_API_KEY
general_settings:
  master_key: os.environ/LITELLM_MASTER_KEY
python litellm/proxy/proxy_cli.py --config h3_proxy_config.yaml --port <port> --detailed_debug

Before (9a90ada)

text-to-video, size 768P

  1. Create
    curl -s -D - localhost:4000/v1/videos -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" \
      -d '{"model":"minimax-h3","prompt":"a red fox trotting through fresh snow at dawn, cinematic","seconds":"6","size":"768P"}'
    x-litellm-model-name: fal_ai/minimax/h3/text-to-video
    x-litellm-key-spend: 0.0
    {"id":"video_bGl0...","object":"video","status":"queued",...,"seconds":"6","size":null,"model":"minimax-h3","usage":{"duration_seconds":6.0,"video_resolution":"720p"}}
    
    There is no x-litellm-response-cost header
  2. Proxy log, the request fal received and the cost that was logged
    POST https://queue.fal.run/minimax/h3/text-to-video
    -d '{'prompt': 'a red fox trotting through fresh snow at dawn, cinematic', 'duration': '6'}'
    cost_calculation.py:173 - No cost information found for video model minimax/h3/text-to-video. Please add pricing to model_prices_and_context_window.json
    db_spend_update_writer.py:405 - Enters prisma db call, response_cost: 0.0
    
  3. Poll until "status":"completed", then download and inspect
    curl -s localhost:4000/v1/videos/$ID -H "Authorization: Bearer $LITELLM_MASTER_KEY"
    curl -s -o before.mp4 localhost:4000/v1/videos/$ID/content -H "Authorization: Bearer $LITELLM_MASTER_KEY"
    ffprobe -v error -show_entries stream=width,height,duration -of csv=p=0 before.mp4
    2544,1456,6.583333
    
    fal rendered 2K (its default) instead of 768P, and the proxy logged $0 for a clip fal bills at 6 * $0.13 = $0.78

reference-to-video, size 480P

  1. Create
    curl -s -D - localhost:4000/v1/videos -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" \
      -d '{"model":"minimax-h3-reference","prompt":"the owl in the reference image slowly turns its head toward the camera","seconds":"5","size":"480P","input_reference":"https://storage.googleapis.com/falserverless/model_tests/upscale/owl.png"}'
    x-litellm-key-spend: 0.0
    {"id":"video_bGl0...","object":"video","status":"queued",...,"seconds":"5","size":null,"model":"minimax-h3-reference","usage":{"duration_seconds":5.0,"video_resolution":"720p"}}
    
  2. Proxy log, the request fal received
    -d '{'prompt': 'the owl in the reference image slowly turns its head toward the camera', 'image_url': 'https://storage.googleapis.com/falserverless/model_tests/upscale/owl.png', 'duration': '5'}'
    
  3. Poll until "status":"completed", then download
    curl -s localhost:4000/v1/videos/$ID/content -H "Authorization: Bearer $LITELLM_MASTER_KEY"
    {"error":{"message":"litellm.APIConnectionError: Fal_aiException - fal.ai video result did not include a video URL. ...","code":"500"}}
    
    fal's own result for that request id is a validation error: At least one reference image, video, or audio must be provided, because image_url is not a field H3 accepts

After (8d73ce7)

text-to-video, size 768P

  1. Create
    curl -s -D - localhost:4001/v1/videos -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" \
      -d '{"model":"minimax-h3","prompt":"a red fox trotting through fresh snow at dawn, cinematic","seconds":"6","size":"768P"}'
    x-litellm-model-name: fal_ai/minimax/h3/text-to-video
    x-litellm-response-cost: 0.36
    x-litellm-key-spend: 0.36
    {"id":"video_bGl0...","object":"video","status":"queued",...,"seconds":"6","size":"768P","model":"minimax-h3","usage":{"duration_seconds":6.0,"video_resolution":"768P"}}
    
  2. Proxy log, the request fal received and the cost that was logged
    POST https://queue.fal.run/minimax/h3/text-to-video
    -d '{'prompt': 'a red fox trotting through fresh snow at dawn, cinematic', 'duration': 6, 'resolution': '768P'}'
    litellm_logging.py:1839 - response_cost: 0.36
    db_spend_update_writer.py:405 - Enters prisma db call, response_cost: 0.36
    
  3. Poll until "status":"completed", then download and inspect
    curl -s -o after.mp4 localhost:4001/v1/videos/$ID/content -H "Authorization: Bearer $LITELLM_MASTER_KEY"
    ffprobe -v error -show_entries stream=width,height,duration -of csv=p=0 after.mp4
    1344,768,6.583333
    
    768P as requested, billed at 6 * $0.06 = $0.36

reference-to-video, size 480P

  1. Create
    curl -s -D - localhost:4001/v1/videos -H "Authorization: Bearer $LITELLM_MASTER_KEY" -H "Content-Type: application/json" \
      -d '{"model":"minimax-h3-reference","prompt":"the owl in the reference image slowly turns its head toward the camera","seconds":"5","size":"480P","input_reference":"https://storage.googleapis.com/falserverless/model_tests/upscale/owl.png"}'
    x-litellm-response-cost: 0.25
    {"id":"video_bGl0...","object":"video","status":"queued",...,"seconds":"5","size":"480P","model":"minimax-h3-reference","usage":{"duration_seconds":5.0,"video_resolution":"480P"}}
    
  2. Proxy log, the request fal received
    -d '{'prompt': 'the owl in the reference image slowly turns its head toward the camera', 'reference_image_urls': ['https://storage.googleapis.com/falserverless/model_tests/upscale/owl.png'], 'duration': 5, 'resolution': '480P'}'
    
  3. Poll until "status":"completed", then download and inspect
    curl -s -o after_ref.mp4 -w "%{http_code} %{size_download} %{content_type}\n" localhost:4001/v1/videos/$ID/content -H "Authorization: Bearer $LITELLM_MASTER_KEY"
    ffprobe -v error -show_entries stream=width,height,duration -of csv=p=0 after_ref.mp4
    200 1528667 video/mp4
    832,480,5.166667
    

Type

🆕 New Feature

Caveats (if any)

Medium

  • Proxies that load the cost map from the hosted URL only see the new rows once this lands on main, until then set LITELLM_LOCAL_MODEL_COST_MAP=True
  • When fal rejects a request (bad reference URL, validation error) the status still flips to completed and the content download returns a generic 500 instead of fal's error text. Pre-existing adapter behavior, not changed here

Low

  • H3 is selected by the minimax/h3/ model prefix; other fal video models keep the Seedance behavior
  • Dimension sizes map to H3 tiers by short side: <=480 -> 480P, <=768 -> 768P, <=1440 -> 2K, else 4K
  • Prices are the fal.ai listed rates on 2026-09-21, tests read them from the cost map rather than pinning them

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

Link to Devin session: https://app.devin.ai/sessions/a8bdf1069abf462eb88cce7de1941407
Open in Devin Desktop: https://app.devin.ai/desktop/session/a8bdf1069abf462eb88cce7de1941407?variant=devin

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration
devin-ai-integration Bot requested a review from a team September 21, 2026 19:18
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@CLAassistant

CLAassistant commented Sep 21, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@codspeed

codspeed Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_fal_ai_minimax_h3 (8d73ce7) with main (f92ff60)

Open in CodSpeed

@codecov

codecov Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@greptile-apps

greptile-apps Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge, with no outstanding findings.

Summary

Adds MiniMax H3 support to the existing fal.ai video adapter.

  • Introduces H3-specific resolution, duration, reference-image, and usage metadata handling.
  • Adds text-to-video and reference-to-video pricing across the primary and backup cost maps.
  • Extends typed pricing metadata and generated dashboard schema definitions for 768P and 2K rates.
  • Adds unit and integration coverage for H3 request transformation, queue behavior, and resolution-based cost calculation.

Reviews (2) · Last reviewed commit: "feat(fal_ai): add MiniMax H3 text-to-vid..."

@kerry-berri

Copy link
Copy Markdown
Contributor

@greptileai

@kerry-berri
kerry-berri merged commit 5216844 into main Sep 21, 2026
98 checks passed
@kerry-berri
kerry-berri deleted the litellm_fal_ai_minimax_h3 branch September 21, 2026 20:16
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