Gemini Native API#
Overview#
AIone supports calling the gateway directly using the Google Gemini native API format, suitable for custom gateway aggregation, the Google Gemini SDK, and scenarios where you already have Gemini integration code.The request and response formats are fully identical to the Google Gemini API. The gateway only handles authentication, routing, and billing — no format conversion is performed.Connection Details#
| Item | Value |
|---|
| Base URL | https://api.nexara.net |
| Authentication header | Authorization: Bearer sk-nex-your-key-here |
| Non-streaming endpoint | POST /v1beta/models/{model}:generateContent |
| Streaming endpoint | POST /v1beta/models/{model}:streamGenerateContent?alt=sse |
Note: Use your AIone API Key (sk-nex-xxx), not a Google API Key.
Supported Models#
All connected Gemini models are available through the native API, including:Text models: gemini-2.5-flash, gemini-2.5-pro, gemini-3-pro-preview, gemini-3-flash-preview, gemini-3.1-pro, etc.Image generation models: gemini-3.1-flash-image-preview, gemini-3-pro-image-preview, gemini-2.5-flash-image, etc.For the full list, query GET https://api.nexara.net/v1/models.Non-Streaming Request — generateContent#
Basic Example#
{
"candidates": [
{
"content": {
"parts": [{"text": "Quantum computing leverages quantum mechanics principles..."}],
"role": "model"
},
"finishReason": "STOP",
"index": 0
}
],
"usageMetadata": {
"promptTokenCount": 10,
"candidatesTokenCount": 25,
"totalTokenCount": 35
},
"modelVersion": "gemini-2.5-flash"
}
Image Generation Example#
Images are returned as inlineData (base64-encoded) in the candidates[0].content.parts[] of the response.Note: 4K image generation may take 2-3 minutes. Set your client's HTTP timeout to at least 600 seconds.
Streaming Request — streamGenerateContent#
Append ?alt=sse to the endpoint URL. The response is returned as SSE (Server-Sent Events) chunks.Example#
data: {"candidates":[{"content":{"parts":[{"text":"Spring"}],"role":"model"},"index":0}],"usageMetadata":{"promptTokenCount":8,"candidatesTokenCount":2,"totalTokenCount":10}}
data: {"candidates":[{"content":{"parts":[{"text":" breeze blows,"}],"role":"model"},"index":0}],"usageMetadata":{"promptTokenCount":8,"candidatesTokenCount":5,"totalTokenCount":13}}
data: {"candidates":[{"content":{"role":"model"},"finishReason":"STOP","index":0}],"usageMetadata":{"promptTokenCount":8,"candidatesTokenCount":28,"totalTokenCount":36}}
Each data: line is an independent JSON object. usageMetadata values are cumulative — the last chunk contains the final usage totals.Note: Image generation models do not support streamGenerateContent. Use generateContent instead.
Python SDK Example#
Node.js SDK Example#
Note: The official Google SDK may not directly support custom endpoints. If you encounter this limitation, we recommend using direct HTTP calls or a third-party library that supports custom Base URLs.
| Dimension | Gemini Native Format | OpenAI-Compatible Format |
|---|
| Endpoint | /v1beta/models/{model}:generateContent | /v1/chat/completions |
| Request body | contents + generationConfig | messages + max_tokens |
| Response body | candidates + usageMetadata | choices + usage |
| Image parameters | imageConfig.imageSize / imageConfig.aspectRatio | image_size / aspect_ratio |
| Streaming | :streamGenerateContent?alt=sse | "stream": true |
| Best for | Custom gateway aggregation, existing Gemini code | General-purpose clients, IDE plugins |
Both formats access the same set of models and upstream channels. Choose based on your client's requirements.Limitations & Notes#
1.
Authentication: Use your AIone sk-nex- API Key, not a Google API Key
2.
Image models do not support streaming: streamGenerateContent returns 503 for image generation models — use generateContent instead
3.
Supported actions: Only generateContent and streamGenerateContent are supported; countTokens, embedContent, etc. are not available
4.
Timeout settings: For image generation (especially 4K), set your HTTP timeout to at least 600 seconds
5.
Byte-level passthrough: Both requests and responses are passed through at the byte level — the gateway performs no format conversion
Modified at 2026-04-10 07:46:56