LLM ROUTING

Build mixed text and image messages for OpenRouter

In this article
THE QUICK TAKE

Content blocks preserve modality and ordering, so an image must be represented as image input rather than a text string that merely mentions its address.

A multimodal request is not just a text prompt with an image filename appended. OpenRouter’s image-input documentation describes multipart content for supported models. The structure tells the API which content is text and which is visual input, while the application supplies the question that makes the image relevant to the task.

Choose the model’s actual input capability

For a hypothetical diagram-explanation app, select a model and provider endpoint that accept image input. A text-only route cannot infer the visual content simply because the request includes a URL in prose. Capability discovery should precede request construction. Keep the current supported modalities in the integration record rather than assuming that a provider’s general brand implies every model behind it can interpret images.

Use the chosen API’s block shape

The current image-input page presents Responses examples using input_image content parts and an image_url value. Chat Completions has its own documented content-part structure. Do not combine those field shapes into a hybrid object. For the diagram app, keep text and image parts inside the relevant user message according to the endpoint contract, so the client can validate the request before sending it.

Preserve a useful relationship between parts

The documentation recommends text before images, with guidance for cases where images come first inside the same user message. Give each image a clear role in the question. If the diagram app compares alternatives, identify which image is the reference and which is the candidate. Ordering alone should not carry an undocumented meaning that disappears when another component rearranges the content array.

Choose URL or embedded data deliberately

The image page supports direct URLs and base64 data URLs. A remote address must be retrievable by the processing path; a workstation-local file path is not a public image URL. Embedded data can represent an image that the application already holds, subject to documented model and request limits. Choose the representation according to accessibility and size rather than assuming a browser’s logged-in image can be fetched upstream.

Validate the visual task result

A successfully accepted image block does not establish a correct explanation of the diagram. Use a representative image with known relationships and assess whether the answer identifies them. Keep the source image associated with the response so a reviewer can inspect the basis of the interpretation. The client’s job is to preserve modality and task context, while domain evaluation determines whether the model’s visual conclusion is useful.

Documentation and further study

Related engineering guides: Fetching the OpenRouter model catalog before deployment; OpenRouter base URL: configuring a compatible client.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles