Skip to main content

🌟 Before You Start

Get started with LaoZhang API in just 5 minutes. All you need: 1️⃣ Create an account (free trial credits included) 2️⃣ Get your API key (takes 30 seconds) 3️⃣ Change one line of code (replace base URL) This guide will show you how to:
  • ✅ Access 200+ AI models through a single API
  • ✅ Use existing OpenAI SDK with zero code changes
  • ✅ Switch between models with one parameter
  • ✅ Start building immediately with free credits

Step 1: Create Account and Get API Key

📧 Create Account (Free Trial Credits Included)

1

Sign Up

Visit LaoZhang API to create your account🎁 New User Bonus: Free trial credits automatically added upon registration
2

Verify Email

  • Enter your email address
  • Create a secure password (8+ characters)
  • Verify your email via the confirmation link
3

Access Console

Log in to your console dashboardYou’ll see:
  • Account balance with trial credits
  • Usage statistics and history
  • API key management
🎉 Trial Credits: New users receive free credits to test all features. Start building immediately without payment information.

Step 2: Get Your API Key

🔑 Generate Your API Key

  • Use Default Key (Quickest)
  • Create Custom Key
  1. Navigate to Token Management
  2. Locate your Default Token
  3. Click Copy to clipboard
Advantage: Pre-configured and ready to use immediately
Security Best Practices:
  • API keys are shown only once - save securely immediately
  • Never commit keys to version control (use .gitignore)
  • Store keys in environment variables
  • Rotate keys periodically for enhanced security

Step 3: Make Your First API Call

🎯 Test Your Integration

🔧 Integration Configuration

Remember These Three Things

# API Base URL
base_url: https://api.laozhang.ai/v1

# API Key (starts with sk-)
api_key: sk-xxxxxxxxxxxxxx

# Model Name (plug and play)
model: gpt-4.1-mini  # or claude-sonnet-4-20250514, etc.

💻 Complete Examples in Different Languages

  • Python (Most Common)
  • Node.js / TypeScript
  • Curl / Command Line
# Install: pip install openai
from openai import OpenAI

# Initialize client
client = OpenAI(
    api_key="Your API Key",  # Get from LaoZhang API
    base_url="https://api.laozhang.ai/v1"  # Direct connection URL
)

# Examples of calling different models
def test_models():
    models = [
        "gpt-4.1-mini",  # Best value
        "claude-sonnet-4-20250514",  # Best for coding
        "deepseek-v3"  # Best Chinese model
    ]
    
    for model in models:
        try:
            response = client.chat.completions.create(
                model=model,
                messages=[
                    {"role": "system", "content": "You are a helpful AI assistant"},
                    {"role": "user", "content": "Introduce yourself in one sentence"}
                ],
                temperature=0.7,
                max_tokens=100
            )
            print(f"{model}: {response.choices[0].message.content}")
            print(f"Tokens used: {response.usage.total_tokens}\n")
        except Exception as e:
            print(f"{model} call failed: {e}\n")

if __name__ == "__main__":
    test_models()
Best Practice: Store API key in environment variables
import os
client = OpenAI(
    api_key=os.getenv("LAOZHANG_API_KEY"),
    base_url="https://api.laozhang.ai/v1"
)

Next Steps

Congratulations! You’ve successfully integrated LaoZhang API. Next you can:

🔥 Common Questions Quick Reference

Three signs:
  1. ✅ API call returns normal results (no errors)
  2. ✅ Response time under 1 second
  3. ✅ Can see call records in console
View call records: Usage Logs
Choose by scenario:💻 Programming Development:
  • First choice: claude-sonnet-4-20250514
  • Alternative: deepseek-coder-v3
📝 Article Writing:
  • First choice: gpt-4o
  • Alternative: claude-3.5-sonnet
Quick Response:
  • First choice: gpt-4.1-mini
  • Alternative: gemini-2.5-flash
💰 Cost Sensitive:
  • First choice: deepseek-v3
  • Alternative: qwen-max
Immediate actions:
  1. Go to Token Management
  2. Revoke the compromised key immediately
  3. Generate a new API key
  4. Update the key in all your applications
🔒 Prevention measures:
  • Always use environment variables
  • Never hardcode keys in source code
  • Set spending limits per key
  • Rotate keys every 90 days
Options available:
  1. Add credits to your account via the billing page
  2. Switch to more cost-effective models (e.g., gpt-4o-mini, gemini-flash)
  3. Optimize your usage with max_tokens limits
Cost management tips:
  • Monitor usage in the console dashboard
  • Set budget alerts
  • Use streaming for better user experience
Visit the billing page to add credits to your account.Payment options:
  • Credit/debit cards
  • Cryptocurrency (USDT)
  • Wire transfer for enterprise accounts
Enterprise users: Contact [email protected] for invoicing and contract options.
Tip: Save your API key properly and check usage logs in the console regularly. Every request has message history for reasonable cost optimization. Enjoy using LaoZhang API~
I