Skip to main content

Gemini Native API

Our Chat service also supports the native Google Gemini API format, allowing you to use the official Google GenAI libraries directly.
This API is designed for developers who prefer using Google’s native SDK instead of the OpenAI-compatible format.

🌟 Key Features

  • βœ… Use the official Google GenAI SDK directly
  • βœ… Full compatibility with Gemini API format
  • βœ… Support for streaming and non-streaming responses
  • βœ… Access to Gemini models through our service

πŸ“‹ Available Endpoints

EndpointMethodDescription
/chat/gemini/{apiVersion}/models/{model}:generateContentPOSTGenerate content (non-streaming)
/chat/gemini/{apiVersion}/models/{model}:streamGenerateContentPOSTGenerate content (streaming with SSE)

πŸ’‘ Quick Examples

import { GoogleGenAI } from '@google/genai';

const API_KEY = 'your-api-key';
const API_VERSION = 'v1beta';
const BASE_URL = 'https://api.mountsea.ai/chat/gemini';

const client = new GoogleGenAI({
  apiKey: API_KEY,
  apiVersion: API_VERSION,
  httpOptions: {
    baseUrl: BASE_URL,
    headers: {
      "Authorization": `Bearer ${API_KEY}`,
    },
  },
});

// Generate content (non-streaming)
const response = await client.models.generateContent({
  model: 'gemini-3-flash',
  contents: [
    {
      role: 'user',
      parts: [{ text: 'Hello! Tell me a joke.' }]
    }
  ],
  config: {
    temperature: 1,
    maxOutputTokens: 1024,
  }
});

console.log(response.text);
Streaming:
const stream = await client.models.streamGenerateContent({
  model: 'gemini-3-flash',
  contents: [
    {
      role: 'user',
      parts: [{ text: 'Write a short story about a robot.' }]
    }
  ],
  config: {
    temperature: 0.8,
    maxOutputTokens: 2048,
  }
});

for await (const chunk of stream) {
  process.stdout.write(chunk.text || '');
}
Install:
npm install @google/genai

πŸ“€ Response Format

Non-streaming Response

{
  "candidates": [
    {
      "content": {
        "parts": [
          {
            "text": "Why don't scientists trust atoms? Because they make up everything!"
          }
        ],
        "role": "model"
      },
      "finishReason": "STOP",
      "safetyRatings": [...]
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 10,
    "candidatesTokenCount": 15,
    "totalTokenCount": 25
  }
}

Streaming Response (SSE)

data: {"candidates":[{"content":{"parts":[{"text":"Why"}],"role":"model"}}]}

data: {"candidates":[{"content":{"parts":[{"text":" don't"}],"role":"model"}}]}

data: {"candidates":[{"content":{"parts":[{"text":" scientists"}],"role":"model"}}]}

...

πŸ”§ Configuration Options

The config / generationConfig object supports:
ParameterTypeDescription
temperaturenumberControls randomness (0-2)
maxOutputTokensnumberMaximum tokens in response
topPnumberNucleus sampling parameter
topKnumberTop-K sampling parameter
systemInstructionobjectSystem prompt configuration
toolsarrayFunction calling tools

With System Instruction

const response = await client.models.generateContent({
  model: 'gemini-3-flash',
  contents: [
    { role: 'user', parts: [{ text: 'What is the capital of France?' }] }
  ],
  config: {
    temperature: 0.7,
    maxOutputTokens: 1024,
    systemInstruction: {
      role: 'user',
      parts: [{ text: 'You are a helpful geography teacher. Answer concisely.' }]
    }
  }
});

πŸ“ Multi-turn Conversation

{
  "contents": [
    {
      "role": "user",
      "parts": [{ "text": "Hi, my name is Alice." }]
    },
    {
      "role": "model",
      "parts": [{ "text": "Hello Alice! Nice to meet you." }]
    },
    {
      "role": "user",
      "parts": [{ "text": "What's my name?" }]
    }
  ]
}

For OpenAI-compatible API, see Chat Completions.