Login
Back to Blog
คู่มือเริ่มต้นใช้งาน CrazyRouter API อย่างรวดเร็ว

คู่มือเริ่มต้นใช้งาน CrazyRouter API อย่างรวดเร็ว

C
Crazyrouter Team
January 22, 2026
8 viewsไทย
Share:

ยินดีต้อนรับสู่ Crazyrouter! คู่มือนี้จะช่วยให้คุณเชื่อมต่อกับ API ได้ภายใน 5 นาที และเริ่มใช้งานโมเดล AI ชั้นนำระดับโลก

ทำไมต้องเลือก Crazyrouter?#

  • อินเทอร์เฟซแบบรวมศูนย์: ใช้ API Key เดียวเพื่อเข้าถึงโมเดล AI กว่า 300+ รายการ
  • รองรับมาตรฐาน OpenAI: ไม่ต้องแก้ไขโค้ด เพียงแค่เปลี่ยน base_url ก็ใช้งานได้ทันที
  • ราคาถูกกว่า: ถูกกว่าราคาทางการ คิดค่าบริการตามการใช้งานจริง ไม่มีค่าสมาชิกรายเดือน
  • ความพร้อมใช้งานสูง: ระบบ routing อัจฉริยะ พร้อมสลับเส้นทางอัตโนมัติเมื่อเกิดปัญหา

1. รับ API Key#

  1. เข้าไปที่ Crazyrouter เว็บไซต์หลัก
  2. สมัครสมาชิกและล็อกอินเข้าสู่ คอนโซล
  3. เข้าเมนูหน้า "การจัดการโทเคน"
  4. คลิก "สร้างโทเคน"
  5. คัดลอก API Key ที่สร้างขึ้น (ขึ้นต้นด้วย sk-)

หมายเหตุ: โปรดเก็บรักษา API Key ของคุณให้ปลอดภัย และอย่าเปิดเผยในที่สาธารณะ

2. ส่งคำขอครั้งแรก#

ใช้ curl#

bash
curl https://crazyrouter.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" \
  -d '{
    "model": "gpt-5.2",
    "messages": [{"role": "user", "content": "Hello, how are you?"}],
    "temperature": 0.7
  }'

ใช้ Python (แนะนำ)#

python
from openai import OpenAI

client = OpenAI(
    api_key="sk-your-api-key",
    base_url="https://crazyrouter.com/v1"
,
    default_headers={
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
    }
)

response = client.chat.completions.create(
    model="gpt-5.2",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Hello, how are you?"}
    ],
    temperature=0.7,
    max_tokens=1000
)

print(response.choices[0].message.content)

ใช้ Node.js#

javascript
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: 'sk-your-api-key',
  baseURL: 'https://crazyrouter.com/v1'
});

async function main() {
  const response = await client.chat.completions.create({
    model: 'gpt-5.2',
    messages: [
      { role: 'system', content: 'You are a helpful assistant.' },
      { role: 'user', content: 'Hello,Please introduce yourself' }
    ],
    temperature: 0.7
  });

  console.log(response.choices[0].message.content);
}

main();

การสตรีมผลลัพธ์ (Streaming)#

python
from openai import OpenAI

client = OpenAI(
    api_key="sk-your-api-key",
    base_url="https://crazyrouter.com/v1"
,
    default_headers={
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
    }
)

stream = client.chat.completions.create(
    model="gpt-5.2",
    messages=[{"role": "user", "content": "Write a poem about spring"}],
    stream=True
)

for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)

3. โมเดลที่รองรับ#

Crazyrouter รองรับโมเดล AI มากกว่า 300+ ตัว ด้านล่างคือบางส่วนของโมเดลยอดนิยม:

