Skip to main content
If you’re using the Keywords AI gateway, you can upload images to the LLM request. We support base64 or url format for image variables.

Upload image variables

  • OpenAI SDK
  • Standard API
from openai import OpenAI

client = OpenAI(
    base_url="https://api.keywordsai.co/api/",
    api_key="YOUR_KEYWORDSAI_API_KEY",
)

response = client.chat.completions.create(
    model="gpt-4o-mini", # any model that supports image variables
    messages=[{"role":"user", "content":"Tell me a long story"}],
    extra_body={
        "variables": {
            "image_variable": {"_type": "image_url", "value": "url_string"}
        }
    },  
)
I