from openai import OpenAI
import requests
client = OpenAI(
api_key="YOUR_EDEN_AI_API_KEY",
base_url="https://api.edenai.run/v3/llm"
)
# First, upload the image to get a file_id
upload_response = requests.post(
"https://api.edenai.run/v3/upload",
headers={"Authorization": f"Bearer YOUR_EDEN_AI_API_KEY"},
files={"file": open("image.jpg", "rb")}
)
file_id = upload_response.json()["file_id"]
# Use the file_id in a chat message
response = client.chat.completions.create(
model="openai/gpt-4o",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "What's in this image?"},
{"type": "file", "file": {"file_id": file_id}}
]
}
]
)
print(response.choices[0].message.content)