convertToLanguageModelPrompt

suspend fun convertToLanguageModelPrompt(messages: List<ModelMessage>, supportedUrls: Map<String, List<String>> = emptyMap(), download: DownloadFunction? = null): List<ModelMessage>(source)

Resolve a prompt for a specific model — the port of upstream's convertToLanguageModelPrompt:

  • URL assets: ContentPart.Image/ContentPart.File parts that carry a url the model's supportedUrls does NOT cover are inlined as base64. data: URLs are decoded directly; remote URLs are fetched via download (when supplied). URLs the model supports pass through untouched.

  • Dangling tool calls: every assistant tool call must have a matching tool result before the next user/system turn (and by the end), else MissingToolResultsError is thrown — providers otherwise reject the prompt with a cryptic error.

Call this before handing a prompt to a provider that doesn't natively accept asset URLs. It is a no-op for prompts that are already inline and well-formed.