Skip to content

feat(llm): add moonshot/kimi-k3 to model prices and context window map - #37552

Merged
mateo-berri merged 2 commits into
litellm_internal_stagingfrom
litellm_add_kimi_k3_pricing
Aug 21, 2026
Merged

feat(llm): add moonshot/kimi-k3 to model prices and context window map#37552
mateo-berri merged 2 commits into
litellm_internal_stagingfrom
litellm_add_kimi_k3_pricing

Conversation

@tin-berri

@tin-berri tin-berri commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • moonshot/kimi-k3 is missing from the model price map
  • Requests to it fail model-info lookup and track $0 spend

How it solves it:

  • Adds moonshot/kimi-k3 to model_prices_and_context_window.json (+ backup copy)
  • Official pricing: $3.00/M input, $0.30/M cache read, $15.00/M output, 1,048,576 context

User Flow

Before: a developer routing Kimi K3 through the gateway gets no pricing metadata, so spend tracking reads zero

  1. They send POST https://litellm-domain/v1/chat/completions with "model": "moonshot/kimi-k3"
  2. The response comes back fine, but the spend logs show $0.00 for the request
  3. Calling GET https://litellm-domain/v1/model/info for the model shows no max_input_tokens or cost fields
  4. https://litellm-domain/ui/?page=logs shows the request at $0.00 spend

After: the same request is priced correctly

  1. They send POST https://litellm-domain/v1/chat/completions with "model": "moonshot/kimi-k3"
  2. The response comes back, and the spend logs show real cost ($3.00/M input, $15.00/M output, $0.30/M cache hits)
  3. GET https://litellm-domain/v1/model/info returns 1,048,576 max input/output tokens plus reasoning/vision/tool-calling support flags
  4. https://litellm-domain/ui/?page=logs shows the request at non-zero spend

Relevant issues

No issue was filed for the moonshot entry: kimi-k3 was noticed absent while configuring it as a gateway model. Related: #35344 asks for the Fireworks kimi-k3 entry, which is a separate change

Linear ticket

Resolves LIT-5873

Pre-Submission checklist

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

  • I have added meaningful tests (n/a: data-only change to the price map)
  • 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 (for this data-only change, the same checks CI runs pass locally: jq empty, ci_cd/check_files_match.py, ci_cd/generate_model_prices_schema.py --check)
  • 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

Full before/after QA, live against Moonshot: the before leg at the merge base (9821b45) prices a real completion at $0, the after leg at the PR tip (277ed88) prices the same completion from the new entry. Each leg ran on its own proxy booted from that commit with LITELLM_LOCAL_MODEL_COST_MAP=True, its own Postgres, and a virtual key

Pricing source: https://platform.kimi.ai/docs/pricing/chat-k3 ($3.00/M cache-miss input, $0.30/M cache-hit input, $15.00/M output, 1,048,576-token context). Capabilities per https://platform.kimi.ai/docs/guide/kimi-k3-quickstart.md: max_completion_tokens settable up to 1,048,576, native vision and video file input, always-on reasoning with reasoning_effort (low/high/max)

Before, at the merge base (9821b45)

  1. Live chat completion on a proxy booted from this commit
curl -sS -w '\nHTTP_STATUS=%{http_code}\n' http://localhost:57773/v1/chat/completions \
  -H 'Authorization: Bearer sk-qa-37552-before' -H 'Content-Type: application/json' \
  -d '{"model":"kimi-k3","messages":[{"role":"user","content":"Reply with exactly: ok"}],"max_tokens":10}'

HTTP_STATUS=200, a real completion (id chatcmpl-6a88dda82e203c136a972943, 90 prompt + 10 completion tokens)

  1. The spend surface logs that request at $0
curl -sS -w '\nHTTP_STATUS=%{http_code}\n' \
  'http://localhost:57773/spend/logs?request_id=chatcmpl-6a88dda82e203c136a972943' \
  -H 'Authorization: Bearer sk-master-qa37552-before'

HTTP_STATUS=200, one row (relevant fields):

