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
| Endpoint | Method | Description |
|---|
/chat/gemini/{apiVersion}/models/{model}:generateContent | POST | Generate content (non-streaming) |
/chat/gemini/{apiVersion}/models/{model}:streamGenerateContent | POST | Generate 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
from google import genai
API_KEY = "your-api-key"
API_VERSION = "v1beta"
BASE_URL = "https://api.mountsea.ai/chat/gemini"
client = genai.Client(
api_key=API_KEY,
http_options={
"base_url": BASE_URL,
"headers": {
"Authorization": f"Bearer {API_KEY}",
},
},
)
# Generate content (non-streaming)
response = client.models.generate_content(
model="gemini-3-flash",
contents=[
{
"role": "user",
"parts": [{"text": "Hello! Tell me a joke."}]
}
],
config={
"temperature": 1,
"max_output_tokens": 1024,
}
)
print(response.text)
Streaming:stream = client.models.generate_content_stream(
model="gemini-3-flash",
contents=[
{
"role": "user",
"parts": [{"text": "Write a short story about a robot."}]
}
],
config={
"temperature": 0.8,
"max_output_tokens": 2048,
}
)
for chunk in stream:
print(chunk.text, end="")
Install:package main
import (
"context"
"fmt"
"google.golang.org/genai"
)
func main() {
ctx := context.Background()
apiKey := "your-api-key"
baseURL := "https://api.mountsea.ai/chat/gemini"
client, _ := genai.NewClient(ctx, &genai.ClientConfig{
APIKey: apiKey,
BaseURL: baseURL,
Headers: map[string]string{
"Authorization": "Bearer " + apiKey,
},
})
defer client.Close()
// Generate content (non-streaming)
model := client.GenerativeModel("gemini-3-flash")
model.Temperature = genai.Ptr(float32(1.0))
model.MaxOutputTokens = genai.Ptr(int32(1024))
resp, _ := model.GenerateContent(ctx, genai.Text("Hello! Tell me a joke."))
for _, part := range resp.Candidates[0].Content.Parts {
fmt.Println(part)
}
}
Streaming:iter := model.GenerateContentStream(ctx, genai.Text("Write a short story about a robot."))
for {
resp, err := iter.Next()
if err == iterator.Done {
break
}
for _, part := range resp.Candidates[0].Content.Parts {
fmt.Print(part)
}
}
Install:go get google.golang.org/genai
# Non-streaming
curl -X POST "https://api.mountsea.ai/chat/gemini/v1beta/models/gemini-3-flash:generateContent?key=your-api-key" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-api-key" \
-d '{
"contents": [
{
"role": "user",
"parts": [{"text": "Hello! Tell me a joke."}]
}
],
"generationConfig": {
"temperature": 1,
"maxOutputTokens": 1024
}
}'
# Streaming (SSE)
curl -X POST "https://api.mountsea.ai/chat/gemini/v1beta/models/gemini-3-flash:streamGenerateContent?alt=sse&key=your-api-key" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-api-key" \
-d '{
"contents": [
{
"role": "user",
"parts": [{"text": "Write a story"}]
}
]
}'
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:
| Parameter | Type | Description |
|---|
temperature | number | Controls randomness (0-2) |
maxOutputTokens | number | Maximum tokens in response |
topP | number | Nucleus sampling parameter |
topK | number | Top-K sampling parameter |
systemInstruction | object | System prompt configuration |
tools | array | Function 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.' }]
}
}
});
response = client.models.generate_content(
model="gemini-3-flash",
contents=[
{"role": "user", "parts": [{"text": "What is the capital of France?"}]}
],
config={
"temperature": 0.7,
"max_output_tokens": 1024,
"system_instruction": {
"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?" }]
}
]
}