Created
April 10, 2025 11:23
-
-
Save jondurbin/bf38b2e6f344a27668e89e50585bf39b to your computer and use it in GitHub Desktop.
kimi-vl example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import base64 | |
import openai | |
import glob | |
client = openai.Client(base_url="https://llm.chutes.ai/v1", api_key=os.environ["CHUTES_API_KEY"]) | |
image_base64s = [] | |
for path in glob.glob("/home/jdurbin/Downloads/logo*.png")[:8]: | |
with open(path, "rb") as infile: | |
image_base64s.append(base64.b64encode(infile.read()).decode()) | |
result = client.chat.completions.create( | |
model="moonshotai/Kimi-VL-A3B-Thinking", | |
messages=[ | |
{ | |
"role": "user", | |
"content": [ | |
{"type": "text", "text": "Give me a detailed description of the images."}, | |
] | |
+ [ | |
{ | |
"type": "image_url", | |
"image_url": {"url": f"data:image/png;base64,{image_base64}"}, | |
} | |
for image_base64 in image_base64s | |
], | |
} | |
], | |
temperature=0.0, | |
) | |
print(result.choices[0].message.content) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment