# Images

Many models support processing **image inputs**. This lets you combine text and images for richer, multimodal interactions. To get a full list of models, visit [cortecs.ai](https://cortecs.ai/serverlessModels) and filter by the **Image** tag.

**Code Samples:**

* **Using Image URLs:**

You can send images directly by referencing a public image URL.

{% tabs %}
{% tab title="Python" %}

```python
from openai import OpenAI

client = OpenAI(
  base_url="https://api.cortecs.ai/v1",
  api_key="<API_KEY>",
)

completion = client.chat.completions.create(
  model="<MODEL_NAME>",
  messages=[
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "What is in this image?"
          },
          {
            "type": "image_url",
            "image_url": {
              "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"
            }
          }
        ]
      }
    ],
)

print(completion.choices[0].message.content)
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
import OpenAI from "openai";

const openai = new OpenAI({
    baseURL: 'https://api.cortecs.ai/v1',
    apiKey: '<API_KEY>'
});

const completion = await openai.chat.completions.create({
  model: "<MODEL_NAME>",
  messages: [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "What is in this image?"
        },
        {
          "type": "image_url",
          "image_url": {
            "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"
          }
        }
      ]
    }
  ]
});

console.log(completion.choices[0].message.content);
```

{% endtab %}

{% tab title="Curl" %}

```bash
curl 'https://api.cortecs.ai/v1/chat/completions' \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer <API_KEY>' \
    -d '{
      "model": "<MODEL_NAME>",
      "messages": [
        {
          "role": "user",
          "content": [
            {
              "type": "text",
              "text": "What is in this image?"
            },
            {
              "type": "image_url",
              "image_url": {
                "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"
              }
            }
          ]
        }
       ]
     }'
```

{% endtab %}
{% endtabs %}

* **Using Base64 Encoded Images:**

For local or private images that are not publicly accessible, you can embed the image using Base64 encoding.

{% tabs %}
{% tab title="Python" %}

```python
from openai import OpenAI
import base64

with open("path/to/image.png", "rb") as image_file:
    base64_image = base64.b64encode(image_file.read()).decode("utf-8")

client = OpenAI(
    base_url="https://api.cortecs.ai/v1",
    api_key="<API_KEY>",
)


completion = client.chat.completions.create(
    model="<MODEL_NAME>",
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "What is in this image?"
                },
                {
                    "type": "image_url",
                    "image_url": {
                        "url": f"data:image/png;base64,{base64_image}"
                    }
                }
            ]
        }
    ],
)

print(completion.choices[0].message.content)

```

{% endtab %}

{% tab title="Node.js" %}

```javascript
import fs from "fs";
import OpenAI from "openai";


const imageBuffer = fs.readFileSync("path/to/image.png");
const base64Image = imageBuffer.toString("base64");

const openai = new OpenAI({
  baseURL: "https://api.cortecs.ai/v1",
  apiKey: "<API_KEY>"
});

const completion = await openai.chat.completions.create({
  model: "<MODEL_NAME>",
  messages: [
    {
      role: "user",
      content: [
        {
          type: "text",
          text: "What is in this image?"
        },
        {
          type: "image_url",
          image_url: {
            url: `data:image/png;base64,${base64Image}`
          }
        }
      ]
    }
  ]
});

console.log(completion.choices[0].message.content);

```

{% endtab %}

{% tab title="Curl" %}

```bash
base64_image=$(base64 -w 0 path/to/image.png)

curl 'https://api.cortecs.ai/v1/chat/completions' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <API_KEY>' \
  -d '{
    "model": "<MODEL_NAME>",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "What is in this image?"
          },
          {
            "type": "image_url",
            "image_url": {
              "url": "data:image/png;base64,'"${base64_image}"'"
            }
          }
        ]
      }
    ]
  }'

```

{% endtab %}
{% endtabs %}