"model": "moonshot/kimi-k3",
"custom_llm_provider": "moonshot",
"spend": 0.0,
"prompt_tokens": 90,
"completion_tokens": 10,
"total_tokens": 100
  1. GET /v1/model/info on the same proxy: HTTP_STATUS=200 with model_info for kimi-k3 all null (relevant fields):
"key": "moonshot/kimi-k3",
"litellm_provider": "moonshot",
"max_input_tokens": null,
"max_output_tokens": null,
"max_tokens": null,
"mode": null,
"input_cost_per_token": 0,
"output_cost_per_token": 0,
"cache_read_input_token_cost": null,
"supports_vision": null,
"supports_function_calling": null

Every other cost field and supports_* flag also came back null

  1. SDK at the same commit
LITELLM_LOCAL_MODEL_COST_MAP=True python -c '
import litellm
litellm.get_model_info("moonshot/kimi-k3")
litellm.cost_per_token(model="moonshot/kimi-k3", prompt_tokens=1000000, completion_tokens=100000)'
get_model_info -> Exception: This model isn't mapped yet. model=moonshot/kimi-k3, custom_llm_provider=moonshot. Add it here - https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json.
cost_per_token -> Exception: This model isn't mapped yet. model=moonshot/kimi-k3, custom_llm_provider=moonshot. Add it here - https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json.

After, at the PR tip (277ed88)

  1. The same live chat completion on a proxy booted from this commit
curl -sS -w '\nHTTP_STATUS=%{http_code}\n' http://localhost:48290/v1/chat/completions \
  -H 'Authorization: Bearer sk-qa-37552-after' -H 'Content-Type: application/json' \
  -d '{"model":"kimi-k3","messages":[{"role":"user","content":"Reply with exactly: ok"}],"max_tokens":10}'

HTTP_STATUS=200, a real completion (id chatcmpl-6a88db3f50c94b5b8f5a3029, 90 prompt + 10 completion tokens), and the response now carries cost headers

x-litellm-response-cost: 0.00042
x-litellm-response-cost-input: 0.00027
x-litellm-response-cost-output: 0.00015
  1. The spend surface logs real cost priced from the new entry
curl -sS -w '\nHTTP_STATUS=%{http_code}\n' \
  'http://localhost:48290/spend/logs?request_id=chatcmpl-6a88db3f50c94b5b8f5a3029' \
  -H 'Authorization: Bearer sk-master-qa37552-after'

HTTP_STATUS=200, one row (relevant fields):

"model": "moonshot/kimi-k3",
"custom_llm_provider": "moonshot",
"spend": 0.00042,
"prompt_tokens": 90,
"completion_tokens": 10,
"total_tokens": 100

90 * $3.00/M input + 10 * $15.00/M output = $0.00042, matching the logged spend exactly, and the row's model_map_information names moonshot/kimi-k3 with input_cost_per_token: 3e-06

  1. GET /v1/model/info on the same proxy: HTTP_STATUS=200, model_info for kimi-k3 (relevant fields verbatim):
"key": "moonshot/kimi-k3",
"litellm_provider": "moonshot",
"max_input_tokens": 1048576,
"max_output_tokens": 1048576,
"max_tokens": 1048576,
"mode": "chat",
"input_cost_per_token": 3e-06,
"output_cost_per_token": 1.5e-05,
"cache_read_input_token_cost": 3e-07,
"supports_reasoning": true,
"supports_vision": true,
"supports_function_calling": true,
"supports_response_schema": true,
"supports_tool_choice": true,
"supports_video_input": true
  1. SDK at the same commit
LITELLM_LOCAL_MODEL_COST_MAP=True python -c '
import litellm, json
print(json.dumps(litellm.get_model_info("moonshot/kimi-k3"), indent=1))
p, c = litellm.cost_per_token(model="moonshot/kimi-k3", prompt_tokens=1000000, completion_tokens=100000)
print(f"prompt cost: ${p:.2f}, completion cost: ${c:.2f}, total: ${p+c:.2f}")'
{
 "max_input_tokens": 1048576,
 "max_output_tokens": 1048576,
 "input_cost_per_token": 3e-06,
 "cache_read_input_token_cost": 3e-07,
 "output_cost_per_token": 1.5e-05,
 "litellm_provider": "moonshot",
 "mode": "chat",
 "supports_vision": true,
 "supports_reasoning": true,
 "supports_function_calling": true
}
prompt cost: $3.00, completion cost: $1.50, total: $4.50

