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}:generateContentPOST https://api.4allapi.com/v1beta/models/{model}:streamGenerateContentRequest Example
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-keyheader (the?key=query parameter is also supported); - Multimodal input is passed through the
partsarray, includinginline_data(base64 image), etc.; - Streaming uses
:streamGenerateContentand returns incremental JSON chunks; - Generation parameters are placed in
generationConfig(temperature,maxOutputTokens, etc.).
Should you use native or OpenAI compatibility?
| Scenario | Recommendation |
|---|---|
| New projects / switching between multiple models | Use the OpenAI-compatible interface; only change model when switching models |
| Existing Google SDK codebase | Use the native protocol; just change the base_url |
| Need Gemini-specific fields (such as safety settings) | Use the native protocol |