Gemini API(/v1 )
curl --request POST \
--url https://token.nusabase.com/silver/v1/models/{model} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"contents": [
{
"parts": [
{
"text": "<string>",
"inlineData": {
"mimeType": "<string>",
"data": "<string>"
}
}
]
}
],
"generationConfig": {
"temperature": 123,
"topP": 123,
"topK": 123,
"maxOutputTokens": 123,
"stopSequences": [
"<string>"
]
},
"safetySettings": [
{
"category": "<string>",
"threshold": "<string>"
}
],
"tools": [
{}
],
"systemInstruction": {
"parts": [
{}
]
}
}
'import requests
url = "https://token.nusabase.com/silver/v1/models/{model}"
payload = {
"contents": [{ "parts": [
{
"text": "<string>",
"inlineData": {
"mimeType": "<string>",
"data": "<string>"
}
}
] }],
"generationConfig": {
"temperature": 123,
"topP": 123,
"topK": 123,
"maxOutputTokens": 123,
"stopSequences": ["<string>"]
},
"safetySettings": [
{
"category": "<string>",
"threshold": "<string>"
}
],
"tools": [{}],
"systemInstruction": { "parts": [{}] }
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
contents: [
{
parts: [{text: '<string>', inlineData: {mimeType: '<string>', data: '<string>'}}]
}
],
generationConfig: {
temperature: 123,
topP: 123,
topK: 123,
maxOutputTokens: 123,
stopSequences: ['<string>']
},
safetySettings: [{category: '<string>', threshold: '<string>'}],
tools: [{}],
systemInstruction: {parts: [{}]}
})
};
fetch('https://token.nusabase.com/silver/v1/models/{model}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://token.nusabase.com/silver/v1/models/{model}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'contents' => [
[
'parts' => [
[
'text' => '<string>',
'inlineData' => [
'mimeType' => '<string>',
'data' => '<string>'
]
]
]
]
],
'generationConfig' => [
'temperature' => 123,
'topP' => 123,
'topK' => 123,
'maxOutputTokens' => 123,
'stopSequences' => [
'<string>'
]
],
'safetySettings' => [
[
'category' => '<string>',
'threshold' => '<string>'
]
],
'tools' => [
[
]
],
'systemInstruction' => [
'parts' => [
[
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://token.nusabase.com/silver/v1/models/{model}"
payload := strings.NewReader("{\n \"contents\": [\n {\n \"parts\": [\n {\n \"text\": \"<string>\",\n \"inlineData\": {\n \"mimeType\": \"<string>\",\n \"data\": \"<string>\"\n }\n }\n ]\n }\n ],\n \"generationConfig\": {\n \"temperature\": 123,\n \"topP\": 123,\n \"topK\": 123,\n \"maxOutputTokens\": 123,\n \"stopSequences\": [\n \"<string>\"\n ]\n },\n \"safetySettings\": [\n {\n \"category\": \"<string>\",\n \"threshold\": \"<string>\"\n }\n ],\n \"tools\": [\n {}\n ],\n \"systemInstruction\": {\n \"parts\": [\n {}\n ]\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://token.nusabase.com/silver/v1/models/{model}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"contents\": [\n {\n \"parts\": [\n {\n \"text\": \"<string>\",\n \"inlineData\": {\n \"mimeType\": \"<string>\",\n \"data\": \"<string>\"\n }\n }\n ]\n }\n ],\n \"generationConfig\": {\n \"temperature\": 123,\n \"topP\": 123,\n \"topK\": 123,\n \"maxOutputTokens\": 123,\n \"stopSequences\": [\n \"<string>\"\n ]\n },\n \"safetySettings\": [\n {\n \"category\": \"<string>\",\n \"threshold\": \"<string>\"\n }\n ],\n \"tools\": [\n {}\n ],\n \"systemInstruction\": {\n \"parts\": [\n {}\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://token.nusabase.com/silver/v1/models/{model}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"contents\": [\n {\n \"parts\": [\n {\n \"text\": \"<string>\",\n \"inlineData\": {\n \"mimeType\": \"<string>\",\n \"data\": \"<string>\"\n }\n }\n ]\n }\n ],\n \"generationConfig\": {\n \"temperature\": 123,\n \"topP\": 123,\n \"topK\": 123,\n \"maxOutputTokens\": 123,\n \"stopSequences\": [\n \"<string>\"\n ]\n },\n \"safetySettings\": [\n {\n \"category\": \"<string>\",\n \"threshold\": \"<string>\"\n }\n ],\n \"tools\": [\n {}\n ],\n \"systemInstruction\": {\n \"parts\": [\n {}\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"candidates": [
{
"content": {
"role": "<string>",
"parts": [
{}
]
},
"finishReason": "<string>",
"safetyRatings": [
{}
]
}
],
"usageMetadata": {
"promptTokenCount": 123,
"candidatesTokenCount": 123,
"totalTokenCount": 123
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}Gemini
Gemini API(/v1 )
Gemini 原生 API 接口(通过 /v1 前缀访问)。/v1/models/ 之后的路径直接透传(如 gemini-2.0-flash:generateContent)。
POST
/
v1
/
models
/
{model}
Gemini API(/v1 )
curl --request POST \
--url https://token.nusabase.com/silver/v1/models/{model} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"contents": [
{
"parts": [
{
"text": "<string>",
"inlineData": {
"mimeType": "<string>",
"data": "<string>"
}
}
]
}
],
"generationConfig": {
"temperature": 123,
"topP": 123,
"topK": 123,
"maxOutputTokens": 123,
"stopSequences": [
"<string>"
]
},
"safetySettings": [
{
"category": "<string>",
"threshold": "<string>"
}
],
"tools": [
{}
],
"systemInstruction": {
"parts": [
{}
]
}
}
'import requests
url = "https://token.nusabase.com/silver/v1/models/{model}"
payload = {
"contents": [{ "parts": [
{
"text": "<string>",
"inlineData": {
"mimeType": "<string>",
"data": "<string>"
}
}
] }],
"generationConfig": {
"temperature": 123,
"topP": 123,
"topK": 123,
"maxOutputTokens": 123,
"stopSequences": ["<string>"]
},
"safetySettings": [
{
"category": "<string>",
"threshold": "<string>"
}
],
"tools": [{}],
"systemInstruction": { "parts": [{}] }
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
contents: [
{
parts: [{text: '<string>', inlineData: {mimeType: '<string>', data: '<string>'}}]
}
],
generationConfig: {
temperature: 123,
topP: 123,
topK: 123,
maxOutputTokens: 123,
stopSequences: ['<string>']
},
safetySettings: [{category: '<string>', threshold: '<string>'}],
tools: [{}],
systemInstruction: {parts: [{}]}
})
};
fetch('https://token.nusabase.com/silver/v1/models/{model}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://token.nusabase.com/silver/v1/models/{model}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'contents' => [
[
'parts' => [
[
'text' => '<string>',
'inlineData' => [
'mimeType' => '<string>',
'data' => '<string>'
]
]
]
]
],
'generationConfig' => [
'temperature' => 123,
'topP' => 123,
'topK' => 123,
'maxOutputTokens' => 123,
'stopSequences' => [
'<string>'
]
],
'safetySettings' => [
[
'category' => '<string>',
'threshold' => '<string>'
]
],
'tools' => [
[
]
],
'systemInstruction' => [
'parts' => [
[
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://token.nusabase.com/silver/v1/models/{model}"
payload := strings.NewReader("{\n \"contents\": [\n {\n \"parts\": [\n {\n \"text\": \"<string>\",\n \"inlineData\": {\n \"mimeType\": \"<string>\",\n \"data\": \"<string>\"\n }\n }\n ]\n }\n ],\n \"generationConfig\": {\n \"temperature\": 123,\n \"topP\": 123,\n \"topK\": 123,\n \"maxOutputTokens\": 123,\n \"stopSequences\": [\n \"<string>\"\n ]\n },\n \"safetySettings\": [\n {\n \"category\": \"<string>\",\n \"threshold\": \"<string>\"\n }\n ],\n \"tools\": [\n {}\n ],\n \"systemInstruction\": {\n \"parts\": [\n {}\n ]\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://token.nusabase.com/silver/v1/models/{model}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"contents\": [\n {\n \"parts\": [\n {\n \"text\": \"<string>\",\n \"inlineData\": {\n \"mimeType\": \"<string>\",\n \"data\": \"<string>\"\n }\n }\n ]\n }\n ],\n \"generationConfig\": {\n \"temperature\": 123,\n \"topP\": 123,\n \"topK\": 123,\n \"maxOutputTokens\": 123,\n \"stopSequences\": [\n \"<string>\"\n ]\n },\n \"safetySettings\": [\n {\n \"category\": \"<string>\",\n \"threshold\": \"<string>\"\n }\n ],\n \"tools\": [\n {}\n ],\n \"systemInstruction\": {\n \"parts\": [\n {}\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://token.nusabase.com/silver/v1/models/{model}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"contents\": [\n {\n \"parts\": [\n {\n \"text\": \"<string>\",\n \"inlineData\": {\n \"mimeType\": \"<string>\",\n \"data\": \"<string>\"\n }\n }\n ]\n }\n ],\n \"generationConfig\": {\n \"temperature\": 123,\n \"topP\": 123,\n \"topK\": 123,\n \"maxOutputTokens\": 123,\n \"stopSequences\": [\n \"<string>\"\n ]\n },\n \"safetySettings\": [\n {\n \"category\": \"<string>\",\n \"threshold\": \"<string>\"\n }\n ],\n \"tools\": [\n {}\n ],\n \"systemInstruction\": {\n \"parts\": [\n {}\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"candidates": [
{
"content": {
"role": "<string>",
"parts": [
{}
]
},
"finishReason": "<string>",
"safetyRatings": [
{}
]
}
],
"usageMetadata": {
"promptTokenCount": 123,
"candidatesTokenCount": 123,
"totalTokenCount": 123
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"param": "<string>",
"code": "<string>"
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Model Model name
Body
application/json