Base URL 및 인증
API는 다음에서 요청을 받습니다. https://api.qwenapipricing.com/v1. 모든 호출에는 Authorization header. 회원가입 페이지에서 이 키를 생성하며, 이는 선불 크레딧 계정을 식별합니다.
- 인증에 표준 HTTP 헤더를 사용하세요.
- 키는 크레딧이 만료되거나 취소될 때까지 유효합니다.
첫 번째 요청
연결성을 테스트하기 위해 채팅 완료 요청을 전송합니다. 이 간단한 호출은 키가 작동하는지 확인하고 기본 응답을 반환합니다.
이 예제를 사용하여 키가 작동하는지 확인할 수 있습니다.
curl https://api.qwenapipricing.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "list the costs for the qwen2.5 models"}]
}'
Python 통합
서비스와 상호 작용을 위한 공식 OpenAI Python SDK를 사용하세요. 클라이언트를 우리 base URL로 지정하고 키를 제공하세요.
이러한 구성은 OpenAI 엔드포인트를 기대하는 모든 표준 Python 라이브러리와 작동합니다.
from openai import OpenAI
client = OpenAI(base_url="https://api.qwenapipricing.com/v1", api_key="YOUR_KEY")
resp = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Summarise this thread without softening it."}],
)
print(resp.choices[0].message.content)
Node.js 통합
Node 개발자는 다음을 사용할 수 있습니다. openai npm 패키지입니다. base URL을 설정하여 요청을 보내세요.
이 방식은 기존 OpenAI 코드베이스와의 호환성을 유지합니다.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.qwenapipricing.com/v1", apiKey: process.env.API_KEY });
const resp = await client.chat.completions.create({
model: "uncensored",
messages: [{ role: "user", content: "Draft a villain monologue for my game." }],
});
console.log(resp.choices[0].message.content);
스트리밍 응답
stream을 true로 설정하여 스트리밍 활성화 stream: true 요청에 포함됩니다. API는 서버 전송 이벤트를 통해 토큰을 반환합니다.
각 청크에는 마지막 이벤트에 사용 데이터가 포함되어 실시간으로 소비량을 추적할 수 있습니다.
stream = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Tell the story in second person."}],
stream=True,
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
속도 제한 및 오류
각 키는 분당 300개의 요청과 8개의 동시 연결을 허용합니다. 유효하지 않은 키의 경우 401 오류, 크레딧이 고갈된 경우 402 오류, 속도 제한에 도달한 경우 429 오류가 발생합니다. 컨텍스트 창은 총 100,000 토큰을 지원합니다.