Bỏ qua để đến nội dung

Gemini (Preview)

Gemini là mô hình AI đa phương thức (multimodal) hàng đầu của Google, có khả năng xử lý văn bản, hình ảnh, âm thanh và video. Gemini được tích hợp vào nhiều sản phẩm Google và có API riêng cho developer.

📚 Bài viết liên quan:

  • Generative AI - Cách AI hoạt động từ prompt đến response
  • Context Window - Hiểu về giới hạn tokens và cách tối ưu
  • Context Engineering - Nghệ thuật sắp xếp context hiệu quả
  • RAG - Tích hợp dữ liệu bên ngoài vào LLM
Phiên bản Mô tả Use case
Gemini 3 Pro Model mạnh nhất, suy luận nâng cao, 1M tokens context Nghiên cứu, phân tích phức tạp, agentic tasks
Gemini 3 Flash Nhanh, tiết kiệm chi phí, Pro-grade intelligence Chatbot, coding, high-frequency workflows
Phiên bản Mô tả Use case
Gemini 2.5 Pro Cân bằng giữa performance và chi phí Tác vụ chung, production apps
Gemini 2.0 Flash Nhanh, context lớn (1M tokens) Chatbot, coding, tác vụ hàng ngày
Gemini 2.0 Flash Thinking Tối ưu cho suy luận step-by-step Toán học, logic phức tạp

Truy cập miễn phí tại gemini.google.com:

  • Chat với AI bằng text
  • Upload hình ảnh để phân tích
  • Tạo hình ảnh với Imagen
  • Kết nối với Google Workspace

Dành cho developer, truy cập tại ai.google.dev:

import google.generativeai as genai
genai.configure(api_key="YOUR_API_KEY")
model = genai.GenerativeModel("gemini-3-flash")
response = model.generate_content("Giải thích recursion trong lập trình")
print(response.text)

Gemini được tích hợp sẵn trong:

  • Gmail - Viết và tóm tắt email
  • Google Docs - Soạn thảo văn bản
  • Google Sheets - Phân tích dữ liệu
  • Google Slides - Tạo presentation

Tích hợp vào IDE cho lập trình viên:

  • VS Code extension
  • JetBrains plugin
  • Cloud Workstations

Gemini có thể xử lý đồng thời nhiều loại input:

import PIL.Image
image = PIL.Image.open("diagram.png")
response = model.generate_content([
"Giải thích sơ đồ này:",
image
])
  • Gemini 2.0 Flash: 1 triệu tokens (~700.000 từ)
  • Có thể phân tích cả file PDF, codebase lớn

Kết hợp thông tin real-time từ Google Search:

model = genai.GenerativeModel(
"gemini-3-flash",
tools=[genai.Tool.from_google_search()]
)
response = model.generate_content("Tin tức công nghệ hôm nay")

Cho phép Gemini gọi các hàm bạn định nghĩa:

def get_weather(city: str) -> dict:
"""Lấy thông tin thời tiết của thành phố."""
# Implementation
return {"temp": 28, "condition": "sunny"}
model = genai.GenerativeModel(
"gemini-3-flash",
tools=[get_weather]
)
Prompt: "Viết hàm Python sort một list các dictionary theo key 'age'"
Prompt: "Review đoạn code sau và đề xuất cải thiện:
[paste code here]"
Prompt: "Giải thích lỗi sau và cách fix:
TypeError: Cannot read property 'map' of undefined"
Prompt: "Viết docstring cho hàm sau theo chuẩn Google style:
[paste function here]"
Model Input (per 1M tokens) Output (per 1M tokens)
Gemini 3 Pro $2.00 $8.00
Gemini 3 Flash $0.15 $0.60
Gemini 2.5 Pro $1.25 $5.00
Gemini 2.0 Flash $0.10 $0.40

Lưu ý: Free tier có giới hạn 15 RPM (requests per minute)

❌ "Viết code"
✅ "Viết một hàm Python tên `calculate_total` nhận parameter
là list các số, return tổng của chúng. Thêm docstring và
type hints."
model = genai.GenerativeModel(
"gemini-3-flash",
system_instruction="Bạn là trợ lý lập trình Python. "
"Luôn giải thích code rõ ràng. "
"Ưu tiên code clean và hiệu quả."
)
generation_config = genai.GenerationConfig(
temperature=0.2, # 0 = deterministic, 1 = creative
max_output_tokens=2048
)
Tính năng Gemini 3 Pro Gemini 3 Flash GPT-5 Claude 4.5 Sonnet
Context window 1M tokens 1M tokens 400K tokens 200K - 1M tokens
Agentic capabilities ✅ Mạnh ✅ Tốt
Multimodal
Grounding/Search ❌ (riêng)
Speed Trung bình Rất nhanh Trung bình Nhanh
Price (input) $2.00/1M $0.15/1M $1.25/1M $3.00/1M

Gemini là lựa chọn tuyệt vời cho:

  • Developer: API mạnh mẽ, context window lớn, giá cạnh tranh
  • Người dùng thường: Miễn phí qua gemini.google.com
  • Doanh nghiệp: Tích hợp sâu với Google Workspace

Với sự phát triển liên tục từ Google DeepMind, Gemini đang là một trong những AI model hàng đầu thế giới.