Skip to content

Gemini-compatible ​

Gemini-compatible API uses the Gemini style path and request body. This is suitable for applications that have accessed the Gemini format and for text understanding and media input.

Method and Path ​

http
POST /v1beta/models/{model}:generateContent
POST /v1beta/models/{modelName}:generateContent

Text request ​

bash
curl https://moonnexai.com/v1beta/models/gemini-compatible:generateContent \
  -H "Authorization: Bearer <MOONNEXAI_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      {
        "role": "user",
        "parts": [
          {
            "text": "写一段简短的产品介绍。"
          }
        ]
      }
    ]
  }'

Picture Understanding ​

json
{
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "text": "描述这张图片。"
        },
        {
          "inlineData": {
            "mimeType": "image/png",
            "data": "<BASE64_IMAGE>"
          }
        }
      ]
    }
  ]
}

Use recommendations ​

  • The model name in the path should be consistent with the model available in the MoonNexAI console.
  • Pictures, PDF, audio or video input suggest that the file be kept in size to avoid an oversized request.
  • OpenAI-compatible applications are used to continue text series; application in Gemini format prioritizes page API.

Relevant Pages ​