generateContentStream throwing error for Gemini Tuned Model

I am using Gemini tuned model to generate text for a user session which can have large amount of text. While calling the API generateContentStream, I am getting error: “Error: [GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/tunedModels/[TunedModelName]:streamGenerateContent?alt=sse: [404 Not Found]”

The streaming works fine for the base model “gemini-1.5-flash” and facing issue only for the Tuned Model. The generateContent works fine which trims the overall content which is not desirable for my use case.

As per documentation from Google: “Gemini API'yi kullanarak metin oluşturma  |  Google AI for Developers” generateContentStream should be able to return partial data.

Here is the code:

const { GoogleGenerativeAI } = require(“@google/generative-ai”);

const genAI = new GoogleGenerativeAI(“API KEY”);
const model = genAI.getGenerativeModel({ model: “tunedModels/[Tuned Model name]”

const result = await model.generateContentStream(userPrompt);
let content = “”;
for await (const item of result.stream) {
content = content + item.candidates[0].content.parts[0].text;
}

req.body.modelResponse = content;

Actual vs expected behavior:

Actual:

Error: [GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/tunedModels/[TunedModelName]:streamGenerateContent?alt=sse: [404 Not Found]

Expected:

result.stream should be populated with the partial results.

Thanks for your help.

As best as I can tell, there’s no streaming for tuned model, it’s never been there, maybe in the future perhaps. But for now only base models have streaming. This API Reference also proves the point: All methods  |  Gemini API  |  Google AI for Developers

Thanks for your reply.