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 and filter by the Image tag.

Code Samples:

  • Using Image URLs:

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

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)
  • Using Base64 Encoded Images:

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

Last updated