Skip to content

feat(pricing): add xai/grok-4.5 model pricing and metadata - #32549

Merged
mateo-berri merged 1 commit into
litellm_internal_stagingfrom
litellm_add_grok_4_5
Jul 9, 2026
Merged

feat(pricing): add xai/grok-4.5 model pricing and metadata#32549
mateo-berri merged 1 commit into
litellm_internal_stagingfrom
litellm_add_grok_4_5

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Relevant issues

Linear ticket

Pre-Submission checklist

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

  • 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

xAI just shipped Grok 4.5 (grok-4.5, with grok-4.5-latest as an alias). This adds both to the cost map so cost tracking and context-window metadata resolve for the model

Pricing and metadata are taken from https://docs.x.ai/docs/models. The docs express per-token prices in internal units where the existing grok-4.3 entry (docs value 12500) maps to 1.25e-06, i.e. units x 1e-10. Applying that to grok-4.5's docs values gives input 2e-06, output 6e-06, cached input 5e-07, and the >200k long-context tier at input 4e-06, output 1.2e-05, cached 1e-06, with a 500k context window and reasoning, vision, function calling, structured outputs, prompt caching and web search all supported

Live billed call against the real xAI API, captured at commit fbad6ad8ad:

$ LITELLM_LOCAL_MODEL_COST_MAP=True XAI_API_KEY=*** python3 -c "
import litellm
from litellm import completion_cost
r=litellm.completion(model='xai/grok-4.5',messages=[{'role':'user','content':'Reply with exactly: grok-4.5 live test ok'}],max_tokens=50)
print('CONTENT:',r.choices[0].message.content)
print('MODEL:',r.model)
print('USAGE:',r.usage)
print('COST_USD:',completion_cost(completion_response=r))
"
CONTENT: grok-4.5 live test ok
MODEL: grok-4.5
USAGE: Usage(completion_tokens=59, prompt_tokens=219, total_tokens=278,
  completion_tokens_details=CompletionTokensDetailsWrapper(reasoning_tokens=50, ...),
  prompt_tokens_details=PromptTokensDetailsWrapper(cached_tokens=128, text_tokens=219, ...),
  cost_in_usd_ticks=6000000)
COST_USD: 0.0006

The $0.0006 LiteLLM computes matches the tiered pricing exactly: 91 uncached input x 2e-06 + 128 cached input x 5e-07 + 59 output x 6e-06 = 6.0e-04, which also lines up with xAI's own cost_in_usd_ticks=6000000 (ticks x 1e-10)

Metadata resolution from the local cost map:

$ LITELLM_LOCAL_MODEL_COST_MAP=True python3 -c "
import litellm
for m in ['xai/grok-4.5','xai/grok-4.5-latest']:
    i=litellm.get_model_info(m)
    print(m,'in',i['input_cost_per_token'],'out',i['output_cost_per_token'],'cache',i['cache_read_input_token_cost'],'ctx',i['max_input_tokens'],'reason',i.get('supports_reasoning'),'vision',i.get('supports_vision'),'prov',i['litellm_provider'])
"
xai/grok-4.5 in 2e-06 out 6e-06 cache 5e-07 ctx 500000 reason True vision True prov xai
xai/grok-4.5-latest in 2e-06 out 6e-06 cache 5e-07 ctx 500000 reason True vision True prov xai

Type

🆕 New Feature

Changes

Add xai/grok-4.5 and its xai/grok-4.5-latest alias to model_prices_and_context_window.json and the bundled litellm/model_prices_and_context_window_backup.json

Link to Devin session: https://app.devin.ai/sessions/e8043e650ee9475195e2caead0d4bd46
Requested by: @ishaan-berri

Co-Authored-By: Ishaan Jaffer <155045088+ishaan-berri@users.noreply.github.com>
@ishaan-berri ishaan-berri self-assigned this Jul 8, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@greptile-apps

greptile-apps Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds pricing and capability metadata for xai/grok-4.5 and its xai/grok-4.5-latest alias to both the main and backup cost-map JSON files. The values have been cross-checked against the xAI public documentation and are consistent with the structure of adjacent grok-4.3 entries.

  • Pricing ($2/M input, $6/M output, $0.50/M cached) and the 500k context window match the xAI docs; the above-200k tiered rates follow the same 2× multiplier pattern used by grok-4.3.
  • Both model_prices_and_context_window.json and the bundled backup are updated identically, and all capability flags (supports_reasoning, supports_vision, supports_prompt_caching, etc.) align with the model's published feature set.

Confidence Score: 5/5

Safe to merge — two JSON pricing files updated with well-sourced, structurally consistent metadata.

The change is additive-only (two new JSON objects), the per-token prices match the xAI public documentation, the above-200k tier follows the same doubling pattern as grok-4.3, and both files are kept in sync. No logic, tests, or existing entries are touched.

No files require special attention.

Important Files Changed

Filename Overview
model_prices_and_context_window.json Adds xai/grok-4.5 and xai/grok-4.5-latest with pricing and capability metadata; values match xAI docs and are structurally consistent with existing xAI model entries.
litellm/model_prices_and_context_window_backup.json Backup JSON updated in sync with the main pricing file; identical entries for xai/grok-4.5 and xai/grok-4.5-latest.

Reviews (1): Last reviewed commit: "feat(pricing): add xai/grok-4.5 model pr..." | Re-trigger Greptile

@codecov

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed-hq

codspeed-hq Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 30 untouched benchmarks


Comparing litellm_add_grok_4_5 (fbad6ad) with litellm_internal_staging (bd23c44)

Open in CodSpeed

@mateo-berri
mateo-berri self-requested a review July 9, 2026 00:34

@mateo-berri mateo-berri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM; thanks!

@mateo-berri
mateo-berri merged commit e1b9ec1 into litellm_internal_staging Jul 9, 2026
125 checks passed
@mateo-berri
mateo-berri deleted the litellm_add_grok_4_5 branch July 9, 2026 00:37
edelauna pushed a commit to edelauna/litellm that referenced this pull request Jul 22, 2026
…2549)

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Ishaan Jaffer <155045088+ishaan-berri@users.noreply.github.com>
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.

3 participants