5.1. Azure API 설정 - OpenAI (gpt-4o, o1-mini, ...)

OpenAI 가 제공하는 LLM 을 Azure 에서 사용하도록 설정하는 방법

Azure 는 서버리스 서비스를 배포(depoly)하며 api_base URL 과 키를 생성하여 설정함


Azure 리소스 그룹 생성

https://portal.azure.com/#browse/resourcegroups


Azure OpenAI 서비스 생성

https://portal.azure.com/#view/Microsoft_Azure_ProjectOxford/CognitiveServicesHub/~/OpenAI


서비스에 모델 추가 (배포)

https://oai.azure.com/resource/deployments

배포 → 모델 배포 클릭 → 모델 선택 → 배포 이름 (Deployment name) 설정 → Customize 클릭 → 모델 버전, 리전, 분당 토큰 속도 제한 올리기 → 저장

서비스에 모델을 추가할 때 Resource location이 해외이거나, AI resource 가 내가 설정한 리소스 그룹이 아닌 경우, Model version을 낮추어 내가 원하는 리전에서 서비스 되도록 설정


litellm_config.yml 수정

os.environ/XXXX 은 .env 파일에 선언된 XXXX 변수의 값을 사용하겠다는 의미

api_version 버전은 model_version 이 아님. 2024-08-01-preview 으로 둘 것

상세한 옵션은 다음 문서를 참고할 것
https://docs.litellm.ai/docs/providers/azure

litellm_config.yml
model_list:

  - model_name: gpt-4o
    litellm_params:
      model: azure/gpt-4o
      api_base: os.environ/AZURE_OPENAI_ENDPOINT
      api_version: "2024-08-01-preview"
      api_key: os.environ/AZURE_OPENAI_API_KEY

  - model_name: gpt-4o-mini
    litellm_params:
      model: azure/gpt-4o-mini
      api_base: os.environ/AZURE_OPENAI_ENDPOINT
      api_version: "2024-08-01-preview"
      api_key: os.environ/AZURE_OPENAI_API_KEY

  - model_name: o1-mini
    litellm_params:
      model: azure/o1-mini
      api_base: https://ai-westusxxxx.cognitiveservices.azure.com
      api_version: "2024-08-01-preview"
      api_key: xxxx