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-4, Claude, Gemini, DeepSeek 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, gpt-4.5, gpt-4o, o3, o3-mini, o4-mini, etc.
- 🧠 Anthropic: claude-opus-4-5, claude-sonnet-4-5, claude-opus-4-1, claude-sonnet-4, etc.
- 💎 Google: gemini-3-pro, gemini-3-flash, gemini-2.5-pro, gemini-2.5-flash, etc.
- 🚀 xAI: grok-4, grok-3, etc.
- 🔍 DeepSeek: deepseek-r1, deepseek-v3, etc.
- 🌟 Alibaba: Qwen series models
- 💬 Moonshot: Kimi models, etc.
Feature Support
✅ Supported Features:- 💬 Chat Completions: Chat Completions interface
- 🖼️ Image Generation: gpt-image-1, 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
- 🔧 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:Quick Start
Get API Key
- Visit LaoZhang API Console
- Log in to your account
- Click “Add” on the token management page to create an API Key
- 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:- Go to Token Management Page
- Find the row with the API Key you want to use
- Click the 🔧wrench icon (tool icon) in the “Actions” column
- Select “Request Example” from the pop-up menu
- View complete code examples in the following languages:
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…
- ✅ 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
Basic Information
API Endpoints
- Primary endpoint:
https://api.yelinai.com/v1(Recommended, globally accelerated) - Backup endpoint:
https://api-vip.laozhang.ai/v1(Direct access for overseas servers)
api.yelinai.com 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| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | Model name, e.g., gpt-4o-mini |
| messages | array | Yes | Array of conversation messages |
| temperature | number | No | Sampling temperature, between 0-2, default 1 |
| max_tokens | integer | No | Maximum tokens to generate |
| stream | boolean | No | Whether to return streaming, default false |
| top_p | number | No | Nucleus sampling parameter, between 0-1 |
| n | integer | No | Number of generations, default 1 |
| stop | string/array | No | Stop sequences |
| presence_penalty | number | No | Presence penalty, between -2 to 2 |
| frequency_penalty | number | No | Frequency penalty, between -2 to 2 |
- cURL
- Python (SDK)
- Python (requests)
- Node.js
- Java
- C#
- Go
- PHP
- Ruby
2. Text Completions
Kept for compatibility with legacy interfaces, Chat Completions is recommended. Request Endpoint| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | Model name |
| prompt | string/array | Yes | Prompt text |
| max_tokens | integer | No | Maximum generation length |
| temperature | number | No | Sampling temperature |
| top_p | number | No | Nucleus sampling parameter |
| n | integer | No | Number of generations |
| stream | boolean | No | Streaming output |
| stop | string/array | No | Stop sequences |
3. Embeddings
Convert text to vector representation. Request Endpoint| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | Model name, e.g., text-embedding-ada-002 |
| input | string/array | Yes | Input text |
| encoding_format | string | No | Encoding format, float or base64 |
- cURL
- Python (SDK)
- Python (requests)
- Node.js
4. Images
Generate, edit, or transform images. Generate Images| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | Model name, recommended gpt-image-1 |
| prompt | string | Yes | Image description prompt |
| n | integer | No | Number to generate, default 1 |
| size | string | No | Image size: 1024x1024, 1792x1024, 1024x1792 |
| quality | string | No | Quality: standard or hd |
| style | string | No | Style: vivid or natural |
gpt-image-1 model for image generation. For more image generation features and parameter descriptions, please see GPT Image Generation detailed documentation.
Complete Code Examples
- cURL
- Python (SDK)
- Node.js
5. Audio
Speech recognition and transcription. Transcribe Audio| Parameter | Type | Required | Description |
|---|---|---|---|
| file | file | Yes | Audio file |
| model | string | Yes | Model name, e.g., whisper-1 |
| language | string | No | Language code |
| prompt | string | No | Guidance prompt |
| response_format | string | No | Response format |
| temperature | number | No | Sampling temperature |
6. Model List
Get list of available models. Request EndpointStreaming Responses
Enable Streaming Output
Setstream: true in the request:
Streaming Response Format
Response will be returned in Server-Sent Events (SSE) format:Handling Streaming Responses
- Python
- JavaScript
Error Handling
Error Response Format
Common Error Codes
| Error Code | HTTP Status | Description |
|---|---|---|
| invalid_api_key | 401 | Invalid API key |
| insufficient_quota | 429 | Insufficient quota |
| model_not_found | 404 | Model does not exist |
| invalid_request_error | 400 | Invalid request parameters |
| server_error | 500 | Internal server error |
| rate_limit_exceeded | 429 | Request rate too high |
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
LaoZhang API implements the following rate limits:| Limit Type | Limit Value | Description |
|---|---|---|
| RPM (Requests Per Minute) | 3000 | Per API key |
| TPM (Tokens Per Minute) | 1000000 | Per API key |
| Concurrent Requests | 100 | Simultaneously processed requests |
Need Help?
- Visit LaoZhang API Official Site
- Check Supported Models
- Contact technical support: support@laozhang.ai