import os
from perceptron import Client, video
client = Client(api_key=os.environ["PERCEPTRON_API_KEY"])
video_url = (
"https://raw.githubusercontent.com/perceptron-ai-inc/perceptron/"
"main/cookbook/_shared/assets/capabilities/video-qa/robot_assembly.mp4"
)
messages = [{
"role": "user",
"content": [
video(video_url),
{"type": "text", "text": (
"Watch this robot-assembly episode. State the likely overall goal, "
"then list the observed subgoals in chronological order. "
"For each subgoal, describe the visible action that supports it. "
"Distinguish an inferred intention from something directly visible. "
"Finally, say whether the video shows the overall goal being "
"completed, remaining incomplete, or an uncertain outcome."
)},
],
}]
response = client.chat.completions.create(
model="perceptron-mk1.5",
messages=messages,
reasoning_effort="high",
max_completion_tokens=2048,
)
choice = response.choices[0]
if choice.finish_reason != "stop":
raise RuntimeError(f"Incomplete video answer: {choice.finish_reason}")
answer = choice.message.content or ""
print(answer)