Images & Vision

View as Markdown

Mesh API uses POST /v1/chat/completions for image input and image generation.

Use this guide for two common workflows:

  • Send image input to a multimodal model
  • Generate images from a text prompt

Find image-capable models

Call GET /v1/models and inspect:

  • input_modalities for image input support
  • output_modalities for image output support

Send image input

You can send images to multimodal models (like GPT-4o or Claude 3.5 Sonnet) by passing an array of content parts in the message.

Mesh API supports two ways to provide images:

  1. Base64 encoded data: Use data:image/jpeg;base64,... URLs.
  2. Public HTTP URLs: Use standard https://... URLs.

[!WARNING] Not all models support passing images via public URL. Some models (especially from certain providers) require images to be base64 encoded. Check the provider documentation or use base64 encoding to ensure maximum compatibility.

Here is an example request sending an image via URL:

$curl https://api.meshapi.ai/v1/chat/completions \
> -H "Authorization: Bearer <YOUR_RSK_KEY>" \
> -H "Content-Type: application/json" \
> -d '{
> "model": "openai/gpt-4o",
> "messages": [
> {
> "role": "user",
> "content": [
> {
> "type": "text",
> "text": "What is in this image?"
> },
> {
> "type": "image_url",
> "image_url": {
> "url": "https://example.com/image.jpg",
> "detail": "auto"
> }
> }
> ]
> }
> ]
> }'

To send a base64 encoded image, replace the url value with the data URL: "url": "data:image/jpeg;base64,iVBORw0KGgo..."

Generate images

Use the same chat completions endpoint with image-generation-capable models.

$curl https://api.meshapi.ai/v1/chat/completions \
> -H "Authorization: Bearer <YOUR_RSK_KEY>" \
> -H "Content-Type: application/json" \
> -d '{
> "model": "openai/gpt-image-1",
> "image": {
> "size": "1024x1024",
> "quality": "high",
> "response_format": "url"
> },
> "messages": [
> {
> "role": "user",
> "content": "Generate a watercolor of a fox in a snowy forest."
> }
> ]
> }'

The exact assistant payload may vary by model. Build against the documented response fields for the model you choose and the media format you request.

Request tips

  • Use detail: "low" for lower-cost image understanding when supported.
  • Use hosted HTTPS URLs or data: URLs for image input.

SDK coverage

  • Node: client.chat.completions.create(...)
  • Python: client.chat.completions.create(...)
  • Go: client.Chat.Completions.Create(...)
  • Java: client.chat().completions().create(...)