Types missing for new AI models `gpt-oss-120b`, `gpt-oss-20b`
This model is missing from the input types:
await env.AI.run('@cf/openai/gpt-oss-120b', {
instructions: 'some prompt'
input: 'some input',
max_tokens: 10240,
})
Argument of type '"@cf/openai/gpt-oss-120b"' is not assignable to parameter of type 'keyof AiModels'.ts(2345)
And I've not found any output type that matches the output correctly either. It's very different from AiTextGenerationOutput. This isn't helped when https://developers.cloudflare.com/workers-ai/models/gpt-oss-120b/ doesn't document this type either.
It seems like an update here landed as per https://github.com/cloudflare/workerd/pull/5111, but as per my comment at https://github.com/cloudflare/workerd/pull/5111#issuecomment-3304247714, the output types for these models are not quite accurate and now throw errors like this:
const response = await context.env.AI.run('@cf/openai/gpt-oss-120b', {
instructions: 'some prompt',
input: 'some input',
max_tokens: 10240,
});
const results = response?.output?.find?.(item => item.type === 'message');
Property 'output' does not exist on type 'Ai_Cf_Openai_Gpt_Oss_120B_Output'.
Property 'output' does not exist on type '{}'.
cc @thatsKevinJain
Hello, I am hitting this issue as well when trying to use the model. Is there any workaround till the issue is fixed?
any update?
Hey @robzlabz the types package has been updated for the gpt-oss models: https://github.com/cloudflare/workerd/pull/5434
You can update the "@cloudflare/workers-types" to the latest version.