<!-- GENERATED BY scripts/gen_localization_release.py; DO NOT EDIT; source: th/guides/litellm/index.html -->

# ใช้ LiteLLM ร่วมกับโมเดล AI ของจีนผ่านทาง ChinaAPI

> ตั้งค่าพร็อกซี LiteLLM และ SDK กับ ChinaAPI's OpenAI-compatible endpoint for DeepSeek, Kimi, Qwen, GLM, and MiniMax models.

- Canonical page: https://chinaapi.ai/th/guides/litellm/
- Human-readable page: https://chinaapi.ai/th/guides/litellm/
- Live pricing: https://dash.chinaapi.ai/pricing?lang=th&utm_source=chinaapi&utm_medium=markdown&utm_campaign=litellm

เพิ่ม ChinaAPI เป็น OpenAI-compatible แบ็กเอนด์ใน LiteLLM พร็อกซีหรือ Python SDK จากนั้นกำหนดเส้นทางแอปพลิเคชันไปยังรุ่นจีนราคาทางการด้วยคีย์เดียว

[เริ่มใช้งานฟรี — รับเครดิต $2](https://dash.chinaapi.ai/register?lang=th&utm_source=chinaapi&utm_medium=web&utm_campaign=guide-litellm)

[การกำหนดราคาโมเดลสด](https://dash.chinaapi.ai/pricing?lang=th&utm_source=chinaapi&utm_medium=web&utm_campaign=guide-litellm)

## ก่อนแก้ไขไฟล์การตั้งค่า

### ติดตั้ง LiteLLM แล้ว

ใช้พร็อกซีเซิร์ฟเวอร์ LiteLLM หรือ Python SDK อย่างใดอย่างหนึ่งก็ได้

### จุดเชื่อมต่อ ChinaAPI

Base URL `https://api.chinaapi.ai/v1`API keys จะถูกสร้างขึ้นภายใต้ แดชบอร์ด -> คอนโซล -> โทเค็น

## ใช้ `openai /<model>` รายการใน `config.yaml`.

```
model_list:
  - model_name: deepseek-fast
    litellm_params:
      model: openai/deepseek-v4-flash
      api_base: https://api.chinaapi.ai/v1
      api_key: os.environ/CHINAAPI_API_KEY

  - model_name: kimi-code
    litellm_params:
      model: openai/kimi-k2.7-code
      api_base: https://api.chinaapi.ai/v1
      api_key: os.environ/CHINAAPI_API_KEY

  - model_name: qwen-max
    litellm_params:
      model: openai/qwen3.7-max
      api_base: https://api.chinaapi.ai/v1
      api_key: os.environ/CHINAAPI_API_KEY
```

```
export CHINAAPI_API_KEY="sk-..."
litellm --config config.yaml --port 4000
```

## เรียกใช้ ChinaAPI โดยตรงจาก LiteLLM

```
import os
from litellm import completion

response = completion(
    model="openai/deepseek-v4-flash",
    api_base="https://api.chinaapi.ai/v1",
    api_key=os.environ["CHINAAPI_API_KEY"],
    messages=[{"role": "user", "content": "Say LiteLLM is connected to ChinaAPI."}],
    stream=True,
)

for chunk in response:
    print(chunk, end="")
```

## เส้นทาง LiteLLM ที่ดี

สำหรับรายละเอียดรุ่นปัจจุบันและหลักฐานอัตรา โปรดตรวจสอบ [DeepSeek-V4](https://chinaapi.ai/th/models/deepseek-v4-flash/) และ [Kimi K2.7](https://chinaapi.ai/th/models/kimi-k2.7-code/) ก่อนกำหนดเส้นทางการผลิต

### `deepseek-v4-flash`

เส้นทางสำรองที่รวดเร็วสำหรับการแชท ความช่วยเหลือด้านการเขียนโค้ด และการติดต่อกับเจ้าหน้าที่

### `kimi-k2.7-code`

เส้นทางการเขียนโค้ดที่ดีสำหรับงานระดับคลังเก็บข้อมูลและการทำงานที่ใช้เวลานาน

### `qwen3.7-max`

เส้นทางที่เน้นการใช้เหตุผลเมื่อคุณภาพมีความสำคัญมากกว่าความเร็วในการตอบสนอง

### `glm-5.2`

เส้นทางการเข้าถึงข้อมูลระยะยาวสำหรับเอกสารและโค้ดเบสขนาดใหญ่

### `MiniMax-M3`

การเข้ารหัสแบบหลายรูปแบบและแบบจำลองบริบทระยะยาวสำหรับการกำหนดเส้นทางสำรอง

## ปัญหาทั่วไปของการใช้ LiteLLM

รูปแบบความคิด เช่น `qwen3.7-max` สามารถสร้างโทเค็นการให้เหตุผลก่อนเอาต์พุตสุดท้ายได้ ใช้การสตรีมในไคลเอ็นต์ที่อยู่เบื้องหลัง LiteLLM หรือเพิ่มเวลาหมดอายุของอัปสตรีม/ไคลเอ็นต์

**ไม่พบรุ่น:** ตรวจสอบ model ID ที่แน่นอนบน [ราคาแบบเรียลไทม์](https://dash.chinaapi.ai/pricing?lang=th&utm_source=chinaapi&utm_medium=web&utm_campaign=guide-litellm)จากนั้นอัปเดต `litellm_params .โมเดล`เก็บไว้ `openai /` คำนำหน้าสำหรับการกำหนดเส้นทาง OpenAI-compatible

**401 :** ยืนยัน `CHINAAPI_API_KEY` แก้ไขเป็น `สก-...` คีย์และ LiteLLM กำลังส่งผ่านเป็นผู้ให้บริการ API key

## ใช้การกำหนดราคาโทเค็นที่ซิงโครไนซ์กับเกตเวย์เบื้องหลังเกตเวย์ LiteLLM ของคุณ

อัตราค่าบริการอาจเป็นไปตามราคาอย่างเป็นทางการของผู้ให้บริการในประเทศจีน หากมีการตั้งค่าไว้ ลงทะเบียนเพื่อรับเครดิตฟรี $2 จากนั้นตรวจสอบราคาจริงก่อนส่งทราฟฟิกใช้งานจริง

[ลงทะเบียน — รับเครดิต $2](https://dash.chinaapi.ai/register?lang=th&utm_source=chinaapi&utm_medium=web&utm_campaign=guide-litellm)

[ราคาแบบเรียลไทม์](https://dash.chinaapi.ai/pricing?lang=th&utm_source=chinaapi&utm_medium=web&utm_campaign=guide-litellm)

---

Markdown twin of https://chinaapi.ai/th/guides/litellm/ — generated from its canonical HTML by scripts/gen_localization_release.py. Full site reference: https://chinaapi.ai/llms-full.txt
