Skip to content

openRouter.callModel does not work in Nextjs Production app router #183

@ryankashi

Description

@ryankashi
	const result = openRouter.callModel({
		model: 'openai/gpt-5.2',
		instructions: 'model instructions!',
		input: 'hi!',
		parallelToolCalls: false,
		tools: [tool1, tool2, tool3...]
	});

Will create the function

	 try {
	 	const textStream = result.getTextStream();
	 	for await (const item of textStream) {
	 		console.log('item:', item);
	 	}
	 } catch (error) {
	 	console.log('got error:', error);
	 }

Causes an error, Unexpected response type from API

To recreate, just create a route.ts on Nextjs 15/16+ , run npm run build -> npm run start.

In production, the function will fail

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions