Google endpointμ κ²½μ°, Generative Language API(Gemini λͺ¨λΈμ©) λλ Vertex AI API(Gemini, PaLM2 λ° Codey λͺ¨λΈμ©)λ₯Ό μ¬μ©ν μ μμ΅λλ€.
Generative Language APIλ Google AI Studioμμ μ»μ μ μλ API ν€λ₯Ό μ¬μ©ν©λλ€.
Vertex AIμ κ²½μ°, μ μ ν μ‘μΈμ€ κΆνμ΄ κ΅¬μ±λ μλΉμ€ κ³μ (Service Account) JSON ν€ νμΌμ΄ νμν©λλ€.
λ κ°μ§ λͺ¨λμ λν μ§μΉ¨μ μλμ λμ μμ΅λλ€.
Generative Language API (Gemini)
Gemini API μκΈ λ° μ¬μ©λ μ νμ μ¬κΈ°λ₯Ό μ°Έμ‘°νμΈμ
β οΈ Google λͺ¨λΈμ 무λ£μ΄μ§λ§, κ·νμ Google κ³μ λ° API ν€μμ μλ³ μ λ³΄κ° μ κ±°λ λ°μ΄ν°λ₯Ό μ¬μ©νμ¬ λͺ¨λΈ κ°μ μ λμμ μ€λλ€. β οΈ μ΄ κΈ°κ° λμ κ·νμ λ©μμ§λ "νλ ¨λ κ²ν μκ° μ‘μΈμ€ν μ μμ΅λλ€."
Google AI Studioλ₯Ό ν΅ν΄ Gemini λͺ¨λΈμ μ¬μ©νλ €λ©΄ API ν€κ° νμν©λλ€. μμ§ API ν€κ° μλ€λ©΄ Google AI Studioμμ ν€λ₯Ό μμ±νμΈμ.
λ€μμμ API ν€λ₯Ό λ°μΌμΈμ: aistudio.google.com
ν€λ₯Ό ν보ν ν, .env νμΌμ ν΄λΉ ν€λ₯Ό μ λ ₯νλ©΄ μΈμ€ν΄μ€μ λͺ¨λ μ¬μ©μκ° μ΄λ₯Ό μ¬μ©ν μ μκ² λ©λλ€.
GOOGLE_KEY=mY_SeCreT_w9347w8_kEYλλ, λ€μμ μ€μ νμ¬ μ¬μ©μκ° νλ‘ νΈμλμμ μ§μ μ 곡νλλ‘ ν μ μμ΅λλ€:
GOOGLE_KEY=user_providedμΌλΆ 리λ²μ€ νλ‘μλ X-goog-api-key ν€λλ₯Ό μ§μνμ§ μμ΅λλ€. LibreChatμ΄ λμ Authorization ν€λλ₯Ό μ¬μ©νλλ‘ κ΅¬μ±ν μ μμ΅λλ€:
GOOGLE_AUTH_HEADER=trueλͺ¨λΈ λͺ©λ‘μ κ°μ Έμ€λ κΈ°λ₯μ΄ μμ§ μ§μλμ§ μμΌλ―λ‘, μ¬μ©νλ €λ λͺ¨λΈμ .env νμΌμ μ€μ ν΄μΌ ν©λλ€.
νΈμλ₯Ό μν΄, 2024λ 5μ 18μΌ κΈ°μ€μΌλ‘ Generative Language APIμ ν¨κ» μ¬μ©ν μ μλ μ΅μ λͺ¨λΈλ€μ μ 리νμ΅λλ€:
GOOGLE_MODELS=gemini-1.5-flash-latest,gemini-1.0-pro,gemini-1.0-pro-001,gemini-1.0-pro-latest,gemini-1.0-pro-vision-latest,gemini-1.5-pro-latest,gemini-pro,gemini-pro-visionμ°Έκ³ :
- μ΄λ―Έμ§ 첨λΆλ₯Ό μν΄μλ λͺ©λ‘μ gemini-pro λͺ¨λΈ λλ
gemini-pro-visionμ΄ νμν©λλ€. - LibreChatμμ PaLM2 λ° Codey λͺ¨λΈμ Generative Language APIκ° μλ Vertex AIλ₯Ό ν΅ν΄μλ§ μ‘μΈμ€ν μ μμ΅λλ€.
generateContentλ©μλλ₯Ό μ§μνλ λͺ¨λΈλ§ LibreChat + Gen AI APIμμ κΈ°λ³Έμ μΌλ‘ μ¬μ©ν μ μμ΅λλ€.
- μ²¨λΆ νμΌμ΄ ν¬ν¨λ λ©μμ§μ κ²½μ°
gemini-pro-visionμ μ νν νμκ° μμ΅λλ€. λ°±μλμμ μλμΌλ‘ μ νλκΈ° λλ¬Έμ λλ€. gemini-pro-visionμ μ²¨λΆ νμΌμ΄ μλ λ©μμ§λ₯Ό νμ©νμ§ μμΌλ―λ‘, μ²¨λΆ νμΌμ΄ μλ λ©μμ§λ μλμΌλ‘gemini-proλ₯Ό μ¬μ©νλλ‘ μ νλ©λλ€. κ·Έλ μ§ μμΌλ©΄ Googleμ΄ μ€λ₯λ₯Ό λ°νν©λλ€.- Google endpointλ₯Ό μ¬μ©ν λλ Vertex AIμ Generative Language APIλ₯Ό λμμ μ¬μ©ν μ μμ΅λλ€. λ μ€ νλλ₯Ό μ νν΄μΌ ν©λλ€.
- μΌλΆ PaLM/Codey λͺ¨λΈ λ°
gemini-pro-visionμmaxOutputTokensκ° λμ κ°μΌλ‘ μ€μ λ κ²½μ° μ€ν¨ν μ μμ΅λλ€. μ΄ λ¬Έμ κ° λ°μνλ©΄ λν λ§€κ°λ³μλ₯Ό ν΅ν΄ κ°μ μ€μ¬λ³΄μμμ€.
.env νμΌμμ GOOGLE_KEY=user_providedλ₯Ό μ€μ νλ©΄ Vertex AI μλΉμ€ κ³μ JSON ν€ νμΌκ³Ό Generative Language API ν€λ₯Ό λͺ¨λ νλ‘ νΈμλμμ λ€μκ³Ό κ°μ΄ μ 곡νλλ‘ μ€μ λ©λλ€:
URL Context
Googleμ URL Context λꡬλ μ§μλλ Gemini λͺ¨λΈμ΄ μΉ νμ΄μ§, μ΄λ―Έμ§, PDFμ κ°μ΄ μ¬μ©μ λ©μμ§μ ν¬ν¨λ URLμ μ½μ μ μλλ‘ ν©λλ€. LibreChatμμλ Google endpoint λ§€κ°λ³μ url_contextλ₯Ό μ¬μ©νμ¬ μ΄λ₯Ό νμ±νν μ μμ΅λλ€.
preset:
endpoint: google
model: gemini-2.5-flash
url_context: trueaddParams λλ λ§€κ°λ³μ κΈ°λ³Έκ°μ μ¬μ©νμ¬ Google ννμ μ¬μ©μ μ§μ endpointμ λν΄μλ νμ±νν μ μμ΅λλ€:
custom:
- name: 'Google Gateway'
apiKey: '${GOOGLE_KEY}'
baseURL: 'https://gateway.example.com/v1'
models:
default: ['gemini-2.5-flash']
customParams:
defaultParamsEndpoint: google
addParams:
url_context: trueurl_contextλ Gemini 2.5+ λ° Gemini 3.x λͺ¨λΈμ ν¬ν¨νμ¬ μ§μλλ Gemini ν
μ€νΈ λͺ¨λΈμμ μ¬μ©ν μ μμ΅λλ€. url_contextκ° νμ±νλλ©΄ YouTube λ§ν¬λ Googleμ URL Context λκ΅¬κ° YouTube URLμ μ§μ μ§μνμ§ μκΈ° λλ¬Έμ Geminiμ κΈ°λ³Έ λΉλμ€ μ΄ν΄ κΈ°λ₯μ ν΅ν΄ λ³λλ‘ μ²λ¦¬λ©λλ€.
Vertex AI
Vertex API κ°κ²© λ° μ¬μ©λ μ νμ μ¬κΈ°λ₯Ό μ°Έμ‘°νμΈμ
Google LLM(Google Cloud Vertex AIλ₯Ό ν΅ν΄)μ μ€μ νλ €λ©΄ λ¨Όμ Google Cloudμ κ°μ νμΈμ: cloud.google.com
μΌλ°μ μΌλ‘ $300μ μμ ν¬λ λ§μ λ°μ μ μμΌλ©°, μ΄λ₯Ό ν΅ν΄ 90μΌ λμ μ΄ μ΅μ μ 무λ£λ‘ μ¬μ©ν μ μμ΅λλ€.
- κ°μ
μ΄ μλ£λλ©΄, Google Cloudμμ Vertex AI APIλ₯Ό νμ±ννμΈμ:
- **Google Cloud μ½μμ Vertex AI νμ΄μ§**λ‘ μ΄λνμΈμ.
- λ©μμ§κ° νμλλ©΄
Enable APIλ₯Ό ν΄λ¦νμΈμ.
- Vertex AI μν μ΄ ν¬ν¨λ μλΉμ€ κ³μ μμ±:
- μλΉμ€ κ³μ μ μμ±νλ €λ©΄ μ¬κΈ°λ₯Ό ν΄λ¦νμΈμ
- νλ‘μ νΈλ₯Ό μ ννκ±°λ μμ±νμΈμ
- μλΉμ€ κ³μ IDλ₯Ό μ
λ ₯νμΈμ(νμ). μ΄λ¦κ³Ό μ€λͺ
μ μ ν μ¬νμ
λλ€.
- "Create and Continue"μ ν΄λ¦νμ¬ μ΅μν "Vertex AI User" μν μ λΆμ¬νμΈμ.
- "Continue/Done"μ ν΄λ¦νμΈμ
- νλ‘μ νΈ λλ ν 리μ μ μ₯ν JSON ν€ μμ±:
- μλΉμ€ κ³μ νμ΄μ§λ‘ λμκ°κΈ°
- μλΉμ€ κ³μ μ ν
- "Keys"λ₯Ό ν΄λ¦νμΈμ
- "Add Key"λ₯Ό ν΄λ¦ν λ€μ "Create new key"λ₯Ό ν΄λ¦νμΈμ.
- ν€ μ νμΌλ‘ JSONμ μ ννκ³ "Create"λ₯Ό ν΄λ¦νμΈμ
- ν€ νμΌμ λ€μ΄λ‘λνκ³ μ΄λ¦μ 'auth.json'μΌλ‘ λ³κ²½νμΈμ.
- νλ‘μ νΈ λλ ν 리 λ΄μ
/api/data/μ μ μ₯νμΈμ.
λμ: GOOGLE_SERVICE_KEY_FILE μ¬μ©νκΈ°
ν€ νμΌμ /api/data/auth.jsonμ μ μ₯νλ λμ , GOOGLE_SERVICE_KEY_FILE νκ²½ λ³μλ₯Ό μ¬μ©νμ¬ μλΉμ€ κ³μ ν€ νμΌμ κ²½λ‘λ₯Ό μ§μ ν μ μμ΅λλ€. μ΄λ μ격 μ¦λͺ
μ κ΄λ¦¬νλ λ°©μμ λ λ§μ μ μ°μ±μ μ 곡ν©λλ€. μμΈν λ΄μ©μ μλμ νκ²½ λ³μ μΉμ
μ μ°Έμ‘°νμΈμ.
JSON ν€ νμΌμ νλ‘μ νΈ λλ ν 리μ μ μ₯νλ©΄ LibreChat μΈμ€ν΄μ€μ λͺ¨λ μ¬μ©μκ° μ΄λ₯Ό μ¬μ©ν μ μμ΅λλ€.
λλ, λ€μμ μ€μ νμ¬ μ¬μ©μκ° νλ‘ νΈμλμμ μ§μ μ 곡νλλ‘ ν μ μμ΅λλ€:
# Note: this configures both the Vertex AI Service Account JSON key file
# and the Generative Language API key to be provided from the frontend.
GOOGLE_KEY=user_providedGOOGLE_SERVICE_KEY_FILE νκ²½ λ³μλ₯Ό μ¬μ©νμ¬ μλΉμ€ κ³μ ν€ νμΌμ μ§μ ν μλ μμ΅λλ€:
# Path to the service account JSON key file
GOOGLE_SERVICE_KEY_FILE=/path/to/auth.json
# Or provide as a URL
GOOGLE_SERVICE_KEY_FILE=https://example.com/path/to/auth.json
# Or provide as stringified JSON
GOOGLE_SERVICE_KEY_FILE='{"type":"service_account","project_id":"your-project",...}'
# Or provide as base64 encoded JSON
GOOGLE_SERVICE_KEY_FILE=eyJ0eXBlIjogInNlcnZpY2VfYWNjb3VudCIsICJwcm9qZWN0X2lkIjogInlvdXItcHJvamVjdC1pZCIsIC4uLn0=μ΄λ OCR κΈ°λ₯κ³Ό κ°μ΄ Vertex AI μΈμ¦μ΄ νμν κΈ°λ₯μ νΉν μ μ©ν©λλ€.
Vertex AI API μμ²μ μν Google Cloud μμΉλ₯Ό μ§μ ν μλ μμ΅λλ€:
# Google Cloud region for Vertex AI
GOOGLE_LOC=us-central1
# Alternative region for Gemini Image Generation (defaults to global)
GOOGLE_CLOUD_LOCATION=globalλͺ¨λΈ λͺ©λ‘μ κ°μ Έμ€λ κΈ°λ₯μ΄ μμ§ μ§μλμ§ μμΌλ―λ‘, μ¬μ©νλ €λ λͺ¨λΈμ .env νμΌμ μ€μ ν΄μΌ ν©λλ€.
νΈμλ₯Ό μν΄, 2024λ 5μ 18μΌ κΈ°μ€μΌλ‘ Generative Language APIμ ν¨κ» μ¬μ©ν μ μλ μ΅μ λͺ¨λΈλ€μ μ 리νμ΅λλ€:
GOOGLE_MODELS=gemini-1.5-flash-preview-0514,gemini-1.5-pro-preview-0514,gemini-1.0-pro-vision-001,gemini-1.0-pro-002,gemini-1.0-pro-001,gemini-pro-vision,gemini-1.0-proDockerλ₯Ό μ¬μ©νλ κ²½μ°
Dockerλ₯Ό μ¬μ© μ€μ΄λ©° auth.json νμΌμ μ 곡νλ €λ κ²½μ°, docker-compose.override.ymlμμ λ³Όλ₯¨μ λ§μ΄νΈν΄μΌ ν©λλ€.
version: '3.4'
services:
api:
volumes:
- type: bind
source: ./api/data/auth.json
target: /app/api/data/auth.jsonGoogle μμ μ€μ
Vertex AI λ° Generative Language API λͺ¨λμ λν μμ μ€μ μ μ§μ νλ €λ©΄ .env νμΌμ λ€μμ μ€μ ν μ μμ΅λλ€:
GOOGLE_SAFETY_SEXUALLY_EXPLICIT=BLOCK_ONLY_HIGH
GOOGLE_SAFETY_HATE_SPEECH=BLOCK_ONLY_HIGH
GOOGLE_SAFETY_HARASSMENT=BLOCK_ONLY_HIGH
GOOGLE_SAFETY_DANGEROUS_CONTENT=BLOCK_ONLY_HIGH
GOOGLE_SAFETY_CIVIC_INTEGRITY=BLOCK_ONLY_HIGHλν .env νμΌμ λ€μμ μ€μ νμ¬ μμ μ€μ μ μ μΈν μ μμΌλ©°, μ΄ κ²½μ° κ³΅κΈμμ κΈ°λ³Έκ°μ΄ μ¬μ©λ©λλ€. μ΄λ νΉμ μμ μ€μ κ³Ό κ΄λ ¨νμ¬ λ¬Έμ κ° λ°μν λ μ μ©ν μ μμ΅λλ€.
GOOGLE_EXCLUDE_SAFETY_SETTINGS=trueμ°Έκ³ : κΈ°λ³Έμ μΌλ‘ BLOCK_NONE μ€μ μ μ‘μΈμ€ν μ μμ΅λλ€.
μ΄ μ νλ HarmBlockThreshold μ€μ μ μ¬μ©νλ €λ©΄ λ€μ μ€ νλλ₯Ό μνν΄μΌ ν©λλ€:
- (a) Google κ³μ νμ ν΅ν΄ νμ© λͺ©λ‘(allowlist)μ λν μ‘μΈμ€ κΆνμ μ»μΌμΈμ
- (b) λ€μ μ§μΉ¨μ λ°λΌ κ³μ μ νμ μλ³ μ²κ΅¬μ λ°ν λ°©μμΌλ‘ μ ννμΈμ: https://cloud.google.com/billing/docs/how-to/invoiced-billing
μ°Έκ³ :
- Google endpointλ
streamRate,headers,titleModel,titleMethod,titlePrompt,titlePromptTemplate,titleEndpointλ₯Ό ν¬ν¨νμ¬librechat.yamlκ΅¬μ± νμΌμ ν΅ν λͺ¨λ Shared Endpoint Settingsμ μ§μν©λλ€.
μ΄ κ°μ΄λλ μ΄λ€κ°μ?