> For the list of every page, fetch /llms.txt. The API contract is the OpenAPI file linked from the API reference.

# Stream generated content (Gemini streamGenerateContent format)

POST https%3A%2F%2Fapi.usemeadow.ai/v1beta/models/{model}:streamGenerateContent
Content-Type: application/json

The streamed form of `generateContent`. Send `?alt=sse`, as the Google GenAI
SDKs and gemini-cli do. Meadow refuses the stream without it. The response is
`text/event-stream` with one `data:` line per `GenerateContentResponse` chunk,
as the vendor sent it. Token counts in `usageMetadata` add up over the stream,
so the last chunk holds the final ones. Auth, model ids, limits and errors are
as on `generateContent`. `/v1/models/{model}:streamGenerateContent` is served
too.

Scope: `models`.

```bash
curl -sS -N "$MEADOW_BASE_URL/v1beta/models/gemini-3.8-flash:streamGenerateContent?alt=sse" \
  -H "x-goog-api-key: $MEADOW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"contents":[{"role":"user","parts":[{"text":"Reply with the single word: meadow"}]}],
       "generationConfig":{"maxOutputTokens":16}}'
```

Reference: https://docs.usemeadow.ai/api-endpoints/models/stream-generate-content

## Authentication

- `Authorization` header (bearer token, required) — A Meadow API key, sent as `Authorization: Bearer mdw_...`. The header `x-api-key: mdw_...` is accepted in its place.

## Request

### Path parameters

- `model` (string, required) — A Meadow model id, for example `gemini-3.8-flash`.

### Query parameters

- `alt` (enum, required) — Must be `sse`.
  - Allowed values: `sse`

### Body (application/json)

This endpoint expects a map from string to any.

- `map from string to any`

## Response

### 200

The vendor's event stream, unchanged.

- Streaming response of `string`.

## Examples

**Request**

```json
{}
```

**SDK Code**

```python
import requests

url = "https://api.example.com/v1beta/models/model:streamGenerateContent"

querystring = {"alt":"sse"}

payload = {}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers, params=querystring)

print(response.json())
```

```javascript
const url = 'https://api.example.com/v1beta/models/model:streamGenerateContent?alt=sse';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.example.com/v1beta/models/model:streamGenerateContent?alt=sse"

	payload := strings.NewReader("{}")

	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(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.example.com/v1beta/models/model:streamGenerateContent?alt=sse")

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 = "{}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.example.com/v1beta/models/model:streamGenerateContent?alt=sse")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.example.com/v1beta/models/model:streamGenerateContent?alt=sse', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.example.com/v1beta/models/model:streamGenerateContent?alt=sse");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/v1beta/models/model:streamGenerateContent?alt=sse")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```