From ec0dea0769325854b62a7dd6cf4f6c57bf24b53e Mon Sep 17 00:00:00 2001 From: kappa Date: Sun, 18 Jan 2026 11:36:04 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20Cloudflare=20AI=20Gateway=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - OpenAI API 호출을 AI Gateway 경유로 변경 - 지역 제한 (403 unsupported_country_region_territory) 해결 - Gateway: telegram-bot (d8e5997eb4040f8b489f09095c0f623c) Co-Authored-By: Claude Opus 4.5 --- src/openai-service.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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',