DGrid AI Gateway는 200개 이상의 주요 AI 모델에 접근할 수 있는 단일 통합 API를 제공합니다. 사용자는 자신의 API 키를 Claude Code, Codex, Moltbot(Clawdbot)과 같은 도구에 직접 연결할 수 있어, 통합의 복잡성과 운영 비용을 크게 줄일 수 있습니다.
빠른 시작
DGrid AI Gateway는 수백 개의 AI 모델의 인터페이스를 통합합니다. 코드에서 모델마다 다른 호환성 문제를 처리할 필요 없이, 단일 API 엔드포인트와 표준화된 API 요청 형식을 통해 DGrid가 제공하는 수백 개의 모델을 자유롭게 전환하고 사용할 수 있습니다.
도구별 가이드(OpenClaw / Cursor / SDK 등)를 찾고 계신가요? 통합 가이드를 참고하세요.
DGrid 공식 SDK는 현재 활발하게 개발 중입니다. 출시를 기대해 주세요. 아래는 DGrid AI Gateway와 상호 작용하기 위한 현재 사용 가능한 임시 요청 방법입니다.
사전 준비 사항
시작하기 전에 다음을 준비해야 합니다.
- 유효한
DGRID_API_KEY를 발급받습니다 (가이드).
- 개발 환경에서
https://api.dgrid.ai/v1에 네트워크로 접근할 수 있는지 확인합니다.
- SDK를 사용하는 경우, 프로젝트에 해당 OpenAI SDK 패키지를 설치합니다.
cURL을 통한 직접 API 요청
cURL을 사용하여 DGrid AI Gateway 엔드포인트로 직접 HTTP POST 요청을 보낼 수 있습니다.
curl https://api.dgrid.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DGRID_API_KEY" \
-d '{
"model": "openai/gpt-4o",
"messages": [
{
"role": "user",
"content": "What is the meaning of life?"
}
]
}'
OpenAI SDK 사용 (DGrid 호환)
DGrid AI Gateway는 OpenAI SDK 사양과 완전히 호환됩니다. baseURL만 수정하고(DGRID_API_KEY를 입력하면) 빠르게 마이그레이션하거나 통합할 수 있습니다.
사전 준비: OpenAI SDK 설치
먼저 프로젝트에 OpenAI SDK를 설치합니다.
# TypeScript/Node.js의 경우
npm install openai
# Python의 경우
pip install openai
TypeScript 구현
import OpenAI from 'openai';
// Initialize the OpenAI client with DGrid AI Gateway configuration
const openai = new OpenAI({
baseURL: 'https://api.dgrid.ai/v1', // Point to DGrid AI Gateway endpoint
apiKey: '<DGRID_API_KEY>', // Replace with your valid DGrid API key
defaultHeaders: {
'HTTP-Referer': '<YOUR_SITE_URL>', // Optional: Your application's site URL
'X-Title': '<YOUR_SITE_NAME>', // Optional: Your application's name
},
});
// Async function to send chat completion request
async function getChatCompletion() {
const completion = await openai.chat.completions.create({
model: 'openai/gpt-4o', // Specify the target model (DGrid-supported format)
messages: [
{
role: 'user',
content: 'What is the meaning of life?',
},
],
});
// Print the response result
console.log(completion.choices[0].message);
}
getChatCompletion();
Python 구현
from openai import OpenAI
# Initialize the OpenAI client with DGrid AI Gateway configuration
client = OpenAI(
base_url="https://api.dgrid.ai/v1", # Point to DGrid AI Gateway endpoint
api_key="<DGRID_API_KEY>", # Replace with your valid DGrid API key
)
completion = client.chat.completions.create(
extra_headers={
"HTTP-Referer": "<YOUR_SITE_URL>", # Optional: Your application's site URL
"X-Title": "<YOUR_SITE_NAME>", # Optional: Your application's name
},
model="openai/gpt-4o", # Specify the target model (DGrid-supported format)
messages=[
{
"role": "user",
"content": "What is the meaning of life?"
}
]
)
# Print the response content
print(completion.choices[0].message.content)
추가 참고 사항
- 선택적 헤더:
HTTP-Referer와 X-Title 헤더는 선택 사항이지만, 입력하면 DGrid가 사용자의 애플리케이션을 더 잘 식별하고 최적화된 서비스를 제공하는 데 도움이 됩니다.
- 모델 명명 형식:
model 매개변수는 [provider]/[model-name] 형식(예: openai/gpt-4o)을 사용하며, DGrid가 지원하는 모든 모델에서 일관되게 적용되어 손쉽게 전환할 수 있습니다.
- SDK 개발 현황: DGrid 공식 SDK는 개발 중이며, 더 많은 네이티브 기능과 최적화된 성능을 제공할 예정입니다. 출시 정보는 DGrid 공식 문서 업데이트를 참고해 주세요.