LLM

Send images to LLMs (vision) via API

In POST /llm/chat/completions, a message's content can mix text and image_url parts, as in OpenAI. Models with supports_vision in GET /llm/models accept images, and Connect translates image_url for Anthropic, so the code is the same.

The request

POST /api/llm/chat/completions
Authorization: Bearer <merchant token>

{
  "model": "anthropic/claude-sonnet-5-5",
  "max_tokens": 512,
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "Describe this ad creative."
        },
        {
          "type": "image_url",
          "image_url": {
            "url": "https://example.com/creative.jpg"
          }
        }
      ]
    }
  ]
}

What you can do

  • Ask the model to describe or analyze an image.
  • Mix text and several images in the same message.
  • Check in GET /llm/models which models have supports_vision.
  • Combine images with stream and fallback.

Rules and limits

  • image_url parts are only accepted if every model in the call (model and each item of models) has supports_vision. Otherwise: 400 llm_unsupported_field.
  • On Anthropic, audio or file parts return 400 llm_unsupported_field; images through image_url are translated.
  • The request body is at most 1 MB (413 llm_request_too_large).
  • max_tokens is still required and cannot exceed the account cap or the models' max_output_tokens.
  • Images count as input tokens, billed by the provider on your key.

Main fields

FieldTypeRequiredDescription
modelstringYesModel id from GET /llm/models, in provider/model form.
messagesarrayYesThe conversation. content can be text or text and image_url parts.
max_tokensintegerYesRequired (or max_completion_tokens). Up to the account cap and each model's max_output_tokens in the call.
modelsarrayNoFallback: up to 3 models from GET /llm/models, tried in order if model fails before the first token.

Who it is for

  • Ad creative analysis

    Your product sends a campaign's creative and gets an assessment of the visual and the copy.

  • Alt text and captions

    Generate image descriptions for customers' posts straight from your SaaS.

  • Agents that read screenshots and charts

    An agent receives a dashboard screenshot and explains the numbers in text.

Frequently asked questions

Which models accept images?

Those with supports_vision true in GET /llm/models. Sending image_url to a model without it returns 400 llm_unsupported_field.

How do I send the image?

As in OpenAI: a content part with type image_url and the image_url object. Connect translates it for Anthropic.

Is there a size limit?

The whole request body can be up to 1 MB. Above that the response is 413 llm_request_too_large.

Related

See everything you can do with LLM

See Connect applied to your product.

Try it for 15 days with no card, or walk our team through your use case.