---
title: Gemini Stream Inhalte generieren | RunAPI
description: Eine Anfrage über RunAPIs Gemini-kompatible Stream-Generate-Content-Operation
  senden.
url: https://runapi.ai/de/docs/api/gemini/stream-generate-content.md
canonical: https://runapi.ai/de/docs/api/gemini/stream-generate-content
locale: de
---

> HTML-Version: https://runapi.ai/de/docs/api/gemini/stream-generate-content
> Website-Index für KI-Agenten: https://runapi.ai/llms.txt

# Gemini Stream Inhalte generieren

## Übersicht

Verwende RunAPI's Gemini-kompatible Stream Generate Content-Operation mit einem kompatiblen Modell sowie den Anfrage- und Antwortstrukturen des Protokolls.

### Schnellstart

1. Erstellen Sie einen API-Schlüssel und setzen Sie ihn als RUNAPI_API_KEY.
2. Wählen Sie ein kompatibles Modell, senden Sie dann die dokumentierten Pfadparameter und den JSON-Body.
3. Lesen Sie die für diesen Vorgang angezeigte JSON-Antwort oder die server-sent events und behandeln Sie Protokollfehler.

## Endpunkt

POST /v1beta/models/{model}:streamGenerateContent?alt=sse

Basis-URL: https://runapi.ai

Vertragsversion: v1

Bevorzugte Authentifizierung: x-goog-api-key: YOUR_API_TOKEN

## Authentifizierungsträger

RunAPI akzeptiert jeden der unten aufgeführten Träger. Generierte Beispiele verwenden den bevorzugten Header des Protokolls.

- `Authorization: Bearer YOUR_API_TOKEN`
- `x-api-key: YOUR_API_TOKEN`
- `x-goog-api-key: YOUR_API_TOKEN` (Bevorzugt)
- `?key=YOUR_API_TOKEN`

## Kompatible Modelle

Öffnen Sie eine Modellseite für aktuelle Preise, Ratenlimits und Details zur kommerziellen Nutzung.

