Analyzing dense technical documentation, hundred-page financial disclosures, and multi-party commercial contracts frequently overwhelms conventional AI tools constrained by short context windows. Kimi, developed by Moonshot AI, addresses this bottleneck through native ultra-long context reasoning, supporting up to one million tokens in its flagship models alongside robust multi-document processing. This guide outlines how to use Kimi to analyze lengthy individual documents, perform comparative multi-file information extraction, leverage automated context caching in automated pipelines, and enforce verification controls across high-stakes research and enterprise workflows.
Understanding Kimi's Long-Context Architecture and File Limits
Kimi eliminates the need to manually partition documents into fragmented snippets before querying an AI model. Its underlying models—including Kimi K3, powered by a hybrid architecture combining Kimi Delta Attention (KDA) and Gated Multi-Head Latent Attention (MLA)—enable global comprehension across hundreds of thousands of words without losing coherence or missing buried details.
Supported File Formats and Specifications
Kimi accepts a wide range of document and data formats across its web interface, desktop workspace, and developer API:
- Text and Office Documents:
.pdf,.docx,.doc,.txt,.md,.epub,.dot,.mobi,.html - Data Spreadsheets:
.xlsx,.xls,.csv - Presentations:
.pptx,.ppt - Code and Configuration Files:
.py,.js,.ts,.tsx,.json,.yaml,.yml,.go,.java,.cpp,.c,.cs,.sql,.log,.ini,.conf
For developer applications, uploaded files intended for textual extraction are designated with purpose="file-extract". Single files may reach up to 100 MiB. While individual organizations operate within a default 10 GiB storage ceiling, there is no rigid limit on the total count of uploaded files. Users of the Kimi Web and Kimi Work applications can upload up to 50 individual documents into a single analytical session.
Text Extraction Versus Native Visual Inspection
Kimi distinguishes between text extraction and native visual reasoning:
- Text Extraction (
file-extract): Converts documents, spreadsheets, and presentations into structured text. Kimi's extraction engine preserves heading hierarchies, structural outlines, complex mathematical equations, and formatted data tables. - Multimodal Visual Processing (
imageorvideo): Scanned image-only PDFs and standalone image assets bypass standard text extraction and are routed directly to Kimi's visual encoder (such as MoonViT) for OCR and layout reasoning.
Step-by-Step Workflow for Single Long Document Analysis
Whether reviewing an academic thesis, an annual 10-K SEC filing, or a clinical trial report, analyzing a single comprehensive document with Kimi follows a structured path from upload to targeted verification.
Option A: Interactive Document Exploration via Kimi Web
For research analysts, legal teams, and knowledge workers working in a browser or desktop client:
- Access the Interface: Navigate to
kimi.ai(orkimi.com) and open a new conversation. - Attach Document: Click the attachment icon or drag and drop a file directly into the prompt box.
- Wait for Ingestion: The interface parses the document and presents a file tag confirming that full text extraction is complete.
- Generate Initial Orientation: Request a structured overview to establish document scope before diving into specific details.
- Drill Down Interactively: Submit targeted inquiries, referencing specific sections, fiscal periods, or technical definitions.
Option B: Programmatic Document Analysis via Kimi API
For developers integrating document analysis into backend pipelines, Kimi provides an OpenAI-compatible API endpoint hosted at https://api.moonshot.cn/v1. The process requires four concise steps:
import os
from pathlib import Path
from openai import OpenAI
# Initialize client pointing to Moonshot API
client = OpenAI(
api_key=os.environ["MOONSHOT_API_KEY"],
base_url="https://api.moonshot.cn/v1",
)
# Step 1: Upload document for text extraction
uploaded_file = client.files.create(
file=Path("annual_report_2025.pdf"),
purpose="file-extract",
)
# Step 2: Retrieve extracted text content
extracted_text = client.files.content(file_id=uploaded_file.id).text
# Step 3: Inject extracted text into system messages
system_persona = (
"You are Kimi, an AI assistant developed by Moonshot AI. Provide accurate, "
"well-structured, and verified answers based strictly on provided documentation."
)
messages = [
{"role": "system", "content": system_persona},
{"role": "system", "content": extracted_text},
{
"role": "user",
"content": "Provide an executive summary of key revenue drivers and identify the top three operational risks disclosed in this filing.",
},
]
# Step 4: Execute inference using Kimi K3
response = client.chat.completions.create(
model="kimi-k3",
messages=messages,
temperature=0.3,
)
print(response.choices[0].message.content)
[!IMPORTANT] When querying documents via the API, always fetch the extracted string and pass it directly inside
messages. Never submit the rawfile_idas the message content, and do not inline large documents as base64 strings, which causes unnecessary token overhead and bypasses text extraction optimizations.
Core Query Patterns for In-Depth Single Document Analysis
To maximize extraction quality from a massive text, use specific prompting angles:
- Structural Summaries: Ask Kimi to break down the document by thematic chapters or report sections, summarizing main arguments and findings for each.
- Granular Data Point Extraction: Instruct the model to locate specific figures, such as gross margin expansion, capital expenditure totals, or debt maturity schedules, along with qualifying footnotes.
- Logical Stress-Testing: Request that Kimi identify inconsistencies, contingent liabilities, or unaddressed assumptions embedded within complex agreements.
Multi-File Information Extraction and Comparative Analysis
One of Kimi's greatest operational advantages is its capacity to evaluate multiple dense documents simultaneously. Rather than analyzing files in isolation and manually compiling findings, you can ingest several files at once to generate cross-document syntheses, contract redlines, and longitudinal trend analyses.
Ingestion Pattern for Multi-File Analysis
In the API, each distinct document is passed as an independent system message positioned at the beginning of the messages array:
def prepare_multi_file_context(file_paths: list[str]) -> list[dict]:
"""Uploads multiple files and generates a system message for each extracted document."""
file_messages = []
for path in file_paths:
file_obj = client.files.create(file=Path(path), purpose="file-extract")
file_text = client.files.content(file_id=file_obj.id).text
file_messages.append({"role": "system", "content": file_text})
return file_messages
# Ingest multiple annual filings or competitor reports
docs = ["filing_2023.pdf", "filing_2024.pdf", "filing_2025.pdf"]
file_messages = prepare_multi_file_context(docs)
multi_doc_messages = [
*file_messages,
{"role": "system", "content": system_persona},
{
"role": "user",
"content": (
"Compare financial performance across 2023, 2024, and 2025. "
"Construct a Markdown table comparing Total Revenue, Operating Margin, "
"and Free Cash Flow, followed by an explanation of major margin variances."
),
},
]
completion = client.chat.completions.create(
model="kimi-k3",
messages=multi_doc_messages,
)
print(completion.choices[0].message.content)
High-Value Multi-File Use Cases
Analyzing multiple documents in a single context window unlocks several powerful workflows:
| Use Case | Input Documents | Extraction and Synthesis Objective | Output Format |
|---|---|---|---|
| Multi-Year Financial Trends | Consecutive annual reports (10-K, audited statements) | Identify revenue growth trajectories, shifting debt liabilities, and evolving risk factors over time | Comparative metrics table and variance analysis |
| Contract Redlining and Vendor Alignment | Standard Master Services Agreement (MSA) vs. Counterparty Draft | Locate deviations in liability caps, intellectual property rights, indemnification, and payment terms | Clause-by-clause discrepancy matrix |
| Competitive Benchmarking | Product whitepapers, technical specifications, or datasheets | Compare architectural throughput, latency, security compliance, and licensing constraints | Feature parity checklist with trade-off evaluation |
| Cross-Disciplinary Literature Synthesis | Multiple scientific papers exploring related hypotheses | Extract consensus methodologies, isolate conflicting experimental results, and identify literature gaps | Systematic thematic literature review |
Constructing Effective Comparative Prompts
When comparing multiple documents, open-ended questions like "tell me what is different" often yield generic responses. Formulate prompts that enforce explicit comparison axes:
- Enforce Side-by-Side Tables: Require columns representing each document, with rows dedicated to specific attributes (e.g., pricing, termination rights, governing law).
- Mandate Source Disambiguation: Instruct Kimi to explicitly prefix every extracted finding with the corresponding file name or document identifier.
- Direct Discrepancy Scrutiny: Prompt the model to evaluate whether statements in File B contradict commitments or assertions made in File A.
Optimizing Latency and Cost with Context Caching
Submitting dozens of pages across multiple conversational turns can become computationally expensive if the entire document text is reprocessed on every request. Kimi resolves this through an automated Context Caching engine.
How Kimi Context Caching Operates
Context Caching stores the processed representation of an extensive input prefix on server clusters. When subsequent requests share the identical initial context, Kimi skips reprocessing the prefix and charges a fraction of the standard input rate.
- Fully Automatic Activation: There is no need to manually register cache objects, track cache IDs, or set time-to-live (TTL) configurations.
- Prefix Threshold: Caching engages automatically when the stable initial prompt prefix exceeds 256 tokens. Because any practical document extraction easily surpasses this threshold, document QA workflows benefit immediately.
- Substantial Cost Savings: Prompt tokens that hit the context cache can reduce inference input costs by up to 90%.
- Reduced Time-to-First-Token (TTFT): Average response latency for large-context requests drops to under 5 seconds, as the engine reuses precomputed attention states.
Architectural Rule: Maintain Prefix Stability
To maximize cache hits, the layout of your messages array must remain consistent. Keep the static parts of your prompt—document contents, system personas, and formatting rules—at the beginning of the list, and append conversational turns strictly at the end:
# Fixed document prefix (cached across turns)
base_context = [
*file_messages,
{"role": "system", "content": system_persona},
{"role": "system", "content": "Format all tabular data in GitHub Flavored Markdown."},
]
# Turn 1
conversation = list(base_context)
conversation.append({"role": "user", "content": "What are the total assets listed?"})
turn1_reply = client.chat.completions.create(model="kimi-k3", messages=conversation)
# Turn 2: Preserves original prefix, hits context cache
conversation.append({"role": "assistant", "content": turn1_reply.choices[0].message.content})
conversation.append({"role": "user", "content": "How does that compare to cash reserves?"})
turn2_reply = client.chat.completions.create(model="kimi-k3", messages=conversation)
# Check cache utilization in token usage metadata
usage = turn2_reply.usage
cached_tokens = getattr(usage.prompt_tokens_details, "cached_tokens", 0)
print(f"Total Prompt Tokens: {usage.prompt_tokens}")
print(f"Cached Tokens Reused: {cached_tokens}")
Context Caching Versus Retrieval-Augmented Generation (RAG)
Understanding when to feed raw documents into Kimi's context window versus deploying an external vector RAG architecture is key to balancing operational simplicity and cost:
| Evaluation Dimension | Kimi Long-Context with Context Caching | Traditional Chunk-Based RAG |
|---|---|---|
| Contextual Integrity | Complete holistic context; zero retrieval misses; preserves multi-page tables and cross-chapter dependencies | Prone to chunk-boundary slicing; may miss nuances spread across disparate chapters |
| Engineering Complexity | Minimal: upload text and prompt the model; no embeddings, chunkers, or vector databases | High: requires embedding models, chunking heuristics, vector index tuning, and rerankers |
| Latency Profile | Sub-5-second TTFT once prefix cache is warm; predictable response times | Fast initial retrieval, but latency accumulates across multi-stage search and reranking |
| Cost Dynamics | Up to 90% cheaper on warm prefix; cost-effective for deep, repeated queries on fixed document sets | Lower raw per-query cost across massive document corpora, but overhead in maintaining vector infrastructure |
| Optimal Application | Analyzing targeted document bundles (1 to 50 files, financial audits, legal review, diligence) | Enterprise-wide search across millions of disconnected internal tickets, emails, or wiki pages |
Prompting Best Practices and Output Governance
Achieving reliable results when analyzing hundreds of pages requires disciplined prompt construction, clear answer constraints, and systematic factual verification.
Constraining Answers with Explicit Rules
Unconstrained models can produce overly verbose narratives. You can enforce concise, auditable responses by appending a dedicated rule set to your system prompt:
structured_rules = """
Adhere strictly to these response constraints:
1. Provide a maximum of 5 bullet points.
2. For every assertion or metric, cite the exact source section, page number, or table title.
3. If an answer cannot be deduced directly from the uploaded files, state explicitly: "Information not present in source documents."
4. Do not extrapolate, speculate, or introduce external industry generalities.
"""
governed_messages = [
*file_messages,
{"role": "system", "content": system_persona},
{"role": "system", "content": structured_rules},
{"role": "user", "content": "Summarize the customer churn rate and retention benchmarks."},
]
Verifying High-Stakes Financial and Legal Facts
While Kimi's long-context attention minimizes retrieval hallucinations, mission-critical decisions require systematic verification:
- Traceable Footnotes: Financial metrics frequently carry non-GAAP adjustments or restatements buried in accounting footnotes. Instruct Kimi to identify any explanatory notes tied to reported figures.
- Negative Inquiries: Prompt Kimi to actively check whether mandatory clauses (such as audit rights, data ownership guarantees, or liquidated damage provisions) are omitted from a draft agreement.
- Double-Checking High-Consequence Clauses: For core contract conditions or regulatory compliance attestations, verify Kimi's extracted excerpt against the original document page to confirm that punctuation and surrounding qualifications were accurately interpreted.
Storage and File Lifecycle Management
Uploaded files remain stored under your account to facilitate ongoing extraction and caching, counting against your organization's storage quota (default 10 GiB). Once analysis is complete, clean up ephemeral files to ensure sufficient capacity for future jobs:
# Remove a specific completed file
client.files.delete(file_id=uploaded_file.id)
# Batch cleanup: List and delete all transient extraction files
all_files = client.files.list()
for file_record in all_files.data:
client.files.delete(file_id=file_record.id)
Platform Options, Access Tiers, and Enterprise Privacy
Moonshot AI offers multiple deployment paths and privacy safeguards tailored to individual analysts, developer teams, and regulated organizations.
Choosing Between Consumer Workspaces and Developer APIs
- Kimi Web (
kimi.com/kimi.ai) & Kimi Work: Designed for business professionals seeking an interactive graphical workspace. Includes document upload, conversational Q&A, automatic citation links back to document sections, and native integration with deep research and slide generation tools. - Kimi Membership Subscriptions: Individual subscriptions offering enhanced compute allocation, priority generation during peak hours, and expanded multi-turn session thresholds for power users.
- Kimi API Open Platform (
platform.kimi.com): Pay-as-you-go developer platform charging purely for consumed input, output, and cached tokens. Enables integration into automated back-office pipelines, enterprise ETL jobs, and custom agentic frameworks.
Enterprise Data Protection and Zero Data Retention (ZDR)
For organizations handling sensitive intellectual property, proprietary financial statements, or confidential customer agreements, data exposure is a primary concern:
- Default API Privacy: Data submitted via the Kimi Open Platform API is not used to train Moonshot AI foundation models.
- Zero Data Retention (ZDR) Mode: Enterprise customers can activate ZDR. Under this policy, prompts and model outputs exist in volatile server memory solely during the active inference generation cycle and are immediately expunged once the response is transmitted. No persistent logs of request payloads are retained on platform disks, aligning with rigorous compliance and regulatory data handling standards.
Sources
- Kimi API PDF Q&A and Document Processing Guide
- Kimi API File-Based Question Answering Documentation
- Kimi API File Upload and Parsing Specifications
- Kimi API Automatic Context Caching Overview
- Moonshot AI Zero Data Retention (ZDR) Enterprise Policy
- Kimi Product Plans and Subscription Tiers
- Kimi Membership and Work Platform Overview