Gemini로 생성형 AI 솔루션을 개발할 때 개발자는 Gemini Developer API와 Vertex AI Gemini API 중에서 선택합니다.
Gemini Developer API는 Gemini 애플리케이션을 빌드, 프로덕션화, 확장하는 간단한 방법을 제공합니다. Vertex AI는 Google Cloud Platform을 기반으로 생성형 AI 애플리케이션을 빌드하고 배포하기 위한 포괄적인 엔터프라이즈 지원 기능 및 서비스 생태계를 제공합니다.
가장 적합한 방법은 사용자의 요구사항에 따라 다르지만 최근에 이러한 서비스 간에 전환하는 방법이 간소화되었습니다. 이제 통합된 Google 생성형 AI SDK를 통해 Gemini Developer API와 Vertex AI Gemini API에 모두 액세스할 수 있으므로 유연성이 더욱 향상되었습니다.
코드 비교
다음은 텍스트 생성을 위한 Gemini Developer API와 Vertex AI 빠른 시작 간의 코드 비교입니다.
Python
google-genai
라이브러리를 통해 Gemini Developer API와 Vertex AI 서비스에 모두 액세스할 수 있습니다.
라이브러리를 설치하는 방법에 관한 안내는 라이브러리 페이지를 참고하세요.
from google import genai
client = genai.Client(api_key="YOUR_API_KEY ")
response = client.models.generate_content(
model="gemini-2.0-flash", contents="Explain how AI works in a few words"
)
print(response.text)
from google import genai
client = genai.Client(
vertexai=True, project='your-project-id', location='us-central1'
)
response = client.models.generate_content(
model="gemini-2.0-flash", contents="Explain how AI works in a few words"
)
print(response.text)
JavaScript 및 TypeScript
@google/genai
라이브러리를 통해 Gemini Developer API와 Vertex AI 서비스에 모두 액세스할 수 있습니다.
라이브러리를 설치하는 방법에 관한 안내는 라이브러리 페이지를 참고하세요.
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({ apiKey: "YOUR_API_KEY " });
async function main() {
const response = await ai.models.generateContent({
model: "gemini-2.0-flash",
contents: "Explain how AI works in a few words",
});
console.log(response.text);
}
main();
import { GoogleGenAI } from '@google/genai';
const ai = new GoogleGenAI({
vertexai: true,
project: 'your_project',
location: 'your_location',
});
async function main() {
const response = await ai.models.generateContent({
model: "gemini-2.0-flash",
contents: "Explain how AI works in a few words",
});
console.log(response.text);
}
main();
Go
google.golang.org/genai
라이브러리를 통해 Gemini Developer API와 Vertex AI 서비스에 모두 액세스할 수 있습니다.
라이브러리를 설치하는 방법에 관한 안내는 라이브러리 페이지를 참고하세요.
import (
"context"
"encoding/json"
"fmt"
"log"
"google.golang.org/genai"
)
// Your Google API key
const apiKey = "your-api-key"
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, &genai.ClientConfig{
APIKey: apiKey,
Backend: genai.BackendGeminiAPI,
})
// Call the GenerateContent method.
result, err := client.Models.GenerateContent(ctx, "gemini-2.0-flash", genai.Text("Tell me about New York?"), nil)
}
import (
"context"
"encoding/json"
"fmt"
"log"
"google.golang.org/genai"
)
// Your GCP project
const project = "your-project"
// A GCP location like "us-central1"
const location = "some-gcp-location"
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, &genai.ClientConfig
{
Project: project,
Location: location,
Backend: genai.BackendVertexAI,
})
// Call the GenerateContent method.
result, err := client.Models.GenerateContent(ctx, "gemini-2.0-flash", genai.Text("Tell me about New York?"), nil)
}
기타 사용 사례 및 플랫폼
다른 플랫폼 및 사용 사례의 경우 Gemini 개발자 API 문서 및 Vertex AI 문서의 사용 사례별 가이드를 참고하세요.
마이그레이션 고려사항
이전 시 다음 사항에 유의하세요.
Google Cloud 서비스 계정을 사용하여 인증해야 합니다. 자세한 내용은 Vertex AI 문서를 참고하세요.
기존 Google Cloud 프로젝트(API 키를 생성하는 데 사용한 동일한 프로젝트)를 사용하거나 새 Google Cloud 프로젝트를 만들 수 있습니다.
Gemini Developer API와 Vertex AI Gemini API에서 지원되는 지역이 다를 수 있습니다. Google Cloud의 생성형 AI가 지원되는 리전 목록을 참고하세요.
Google AI Studio에서 만든 모든 모델은 Vertex AI에서 재학습을 거쳐야 합니다.
Gemini Developer API에 Gemini API 키를 더 이상 사용할 필요가 없으면 보안 권장사항에 따라 삭제합니다.
API 키를 삭제하는 방법은 다음과 같습니다.
Google Cloud API 사용자 인증 정보 페이지를 엽니다.
삭제할 API 키를 찾아 작업 아이콘을 클릭합니다.
API 키 삭제를 선택합니다.
사용자 인증 정보 삭제 모달에서 삭제를 선택합니다.
API 키 삭제가 반영되기까지 몇 분 정도 걸립니다. 키 삭제가 완료되면, 삭제된 API 키를 사용하는 모든 트래픽이 거부됩니다.
다음 단계
- Vertex AI의 생성형 AI 솔루션에 대해 자세히 알아보려면 Vertex AI의 생성형 AI 개요를 참고하세요.