User Guide
General Model

Gemini Native Format

Use Gemini native paths and native request bodies; supports generateContent and streamGenerateContent; successful responses are Gemini original JSON.

  • Route template: POST /v1beta/models/{model}:{action}
  • Supports generateContent and streamGenerateContent
  • Successful responses follow the Gemini original protocol

Request Example

curl --request POST \
  --url https://api.magickapi.com/v1beta/models/gemini-2.5-pro:generateContent \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "contents": [
      {
        "role": "user",
        "parts": [
          {
            "text": "你好,介绍一下自己"
          }
        ]
      }
    ]
  }'

Successful Response Example

{
  "candidates": [
    {
      "content": {
        "role": "model",
        "parts": [
          {
            "text": "你好!我是一个由 Google 模型协议兼容接入的 AI 助手。"
          }
        ]
      },
      "finishReason": "STOP",
      "index": 0
    }
  ],
  "promptFeedback": {
    "safetyRatings": []
  },
  "usageMetadata": {
    "promptTokenCount": 4,
    "candidatesTokenCount": 18,
    "totalTokenCount": 22
  }
}

Error Response Example

{
  "error": {
    "code": 400,
    "message": "Invalid argument",
    "status": "INVALID_ARGUMENT"
  }
}

Authentication

  • Request header: Authorization: Bearer YOUR_API_KEY
  • The authentication here is still the Magick API gateway key; the Google Key is not directly exposed to the client.

Path Parameters

model

  • Type: string

  • Required: Yes

    Examples: gemini-2.5-pro, gemini-2.5-flash.

action

  • Type: string

  • Required: Yes

    Common actions verified in the current project:

  • generateContent

  • streamGenerateContent

Request Body

The request body maintains the Gemini native JSON structure. Common fields include:

  • contents
  • systemInstruction
  • tools
  • toolConfig
  • generationConfig
  • safetySettings

Compatibility Notes

  • If you want to use OpenAI-style request bodies, please switch to "General Models / General Chat Interface".

Last updated on

On this page