> ## Documentation Index
> Fetch the complete documentation index at: https://openrouter.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Image Inputs

> How to send images to OpenRouter models

Requests with images, to multimodal models, are available via the [Responses API](https://openrouter.ai/docs/api_reference/responses/overview.md) (`/api/v1/responses`) with a multi-part message in the `input` parameter. Each image is an `input_image` content part whose `image_url` can either be a URL or a base64-encoded data URL. Note that multiple images can be sent in separate content array entries. The number of images you can send in a single request varies per provider and per model. Due to how the content is parsed, we recommend sending the text prompt first, then the images. If the images must come first, put them before the text within the same user message; system messages should contain text only.

OpenRouter supports both **direct URLs** and **base64-encoded data** for images:

* **URLs**: More efficient for publicly accessible images as they don't require local encoding
* **Base64**: Required for local files or private images that aren't publicly accessible

### Using Image URLs

Here's how to send an image using a URL:

```typescript title="TypeScript SDK" expandable lines theme={null}
import { OpenRouter } from '@openrouter/sdk';

const openRouter = new OpenRouter({
  apiKey: '<OPENROUTER_API_KEY>',
});

const result = await openRouter.responses.send({
  responsesRequest: {
    model: 'google/gemini-3-flash-preview',
    input: [
      {
        role: 'user',
        content: [
          {
            type: 'input_text',
            text: "What's in this image?",
          },
          {
            type: 'input_image',
            imageUrl: 'https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg',
            detail: 'auto',
          },
        ],
      },
    ],
    stream: false,
  },
});

console.log(result);
```

```python Python expandable lines theme={null}
import os
import requests
import json

url = "https://openrouter.ai/api/v1/responses"
headers = {
    "Authorization": f"Bearer {os.environ['OPENROUTER_API_KEY']}",
    "Content-Type": "application/json"
}

input_items = [
    {
        "role": "user",
        "content": [
            {
                "type": "input_text",
                "text": "What's in this image?"
            },
            {
                "type": "input_image",
                "image_url": "https://upload.wikimedia.org/wikipedia/commons/a/a7/Camponotus_flavomarginatus_ant.jpg",
                "detail": "auto"
            }
        ]
    }
]

payload = {
    "model": "google/gemini-3-flash-preview",
    "input": input_items
}

response = requests.post(url, headers=headers, json=payload)
print(json.dumps(response.json(), indent=2))

```

```typescript title="TypeScript (fetch)" expandable lines theme={null}
const response = await fetch('https://openrouter.ai/api/v1/responses', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${API_KEY_REF}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    model: 'google/gemini-3-flash-preview',
    input: [
      {
        role: 'user',
        content: [
          {
            type: 'input_text',
            text: "What's in this image?",
          },
          {
            type: 'input_image',
            image_url: 'https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg',
            detail: 'auto',
          },
        ],
      },
    ],
  }),
});

const data = await response.json();
console.log(data);
```

```go title="Go" lines theme={null}
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"log"
	"net/http"
	"os"
)

func main() {
	url := "https://openrouter.ai/api/v1/responses"

	inputItems := []map[string]any{
		{
			"role": "user",
			"content": []map[string]any{
				{
					"type": "input_text",
					"text": "What's in this image?",
				},
				{
					"type":      "input_image",
					"image_url": "https://upload.wikimedia.org/wikipedia/commons/a/a7/Camponotus_flavomarginatus_ant.jpg",
					"detail":    "auto",
				},
			},
		},
	}

	payload, _ := json.Marshal(map[string]any{
		"model": "google/gemini-3-flash-preview",
		"input": inputItems,
	})

	req, _ := http.NewRequest("POST", url, bytes.NewReader(payload))
	req.Header.Set("Authorization", "Bearer "+os.Getenv("OPENROUTER_API_KEY"))
	req.Header.Set("Content-Type", "application/json")

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		log.Fatal(err)
	}
	defer resp.Body.Close()

	var result any
	if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
		log.Fatal(err)
	}
	out, _ := json.MarshalIndent(result, "", "  ")
	fmt.Println(string(out))
}

```

```bash title="cURL" lines theme={null}
curl https://openrouter.ai/api/v1/responses \
  -H "Authorization: Bearer $OPENROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "google/gemini-3-flash-preview",
    "input": [
      {
        "role": "user",
        "content": [
          {
            "type": "input_text",
            "text": "What'\''s in this image?"
          },
          {
            "type": "input_image",
            "image_url": "https://upload.wikimedia.org/wikipedia/commons/a/a7/Camponotus_flavomarginatus_ant.jpg",
            "detail": "auto"
          }
        ]
      }
    ]
  }' | jq .

```

```text title="Output" theme={null}
{
  "id": "gen-1794950496-qXeJleMqPYYaHhDfKmc8",
  "object": "response",
  "created_at": 1794950496,
  "model": "google/gemini-3-flash-preview",
  "status": "completed",
  "completed_at": 1794950499,
  "output": [
    {
      "id": "msg_tmp_mfmg6zapsg8",
      "type": "message",
      "role": "assistant",
      "status": "completed",
      "content": [
        {
          "type": "output_text",
          "text": "A close-up, high-angle shot shows a black carpenter ant on a light brown, gritty surface. The ant's head, which has its mandibles open, points towards the upper left corner of the frame. The ant's thorax and abdomen are also black, but its legs are a lighter brown. Its abdomen is a light brown color with thin, horizontal black stripes. The ant's legs are spread out, and its antennae are tucked in towards its head. The background is a blurry blend of dark reddish browns and oranges. The lighting is soft and diffused, creating a shallow depth of field that highlights the ant.",
          "annotations": [],
          "logprobs": []
        }
      ]
    },
    {
      "id": "rs_tmp_kp722gun36",
      "type": "reasoning",
      "status": "completed",
      "summary": [],
      "encrypted_content": "AY89a1+LwO7pEbrfZ/kZ+Qdrc8r/3ztvp8blrnIqc6apf5dNmyC1d14MnaJ/r1EM4bb2VHxM0yy2pAysKsYJuXVyp02rOsI8wUPCAxX7ldEAbF+BaCQrCaztfaAOCEaycyu9HQRWanA2aBY710zQQMXVwceFdHl8z7cgtVQRNxhpqjI/.eyJlbmRwb2ludF9zbHVnIjoiZ29vZ2xlL2dlbWluaS0zLWZsYXNoLXByZXZpZXctMjAyNTEyMTd8Z29vZ2xlLXZlcnRleC9nbG9iYWwifQ",
      "format": "google-gemini-v1"
    }
  ],
  "error": null,
  "incomplete_details": null,
  "access_programs": null,
  "tools": [],
  "tool_choice": "auto",
  "parallel_tool_calls": true,
  "max_output_tokens": null,
  "temperature": 1,
  "top_p": 1,
```

### Using Base64 Encoded Images

For locally stored images, you can send them using base64 encoding. Here's how to do it:

```typescript title="TypeScript SDK" expandable lines theme={null}
import { OpenRouter } from '@openrouter/sdk';
import * as fs from 'fs';

const openRouter = new OpenRouter({
  apiKey: '<OPENROUTER_API_KEY>',
});

async function encodeImageToBase64(imagePath: string): Promise<string> {
  const imageBuffer = await fs.promises.readFile(imagePath);
  const base64Image = imageBuffer.toString('base64');
  return `data:image/jpeg;base64,${base64Image}`;
}

// Read and encode the image
const imagePath = 'path/to/your/image.jpg';
const base64Image = await encodeImageToBase64(imagePath);

const result = await openRouter.responses.send({
  responsesRequest: {
    model: 'google/gemini-3-flash-preview',
    input: [
      {
        role: 'user',
        content: [
          {
            type: 'input_text',
            text: "What's in this image?",
          },
          {
            type: 'input_image',
            imageUrl: base64Image,
            detail: 'auto',
          },
        ],
      },
    ],
    stream: false,
  },
});

console.log(result);
```

```python Python expandable lines theme={null}
import os
import requests
import json
import base64
from pathlib import Path

def encode_image_to_base64(image_path):
    with open(image_path, "rb") as image_file:
        return base64.b64encode(image_file.read()).decode('utf-8')

url = "https://openrouter.ai/api/v1/responses"
headers = {
    "Authorization": f"Bearer {os.environ['OPENROUTER_API_KEY']}",
    "Content-Type": "application/json"
}

# Read and encode the image
image_path = "path/to/your/image.jpg"
base64_image = encode_image_to_base64(image_path)
data_url = f"data:image/jpeg;base64,{base64_image}"

input_items = [
    {
        "role": "user",
        "content": [
            {
                "type": "input_text",
                "text": "What's in this image?"
            },
            {
                "type": "input_image",
                "image_url": data_url,
                "detail": "auto"
            }
        ]
    }
]

payload = {
    "model": "google/gemini-3-flash-preview",
    "input": input_items
}

response = requests.post(url, headers=headers, json=payload)
print(json.dumps(response.json(), indent=2))

```

```typescript title="TypeScript (fetch)" expandable lines theme={null}
import * as fs from 'fs';

async function encodeImageToBase64(imagePath: string): Promise<string> {
  const imageBuffer = await fs.promises.readFile(imagePath);
  const base64Image = imageBuffer.toString('base64');
  return `data:image/jpeg;base64,${base64Image}`;
}

// Read and encode the image
const imagePath = 'path/to/your/image.jpg';
const base64Image = await encodeImageToBase64(imagePath);

const response = await fetch('https://openrouter.ai/api/v1/responses', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.OPENROUTER_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    model: 'google/gemini-3-flash-preview',
    input: [
      {
        role: 'user' as const,
        content: [
          {
            type: 'input_text',
            text: "What's in this image?",
          },
          {
            type: 'input_image',
            image_url: base64Image,
            detail: 'auto',
          },
        ],
      },
    ],
  }),
});

const data = await response.json();
console.log(data);
```

```go title="Go" lines theme={null}
package main

import (
	"bytes"
	"encoding/base64"
	"encoding/json"
	"fmt"
	"log"
	"net/http"
	"os"
)

func encodeImageToBase64(imagePath string) (string, error) {
	data, err := os.ReadFile(imagePath)
	if err != nil {
		return "", err
	}
	return "data:image/jpeg;base64," + base64.StdEncoding.EncodeToString(data), nil
}

func main() {
	// Read and encode the image
	imagePath := "path/to/your/image.jpg"
	base64Image, err := encodeImageToBase64(imagePath)
	if err != nil {
		log.Fatal(err)
	}

	payload, _ := json.Marshal(map[string]any{
		"model": "google/gemini-3-flash-preview",
		"input": []map[string]any{
			{
				"role": "user",
				"content": []map[string]any{
					{"type": "input_text", "text": "What's in this image?"},
					{"type": "input_image", "image_url": base64Image, "detail": "auto"},
				},
			},
		},
		"stream": false,
	})

	req, _ := http.NewRequest("POST", "https://openrouter.ai/api/v1/responses", bytes.NewReader(payload))
	req.Header.Set("Authorization", "Bearer "+os.Getenv("OPENROUTER_API_KEY"))
	req.Header.Set("Content-Type", "application/json")

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		log.Fatal(err)
	}
	defer resp.Body.Close()

	var result any
	if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
		log.Fatal(err)
	}
	out, _ := json.MarshalIndent(result, "", "  ")
	fmt.Println(string(out))
}

```

```bash title="cURL" lines theme={null}
IMAGE_PATH="path/to/your/image.jpg"

# Encode the image as a base64 data URL and build the request body
jq -n --rawfile b64 <(base64 < "$IMAGE_PATH" | tr -d '\n') '{
  model: "google/gemini-3-flash-preview",
  input: [
    {
      role: "user",
      content: [
        {type: "input_text", text: "What'\''s in this image?"},
        {type: "input_image", image_url: ("data:image/jpeg;base64," + $b64), detail: "auto"}
      ]
    }
  ],
  stream: false
}' | curl https://openrouter.ai/api/v1/responses \
  -H "Authorization: Bearer $OPENROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d @- | jq .
```

```text title="Output" theme={null}
{
  background: false,
  completedAt: 1794950529,
  createdAt: 1794950528,
  error: null,
  frequencyPenalty: 0,
  id: "gen-1794950528-vxGvSVDV5FPhcBBaUx4C",
  incompleteDetails: null,
  instructions: null,
  maxOutputTokens: null,
  maxToolCalls: null,
  metadata: {},
  model: "google/gemini-3-flash-preview",
  object: "response",
  output: [
    {
      content: [Array ...],
      id: "msg_tmp_m90y5vwb43f",
      role: "assistant",
      status: "completed",
      type: "message",
    }, {
      encryptedContent: "AY89a1/kzKMhnXBc8+Cbn3I7YIl7POsZC3a3tj204tIt6X2I4Gkh5VIpFSiDl7iQdM2Hwa+H/loO/xbPCirl9rsFMrPa+A24cgwgxqz/PjrWYPO7GBirsx/QRHrPrq4BinUC0mo9HQM4P0hAOz1XJ13aRTxhowpyyAdg+zXyeT/eIJ78.eyJlbmRwb2ludF9zbHVnIjoiZ29vZ2xlL2dlbWluaS0zLWZsYXNoLXByZXZpZXctMjAyNTEyMTd8Z29vZ2xlLXZlcnRleC9nbG9iYWwifQ",
      id: "rs_tmp_25bhq153l4q",
      status: "completed",
      summary: [],
      type: "reasoning",
      format: "google-gemini-v1",
    }
  ],
  parallelToolCalls: true,
  presencePenalty: 0,
  previousResponseId: null,
  promptCacheKey: null,
  promptCacheOptions: null,
  reasoning: null,
  safetyIdentifier: null,
  serviceTier: "provisioned",
  status: "completed",
  store: false,
```

Supported image content types are:

* `image/png`
* `image/jpeg`
* `image/webp`
* `image/gif`
