연동 문서
OpenAI 방식 그대로 쓰면 돼요
OpenAI용 프로그램·라이브러리에 주소(Base URL)와 API 키만 바꿔 넣으면 됩니다. 모델 이름은 대시보드의 '지원 모델' 표에서 복사하세요.
기본 정보
| Base URL | |
|---|---|
| 인증 | Authorization: Bearer gk-… (또는 x-api-key 헤더) |
| 대화 | POST /v1/chat/completions stream 가능 |
| 모델 목록·단가 | GET /v1/models |
| 클로드 전용 | POST /v1/messages (Anthropic 형식, 클로드 모델만) |
curl
curl /chat/completions \
-H "Authorization: Bearer $GUDOK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"모델이름","messages":[{"role":"user","content":"안녕!"}]}'Python (openai 라이브러리)
from openai import OpenAI
client = OpenAI(base_url="", api_key="gk-...")
r = client.chat.completions.create(
model="모델이름",
messages=[{"role": "user", "content": "안녕!"}],
)
print(r.choices[0].message.content)Node.js
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "", apiKey: "gk-..." });
const stream = await client.chat.completions.create({
model: "모델이름", stream: true,
messages: [{ role: "user", content: "안녕!" }],
});
for await (const c of stream) process.stdout.write(c.choices[0]?.delta?.content ?? "");Anthropic 형식 (클로드 모델)
Anthropic 라이브러리나 Anthropic 형식을 쓰는 도구는 주소 끝의 /v1 을 빼고 넣으세요.
import anthropic
client = anthropic.Anthropic(base_url="", api_key="gk-...")
msg = client.messages.create(model="클로드모델이름", max_tokens=1024,
messages=[{"role": "user", "content": "안녕!"}])요금과 크레딧
- 호출이 끝나면 쓴 토큰 × 모델 단가(100만 토큰당 원)만큼 크레딧에서 빠져요.
- 실패한 호출은 차감하지 않아요.
- 크레딧이 0원 이하면 호출이 막혀요(402 insufficient_quota). 운영자에게 충전을 요청하세요.
- 공급사가 사용량을 알려 주지 않는 드문 경우엔 글자 수로 어림해서 차감하고, 기록에 '어림'으로 표시돼요.
자주 나는 오류
| 401 | 키가 틀렸거나 운영자가 껐어요. |
| 402 | 크레딧 부족. |
| 404 | 모델 이름이 목록에 없어요. 대시보드에서 복사해 쓰세요. |
| 429 / 5xx | 공급사가 바쁘거나 오류. 잠시 뒤 다시 시도하세요. |