google cloud vertex ai API로 text 생성 Gemini Pro 사용법

//-------------------------------------
Google Cloud SDK설치
https://cloud.google.com/sdk/?hl=ko
https://cloud.google.com/sdk/docs/install-sdk?hl=ko

* 윈도우
GoogleCloudSDKInstaller.exe 다운로드 실행
https://dl.google.com/dl/cloudsdk/channels/rapid/GoogleCloudSDKInstaller.exe

- 초기화
> gcloud init 


* 우분투에 설치
sudo apt-get update

- 기본툴 설치
sudo apt-get install apt-transport-https ca-certificates gnupg curl sudo

- 공개키 가져오기
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg

- gcloud CLI 배포 URI를 추가
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list

- gcloud CLI를 업데이트하고 설치
sudo apt-get update && sudo apt-get install google-cloud-cli


//-------------------------------------
- 초기화 설정
gcloud init

- 계정 설정 보기
gcloud auth list

- 설정 보기
gcloud config list



//-------------------------------------
> gcloud auth login

- $(gcloud auth print-access-token) 값 알아내기 명령
> gcloud auth print-access-token

- 자동 인증 설정
> gcloud auth application-default login


//-------------------------------------
vertex-ai gemini 메뉴얼
https://cloud.google.com/vertex-ai/docs/generative-ai/model-reference/gemini

vertex project
https://console.cloud.google.com/vertex-ai/generative/language/create/text?project=voltaic-sandbox-407808


//-------------------------------------

* CURL 실행 명령 예제


API_ENDPOINT="asia-northeast3-aiplatforhttp://m.googleapis.com"
PROJECT_ID="voltaic-sandbox-XX"
MODEL_ID="gemini-pro"
LOCATION_ID="asia-northeast3"

curl \
-X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"https://${API_ENDPOINT}/v1beta1/projects/${PROJECT_ID}/locations/${LOCATION_ID}/publishers/google/models/${MODEL_ID}:streamGenerateContent" -d \
$'{
    "contents": [
        {
            "role": "user",
            "parts": [
                {
                    "text": "What is the name of the current president of South Korea?"
                }
            ]
        }
    ],
    "generation_config": {
        "maxOutputTokens": 2048,
        "temperature": 0.9,
        "topP": 1
    }
}'

 

반응형

'AI' 카테고리의 다른 글

Ollama 사용법  (0) 2024.01.11
AI LLM Benchmark Rank 순위 Leaderboard  (0) 2024.01.09
철학적인 질문  (0) 2023.11.08
메타 LLaMA 2 사용법  (0) 2023.11.08
MS 오픈 소스 LLM, Phi 1.5 사용법  (0) 2023.11.08
Posted by codens


반응형