Observations from the run, in scope for a reviewer but not caused by this PR:

Type

🆕 New Feature

Caveats (if any)

  • supports_web_search deliberately omitted: K3 docs say web_search is being updated (matches kimi-k2.5/k2.6)

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

Note

Low Risk
Data-only price-map entry; no runtime, auth, or routing logic changes. Wrong numbers would only affect cost reporting.

Overview
Adds moonshot/kimi-k3 to the model price map (and backup) so LiteLLM can resolve costs and context limits instead of treating the model as unmapped ($0 spend).

Pricing is $3.00/M input, $0.30/M cache read, $15.00/M output, with a 1,048,576-token window. Capability flags match other recent Kimi chat models (tools, reasoning, vision/video, response schema).

Reviewed by Cursor Bugbot for commit 277ed88. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds Moonshot Kimi K3 pricing, context-window, and capability metadata to the canonical model map and its backup copy.

  • Configures input, cache-read, and output token costs.
  • Declares a 1,048,576-token context window.
  • Keeps the canonical and backup entries synchronized.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
model_prices_and_context_window.json Adds the canonical Moonshot Kimi K3 pricing and model-capability entry using existing schema fields.
litellm/model_prices_and_context_window_backup.json Mirrors the canonical Kimi K3 metadata entry in the backup price map.

Reviews (3): Last reviewed commit: "Merge remote-tracking branch 'origin/lit..." | Re-trigger Greptile

@codecov

codecov Bot commented Aug 19, 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 Aug 20, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_add_kimi_k3_pricing (277ed88) with litellm_internal_staging (04113aa)1

Open in CodSpeed

Footnotes

  1. No successful run was found on litellm_internal_staging (9821b45) during the generation of this report, so 04113aa was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Pricing per https://platform.kimi.ai/docs/pricing/chat-k3:
- $3.00/M input (cache miss), $0.30/M cache read, $15.00/M output
- 1,048,576 context window; max_completion_tokens settable up to 1,048,576
- Supports reasoning (reasoning_effort low/high/max), tool calling,
  structured output, vision and video input

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@tin-berri
tin-berri force-pushed the litellm_add_kimi_k3_pricing branch from 0163ce8 to 42cffe9 Compare August 20, 2026 03:49
@tin-berri
tin-berri changed the base branch from main to litellm_internal_staging August 20, 2026 03:49
@tin-berri
tin-berri requested a review from mateo-berri as a code owner August 20, 2026 03:49
@tin-berri tin-berri changed the title Add moonshot/kimi-k3 to model prices and context window map feat(llm): Add moonshot/kimi-k3 to model prices and context window map Aug 20, 2026
@tin-berri tin-berri changed the title feat(llm): Add moonshot/kimi-k3 to model prices and context window map feat(llm): add moonshot/kimi-k3 to model prices and context window map Aug 20, 2026
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot 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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 42cffe9. Configure here.

Setsuna-Yukirin pushed a commit to Setsuna-Yukirin/litellm that referenced this pull request Aug 21, 2026
models.litellm.ai and released litellm versions read
model_prices_and_context_window.json from main at runtime, so Kimi K3 is
missing from the hosted catalog even though the entry is in review for
litellm_internal_staging in BerriAI#37552. This copies that entry onto main so
the catalog picks it up on its next fetch.

Data only: the cost map and its backup copy, no code changes. Pricing
matches Moonshot's published rates ($3/M input, $0.30/M cache read,
$15/M output, 1,048,576-token context). The fireworks_ai and Azure
Foundry kimi-k3 variants are separate work in BerriAI#37512 and BerriAI#37658; neither
touches the native moonshot/kimi-k3 key.
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot 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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 277ed88. Configure here.

@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 9c558df into litellm_internal_staging Aug 21, 2026
75 checks passed
@mateo-berri
mateo-berri deleted the litellm_add_kimi_k3_pricing branch August 21, 2026 23:27
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