Skip to content
Main Site News Console

Gemini Native Format

For applications developed based on the Google GenAI SDK, 4ALL API provides Gemini native protocol compatibility:

POST https://api.4allapi.com/v1beta/models/{model}:generateContent
POST https://api.4allapi.com/v1beta/models/{model}:streamGenerateContent

Request Example

Terminal window
curl "https://api.4allapi.com/v1beta/models/omni-flash:generateContent" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $AIPROXY_KEY" \
-d '{
"contents": [{
"role": "user",
"parts": [{"text": "Introduce black holes in three sentences"}]
}]
}'

Key points:

  • Authentication uses the x-goog-api-key header (the ?key= query parameter is also supported);
  • Multimodal input is passed through the parts array, including inline_data (base64 image), etc.;
  • Streaming uses :streamGenerateContent and returns incremental JSON chunks;
  • Generation parameters are placed in generationConfig (temperature, maxOutputTokens, etc.).

Should you use native or OpenAI compatibility?

ScenarioRecommendation
New projects / switching between multiple modelsUse the OpenAI-compatible interface; only change model when switching models
Existing Google SDK codebaseUse the native protocol; just change the base_url
Need Gemini-specific fields (such as safety settings)Use the native protocol