Skip to main content

Why Choose LaoZhang API?

LaoZhang API is a unified AI API gateway that provides seamless access to 200+ AI models through a single OpenAI-compatible interface. Access GPT-5.6, Claude Sonnet 5, Gemini 3.6 Flash, DeepSeek V4, and more with one API key.

Platform Features

OpenAI Compatible Mode

LaoZhang API uses OpenAI-compatible format, allowing you to easily call GPT, Claude, and 200+ AI models through a unified interface: Supported Model Providers:
  • 🤖 OpenAI: gpt-5.6, gpt-5.6-terra, gpt-5.6-luna, gpt-5.1-codex, etc.
  • 🧠 Anthropic: claude-sonnet-5, claude-opus-4-8, claude-fable-5, etc.
  • 💎 Google: gemini-3.6-flash, gemini-3.5-flash-lite, gemini-3.1-pro-preview, etc.
  • 🚀 xAI: grok-4.5, grok-4.3, Grok 4.20 series, etc.
  • 🔍 DeepSeek: deepseek-v4-pro, deepseek-v4-flash, etc.
  • 🌟 Alibaba: Qwen series models
  • 💬 Moonshot: Kimi models, etc.
Availability depends on the account, token group, and current route. Before production use, confirm the exact model ID, live gateway price, and access status on the console model and pricing page.

Feature Support

✅ Supported Features:
  • 💬 Chat Completions: Chat Completions interface
  • 🖼️ Image Generation: gpt-image-2, flux-kontext-pro, flux-kontext-max, etc.
  • 🔊 Audio Processing: Whisper transcription
  • 📊 Embeddings: Text vectorization
  • Function Calling: Function Calling
  • 📡 Streaming: Real-time responses
  • 🔧 OpenAI Parameters: temperature, top_p, max_tokens, etc.
  • 🆕 Responses Endpoint: Latest OpenAI features
❌ Unsupported Features:
  • 🔧 Fine-tuning interface
  • 📁 Files management interface
  • 🏢 Organization management interface
  • 💳 Billing management interface

Easy Model Switching

Core Advantage: One Codebase, Multiple Models After running with OpenAI format, simply change the model name to switch to other large models:
This design allows you to easily compare different model effects, or flexibly switch models based on cost and performance needs, without rewriting code!

Quick Start

Get API Key

  1. Visit LaoZhang API Console
  2. Log in to your account
  3. Click “Add” on the token management page to create an API Key
  4. Copy the generated API Key for interface calls

View Request Examples

On the token management page, you can quickly get code examples in various programming languages: Steps:
  1. Go to Token Management Page
  2. Find the row with the API Key you want to use
  3. Click the 🔧wrench icon (tool icon) in the “Actions” column
  4. Select “Request Example” from the pop-up menu
  5. View complete code examples in the following languages:
LaoZhang API Token Management Interface Supported Programming Languages:
  • cURL - Command-line testing
  • Python (SDK) - Using official OpenAI library
  • Python (requests) - Using requests library
  • Node.js - JavaScript/TypeScript
  • Java - Java application development
  • C# - .NET application development
  • Go - Go language development
  • PHP - Web development
  • Ruby - Ruby application development
  • And more languages…
Code Example Features:
  • Complete and runnable: Copy and paste to use
  • Parameter descriptions: Detailed parameter configuration
  • Error handling: Includes exception handling logic
  • Best practices: Follows development standards for each language
Developers are encouraged to check the backend request examples first. These examples are updated in real-time based on the latest API versions, ensuring code accuracy and usability.

Basic Information

API Endpoints

  • Primary endpoint: https://api2.laozhang.ai/v1 (Recommended, globally accelerated)
  • Backup endpoint: https://api-vip.laozhang.ai/v1 (Direct access for overseas servers)
api2.laozhang.ai is configured with globally accelerated bandwidth nodes, recommended for primary use. api-vip.laozhang.ai is a backup domain suitable for direct connection from overseas servers. Switch back to the primary domain if you experience instability.

Authentication Method

All API requests need to include authentication information in the Header:

Request Format

  • Content-Type: application/json
  • Encoding: UTF-8
  • Request Method: POST (for most interfaces)

Core Interfaces

1. Chat Completions

Create a chat completion request, supports multi-turn conversations. Request Endpoint
Request Parameters Message Format
Complete Code Examples
Response Example

2. Text Completions

Kept for compatibility with legacy interfaces, Chat Completions is recommended. Request Endpoint
Request Parameters

3. Embeddings

Convert text to vector representation. Request Endpoint
Request Parameters Complete Code Examples

4. Images

Generate, edit, or transform images. Generate Images
Request Parameters
Recommended to use gpt-image-2 model for image generation. For more image generation features and parameter descriptions, please see GPT Image Generation detailed documentation.
Complete Code Examples

5. Audio

Speech recognition and transcription. Transcribe Audio
Request Parameters (Form-Data)

6. Model List

Get list of available models. Request Endpoint
Response Example

Streaming Responses

Enable Streaming Output

Set stream: true in the request:

Streaming Response Format

Response will be returned in Server-Sent Events (SSE) format:

Handling Streaming Responses

Error Handling

Error Response Format

Common Error Codes

Error Handling Example

Best Practices

1. Request Optimization

  • Set max_tokens reasonably: Avoid unnecessarily long outputs
  • Use temperature: Control output randomness
  • Batch processing: Combine multiple requests to reduce call count

2. Error Retry

Implement exponential backoff retry mechanism:

3. Security Recommendations

  • Protect API keys: Store in environment variables
  • Limit permissions: Create different keys for different applications
  • Monitor usage: Regularly check API usage logs

4. Performance Optimization

  • Use streaming output: Improve user experience
  • Cache responses: Cache results for identical requests
  • Concurrency control: Reasonably control concurrent request count

Rate Limits

RPM, TPM, and concurrency limits vary by model, token group, route, and account configuration; there is no single fixed limit for every request. Confirm the current limit in the console and increase production traffic gradually. Requests above the active limit usually return 429. Read the error details, use bounded exponential backoff, and do not retry indefinitely before confirming model access and account credit.

Need Help?

This manual is continuously updated. Please follow the latest version for new features and improvements.