블로그
Tutorials1 분 읽기

Kimi API Long Context Guide: Moonshot AI for Document Processing

Introduction

Kimi by Moonshot AI specializes in processing extremely long documents with its 128K context window. Through AI API Hub, access Kimi via the standard OpenAI-compatible endpoint at just $0.30/1M input tokens.

Setup

import openai
client = openai.OpenAI(api_key="your-api-key", base_url="https://api.apiyihe.org/v1")
response = client.chat.completions.create(
    model="moonshot-v1-128k",
    messages=[{"role": "user", "content": "Summarize this document..."}],
    max_tokens=1000
)

Document Q&A

with open("legal-contract.txt") as f:
    document = f.read()

response = client.chat.completions.create(
    model="moonshot-v1-128k",
    messages=[{
        "role": "user",
        "content": f"Read this contract and identify any unusual clauses:\n\n{document}"
    }],
    max_tokens=2000
)

Multi-Document Analysis

files = ["contract.txt", "amendment.txt", "appendix.txt"]
combined = "\n\n---\n\n".join(open(f).read() for f in files)

response = client.chat.completions.create(
    model="moonshot-v1-128k",
    messages=[{"role": "user", "content": f"Cross-reference these documents for inconsistencies:\n{combined}"}],
    max_tokens=3000
)

FAQ

Q: What's the maximum document size? A: 128K tokens (~200 pages of text). Q: Is Kimi good for legal documents? A: Yes, the long context makes it ideal for contract review. Q: Can I stream Kimi responses? A: Yes, through the OpenAI-compatible streaming API.

Get Your API Key Now

Start building with 50+ AI models through one unified gateway.

계정 만들기
API 키 받기