Knowledge base
Advanced guide
Processing long text
Current mainstream models have substantial context windows. Among models offered by the platform, claude-sonnet-5 has 1M, gpt-5.6-sol has 1.05M and kimi-k3 has 1M. Even so, putting very long text into a single context increases cost and latency and can cause information in the middle to be overlooked. Common strategies:
- Chunking: Split a long document into semantically complete segments and process them separately.
- Recursive summarization (Map-Reduce): Summarize each chunk first, then combine the summaries into an overall conclusion.
- Sliding windows: Keep some overlap between neighboring chunks to avoid losing boundary information.
- Retrieval augmentation (RAG): Retrieve and send only the segments relevant to the question, balancing cost and quality.
Practical guidance: chunks often range from a few hundred to two thousand tokens, with roughly 10–20% overlap. Prefer retrieval when it can solve the task; choose a long-context model such as kimi-k3, glm-5.2 when global understanding is truly needed.
Multimodal interaction
Multimodal interaction combines text, images, audio and other input types in a request. Among models offered by the platform, image understanding can use claude-sonnet-5, gpt-5.6-sol and others. Refer to the Model Catalog (Models in the console) for video and audio understanding or realtime voice conversation models.
Typical vision uses include OCR, document and table analysis, chart interpretation, code-screenshot analysis and product-design reviews. Control image resolution and file size by compressing before upload, and account for privacy and copyright concerns.
Security
Treat security as seriously as functionality when building LLM applications. Common risks:
- Prompt injection: An attacker embeds instructions in user input or external content to divert the model from its intended behavior.
- Data leakage: Sensitive information leaves the system through prompts or remains in logs.
- Harmful content: The model is induced to generate prohibited content.
- Usage abuse: Malicious API calls create extra charges.
Defenses include validating and cleaning user input, separating system instructions from user content, filtering output (optionally with /v1/moderations), rate-limiting endpoints, improving logs and alerts, and following applicable regional data requirements.
Engineering practices
Performance tuning
Track four key metrics: time to first token (TTFT), total latency, throughput (QPS) and output tokens per second. Common improvements include selecting models by task difficulty (lightweight models such as deepseek-v4-flash for simple tasks), enabling streaming, using appropriate concurrency and connection reuse, caching frequent repeated requests and shortening prompts.
Streaming output
Set stream: true to receive SSE chunks with much lower time to first token. Users can read while content is generated and cancel partway through. Enable streaming by default for chat products, with interruption recovery and resource cleanup.
Error handling and retries
Retry temporary errors such as 429, 500 and 503 with exponential backoff, a maximum retry count and request timeouts. Fix deterministic errors such as 400 and 401 instead of retrying them. Prepare fallbacks such as an alternative model, a cached result or a friendly static message. Rate limits vary by route; see the Model Catalog's route information.
Monitoring and logs
Use structured JSON logs with trace IDs and mask sensitive data. Monitor performance (latency and throughput), availability (success and error rates), cost (tokens and spending) and quality (user feedback). Configure separate alert thresholds for errors, latency and cost to detect problems before users report them.
Ecosystem tools
LangChain
LangChain is an open-source framework for LLM applications, with model wrappers, prompt templates, LCEL chains, agents, memory and retrievers. It helps build RAG and multi-step workflows quickly. The platform is OpenAI compatible; point base_url to the platform:
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="deepseek-v4-flash",
api_key="YOUR_API_KEY",
base_url="https://api.yomiapi.com/v1",
)
print(llm.invoke("Hello").content)
Hugging Face
Hugging Face is a major open-source model community and hosting platform. Core products include its model and dataset Hub, Transformers library, PEFT fine-tuning tools and Spaces demo hosting. Self-hosted models often use vLLM or Text Generation Inference for serving. Open-source embedding models such as BAAI/bge-m3 are also commonly combined with the platform's generation endpoints for RAG.
