언어 모델을 사용하면 비용이 발생합니다. 애플리케이션에서 큰 언어 모델을 사용하는 방법을 이해하려면 개발 프록시를 사용하여 OpenAI 호환 요청 및 응답을 가로채세요. Dev Proxy는 요청 및 응답을 분석하고 원격 분석 데이터를 기록하여 애플리케이션이 대규모 언어 모델을 사용하는 방법을 이해하는 데 도움이 됩니다. 이 정보를 통해 애플리케이션을 최적화하고 비용을 절감할 수 있습니다.
개발자 프록시는 언어 모델 사용량 현황 데이터를 OpenTelemetry 형식으로 기록합니다. OpenTelemetry 호환 대시보드를 사용하여 데이터를 시각화할 수 있습니다. 예를 들어 .NET Aspire 대시보드 또는 OpenLIT를 사용할 수 있습니다. 원격 분석 데이터에는 요청 및 응답에 사용된 토큰 수, 사용된 토큰의 비용 및 세션 과정에서 모든 요청의 총 비용이 포함됩니다.
개발 프록시를 사용하여 OpenAI 호환 요청 및 응답 가로채기
OpenAI 호환 요청 및 응답을 가로채려면 OpenAITelemetryPlugin을 사용합니다. 이 플러그인은 OpenAI 호환 요청 및 응답을 가로채서 원격 분석 데이터를 기록하고 OpenTelemetry 데이터를 내보냅니다.
개발자 프록시 구성 파일 만들기
devproxy config new명령 또는 Dev Proxy Toolkit 확장을 사용하여 새로운 개발 프록시 구성 파일을 만듭니다.OpenAITelemetryPlugin구성 파일에 추가합니다.{ "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v1.0.0/rc.schema.json", "plugins": [ { "name": "OpenAITelemetryPlugin", "enabled": true, "pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll" } ], "urlsToWatch": [ ], "logLevel": "information", "newVersionNotification": "stable", "showSkipMessages": true }urlsToWatch가로채려는 OpenAI 호환 요청의 URL을 포함하도록 속성을 구성합니다. 다음 예제에서는 Azure OpenAI 채팅 완료에 대한 요청을 가로채는 예제입니다.{ "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v1.0.0/rc.schema.json", "plugins": [ { "name": "OpenAITelemetryPlugin", "enabled": true, "pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll" } ], "urlsToWatch": [ "https://*.openai.azure.com/openai/deployments/*/chat/completions*", "https://*.cognitiveservices.azure.com/openai/deployments/*/chat/completions*" ], "logLevel": "information", "newVersionNotification": "stable", "showSkipMessages": true }변경 내용을 저장합니다.
OpenTelemetry 수집기와 Dev 프록시 시작
중요합니다
.NET Aspire와 OpenLIT 모두 Docker를 실행해야 합니다. Docker가 설치되어 있지 않은 경우 Docker 설명서 의 지침에 따라 Docker를 설치합니다.
Docker를 시작합니다.
OpenTelemetry 수집기를 시작합니다.
- .NET Aspire
- OpenLIT
다음 명령을 실행하여 .NET Aspire OpenTelemetry 수집기 및 대시보드를 시작합니다.
docker run --rm -it -p 18888:18888 -p 4317:18889 -p 4318:18890 --name aspire-dashboard mcr.microsoft.com/dotnet/aspire-dashboard:latest비고
.NET Aspire 대시보드 사용을 마쳤으면 대시보드를 시작한 터미널에서 Ctrl + C 를 눌러 대시보드를 중지합니다. 컨테이너를 중지하면 Docker에서 컨테이너를 자동으로 제거합니다.
브라우저에서 .NET Aspire 대시보드를 엽니다
http://localhost:18888/login?t=<code>.
개발 프록시를 시작하려면 작업 디렉터리를 개발자 프록시 구성 파일을 만든 폴더로 변경하고 다음 명령을 실행합니다.
devproxy
언어 모델 사용 및 원격 분석 데이터 검사
가로채도록 개발 프록시를 구성한 OpenAI 호환 엔드포인트에 요청합니다.
개발자 프록시가 요청 및 응답을 가로채는지 확인합니다. 개발자 프록시가 실행 중인 콘솔에서 비슷한 정보가 표시됩니다.
info Dev Proxy API listening on http://127.0.0.1:8897... info Dev Proxy listening on 127.0.0.1:8000... Hotkeys: issue (w)eb request, (r)ecord, (s)top recording, (c)lear screen Press CTRL+C to stop Dev Proxy req ╭ POST https://some-resource.cognitiveservices.azure.com/openai/deployments/some-deployment/chat/completions?api-version=2025-01-01-preview time │ 19/05/2025 07:53:38 +00:00 pass │ Passed through proc ╰ OpenAITelemetryPlugin: OpenTelemetry information emitted웹 브라우저에서 OpenTelemetry 대시보드로 이동합니다.
- .NET Aspire
- OpenLIT
실행 중인 터미널에서 Ctrl + C 를 눌러 개발 프록시를 중지합니다.
언어 모델 비용 이해
개발자 프록시는 언어 모델 사용 비용을 예측하는 것을 지원합니다. 개발자 프록시가 비용을 추정할 수 있도록 하려면 사용하는 모델의 가격에 대한 정보를 제공해야 합니다.
가격 파일 만들기
개발자 프록시 구성 파일을 만든 동일한 폴더에서 새
prices.json파일을 만듭니다.파일에 다음 내용을 추가합니다.
{ "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v1.0.0/openaitelemetryplugin.pricesfile.schema.json", "prices": { "o4-mini": { "input": 0.97, "output": 3.87 } } }중요합니다
키는 언어 모델의 이름입니다.
input및output프로퍼티는 입력 및 출력 토큰에 대한 백만 토큰당 가격입니다. 가격 정보가 없는 모델을 사용하는 경우 개발자 프록시는 비용 메트릭을 기록하지 않습니다.변경 내용을 저장합니다.
코드 편집기에서 개발 프록시 구성 파일을 엽니다.
OpenAITelemetryPlugin참조에 구성 섹션을 추가하여 확장합니다.{ "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v1.0.0/rc.schema.json", "plugins": [ { "name": "OpenAITelemetryPlugin", "enabled": true, "pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll", "configSection": "openAITelemetryPlugin" } ], "urlsToWatch": [ "https://*.openai.azure.com/openai/deployments/*/chat/completions*", "https://*.cognitiveservices.azure.com/openai/deployments/*/chat/completions*" ], "logLevel": "information", "newVersionNotification": "stable", "showSkipMessages": true }openAITelemetryPlugin구성 파일에 섹션을 추가합니다.{ "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v1.0.0/rc.schema.json", "plugins": [ { "name": "OpenAITelemetryPlugin", "enabled": true, "pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll", "configSection": "openAITelemetryPlugin" } ], "urlsToWatch": [ "https://*.openai.azure.com/openai/deployments/*/chat/completions*", "https://*.cognitiveservices.azure.com/openai/deployments/*/chat/completions*" ], "openAITelemetryPlugin": { "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v1.0.0/openaitelemetryplugin.schema.json", "includeCosts": true, "pricesFile": "prices.json" }, "logLevel": "information", "newVersionNotification": "stable", "showSkipMessages": true }includeCosts속성을true으로 설정하고,pricesFile속성은 가격 정보가 포함된 파일 이름으로 설정합니다.변경 내용을 저장합니다.
예상 비용 보기
개발 프록시를 시작합니다.
가로채도록 개발 프록시를 구성한 OpenAI 호환 엔드포인트에 요청합니다.
웹 브라우저에서 OpenTelemetry 대시보드로 이동합니다.
- .NET Aspire
- OpenLIT
실행 중인 터미널에서 Ctrl + C 를 눌러 개발 프록시를 중지합니다.
OpenTelemetry 수집기를 중지합니다.
- .NET Aspire
- OpenLIT
.NET Aspire 대시보드가 실행 중인 터미널에서 Ctrl + C 를 눌러 대시보드를 중지합니다. 컨테이너를 중지하면 Docker에서 컨테이너를 자동으로 제거합니다.
다음 단계
OpenAITelemetryPlugin에 대해 자세히 알아봅니다.
Dev Proxy