ผู้ให้บริการตัวอย่างโมเดลจุดเด่น
OpenAIgpt-5.2, gpt-5, gpt-4o, o3-pro, o3-miniความสามารถรอบด้าน รองรับมัลติโหมด
Anthropicclaude-opus-4.5, claude-4, claude-sonnet-4บริบทยาว ความสามารถด้านโค้ดสูง
Googlegemini-3.0-pro, gemini-3-flash, gemini-2.5-proมัลติโหมด ความสามารถด้านการให้เหตุผลสูง
xAIgrok-3, grok-3-mini, grok-3-visionข้อมูลเรียลไทม์ การค้นหาเชิงลึก
DeepSeekdeepseek-r1, deepseek-v3คุ้มค่าเด่น เรื่องภาษาจีนทำได้ดี

ดูรายการโมเดลทั้งหมดได้ที่: โมเดลสแควร์

4. คำอธิบายพารามิเตอร์ที่ใช้บ่อย#

พารามิเตอร์ชนิดคำอธิบาย
modelstringชื่อโมเดล เช่น gpt-5.2
messagesarrayรายการข้อความในการสนทนา
temperaturenumberระดับความสุ่ม 0-2 ค่าเริ่มต้นคือ 1
max_tokensintegerจำนวน token สูงสุดที่ให้โมเดลตอบกลับ
streambooleanเปิด/ปิด การสตรีมผลลัพธ์
top_pnumberค่าพารามิเตอร์ nucleus sampling ช่วง 0-1

5. การจัดการข้อผิดพลาด#

python
from openai import OpenAI, APIError, RateLimitError

client = OpenAI(
    api_key="sk-your-api-key",
    base_url="https://crazyrouter.com/v1"
,
    default_headers={
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
    }
)

try:
    response = client.chat.completions.create(
        model="gpt-5.2",
        messages=[{"role": "user", "content": "Hello!"}]
    )
except RateLimitError:
    print("请求过于频繁,请稍后重试")
except APIError as e:
    print(f"API 错误: {e}")

6. ขั้นตอนถัดไป#

  • ดู ราคาโมเดล เพื่อทำความเข้าใจค่าบริการของแต่ละโมเดล
  • เข้า คอนโซล เพื่อจัดการบัญชีของคุณ
  • อ่าน เอกสาร API เพื่อเรียนรู้ฟังก์ชันเพิ่มเติม
  • เข้าร่วม ชุมชน Discord เพื่อขอความช่วยเหลือ

Related Articles

คู่มือผู้ใช้ Gemini CLI - Google AI ในเทอร์มินัลของคุณTutorial

คู่มือผู้ใช้ Gemini CLI - Google AI ในเทอร์มินัลของคุณ

คู่มือฉบับสมบูรณ์สำหรับการติดตั้งและตั้งค่า Gemini CLI เครื่องมือ AI แบบบรรทัดคำสั่งโอเพ่นซอร์สของ Google เรียนรู้วิธีตั้งค่า proxy ใช้งานเครื่องมือในตัว และ...

Jan 24
Doubao Seed Code: โมเดลสร้างโค้ดด้วย AI ของ ByteDance - คู่มือ API ฉบับสมบูรณ์Tutorial

Doubao Seed Code: โมเดลสร้างโค้ดด้วย AI ของ ByteDance - คู่มือ API ฉบับสมบูรณ์

เรียนรู้การใช้งาน Doubao Seed Code โมเดล AI สร้างโค้ดอันทรงพลังของ ByteDance คู่มือ API ฉบับสมบูรณ์พร้อมตัวอย่างโค้ด Python, Node.js และเปรียบเทียบราคา

Jan 26
สุดยอดเครื่องมือสร้างเพลงด้วย AI ปี 2026: เปรียบเทียบ Suno, Udio และ Stable AudioTutorial

สุดยอดเครื่องมือสร้างเพลงด้วย AI ปี 2026: เปรียบเทียบ Suno, Udio และ Stable Audio

การเลือกเครื่องมือสร้างเพลงด้วย AI ที่เหมาะสมอาจชวนปวดหัว บทความนี้เปรียบเทียบเครื่องมือสร้างเพลงด้วย AI ชั้นนำในปี 2026 อย่าง Suno AI, Udio และ Stable Audio พร้อมข้อมูลราคาและการเข้าถึง API จริง

Jan 23