Skip to content

Support coding-plan (OAuth) endpoints — run agents on Kimi/GLM subscriptions, not pay-as-you-go keys #85

Open

Description

@melvincarvalho

Problem

An agent can run on Kimi 2.7 mechanically — smoke-tested, the agent-micro harness reached Kimi's Anthropic-compatible API and got a real structured response. But only via pay-as-you-go (api.moonshot.ai, static ANTHROPIC_AUTH_TOKEN), which costs money / needs a funded balance (the smoke hit 429: insufficient balance).

The coding plan — the thing you actually pay a flat subscription for — uses a different endpoint and auth that jsclaw/agent-micro can't currently use:

  • base: https://api.kimi.com/coding/v1
  • auth: OAuth ([providers."managed:kimi-code".oauth], api_key is empty) — not a static key
  • model: kimi-code/kimi-for-coding

agent-micro only knows static ANTHROPIC_API_KEY / ANTHROPIC_AUTH_TOKEN, so it can't ride the subscription.

Why it matters

The point of a cheap/sovereign agent is to run on a plan you already have, not spend per-token. Kimi (and GLM, Claude) all offer flat coding plans behind OAuth. Without this, every Scuttle turn either burns pay-as-you-go or can't use the good models.

Ask

Let agents authenticate against coding-plan endpoints (subscription), starting with Kimi-code. The pattern generalizes to other OAuth-gated coding plans.

