Gemini Native Format
Call Gemini models via the Google Gemini native API protocol. Fully compatible with Gemini's native request format, path structure, and response format.
Try it now
Quick Start
Step 1: Get your API Key from the Console.
Step 2: Send a request:
curl -X POST "https://open.dieyuyun.com/v1beta/models/gemini-2.5-pro:generateContent" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxx" \
-d '{
"contents": [
{
"role": "user",
"parts": [{"text": "Hello, introduce yourself"}]
}
]
}'import requests
url = "https://open.dieyuyun.com/v1beta/models/gemini-2.5-pro:generateContent"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer sk-xxx"
}
payload = {
"contents": [
{
"role": "user",
"parts": [{"text": "Hello, introduce yourself"}]
}
]
}
response = requests.post(url, json=payload, headers=headers)
result = response.json()
print(result["candidates"][0]["content"]["parts"][0]["text"])const response = await fetch('https://open.dieyuyun.com/v1beta/models/gemini-2.5-pro:generateContent', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer sk-xxx',
},
body: JSON.stringify({
contents: [
{
role: 'user',
parts: [{ text: 'Hello, introduce yourself' }],
},
],
}),
})
const result = await response.json()
console.log(result.candidates[0].content.parts[0].text)Step 3: Read the response from candidates[0].content.parts[0].text.
Endpoint
| Item | Value |
|---|---|
| Method | POST |
| Path | /v1beta/models/{model}:generateContent |
/v1beta/models/{model}:streamGenerateContent (streaming) | |
| Base URL | https://open.dieyuyun.com |
| Protocol | Google Gemini API |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | Model identifier, e.g. gemini-2.5-pro |
| action | string | Yes | Operation type: generateContent or streamGenerateContent |
Authentication
Uses Bearer Token authentication (shares the same API Key as the OpenAI-compatible endpoint):
Authorization: Bearer sk-xxxTIP
The platform uses a unified API Key for all endpoints. No separate Google API Key is needed. Your API Key is securely forwarded to the upstream provider on the server side.
Supported Models
| Model | Context Length | Description |
|---|---|---|
| gemini-2.5-pro | 1M | Gemini flagship reasoning model |
| gemini-2.5-flash | 1M | Gemini fast model |
| gemini-2.0-flash | 1M | Gemini 2.0 fast model |
TIP
See the full model list in the Console.
Request Parameters
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| contents | array | Yes | — | Conversation content list, each with role and parts |
| systemInstruction | object | No | — | System instruction to define model behavior |
| generationConfig | object | No | — | Generation parameter configuration |
| safetySettings | array | No | — | Safety settings |
| tools | array | No | — | Tool definitions |
| toolConfig | object | No | — | Tool calling configuration |
generationConfig Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| temperature | number | 1.0 | Sampling randomness, range 0~2 |
| topP | number | 0.95 | Nucleus sampling parameter |
| topK | integer | 40 | Top-K sampling |
| maxOutputTokens | integer | — | Maximum output tokens |
| stopSequences | array | — | Strings that stop generation |
| responseMimeType | string | — | Response MIME type, e.g. application/json |
contents Structure
{
"contents": [
{
"role": "user",
"parts": [
{ "text": "Describe this image" },
{
"inline_data": {
"mime_type": "image/jpeg",
"data": "/9j/4AAQ..."
}
}
]
}
]
}Request Examples
With System Instruction and Generation Config
curl -X POST "https://open.dieyuyun.com/v1beta/models/gemini-2.5-pro:generateContent" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxx" \
-d '{
"systemInstruction": {
"parts": [{"text": "You are a professional translator. Translate to English."}]
},
"contents": [
{
"role": "user",
"parts": [{"text": "Artificial intelligence is changing our way of life."}]
}
],
"generationConfig": {
"temperature": 0.7,
"maxOutputTokens": 1024
}
}'import requests
url = "https://open.dieyuyun.com/v1beta/models/gemini-2.5-pro:generateContent"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer sk-xxx"
}
payload = {
"systemInstruction": {
"parts": [{"text": "You are a professional translator. Translate to English."}]
},
"contents": [
{
"role": "user",
"parts": [{"text": "Artificial intelligence is changing our way of life."}]
}
],
"generationConfig": {
"temperature": 0.7,
"maxOutputTokens": 1024
}
}
response = requests.post(url, json=payload, headers=headers)
result = response.json()
print(result["candidates"][0]["content"]["parts"][0]["text"])const response = await fetch('https://open.dieyuyun.com/v1beta/models/gemini-2.5-pro:generateContent', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer sk-xxx',
},
body: JSON.stringify({
systemInstruction: {
parts: [{ text: 'You are a professional translator. Translate to English.' }],
},
contents: [
{
role: 'user',
parts: [{ text: 'Artificial intelligence is changing our way of life.' }],
},
],
generationConfig: {
temperature: 0.7,
maxOutputTokens: 1024,
},
}),
})
const result = await response.json()
console.log(result.candidates[0].content.parts[0].text)Streaming Output
Use the streamGenerateContent endpoint for streaming responses:
curl -X POST "https://open.dieyuyun.com/v1beta/models/gemini-2.5-pro:streamGenerateContent" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxx" \
-d '{
"contents": [
{
"role": "user",
"parts": [{"text": "Write a poem about the ocean"}]
}
]
}'Multimodal Input (Images)
{
"contents": [
{
"role": "user",
"parts": [
{ "text": "What's in this image?" },
{
"inline_data": {
"mime_type": "image/png",
"data": "iVBORw0KGgo..."
}
}
]
}
]
}Function Calling
{
"contents": [
{
"role": "user",
"parts": [{ "text": "What's the weather like in Beijing today?" }]
}
],
"tools": [
{
"functionDeclarations": [
{
"name": "get_weather",
"description": "Get weather information for a city",
"parameters": {
"type": "object",
"properties": {
"city": {
"type": "string",
"description": "City name"
}
},
"required": ["city"]
}
}
]
}
]
}Response Format
Successful Response
{
"candidates": [
{
"content": {
"parts": [
{
"text": "Hello! I'm Gemini, a multimodal AI model developed by Google DeepMind. I can process text, images, code, and more."
}
],
"role": "model"
},
"finishReason": "STOP",
"index": 0
}
],
"usageMetadata": {
"promptTokenCount": 6,
"candidatesTokenCount": 42,
"totalTokenCount": 48
},
"modelVersion": "gemini-2.5-pro"
}Field Reference
| Field | Description |
|---|---|
| candidates[].content.parts[].text | Response text content |
| candidates[].content.role | Role, model for model responses |
| candidates[].finishReason | Stop reason: STOP, MAX_TOKENS, SAFETY |
| candidates[].safetyRatings | Safety ratings |
| usageMetadata.promptTokenCount | Number of input tokens |
| usageMetadata.candidatesTokenCount | Number of output tokens |
| usageMetadata.totalTokenCount | Total token count |
| modelVersion | Actual model version used |
Error Response
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT"
}
}See Error Codes for details.
Compatibility
| Feature | Wuliang AI | Google Gemini Native API |
|---|---|---|
| Path format | /v1beta/models/{model}:action | Same |
| Request body format | Gemini native JSON | Native protocol |
| generateContent | Supported | Native support |
| streamGenerateContent | Supported | Native support |
| Multimodal input | Supports base64 | Supports base64 / file_data |
| Function calling | Supported | Native support |
| System instruction | Supports systemInstruction | Native support |
| Authentication | Bearer Token (platform API Key) | Google API Key |
| safetySettings | Pass-through support | Native support |
TIP
The platform uses Gemini's native paths and request body format. Successful responses return the Gemini native format directly. The only difference is authentication -- the platform's unified API Key replaces the Google API Key.
Best Practices
- Choose the right endpoint: Use
generateContentfor non-streaming andstreamGenerateContentfor streaming. The path structure is identical. - Leverage long context: Gemini supports up to 1M tokens of context, ideal for processing long documents, large codebases, and more.
- Use
systemInstruction: Define model behavior via system instructions. Note the Gemini format:{"parts": [{"text": "..."}]}. - Multimodal input: Supports base64-encoded images for image analysis, OCR, and other visual tasks.
- JSON mode output: Force JSON output via
generationConfig.responseMimeType = "application/json".
Rate Limits
See Rate Limits for details.
Related Docs
- Chat Completions (Streaming) - Use the OpenAI-compatible protocol
- Claude Messages - Use the Anthropic native protocol
- OpenAI Responses - Use the OpenAI Responses API
- Manage API Keys - Create and configure API keys