I'm sorry, but the knowledge sources do not contain explicit information about inferring different return types for a Nitro endpoint based on optional query parameters using InternalApi or a similar type utility. The documentation covers how to define API routes, handle query parameters, and how Nitro generates types for API routes, but it does not describe a built-in way to infer conditional return types based on the presence or absence of specific query parameters in the type system.
You may need to implement your own type logic or use function overloads/typescript conditional types in your own code, but this approach is not documented in the provided Nuxt or Nitro documentation. If you need more advanced type inference based on query parameters, you might need to look for community solutions or open an issue for further guidance from the Nuxt/Nitro team.
For reference, Nitro will generate types for API routes, but these types are not automatically conditional on query parameters—they are based on the handler's return type as defined in your endpoint file, not on runtime query parameter values Server Engine.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: