diff --git a/src/openai-service.ts b/src/openai-service.ts index 3509b7a..ebc01ad 100644 --- a/src/openai-service.ts +++ b/src/openai-service.ts @@ -1,6 +1,9 @@ import type { Env } from './types'; import { callDepositAgent } from './deposit-agent'; +// Cloudflare AI Gateway를 통해 OpenAI API 호출 (지역 제한 우회) +const OPENAI_API_URL = 'https://gateway.ai.cloudflare.com/v1/d8e5997eb4040f8b489f09095c0f623c/telegram-bot/openai/chat/completions'; + interface OpenAIMessage { role: 'system' | 'user' | 'assistant' | 'tool'; content: string | null; @@ -250,7 +253,7 @@ async function suggestDomains(keywords: string, apiKey: string): Promise const excludeList = [...checkedDomains].slice(-30).join(', '); // Step 1: GPT에게 도메인 아이디어 생성 요청 - const ideaResponse = await fetch('https://api.openai.com/v1/chat/completions', { + const ideaResponse = await fetch(OPENAI_API_URL, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -836,7 +839,7 @@ async function executeTool(name: string, args: Record, env?: Env if (hasKorean && env?.OPENAI_API_KEY) { try { - const translateRes = await fetch('https://api.openai.com/v1/chat/completions', { + const translateRes = await fetch(OPENAI_API_URL, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -1090,7 +1093,7 @@ async function callOpenAI( messages: OpenAIMessage[], selectedTools?: typeof tools // undefined = 도구 없음, 배열 = 해당 도구만 사용 ): Promise { - const response = await fetch('https://api.openai.com/v1/chat/completions', { + const response = await fetch(OPENAI_API_URL, { method: 'POST', headers: { 'Content-Type': 'application/json',