Question: How is transform like middle-out used in AI SDK?
Right now i'm passing in as providerOptions. This feels like it's wrong so would love some clarity here. Thanks! https://openrouter.ai/docs/features/message-transforms
const result = streamText({
model,
headers,
messages: [
{
role: 'system',
content: systemPrompt,
providerOptions: {openrouter: { transforms: ['middle-out'] },} ,
},
...messages,
],
maxTokens,
maxSteps,
This feels like it's wrong
[Update]: Oh, I see this is inside the messages block. Do the providerOptions need to be there? My brain places them outside this block, as a sibling to model and headers (transforms could also get placed into headers, right?)
Okay after checking that my brain is not wrong (it often is): The providerOptions should indeed be on the same level as model and headers, so your example should read:
const result = streamText({
model,
headers,
messages: [
{
role: 'system',
content: systemPrompt,
},
...messages,
],
providerOptions: {openrouter: { transforms: ['middle-out'] },} ,
maxTokens,
maxSteps,
})
See here -> https://github.com/OpenRouterTeam/ai-sdk-provider#passing-extra-body-to-openrouter
I'm not sure. some providerOptions can be passed in messages such as caching. Is there a way to confirm from OR side if this option was enabled?
It looks like the recommended way is to use OpenTelemetry tracing to check if the request/payload matches what you expect with AI SDK, see -> https://ai-sdk.dev/docs/ai-sdk-core/telemetry