APICallError [AI_APICallError]: Failed to process successful response
at postToApi (file:///repo/node_modules/@ai-sdk/provider-utils/dist/index.mjs:636:13)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
... 2 lines matching cause stack trace ...
at async file:///repo/node_modules/ai/dist/index.mjs:1426:22
at async _retryWithExponentialBackoff (file:///repo/node_modules/ai/dist/index.mjs:1577:12)
at async streamStep (file:///repo/node_modules/ai/dist/index.mjs:4719:15)
at async fn (file:///repo/node_modules/ai/dist/index.mjs:5060:9)
at async file:///repo/node_modules/ai/dist/index.mjs:1426:22 {
cause: TypeError: First parameter has member 'readable' that is not a ReadableStream.
at assertReadableStream (/repo/node_modules/web-streams-polyfill/dist/ponyfill.js:466:19)
at convertReadableWritablePair (/repo/node_modules/web-streams-polyfill/dist/ponyfill.js:4035:9)
at ReadableStream.pipeThrough (/repo/node_modules/web-streams-polyfill/dist/ponyfill.js:4119:29)
at parseJsonEventStream (file:///repo/node_modules/@ai-sdk/provider-utils/dist/index.mjs:502:17)
at file:///repo/node_modules/@ai-sdk/provider-utils/dist/index.mjs:785:12
at postToApi (file:///repo/node_modules/@ai-sdk/provider-utils/dist/index.mjs:625:20)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async OpenAIResponsesLanguageModel.doStream (file:///repo/node_modules/@ai-sdk/openai/dist/index.mjs:2592:50)
at async fn (file:///repo/node_modules/ai/dist/index.mjs:4763:27)
at async file:///repo/node_modules/ai/dist/index.mjs:1426:22,
url: 'https://api.openai.com/v1/responses',
requestBodyValues: {
model: 'gpt-5',
input: [ [Object], [Object] ],
temperature: undefined,
top_p: undefined,
max_output_tokens: undefined,
text: { verbosity: 'low' },
metadata: undefined,
parallel_tool_calls: undefined,
previous_response_id: undefined,
store: undefined,
user: undefined,
instructions: undefined,
service_tier: 'flex',
include: undefined,
prompt_cache_key: undefined,
safety_identifier: undefined,
reasoning: { effort: 'high' },
tools: [ [Object], [Object] ],
tool_choice: 'auto',
stream: true
},
statusCode: 200,
responseHeaders: {
'alt-svc': 'h3=":443"; m
Error message: [{"code":"invalid_value","values":["url_citation"],"path":["output",13,"content",0,"annotations",0,"type"],"message":"Invalid input: expected \"url_citation\""},{"expected":"number","code":"invalid_type","path":["output",13,"content",0,"annotations",0,"start_index"],"message":"Invalid input: expected number, received undefined"},{"expected":"number","code":"invalid_type","path":["output",13,"content",0,"annotations",0,"end_index"],"message":"Invalid input: expected number, received undefined"},{"expected":"string","code":"invalid_type","path":["output",13,"content",0,"annotations",0,"url"],"message":"Invalid input: expected string, received undefined"},{"expected":"string","code":"invalid_type","path":["output",13,"content",0,"annotations",0,"title"],"message":"Invalid input: expected string, received undefined"},{"code":"invalid_value","values":["url_citation"],"path":["output",13,"content",0,"annotations",1,"type"],"message":"Invalid input: expected \"url_citation\""},{"expected":"number","code":"invalid_type","path":["output",13,"content",0,"annotations",1,"start_index"],"message":"Invalid input: expected number, received undefined"},{"expected":"number","code":"invalid_type","path":["output",13,"content",0,"annotations",1,"end_index"],"message":"Invalid input: expected number, received undefined"},{"expected":"string","code":"invalid_type","path":["output",13,"content",0,"annotations",1,"url"],"message":"Invalid input: expected string, received undefined"},{"expected":"string","code":"invalid_type","path":["output",13,"content",0,"annotations",1,"title"],"message":"Invalid input: expected string, received undefined"}]
at Object.validate (file:///repo/node_modules/@ai-sdk/provider-utils/dist/index.mjs:403:14)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async safeValidateTypes (file:///repo/node_modules/@ai-sdk/provider-utils/dist/index.mjs:431:20)
at async safeParseJSON (file:///repo/node_modules/@ai-sdk/provider-utils/dist/index.mjs:476:12)
at async file:///repo/node_modules/@ai-sdk/provider-utils/dist/index.mjs:820:24
at async postToApi (file:///repo/node_modules/@ai-sdk/provider-utils/dist/index.mjs:625:14)
at async OpenAIResponsesLanguageModel.doGenerate (file:///repo/node_modules/@ai-sdk/openai/dist/index.mjs:2342:9)
at async fn (file:///repo/node_modules/ai/dist/index.mjs:2144:34)
at async file:///repo/node_modules/ai/dist/index.mjs:1426:22
at async _retryWithExponentialBackoff (file:///repo/node_modules/ai/dist/index.mjs:1577:12)
Description
When I attempt to call both tools within a single
generateText(orstreamText) call, the Responses API returns annotations that include bothurl_citationandfile_citationtypes. The SDK’s validator expects onlyurl_citationin certain paths, which leads to a type validation error.Reproduction:
Error:
(omitted some of the output for breivity)
AI SDK Version