Gemini native text generation
curl --request POST \
--url https://api.omnimux.ai/v1beta/models/{model}:generateContent \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Hello."
}
]
}
]
}
'import requests
url = "https://api.omnimux.ai/v1beta/models/{model}:generateContent"
payload = { "contents": [
{
"role": "user",
"parts": [{ "text": "Hello." }]
}
] }
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: [{role: 'user', parts: [{text: 'Hello.'}]}]})
};
fetch('https://api.omnimux.ai/v1beta/models/{model}:generateContent', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.omnimux.ai/v1beta/models/{model}:generateContent"
payload := strings.NewReader("{\n \"contents\": [\n {\n \"role\": \"user\",\n \"parts\": [\n {\n \"text\": \"Hello.\"\n }\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))
}{
"modelVersion": "<string>",
"responseId": "<string>",
"candidates": [
{
"index": 123,
"finishReason": "<string>",
"content": {
"role": "<string>",
"parts": [
{
"text": "<string>",
"thought": true,
"functionCall": {
"name": "<string>",
"args": {}
}
}
]
}
}
],
"usageMetadata": {
"promptTokenCount": 1,
"toolUsePromptTokenCount": 1,
"candidatesTokenCount": 1,
"thoughtsTokenCount": 1,
"cachedContentTokenCount": 1,
"totalTokenCount": 1,
"promptTokensDetails": [
{
"modality": "<string>",
"tokenCount": 1
}
],
"toolUsePromptTokensDetails": [
{
"modality": "<string>",
"tokenCount": 1
}
]
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}Gemini
Gemini · 原生多模态理解
通过原生内容接口提交文字和素材,返回文字或结构化结果。
POST
/
v1beta
/
models
/
{model}
:generateContent
Gemini native text generation
curl --request POST \
--url https://api.omnimux.ai/v1beta/models/{model}:generateContent \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Hello."
}
]
}
]
}
'import requests
url = "https://api.omnimux.ai/v1beta/models/{model}:generateContent"
payload = { "contents": [
{
"role": "user",
"parts": [{ "text": "Hello." }]
}
] }
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: [{role: 'user', parts: [{text: 'Hello.'}]}]})
};
fetch('https://api.omnimux.ai/v1beta/models/{model}:generateContent', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.omnimux.ai/v1beta/models/{model}:generateContent"
payload := strings.NewReader("{\n \"contents\": [\n {\n \"role\": \"user\",\n \"parts\": [\n {\n \"text\": \"Hello.\"\n }\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))
}{
"modelVersion": "<string>",
"responseId": "<string>",
"candidates": [
{
"index": 123,
"finishReason": "<string>",
"content": {
"role": "<string>",
"parts": [
{
"text": "<string>",
"thought": true,
"functionCall": {
"name": "<string>",
"args": {}
}
}
]
}
}
],
"usageMetadata": {
"promptTokenCount": 1,
"toolUsePromptTokenCount": 1,
"candidatesTokenCount": 1,
"thoughtsTokenCount": 1,
"cachedContentTokenCount": 1,
"totalTokenCount": 1,
"promptTokensDetails": [
{
"modality": "<string>",
"tokenCount": 1
}
],
"toolUsePromptTokensDetails": [
{
"modality": "<string>",
"tokenCount": 1
}
]
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}- 模型放在请求路径中,正文使用
contents;无需另加正文model。 - 系统指令使用
systemInstruction。素材是输入内容,不应覆盖系统指令。 - 同一条用户消息可包含文字、完整视频和多张参考图片,输出为文字或结构化结果。
- 流式调用见原生流式理解。
模型
| 模型标识 |
|---|
gemini-4-argon |
gemini-4-hydrogen |
gemini-4-neon |
gemini-4-carbon |
素材与结果
通过parts[].inlineData 提交 PNG、MP4 或 PDF;mimeType 与实际文件一致,data 为不含数据网址前缀的完整文件编码。本页未列出的格式、素材容量和长素材限制,请在接入前确认,勿将请求示例当作服务上限。
通过 generationConfig.thinkingConfig.thinkingLevel 指定思考档位:gemini-4-hydrogen 与 gemini-4-neon 支持 low、medium、high、xhigh;gemini-4-carbon 支持 low、medium、high;gemini-4-argon 文档以 low 为例。maxOutputTokens 同时覆盖思考与可见输出,示例值不代表最大输出上限。
需要结构化结果时,使用 generationConfig.responseMimeType: application/json 与原生 responseSchema。这些结构化输出参数会按原生请求转发,但返回内容仍可能带有代码围栏,或出现不符合结构要求的字段类型,例如预期数组的字段返回为对象。调用方须校验实际返回内容和字段类型,再用于后续处理。
检查完整回复的 finishReason、返回内容及 usageMetadata。收到 functionCall 后,由调用方执行函数;本页不承诺多轮工具执行。
费用与用量
按已公布的账户价格和实际用量结算;自动切换服务线路不会改变该模型的已公布售价。普通输入包含上游已报告的工具输入,输出包含已报告的思考;已报告缓存属于输入子集,不再重复累加。流式累计快照也不按片段重复计费。缺失的用量字段不代表上游明确报告零。 余额不足应检查错误体:除402 外,原生入口也可能返回 403 和 insufficient_user_quota;不要将全部 403 都归为权限问题。请求体
application/json
响应
Native response; inspect finishReason and usageMetadata