> ## Documentation Index
> Fetch the complete documentation index at: https://docs.yelinai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# API Integration Quick Start

> Complete setup guide for integrating LaoZhang API with ChatGPT, Claude, Gemini models. OpenAI SDK compatible - just change base URL. Python/Node.js examples. Start in 5 minutes.

## Before You Start

**Account Usage Notice**Account registration is for **API technical integration testing and enterprise system integration**. The test credits (\$0.5) provided to new accounts are only for:

* API connectivity verification
* Development debugging and technical testing
* Pre-integration functionality verification

**Not intended for** production environments or public-facing content delivery services.

Get started with LaoZhang API in just 5 minutes. This guide shows how to:

* Access 200+ AI models through a single unified API
* Use existing OpenAI SDK with minimal code changes
* Integrate with flexible payment options

## Step 1: Create Account and Add Credits

### Create Account

1

Sign Up

Visit [LaoZhang API](https://api.yelinai.com/register) to create your accountNew accounts receive \$0.5 test credits for API connectivity verification

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 dashboard](https://api.yelinai.com/account/profile)You’ll see:

* Account balance with test credits
* Usage statistics and history
* API key management

### Add Credits

* Online Payment
* Cryptocurrency (USDT)
* Enterprise

1. Navigate to [billing page](https://api.yelinai.com/topup)
2. Select your preferred amount
3. Complete payment
4. Credits available instantly

We support USDT payments on multiple networks:

* TRC20 (TRON)
* Solana
* Other major chains

Contact support for wallet addresses: [hi@yelinai.com](mailto:hi@yelinai.com)

**Enterprise Exclusive Service**:

* Volume discounts
* Invoice support
* Contract options
* Dedicated support

Contact: [hi@yelinai.com](mailto:hi@yelinai.com)

**Credit Information**:

* Test credits for connectivity verification
* Instant credit delivery after payment
* Enterprise inquiries: [hi@yelinai.com](mailto:hi@yelinai.com)

## Step 2: Get Your API Key

### Generate Your API Key

* Use Default Key (Quickest)
* Create Custom Key

1. Navigate to [Token Management](https://api.yelinai.com/token)
2. Locate your **Default Token**
3. Click **Copy** to clipboard

**Advantage**: Pre-configured and ready to use immediately

1. Click **Create New Token** button
2. Name your key (e.g., `production-api`, `development-test`)
3. Optionally set spending limits for budget control
4. Click **Generate**

**Advantage**: Better organization for multiple projects or environments

**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

* Online Playground (Recommended)
* cURL Command

Test instantly in the [API Playground](https://api.yelinai.com/playground):

1. Select a model (e.g., `gpt-4o-mini`)
2. Enter a test prompt: “Hello, introduce yourself”
3. Click **Send**

**No code required** - verify your setup works before integrating

```
# Replace YOUR_API_KEY with your actual key
curl -X POST https://api.yelinai.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [
      {"role": "system", "content": "You are a helpful AI assistant"},
      {"role": "user", "content": "What can you help me with?"}
    ]
  }'
```

**Typical response time**: \< 500ms

### Integration Configuration

## Remember These Three Things

```
# API Base URL
base_url: https://api.yelinai.com/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.yelinai.com/v1"  # Integration 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.yelinai.com/v1"
)
```

```
// Install: npm install openai
import OpenAI from 'openai';

// Initialize client
const client = new OpenAI({
  apiKey: process.env.LAOZHANG_API_KEY || 'Your API Key',
  baseURL: 'https://api.yelinai.com/v1'
});

// Streaming output example (real-time response)
async function streamChat() {
  const stream = await client.chat.completions.create({
    model: 'gpt-4.1-mini',
    messages: [
      { role: 'system', content: 'You are a helpful AI assistant' },
      { role: 'user', content: 'Please write a simple React component' }
    ],
    stream: true,  // Enable streaming
    temperature: 0.7
  });

  // Output word by word
  for await (const chunk of stream) {
    process.stdout.write(chunk.choices[0]?.delta?.content || '');
  }
}

// Concurrent calls to multiple models
async function compareModels(prompt) {
  const models = ['gpt-4.1', 'claude-sonnet-4-20250514', 'gemini-2.5-pro'];

  const promises = models.map(model =>
    client.chat.completions.create({
      model,
      messages: [{ role: 'user', content: prompt }],
      max_tokens: 100
    })
  );

  const results = await Promise.all(promises);
  results.forEach((result, index) => {
    console.log(`\n\`$\{models[index]}:\n\`$\{result.choices[0].message.content}`);
  });
}

// Run examples
streamChat().catch(console.error);
```

```
# Basic call
curl -X POST https://api.yelinai.com/v1/chat/completions -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" -d '{"model": "gpt-4.1-mini", "messages": [{"role": "user", "content": "Hello"}]}'

# Streaming output (SSE)
curl -X POST https://api.yelinai.com/v1/chat/completions -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" -d '{"model": "gpt-4.1", "messages": [{"role": "user", "content": "Write a Python quicksort"}], "stream": true}'

# Image generation
curl -X POST https://api.yelinai.com/v1/images/generations -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" -d '{"model": "gpt-4o-image", "prompt": "A cute kitten", "n": 1, "size": "1024x1024"}'
```

## Next Steps

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

## View API Documentation

Learn about complete API interface documentation

## Explore Model List

View all supported AI models

## Integrate into Apps

Integrate LaoZhang API into various tools

## View Usage Statistics

Monitor usage in console

## Common Questions Quick Reference

How to tell if integration is successful?

**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](https://api.yelinai.com/log)

How to choose the right model?

**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`

What if my API key is leaked?

**Immediate actions**:

1. Go to [Token Management](https://api.yelinai.com/token)
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

What happens when credits run out?

**Options available**:

1. Add credits to your account via the [billing page](https://api.yelinai.com/topup)
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

What payment methods are supported?

**Payment options**:

* Credit/debit cards
* Cryptocurrency (USDT on TRC20, Solana)
* Wire transfer for enterprise accounts

**Enterprise users**: Contact [hi@yelinai.com](mailto:hi@yelinai.com) 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.
