Overview
Text Generation (Chat Completions) is one of the core capabilities of LaoZhang API, supporting 200+ popular AI models for intelligent conversations and text generation. Through a unified OpenAI-compatible interface, you can easily implement:- Intelligent Conversations: Build chatbots and virtual assistants
- Content Creation: Article writing, creative generation, copywriting
- Code Assistance: Code generation, debugging, refactoring suggestions
- Knowledge Q&A: Answer questions, knowledge retrieval, information extraction
- Role Playing: Customized AI characters, scenario simulation
Quick Start
Basic Example
Multi-turn Conversation
Core Parameters
model (Required)
Specify the model name. See Model Info for details.messages (Required)
Array of conversation messages withrole and content fields:
system
System prompt defining AI behavior and roleuser
User message representing user inputassistant
Assistant message representing AI responsetemperature (Optional)
Controls output randomness, range0.0 ~ 2.0, default 1.0:
| Range | Characteristics | Use Cases |
|---|---|---|
| 0.0 ~ 0.3 | More deterministic | Translation, summarization, code |
| 0.7 ~ 1.0 | Balanced | Daily conversations |
| 1.0 ~ 2.0 | More creative | Creative writing, brainstorming |
stream (Optional)
Enable streaming output for better user experience:Recommended Models
| Scenario | Recommended Model | Reason |
|---|---|---|
| Daily Chat | gpt-4.1-mini, deepseek-chat | Fast, low cost |
| Complex Reasoning | gpt-5, claude-sonnet-4-20250514 | Powerful, accurate |
| Code Generation | claude-sonnet-4-20250514, deepseek-coder | Excellent coding |
| Long Text | gemini-2.5-pro, claude-3-opus | Ultra-long context |