OpenAI SDK로 Python과 JavaScript에서 Unquant 호출하기
Unquant는 OpenAI 채팅 완성 형식을 지원하므로 공식 SDK가 그대로 작동합니다. 베이스 URL과 키만 변경하고 나머지 코드는 그대로 유지하십시오.
Python
pip install openaiimport os
from openai import OpenAI
client = OpenAI(base_url="https://api.unquant.io/v1", api_key=os.environ["UNQUANT_API_KEY"])
reply = client.chat.completions.create(
model="glm-5.3-flash",
messages=[{"role": "user", "content": "Write a noir opening line."}],
)
print(reply.choices[0].message.content)JavaScript와 TypeScript
npm install openaiimport OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.unquant.io/v1", apiKey: process.env.UNQUANT_API_KEY });
const reply = await client.chat.completions.create({
model: "qwen-3.8-flash-next",
messages: [{ role: "user", content: "Summarise this chapter in three lines." }],
});
console.log(reply.choices[0].message.content);스트리밍
stream = client.chat.completions.create(
model="glm-5.3-flash",
messages=[{"role": "user", "content": "Tell me a long story."}],
stream=True,
stream_options={"include_usage": True},
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)include_usage는 토큰 수가 포함된 최종 청크를 추가합니다. 사용량은 과금되지 않으며 자체 모니터링을 위한 것입니다.
이미지
이미지를 base64 데이터 URL(PNG, JPEG 또는 WebP)로 인라인 전송하십시오. 원격 이미지 URL은 가져오지 않습니다.
import base64
data = base64.b64encode(open("photo.jpg", "rb").read()).decode()
client.chat.completions.create(
model="glm-5.3-flash",
messages=[{"role": "user", "content": [
{"type": "text", "text": "What is in this picture?"},
{"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{data}"}},
]}],
)도구 호출
tools = [{"type": "function", "function": {
"name": "get_weather",
"description": "Current weather for a city",
"parameters": {"type": "object", "properties": {"city": {"type": "string"}}, "required": ["city"]},
}}]
reply = client.chat.completions.create(model="glm-5.3-flash", tools=tools,
messages=[{"role": "user", "content": "Weather in Lisbon?"}])
print(reply.choices[0].message.tool_calls)추론 제어
모든 모델이 답하기 전에 추론하고 reasoning_content에 별도로 추론 내용을 반환합니다. reasoning_effort를 none, low 또는 high로 전달하십시오 (GLM-5.3-Flash와 DeepSeek V4.1 Flash 1017은 max도 허용):
client.chat.completions.create(model="glm-5.3-flash", reasoning_effort="none",
messages=[{"role": "user", "content": "Quick answer: capital of Peru?"}])오류 처리
429
동시 스트림 한도 도달
플랜의 모든 스트림이 사용 중입니다. 요청이 시작되지 않았으므로, 하나가 완료되면 재시도하십시오.
503
일시적으로 사용 불가
잠깐 재시작 중입니다. Retry-After 헤더를 기다린 후 재시도하십시오.
전체 목록은 오류 참조에 있습니다.
계속 읽기
- 무검열·무제한 모델로 Claude Code 사용하기Unquant의 Anthropic 호환 엔드포인트를 통해 GLM-5.3-Flash, Qwen 3.8 Flash Next 또는 DeepSeek V4.1 Flash 1017로 Claude Code를 실행하십시오: 환경 변수 2개, 프록시 없음, 무제한 토큰, 262K 컨텍스트.
- Open WebUI를 Unquant에 연결하기Unquant를 Open WebUI에 OpenAI API 연결로 추가하십시오: URL, 키, 모델 목록. 무검열 GLM-5.3-Flash, Qwen 3.8 Flash Next, DeepSeek V4.1 Flash 1017의 비공개 ChatGPT 스타일 인터페이스.
- 코딩과 에이전트를 위한 무검열 AI개발자들이 코딩과 에이전트에 무검열 모델을 사용하는 이유: 보안 작업, 역공학, 민감한 콘텐츠 파이프라인에서 거부 없음, 그리고 긴 에이전트 루프를 위한 262K 컨텍스트와 무제한 토큰.