Chuyển đến nội dung chính
POST
/
v1beta
/
models
/
{model}
:generateContent
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
    }
  }'
{
  "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
  }
}
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).

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 phần nội dung (văn bản hoặc dữ liệu inline)
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
    }
  }'
{
  "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
  }
}