콘텐츠로 이동

시작하기

게이트웨이는 OpenAI 호환이라, 기존 코드에서 base_urlapi_key만 바꾸면 됩니다.

1. API 키 발급

포털에 로그인 → 프로젝트 생성 → API Key 발급. 개발/운영 키를 분리해 관리하세요.

2. 첫 호출 (30초)

export API_KEY="sk-..."                       # 발급받은 키
export BASE="https://<gateway-host>/v1"

# 가용 모델 확인
curl $BASE/models -H "Authorization: Bearer $API_KEY"

# 첫 채팅
curl $BASE/chat/completions -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"qwen2.5-72b","messages":[{"role":"user","content":"안녕"}],"max_tokens":64}'

3. SDK로

from openai import OpenAI
client = OpenAI(base_url="https://<gateway-host>/v1", api_key="YOUR_API_KEY")
print(client.chat.completions.create(
    model="qwen2.5-72b",
    messages=[{"role": "user", "content": "한 줄 자기소개"}],
).choices[0].message.content)

다음 단계

  • API 전체: api.md — 채팅·스트리밍·임베딩·리랭크·도구 호출·오류 코드
  • 기능 템플릿으로 빠르게: templates.md — RAG·OCR·챗을 골라 바로 사용
  • 앱 프로젝트 생성: quickstart.md — AppSpec → 표준 프로젝트 → 코딩 에이전트로 완성

보안

  • 키는 환경변수/시크릿 매니저로만. 코드·프론트엔드·커밋에 하드코딩 금지.
  • base_url은 배포 환경 값을 사용하세요.