
คู่มือเริ่มต้นใช้งาน CrazyRouter API อย่างรวดเร็ว
ยินดีต้อนรับสู่ Crazyrouter! คู่มือนี้จะช่วยให้คุณเชื่อมต่อกับ API ได้ภายใน 5 นาที และเริ่มใช้งานโมเดล AI ชั้นนำระดับโลก
ทำไมต้องเลือก Crazyrouter?#
- อินเทอร์เฟซแบบรวมศูนย์: ใช้ API Key เดียวเพื่อเข้าถึงโมเดล AI กว่า 300+ รายการ
- รองรับมาตรฐาน OpenAI: ไม่ต้องแก้ไขโค้ด เพียงแค่เปลี่ยน base_url ก็ใช้งานได้ทันที
- ราคาถูกกว่า: ถูกกว่าราคาทางการ คิดค่าบริการตามการใช้งานจริง ไม่มีค่าสมาชิกรายเดือน
- ความพร้อมใช้งานสูง: ระบบ routing อัจฉริยะ พร้อมสลับเส้นทางอัตโนมัติเมื่อเกิดปัญหา
1. รับ API Key#
- เข้าไปที่ Crazyrouter เว็บไซต์หลัก
- สมัครสมาชิกและล็อกอินเข้าสู่ คอนโซล
- เข้าเมนูหน้า "การจัดการโทเคน"
- คลิก "สร้างโทเคน"
- คัดลอก API Key ที่สร้างขึ้น (ขึ้นต้นด้วย
sk-)
หมายเหตุ: โปรดเก็บรักษา API Key ของคุณให้ปลอดภัย และอย่าเปิดเผยในที่สาธารณะ
2. ส่งคำขอครั้งแรก#
ใช้ curl#
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 (แนะนำ)#
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#
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)#
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+ ตัว ด้านล่างคือบางส่วนของโมเดลยอดนิยม:
| ผู้ให้บริการ | ตัวอย่างโมเดล | จุดเด่น |
|---|---|---|
| OpenAI | gpt-5.2, gpt-5, gpt-4o, o3-pro, o3-mini | ความสามารถรอบด้าน รองรับมัลติโหมด |
| Anthropic | claude-opus-4.5, claude-4, claude-sonnet-4 | บริบทยาว ความสามารถด้านโค้ดสูง |
| gemini-3.0-pro, gemini-3-flash, gemini-2.5-pro | มัลติโหมด ความสามารถด้านการให้เหตุผลสูง | |
| xAI | grok-3, grok-3-mini, grok-3-vision | ข้อมูลเรียลไทม์ การค้นหาเชิงลึก |
| DeepSeek | deepseek-r1, deepseek-v3 | คุ้มค่าเด่น เรื่องภาษาจีนทำได้ดี |
ดูรายการโมเดลทั้งหมดได้ที่: โมเดลสแควร์
4. คำอธิบายพารามิเตอร์ที่ใช้บ่อย#
| พารามิเตอร์ | ชนิด | คำอธิบาย |
|---|---|---|
model | string | ชื่อโมเดล เช่น gpt-5.2 |
messages | array | รายการข้อความในการสนทนา |
temperature | number | ระดับความสุ่ม 0-2 ค่าเริ่มต้นคือ 1 |
max_tokens | integer | จำนวน token สูงสุดที่ให้โมเดลตอบกลับ |
stream | boolean | เปิด/ปิด การสตรีมผลลัพธ์ |
top_p | number | ค่าพารามิเตอร์ nucleus sampling ช่วง 0-1 |
5. การจัดการข้อผิดพลาด#
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 เพื่อขอความช่วยเหลือ


