Skip to main content

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
Supports GPT-5, Claude 4, Gemini 2.5, DeepSeek, Qwen and 200+ mainstream models with a single API Key.

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 with role and content fields:

system

System prompt defining AI behavior and role

user

User message representing user input

assistant

Assistant message representing AI response

temperature (Optional)

Controls output randomness, range 0.0 ~ 2.0, default 1.0:

stream (Optional)

Enable streaming output for better user experience:

Best Practices

Optimize Prompts

Error Handling

Model Info

View all supported models

Text Embedding

Convert text to vectors

API Reference

Detailed API reference

OpenAI SDK

Quick integration with OpenAI SDK