OpenAI 호출을 Cloudflare AI Gateway 경유로 전환 - #51
Merged
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
github | 9b9d10c | Commit Preview URL Branch Preview URL |
Aug 08 2026, 04:50 PM |
DaleSeo
force-pushed
the
feat/openai-via-ai-gateway
branch
from
August 8, 2026 01:36
9b5f17f to
9d54eb6
Compare
DaleSeo
marked this pull request as draft
August 8, 2026 01:37
PR 이벤트마다 도는 워크로드라 게이트웨이의 로그·캐싱·속도 제한·지출 한도가 전부 실효가 있다. 재시도도 게이트웨이에 맡겨 Worker CPU 예산을 쓰지 않는다. OpenAI 키는 게이트웨이에 저장돼 있어 Worker 에서 제거하고, env.OPENAI_API_KEY 를 env.AI_GATEWAY_TOKEN 으로 대체했다.
DaleSeo
force-pushed
the
feat/openai-via-ai-gateway
branch
from
August 8, 2026 01:39
9d54eb6 to
6b709d0
Compare
DaleSeo
marked this pull request as ready for review
August 8, 2026 01:52
parkhojeong
reviewed
Aug 8, 2026
parkhojeong
left a comment
Contributor
There was a problem hiding this comment.
오 Cloudflare 경유하면 여러 이점이 있군요! 좋은 거 같네요. 리뷰 슬쩍 남겨봅니다~
| method: "POST", | ||
| headers: { | ||
| Authorization: `Bearer ${apiKey}`, | ||
| "cf-aig-authorization": `Bearer ${gatewayToken}`, |
Contributor
There was a problem hiding this comment.
이 헤더가 네 군데에서 사용되는데 이것도 한 곳에서 관리하도록 하는건 어떨까요?
Member
Author
There was a problem hiding this comment.
좋은 제안이네요. 아예 헤더 조립을 함수로 감쌌습니다.
Comment on lines
+13
to
+14
| import { AI_GATEWAY_RETRY_HEADERS, OPENAI_CHAT_COMPLETIONS_URL } from "../utils/constants.js"; | ||
|
|
Contributor
There was a problem hiding this comment.
AI_GATEWAY_RETRY_HEADERS가 import 되었는데 사용되는 곳이 없네요. 헤더에 사용하는 부분이 누락된 거 같습니다.
Member
Author
|
@parkhojeong 리뷰 감사합니다. 피드백 반영하였습니다. 재검토 후에 추가 의견없으시면 승인 부탁드리겠습니다. write 권한드렸으니 가능하실 거에요. |
parkhojeong
approved these changes
Aug 8, 2026
parkhojeong
left a comment
Contributor
There was a problem hiding this comment.
함수로 감싸는거 좋네요. 수고하셨습니다!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
OpenAI API를 직접 호출 방식에서 Cloudflare AI Gateway를 통한 경유 호출로 변경하고자 합니다.
Cloudflare AI Gateway를 사용하면 여러 AI 제공업체의 API 키를 한 곳에서 관리할 수 있기 때문에 노출 시 회전도 용이하고, 나중에 트래픽이 많아졌을 때 Throttling, 한도 설정, 캐싱 설정도 가능합니다.
변경 사항은 많지 않습니다. 호출 URL 과 인증 헤더만 바뀌고 요청 본문은 그대로입니다.
4곳에 중복돼 있던 URL 은
utils/constants.js로 모았습니다.