LiteLLM กับ Muapi

LiteLLM เรียก API แชตที่รองรับ OpenAI ของ Muapi ได้โดยตรง หรือส่งต่อผ่าน LiteLLM Proxy

เรียกจาก Python โดยตรง

ติดตั้ง LiteLLM แล้วเลือก ID โมเดลข้อความจากรายการ Muapi เปลี่ยน ID ตัวอย่างเป็นโมเดลที่มีอยู่

pip install litellm
export MUAPI_API_KEY="your-key"
import os
from litellm import completion

response = completion(
    model="openai/qwen-3-8-27b-obliterated",
    api_base="https://api.muapi.ai/v1",
    api_key=os.environ["MUAPI_API_KEY"],
    messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)

ตั้งค่า LiteLLM Proxy

สร้าง config.yaml ตามตัวอย่าง แล้วเรียกใช้ proxy เก็บคีย์ Muapi ไว้บนเซิร์ฟเวอร์ อย่าใส่ในไฟล์ YAML

model_list:
  - model_name: muapi-chat
    litellm_params:
      model: openai/qwen-3-8-27b-obliterated
      api_base: https://api.muapi.ai/v1
      api_key: os.environ/MUAPI_API_KEY
export MUAPI_API_KEY="your-key"
litellm --config config.yaml

หมายเหตุ

Muapi ใช้ POST /v1/chat/completions และ api_base คือ https://api.muapi.ai/v1 การเรียกฟังก์ชันใช้ได้เฉพาะโมเดลที่มี capabilities.tools: true วิธีนี้ใช้กับแชต ส่วนการสร้างภาพเป็น API แยก ดูเอกสาร OpenAI-compatible ของ LiteLLM