- [claude-fable-5-1](https://runapi.ai/de/models/claude)
- [claude-fable-5](https://runapi.ai/de/models/claude)
- [claude-sonnet-5](https://runapi.ai/de/models/claude)
- [claude-opus-5](https://runapi.ai/de/models/claude)
- [claude-opus-4-8](https://runapi.ai/de/models/claude)
- [claude-opus-4-7](https://runapi.ai/de/models/claude)
- [claude-opus-4-6](https://runapi.ai/de/models/claude)
- [claude-sonnet-4-6](https://runapi.ai/de/models/claude)
- [claude-opus-4-5-20251101](https://runapi.ai/de/models/claude)
- [claude-sonnet-4-5-20250929](https://runapi.ai/de/models/claude)
- [claude-haiku-4-5-20251001](https://runapi.ai/de/models/claude)
- [claude-opus-4-1-20250805](https://runapi.ai/de/models/claude)
- [gpt-5.5](https://runapi.ai/de/models/gpt)
- [gpt-5.5-pro](https://runapi.ai/de/models/gpt)
- [gpt-5.4](https://runapi.ai/de/models/gpt)
- [gpt-5.4-mini](https://runapi.ai/de/models/gpt)
- [gpt-5.4-nano](https://runapi.ai/de/models/gpt)
- [gpt-5.4-pro](https://runapi.ai/de/models/gpt)
- [gpt-5.3-codex](https://runapi.ai/de/models/gpt)
- [gpt-5.3-codex-spark](https://runapi.ai/de/models/gpt)
- [gpt-5.2](https://runapi.ai/de/models/gpt)
- [gpt-5.6-luna](https://runapi.ai/de/models/gpt)
- [gpt-5.6-sol](https://runapi.ai/de/models/gpt)
- [gpt-5.6-terra](https://runapi.ai/de/models/gpt)
- [gpt-6-astra](https://runapi.ai/de/models/gpt)
- [gemini-3.7-flash](https://runapi.ai/de/models/gemini)
- [gemini-3.6-flash](https://runapi.ai/de/models/gemini)
- [gemini-3.5-flash](https://runapi.ai/de/models/gemini)
- [gemini-3.1-pro-preview](https://runapi.ai/de/models/gemini)
- [gemini-3-flash-preview](https://runapi.ai/de/models/gemini)
- [gemini-2.5-pro](https://runapi.ai/de/models/gemini)
- [gemini-2.5-flash](https://runapi.ai/de/models/gemini)
- [deepseek-v4-flash-vision-exp](https://runapi.ai/de/models/deepseek)
- [deepseek-v4-pro](https://runapi.ai/de/models/deepseek)
- [deepseek-v4-flash](https://runapi.ai/de/models/deepseek)
- [glm-5.2](https://runapi.ai/de/models/glm)
- [glm-5.1](https://runapi.ai/de/models/glm)
- [glm-5-turbo](https://runapi.ai/de/models/glm)
- [glm-5](https://runapi.ai/de/models/glm)
- [glm-4.7](https://runapi.ai/de/models/glm)
- [glm-4.6](https://runapi.ai/de/models/glm)
- [glm-4.5](https://runapi.ai/de/models/glm)
- [glm-4.5-air](https://runapi.ai/de/models/glm)
- [kimi-k3](https://runapi.ai/de/models/kimi)
- [kimi-k2.7-code](https://runapi.ai/de/models/kimi)
- [kimi-k2.6](https://runapi.ai/de/models/kimi)
- [kimi-k2.5](https://runapi.ai/de/models/kimi)
- [MiniMax-M3](https://runapi.ai/de/models/minimax)
- [MiniMax-M2.7](https://runapi.ai/de/models/minimax)
- [MiniMax-M2.7-highspeed](https://runapi.ai/de/models/minimax)
- [MiniMax-M2.5](https://runapi.ai/de/models/minimax)
- [MiniMax-M2.5-highspeed](https://runapi.ai/de/models/minimax)
- [MiniMax-M2.1](https://runapi.ai/de/models/minimax)
- [MiniMax-M2](https://runapi.ai/de/models/minimax)
- [grok-4.5](https://runapi.ai/de/models/grok)
- [grok-4.3](https://runapi.ai/de/models/grok)

## Anfrage-Vertrag

Es werden nur Felder aufgeführt, für die sowohl öffentliche Protokoll- als auch RunAPI-Unterstützung belegt ist. Weitere JSON-Body-Felder werden durchgereicht.

### JSON-Body

Erforderlich: `contents`

```json
{
  "contents": {
    "description": "Gesprächsinhalt im Gemini Content and Part-Format.",
    "type": "array"
  },
  "generationConfig": {
    "description": "Gemini-Generierungskonfiguration für die Anfrage.",
    "type": "object"
  },
  "systemInstruction": {
    "description": "Systemanweisungen als Gemini Content dargestellt.",
    "type": "object"
  },
  "tools": {
    "description": "Tools, die das Modell aufrufen darf.",
    "type": "array"
  }
}
```

### Pfadparameter

Erforderlich: `model`

```json
{
  "model": {
    "description": "RunAPI-Modellbezeichner, der im Wire-Pfad platziert wird.",
    "type": "string"
  }
}
```

### Anfragebeispiel

```json
{
  "contents": [
    {
      "parts": [
        {
          "text": "Summarize one practical improvement for an API deployment."
        }
      ],
      "role": "user"
    }
  ]
}
```

## SSE-Ereignis: Chunk

Medientyp: `text/event-stream`

### Schema

```json
{
  "additionalProperties": true,
  "properties": {
    "candidates": {
      "items": {
        "additionalProperties": true,
        "properties": {
          "content": {
            "additionalProperties": true,
            "properties": {
              "parts": {
                "type": "array"
              },
              "role": {
                "type": "string"
              }
            },
            "type": "object"
          },
          "finishReason": {
            "type": "string"
          },
          "index": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "type": "array"
    },
    "modelVersion": {
      "type": "string"
    },
    "responseId": {
      "type": "string"
    },
    "usageMetadata": {
      "additionalProperties": true,
      "properties": {
        "candidatesTokenCount": {
          "type": "integer"
        },
        "promptTokenCount": {
          "type": "integer"
        },
        "totalTokenCount": {
          "type": "integer"
        }
      },
      "type": "object"
    }
  },
  "type": "object"
}
```

### Beispiel

```json
{
  "candidates": [
    {
      "content": {
        "parts": [
          {
            "text": "Hello"
          }
        ],
        "role": "model"
      },
      "finishReason": "STOP",
      "index": 0
    }
  ],
  "modelVersion": "gemini-3.5-flash",
  "responseId": "resp_example",
  "usageMetadata": {
    "candidatesTokenCount": 8,
    "promptTokenCount": 12,
    "totalTokenCount": 20
  }
}
```

## Protokollfehler: invalid_request

HTTP 400

### Schema

```json
{
  "additionalProperties": true,
  "properties": {
    "error": {
      "additionalProperties": true,
      "properties": {
        "code": {
          "type": "integer"
        },
        "message": {
          "type": "string"
        },
        "status": {
          "type": "string"
        }
      },
      "required": [
        "code",
        "message",
        "status"
      ],
      "type": "object"
    }
  },
  "required": [
    "error"
  ],
  "type": "object"
}
```

### Beispiel

```json
{
  "error": {
    "code": 400,
    "message": "contents is required",
    "status": "INVALID_ARGUMENT"
  }
}
```

## Verwendung

### Schema

```json
{
  "additionalProperties": true,
  "properties": {
    "candidatesTokenCount": {
      "type": "integer"
    },
    "promptTokenCount": {
      "type": "integer"
    },
    "totalTokenCount": {
      "type": "integer"
    }
  },
  "type": "object"
}
```

### Beispiel

```json
{
  "candidatesTokenCount": 8,
  "promptTokenCount": 12,
  "totalTokenCount": 20
}
```

## Generierte Code-Beispiele

Jedes cURL-, JavaScript- und Python-Beispiel sendet die validierte Anfrage aus diesem Vertrag, ohne ein protokollspezifisches SDK zu benötigen.

### curl

```curl
curl -X POST https://runapi.ai/v1beta/models/gemini-3.5-flash:streamGenerateContent\?alt\=sse \
  -H x-goog-api-key:\ YOUR_API_TOKEN \
  -H Content-Type:\ application/json \
  -d \{\"contents\":\[\{\"role\":\"user\",\"parts\":\[\{\"text\":\"Summarize\ one\ practical\ improvement\ for\ an\ API\ deployment.\"\}\]\}\]\}
```

### javascript

```javascript
const response = await fetch("https://runapi.ai/v1beta/models/gemini-3.5-flash:streamGenerateContent?alt=sse", {
  method: "POST",
  headers: {
  "x-goog-api-key": "YOUR_API_TOKEN",
  "Content-Type": "application/json"
},
  body: JSON.stringify({
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "text": "Summarize one practical improvement for an API deployment."
        }
      ]
    }
  ]
})
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const reader = response.body.getReader();
const decoder = new TextDecoder();
while (true) {
  const { value, done } = await reader.read();
  if (done) break;
  console.log(decoder.decode(value, { stream: true }));
}
```

### python

#### Installieren

```bash
pip install requests
```

```python
import requests

response = requests.post(
    "https://runapi.ai/v1beta/models/gemini-3.5-flash:streamGenerateContent?alt=sse",
    headers={"x-goog-api-key": "YOUR_API_TOKEN", "Content-Type": "application/json"},
    json={"contents": [{"role": "user", "parts": [{"text": "Summarize one practical improvement for an API deployment."}]}]},
    stream=True
)
response.raise_for_status()
for line in response.iter_lines(decode_unicode=True):
    if line:
        print(line)
```

## Verwandte Anleitungen

- [Authentifizierung](https://runapi.ai/de/docs/guides/authentication.md)
- [Schnellstart](https://runapi.ai/de/docs/guides/llm-api/quickstart.md)

---

## Mehr von RunAPI

- [Startseite](https://runapi.ai/de/.md)
- [Modellkatalog](https://runapi.ai/de/models.md)
- [Preise](https://runapi.ai/de/pricing.md)
- [Anbieter](https://runapi.ai/de/models)
- [Dokumentation](https://runapi.ai/de/docs/guides)
- [SDKs](https://runapi.ai/de/sdk.md)
- [CLI](https://runapi.ai/de/cli.md)
- [MCP Server](https://runapi.ai/de/mcp.md)
- [Claude Code vs Cursor](https://runapi.ai/de/claude-code-vs-cursor.md)
- [Cursor API-Einrichtung](https://runapi.ai/de/cursor-api-setup.md)
- [RunAPI vs OpenRouter](https://runapi.ai/de/openrouter-alternative.md)
- [Enterprise](https://runapi.ai/de/contact.md)
- [Kontakt](https://runapi.ai/de/contact.md)
- [Bedingungen](https://runapi.ai/de/terms.md)
- [Datenschutz](https://runapi.ai/de/privacy.md)
- [Website-Index für KI-Agenten](https://runapi.ai/llms.txt)

Kontakt: contact@runapi.ai

## Strukturierte Daten

```json
[
  {
    "@context": "https://schema.org",
    "inLanguage": "de",
    "@type": "WebSite",
    "name": "RunAPI",
    "url": "https://runapi.ai/de",
    "potentialAction": {
      "@type": "SearchAction",
      "target": {
        "@type": "EntryPoint",
        "urlTemplate": "https://runapi.ai/de/models?q={search_term_string}"
      },
      "query-input": "required name=search_term_string"
    }
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "de",
    "@type": "Organization",
    "name": "RunAPI",
    "url": "https://runapi.ai/de",
    "logo": {
      "@type": "ImageObject",
      "url": "https://runapi.ai/deicon.svg"
    },
    "sameAs": [
      "https://github.com/runapi-ai"
    ]
  },
  {
    "@context": "https://schema.org",
    "inLanguage": "de",
    "@type": "TechArticle",
    "headline": "Gemini Stream Inhalte generieren",
    "description": "Eine Anfrage über RunAPIs Gemini-kompatible Stream-Generate-Content-Operation senden.",
    "url": "https://runapi.ai/de/docs/api/gemini/stream-generate-content",
    "mainEntityOfPage": "https://runapi.ai/de/docs/api/gemini/stream-generate-content"
  }
]
```
