Skip to content

Instantly share code, notes, and snippets.

@jondurbin
Created April 10, 2025 11:23
Show Gist options
  • Save jondurbin/bf38b2e6f344a27668e89e50585bf39b to your computer and use it in GitHub Desktop.
Save jondurbin/bf38b2e6f344a27668e89e50585bf39b to your computer and use it in GitHub Desktop.
kimi-vl example
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