AIone API (English)
    • 01 - Quick Start
    • 02 - Authentication
    • 03 - Error Codes
    • 04 - Pricing
    • 05 - Contact Us
    • 06 - Quality of Service
    • 07 - Complete Examples
    • 08 - Caching & Cost Optimization
    • 11 - Model Quality Monitoring
    • 12 - Network & Connectivity
    • 13 - Model Naming & Compatibility
    • 14 - Gemini Image Generation
    • 09 - Model Verification
    • 10 - IDE Integration
    • 15 - Gemini Native API

    15 - Gemini Native API

    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#

    ItemValue
    Base URLhttps://api.nexara.net
    Authentication headerAuthorization: Bearer sk-nex-your-key-here
    Non-streaming endpointPOST /v1beta/models/{model}:generateContent
    Streaming endpointPOST /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#

    Response Format#

    {
      "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#

    SSE Response Format#

    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.

    Comparison with OpenAI-Compatible Format#

    DimensionGemini Native FormatOpenAI-Compatible Format
    Endpoint/v1beta/models/{model}:generateContent/v1/chat/completions
    Request bodycontents + generationConfigmessages + max_tokens
    Response bodycandidates + usageMetadatachoices + usage
    Image parametersimageConfig.imageSize / imageConfig.aspectRatioimage_size / aspect_ratio
    Streaming:streamGenerateContent?alt=sse"stream": true
    Best forCustom gateway aggregation, existing Gemini codeGeneral-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
    Previous
    10 - IDE Integration
    Built with