Deploy Kimi as a Governed AI Agent
Deploy Kimi (Moonshot AI) as a governed production agent on SchemaBounce — 128K–2M context, approval gates, persistent memory, and audit trails. Use Kimi for long-document reasoning and agentic coding, with a runtime that keeps it reliable after handoff.
Deploy Kimi as a Governed AI Agent
Kimi K2 from Moonshot AI is an open-weight agentic model with 128K–256K context (up to 2M via API) optimized for tool use and coding. Running Kimi alone gives you the model — SchemaBounce gives you the governed harness around it: persistent memory, human-in-the-loop approvals, workspace-scoped data, CDC connectivity, and signed execution receipts. You bring your Kimi API key; SchemaBounce handles hosting, memory, and governance.
If you are already building with Kimi's API (platform.kimi.ai), SchemaBounce replaces the glue code you'd otherwise write for state, approvals, and observability.
Why Kimi + SchemaBounce
| Capability | Kimi API alone | Kimi on SchemaBounce |
|---|---|---|
| Context window | 128K (K2), 2M (Kimi long-context API) | Same — passed through to model |
| Memory across runs | You build it (Redis/DB) | ADL memory with vector search built-in |
| Tool approvals | None — tools execute immediately | Human approval gates before external writes |
| Audit trail | Your logs | Signed receipts per action |
| Data freshness | Poll or webhook | Real-time CDC from Postgres, MySQL, HubSpot, Salesforce |
| Multi-agent | Orchestrate yourself | Delegation via ADL messages, parent/child receipts |
| Integrations | Build each one | 100+ MCP servers (GitHub, Stripe, Slack, HubSpot, etc.) |
Kimi's strength is long-context reasoning and agentic tool use. SchemaBounce's strength is making that reasoning safe in production.
How It Works
[Your Kimi Agent Code] → [SchemaBounce ADL] → [Model Provider]
↕ memory/graph/records ↕ approval gate
[CDC Pipelines] [Human Reviewer] → [MCP Tools] → [External Systems]
- Agent calls Kimi via your API key (stored workspace-scoped, never shared across tenants).
- Agent reads/writes structured records, vector memory, and graph edges in its isolated ADL namespace.
- Actions that mutate external systems queue for human approval.
- Approved actions execute and produce a signed receipt.
Code: Kimi Agent with ADL Memory and Approvals
# kimi_governed_agent.py — Kimi K2 on SchemaBounce with memory + approval gate
import os
from openai import OpenAI
# Kimi uses OpenAI-compatible API
client = OpenAI(
api_key=os.environ["KIMI_API_KEY"],
base_url="https://api.moonshot.cn/v1"
)
from schemabounce import ADL, approval_gate
adl = ADL(namespace="kimi-agent")
SYSTEM = """You are a RevOps agent with access to CRM records and long-document context.
Propose CRM updates but never apply them without approval."""
def run_turn(user_msg: str):
memories = adl.memory.search(user_msg, limit=5)
context = "\n".join(m["text"] for m in memories)
account = adl.records.get("companies", "acct_123")
messages = [
{"role": "system", "content": SYSTEM},
{"role": "system", "content": f"Memory:\n{context}\n\nAccount:\n{account}"},
{"role": "user", "content": user_msg},
]
resp = client.chat.completions.create(
model="kimi-k2-0711-preview",
messages=messages,
tools=[{
"type": "function",
"function": {
"name": "propose_crm_update",
"description": "Propose a CRM field update for human approval",
"parameters": {
"type": "object",
"properties": {
"entity": {"type": "string"},
"field": {"type": "string"},
"value": {"type": "string"},
"reason": {"type": "string"}
},
"required": ["entity", "field", "value", "reason"]
}
}
}],
tool_choice="auto",
)
msg = resp.choices[0].message
if msg.tool_calls:
for tc in msg.tool_calls:
receipt = approval_gate.submit(action=tc.function.name, params=tc.function.arguments, adl_namespace=adl.namespace)
adl.memory.add(f"Proposed: {tc.function.arguments} (receipt {receipt.id})")
print(f"Queued for approval: {receipt.id}")
else:
adl.memory.add(f"User: {user_msg}\nAssistant: {msg.content}")
print(msg.content)
run_turn("Review the last 3 call transcripts and propose next steps for Acme Corp.")
When to Choose Kimi
- Long documents & transcripts: Use Kimi's 128K–2M window to analyze contracts, call recordings, or codebases in one pass.
- Agentic coding: K2 is optimized for multi-step tool use and repo-level edits.
- APAC latency & pricing: Moonshot's China/US endpoints can reduce latency for APAC users vs. US-only providers.
Production Checklist for Kimi Agents
- Pin
modelto an immutable version tag - Store
KIMI_API_KEYin workspace secrets (not in code) - Enable ADL memory TTL and decay policies per namespace
- Require approval for all
writetool calls; allowreadwithout gate - Verify receipts (
receipt_id) in compliance exports - Connect CDC to source of truth (Postgres/HubSpot) so agent never reasons on stale data
FAQ
Does SchemaBounce host Kimi's weights? No — you call Moonshot's API with your own key. SchemaBounce hosts the agent runtime, memory, approvals, and data layer around the call.
What context length can I use? Whatever your Kimi plan supports (128K for K2, up to 2M on the long-context endpoint).
Can I swap Kimi for another model later? Yes — change model and base_url, no data migration needed.
Ready to run Kimi in production? Request a Production Readiness Report →