Gemini native streaming text generation
curl --request POST \
--url https://api.omnimux.ai/v1beta/models/{model}:streamGenerateContent \
--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}:streamGenerateContent"
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}:streamGenerateContent', 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}:streamGenerateContent"
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))
}data: {"candidates":[{"content":{"role":"model","parts":[{"text":"Hello"}]}}]}
data: {"candidates":[{"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":74,"candidatesTokenCount":6,"thoughtsTokenCount":115,"totalTokenCount":195}}
{
"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 · Native Streaming Understanding
Consume native response events and inspect final completion and usage.
POST
/
v1beta
/
models
/
{model}
:streamGenerateContent
Gemini native streaming text generation
curl --request POST \
--url https://api.omnimux.ai/v1beta/models/{model}:streamGenerateContent \
--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}:streamGenerateContent"
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}:streamGenerateContent', 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}:streamGenerateContent"
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))
}data: {"candidates":[{"content":{"role":"model","parts":[{"text":"Hello"}]}}]}
data: {"candidates":[{"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":74,"candidatesTokenCount":6,"thoughtsTokenCount":115,"totalTokenCount":195}}
{
"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>"
}
}- Models:
gemini-4-argon,gemini-4-hydrogen,gemini-4-neon,gemini-4-carbon; includealt=ssein the URL. - Use the same body as Native Multimodal Understanding.
- Read native response chunks from
data:events, wait for normal termination, and inspectfinishReasonand the final availableusageMetadata. - Partial text does not establish complete success. Reconcile the result and charge after an interruption before submitting again.
responseSchema.
Usage and errors
Do not sum cumulative usage snapshots. Input includes reported tool-use input, output includes reported thinking, and cached tokens are an input subset. Charges follow published account prices and final settlement. Automatic route changes do not alter the published price for this model. Insufficient balance can return403 with insufficient_user_quota, in addition to 402.Path Parameters
Body
application/json
Response
SSE data events containing native response chunks
The response is of type string.