anomalyco / anomalyco/opencode

[FEATURE]: Route Kimi K3 to the cheaper k3-256k endpoint below 256k context on Kimi for Coding

Open
#41,327 0 comments 0 reactions 1 assignee View on GitHub

@rekram1-node is already working on this.

Since Aug 8, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Feature hasn't been suggested before.
  • I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request

Kimi for Coding exposes the same underlying model under two api ids —
k3 and k3-256k — that are billed/rate-limited differently by
context size. k3-256k is much cheaper on ratelimits than k3 while
the conversation is under 256k tokens, and cache persists between the
two ids, so there's no downside to using k3-256k whenever context is
small enough.

Right now opencode always calls whichever id the user selects (k3),
so anyone using Kimi K3 through the Kimi for Coding Plan pays the more
expensive k3 ratelimit even on short conversations.

Proposed: when a user has k3 selected on the Kimi for Coding
provider, opencode should transparently call k3-256k under the hood
while the conversation is below ~256k tokens, and switch to k3 once
it grows past that, using a small safety margin since token counts are
estimated from the previous turn's reported usage rather than an exact
count of the upcoming request. This should be scoped to Kimi for
Coding specifically and not change behavior for any other provider.

I have a draft implementation ready (small declarative context-tier
table + one cache-key fix in the provider layer) and can open a PR
once this is approved.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.