Approaches (in order of effort)

  1. Reuse the coding tool's live session token — read the current OAuth access token the kimi CLI already holds and send it as the bearer to api.kimi.com/coding. Simplest; token is short-lived so needs refresh handling.
  2. Implement the OAuth client flow (device/auth-code) for the coding plan, with token refresh.
  3. Pluggable credential resolver (cleanest, and it rhymes with soul-trail#1's sign() seam): agent-micro resolves its auth token through a configurable source — static key | oauth | external command — so any subscription auth slots in without changing the request path.

Acceptance

  • Scuttle runs a full turn on the Kimi coding plan with no pay-as-you-go spend
  • the credential mechanism is pluggable enough that GLM/Claude coding plans can follow

Notes

Companion to provider verification (#27). The auth layer lives in jsclaw-agent-micro (src/api.js) + jsclaw provider config (src/providers.js).

Activity

  1. melvincarvalho commented on Jun 12, 2026

    @melvincarvalho
    ContributorAuthor

    Scope audit + T&C check (2026-06-12)

    Technical scope

    • Endpoint: ready. api.kimi.com/coding is Anthropic-compatible (kimi-code is a Claude Code fork). agent-micro would just point ANTHROPIC_BASE_URL there. No protocol work.
    • Auth: the real work. OAuth device-code flow (device_id present), token in the OS keyring (no plaintext file; oauth/kimi-code is a keyring key), with refresh. Not a static key.
    • Better path found: kimi acp runs kimi-code as an Agent Client Protocol server over stdio (cf. ACP support: IDEs (Zed) talk to jsclaw agents #63). That would let jsclaw drive the coding plan without ever touching the OAuth token — auth stays inside kimi-code. Technically the cleanest route, and avoids credential extraction entirely.

    T&C check — this is a blocker

    Kimi's terms (kimi.com/user/agreement/modelUse?version=v2) explicitly prohibit, without written authorization:

    "Using automated means (such as bots, crawlers, scripts, scheduled tasks, or similar technologies) to access, interact with, or exploit the services"

    and prohibit:

    "You may not share your account credentials or make your account available to anyone else."

    So driving the Kimi coding plan from jsclaw — by token reuse or via the ACP server — plausibly falls under prohibited 'automated means', and token reuse also implicates credential-sharing. The kimi acp feature creates ambiguity (Kimi ships an agent-integration interface, yet the ToS broadly bars automation), but the terms grant no explicit exception for it.

    Recommendation

    • Do not build the Kimi token-reuse path. It is T&C-questionable at best.
    • If pursuing Kimi: seek written authorization / clarify with Kimi support about the ACP server + agent use. Until then, blocked.
    • Generalize this issue: coding-plan support is per-provider, and each provider's T&C gates it. Confirm GLM/Z.ai (currently in use) and any others permit agent/automated use before relying on them.
    • The credential-resolver seam (approach 3) and the ACP-client idea remain the right architecture — but only point them at providers whose terms allow it.

    Net: the engineering is small (ACP or a resolver seam); the gate is legal, and for Kimi it's currently red.

  2. melvincarvalho commented on Jun 12, 2026

    @melvincarvalho
    ContributorAuthor

    What's allowed — settled (openclaw's de-facto set)

    openclaw's own docs list these as first-class "subscription-style hosted options":

    • Z.AI (GLM) — Coding Plan or general API. Z.ai publishes its own openclaw integration page (docs.z.ai/devpack/tool/openclaw) → officially sanctioned (best-effort priority vs the official coding-agent under load).
    • MiniMax — Coding Plan via OAuth or API key (explicitly offers a programmatic key path).
    • Qwen Cloud — Coding Plan endpoint mapping (+ Alibaba DashScope).

    Notably absent: the consumer Kimi coding plan. openclaw reaches Kimi via BytePlus ARK (a reseller API), not the kimi.com consumer plan — consistent with Kimi's ToS, which bars automated/agent access to the consumer plan without written authorization.

    Conclusion for this issue

    • Target the sanctioned, provider-documented plans: GLM (Z.ai), MiniMax, Qwen — all permit agent/API use by design.
    • MiniMax's "OAuth or API key" is the model: prefer the API-key path (clean, clearly allowed) over OAuth where offered.
    • Drop the consumer-Kimi-coding-plan path. If Kimi is wanted, go via an API product (BytePlus ARK), not the consumer plan token.
    • The credential-resolver seam (approach 3) still holds — but it points only at these sanctioned providers.

    Net: it's not "coding plans forbid agents" universally — it's per-provider, and GLM/MiniMax/Qwen explicitly allow it. Scuttle already runs on GLM (the safe one).

  3. melvincarvalho commented on Jun 12, 2026

    @melvincarvalho
    ContributorAuthor

    Verified: Kimi coding plan needs no OAuth — it's a standard Anthropic provider preset

    Smoke-tested the Kimi Code subscription (Moderato plan, K2.6/2.7 flagship) against jsclaw/agent-micro. It Just Works as an Anthropic-compatible endpoint with the plan's own API key — no OAuth, no shim.

    Verified config:

    field value
    ANTHROPIC_BASE_URL https://api.kimi.com/coding
    key (ANTHROPIC_API_KEY / ANTHROPIC_AUTH_TOKEN) the plan's sk-kimi-… key from the Kimi Code console → API Keys (up to 5, "never expose client-side" = server-side use expected)
    model kimi-for-coding

    Probe results (the diagnosis):

    • POST https://api.kimi.com/coding/v1/messages (Anthropic, x-api-key) → HTTP 200, real kimi-for-coding reply. The SDK's ${BASE}/v1/messages lands here.
    • POST https://api.kimi.com/coding/v1/chat/completions (OpenAI-style) → HTTP 403: "Kimi For Coding is currently only available for Coding Agents such as Kimi CLI, Claude Code, Roo Code, Kilo Code, etc."
    • The old pay-as-you-go key on api.moonshot.ai/anthropic → HTTP 429 "account suspended due to insufficient balance" — this was the earlier smoke-test failure, a dead key, not a policy/quota wall.

    End-to-end: drove agent-micro's runner.js with providerEnv = the three vars above + model: kimi-for-coding against a real agent workspace → status: success, one turn, usage: 1730 in / 27 out.

    What's allowed (settled)

    The 403 names Claude Code as a sanctioned coding agent — which is the exact harness jsclaw/agent-micro run on (@anthropic-ai/claude-code / the same Anthropic surface). So driving the plan from jsclaw is an intended use of an explicitly-provisioned API key, not a credential-sharing workaround. The kimi.com ToS clause about "bots/scripts/automated access" and "don't share credentials" targets scraping the consumer web product and sharing your login — not using a key the console hands you for exactly this.

    Scope impact

    This shrinks the issue. The title says "(OAuth)", but the sanctioned coding plans don't need it:

    • Kimi — verified above, plain Anthropic preset + sk-kimi-… key.
    • GLM / Z.ai — already running in jsclaw-local (https://api.z.ai/api/anthropic + ZAI_API_KEY). Same shape.
    • MiniMax / Qwen / Volcano / BytePlus — per openclaw's model-providers doc, all reachable by API key; OAuth is an optional variant.

    So the core of #85 is: a credential-resolver seam that maps a named provider preset → {ANTHROPIC_BASE_URL, key, model}, shipping presets for the API-key coding plans (Kimi, GLM, MiniMax, Qwen, Volcano/BytePlus). OAuth-only variants (minimax-portal, qwen-oauth) can be deferred to a follow-up. Suggest retitling away from "(OAuth)" to reflect that the API-key path is primary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions