Chuyển đến nội dung chính
LemonData hỗ trợ định dạng Google Gemini API gốc cho các mô hình Gemini. Điều này cho phép khả năng tương thích trực tiếp với các Google AI SDK.

Tham số đường dẫn

model
string
bắt buộc
Tên mô hình (ví dụ: gemini-2.5-pro, gemini-2.5-flash).For production integrations, prefer URL-based fileData / file_data media parts with a public https URL. LemonData will route supported Gemini-native channels through the native path when possible and automatically fall back to the compatible internal conversion path when a native-ready route is unavailable for that multimodal request.

Tham số truy vấn

key
string
API key (phương thức thay thế cho xác thực qua header).

Xác thực

Các endpoint của Gemini hỗ trợ nhiều phương thức xác thực:
  • ?key=YOUR_API_KEY tham số truy vấn
  • x-goog-api-key: YOUR_API_KEY header
  • Authorization: Bearer YOUR_API_KEY header

Thân yêu cầu

contents
array
bắt buộc
Nội dung cuộc hội thoại.Mỗi đối tượng nội dung bao gồm:
  • role (string): user hoặc model
  • parts (array): các part nội dung. LemonData hiện hỗ trợ:
    • part văn bản: { "text": "..." }
    • part media inline: inlineData / inline_data
    • part tệp dựa trên URL: fileData / file_data
Với các media part, LemonData hiện chấp nhận MIME type của hình ảnh, âm thanh và video, sau đó chuyển tiếp qua public contract tương thích Gemini.
systemInstruction
object
Chỉ dẫn hệ thống cho mô hình.
generationConfig
object
Cấu hình tạo nội dung:
  • temperature (number): Nhiệt độ lấy mẫu (sampling temperature)
  • topP (number): Xác suất lấy mẫu hạt (nucleus sampling)
  • topK (integer): Lấy mẫu Top-K
  • maxOutputTokens (integer): Số lượng token đầu ra tối đa
  • stopSequences (array): Các chuỗi dừng (stop sequences)
safetySettings
array
Cài đặt bộ lọc an toàn.

Phản hồi

candidates
array
Các ứng viên nội dung được tạo.
usageMetadata
object
Thông tin sử dụng token.
curl -X POST "https://api.lemondata.cc/v1beta/models/gemini-2.5-pro:generateContent?key=sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      {
        "parts": [{"text": "Hello, Gemini!"}]
      }
    ],
    "generationConfig": {
      "temperature": 0.7,
      "maxOutputTokens": 1024
    }
  }'

Ví dụ đầu vào đa phương thức

Với các yêu cầu Gemini đa phương thức, hãy đặt media vào contents[].parts[] bằng byte inline hoặc tham chiếu tệp dựa trên URL. Các loại media hiện được hỗ trợ trong public contract Gemini:
  • image
  • audio
  • video
Với media inline, dùng inlineData hoặc inline_data và truyền byte tệp được mã hoá Base64. Với media qua URL, dùng fileData hoặc file_data và truyền một URL công khai https.

Ví dụ đầu vào hình ảnh

{
  "contents": [
    {
      "role": "user",
      "parts": [
        { "text": "Hãy mô tả hình ảnh này." },
        {
          "inlineData": {
            "mimeType": "image/jpeg",
            "data": "/9j/4AAQSkZJRgABAQ..."
          }
        }
      ]
    }
  ]
}

Ví dụ đầu vào âm thanh

{
  "contents": [
    {
      "role": "user",
      "parts": [
        { "text": "Hãy chép lời và tóm tắt đoạn âm thanh này." },
        {
          "file_data": {
            "mime_type": "audio/mpeg",
            "file_uri": "https://example.com/sample.mp3"
          }
        }
      ]
    }
  ]
}

Ví dụ đầu vào video

{
  "contents": [
    {
      "role": "user",
      "parts": [
        { "text": "Hãy mô tả ngắn gọn video này." },
        {
          "fileData": {
            "mimeType": "video/mp4",
            "fileUri": "https://example.com/sample.mp4"
          }
        }
      ]
    }
  ]
}
{
  "candidates": [
    {
      "content": {
        "role": "model",
        "parts": [
          {"text": "Hello! How can I assist you today?"}
        ]
      },
      "finishReason": "STOP",
      "safetyRatings": [
        {"category": "HARM_CATEGORY_HARASSMENT", "probability": "NEGLIGIBLE"}
      ]
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 5,
    "candidatesTokenCount": 10,
    "totalTokenCount": 15
  }
}

Video Input Example

{
  "contents": [
    {
      "role": "user",
      "parts": [
        { "text": "Please describe this video." },
        {
          "fileData": {
            "mimeType": "video/mp4",
            "fileUri": "https://example.com/demo.mp4"
          }
        }
      ]
    }
  ]
}

Audio Input Example

{
  "contents": [
    {
      "role": "user",
      "parts": [
        { "text": "Please describe this audio." },
        {
          "fileData": {
            "mimeType": "audio/mpeg",
            "fileUri": "https://example.com/demo.mp3"
          }
        }
      ]
    }
  ]
}