import base64
import os
from pathlib import Path
from openai import OpenAI
client = OpenAI(
base_url="https://api.inference.wandb.ai/v1",
api_key=os.environ["FORGE_API_KEY"],
)
video_url = "https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4"
# ローカルの H.264 MP4 を使用する場合は、次の 2 行のコメントを解除してファイルパスを設定します。
# encoded = base64.b64encode(Path("clip.mp4").read_bytes()).decode("ascii")
# video_url = f"data:video/mp4;base64,{encoded}"
response = client.chat.completions.create(
model="zai-org/GLM-5.3-Flash",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "How does the scene change over time?"},
{"type": "video_url", "video_url": {"url": video_url}},
],
}
],
max_tokens=1024,
)
print(response.choices[0].message.content)