Skip to main content
POST
/
serve
/
api
/
v1
/
chat
Video Chat
curl --request POST \
  --url https://api.memories.ai/serve/api/v1/chat \
  --header 'Authorization: <api-key>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "video_nos": [
    "VI625239098370850816"
  ],
  "prompt": "Summarize the emotional moments in these videos",
  "session_id": "session-123",
  "unique_id": "default"
}
'
{
  "code": "0000",
  "msg": "success",
  "data": {},
  "success": true,
  "failed": false
}

Prerequisites

  • You have created a memories.ai API key.
  • You have uploaded a video via the Upload API and obtained its videoNo.
  • The video is currently in the PARSE status.

Host URL

Endpoints

Endpoint 1 (non-stream)

POST /serve/api/v1/chat
/serve/api/v1/chat

Endpoint 2 (stream)

POST /serve/api/v1/chat_stream
/serve/api/v1/chat_stream

Request Example

Streaming mode

import requests
import json

headers = { 
    "Authorization": "<API_KEY>", 
    "Content-Type": "application/json", 
    "Accept": "text/event-stream"
}
payload = { 
    "video_nos": ["<VIDEO_ID_1>", "<VIDEO_ID_2>"], # List of video IDs to chat about 
    "prompt": "Summarize the emotional moments in these videos", # User query 
    "session_id": "<SESSION_ID>", # Chat session ID 
    "unique_id": "<UNIQUE_ID>",
}
response = requests.post( 
    "https://api.memories.ai/serve/api/v1/chat_stream", 
    headers=headers, 
    json=payload, 
    stream=True
)
if response.status_code != 200: 
    print(response.status_code) 
    print(response.text)
else: 
    try: 
        for line in response.iter_lines(decode_unicode=True): 
            if line: 
                print(line) 
                if line.strip().lower() == 'data:"done"': 
                    print("\n") 
                    break 
                if line.startswith("data:"): 
                    print(line.replace("data:", "").strip(), end="", flush=True) 
    except Exception as e: 
        print(str(e))

Non-streaming mode

import requests
import json

headers = { 
    "Authorization": "<API_KEY>", 
    "Content-Type": "application/json",
}
payload = { 
    "video_nos": ["<VIDEO_ID_1>", "<VIDEO_ID_2>"], # List of video IDs to chat about 
    "prompt": "Summarize the emotional moments in these videos", # User query 
    "session_id": "<SESSION_ID>", # Chat session ID 
    "unique_id": "<UNIQUE_ID>",
}
response = requests.post( 
    "https://api.memories.ai/serve/api/v1/chat", 
    headers=headers, 
    json=payload, 
    stream=False
)
if response.status_code != 200: 
    print(response.status_code) 
    print(response.text)
else: 
    try: 
        for line in response.iter_lines(decode_unicode=True): 
            if line: 
                print(line) 
                if line.strip().lower() == 'data:"done"': 
                    print("\n") 
                    break 
                if line.startswith("data:"): 
                    print(line.replace("data:", "").strip(), end="", flush=True) 
    except Exception as e: 
        print(str(e))

Request Body

{ 
    "videoNos": [ "string" ], 
    "prompt": "string", 
    "session_id": "123456", 
    "unique_id": "default",
}

Response Example

The response can include “thinking”, “ref” (references with timestamps), and “content” messages.
{ "type": "thinking", "title": "Based on selected videos...", "content": "Okay...", "sessionId": "..."}
{ "type": "ref", "sessionId": "...", "ref": [{ "video": {...}, "refItems": [...] }]}
{ "type": "content", "role": "assistant", "content": "...", "sessionId": "..."}

Response End Example

{ "code": "SUCCESS", "data": "Done"}

Authorizations

Authorization
string
header
required

Body

application/json
video_nos
string[]
required
Example:
["VI625239098370850816"]
prompt
string
required
Example:

"Summarize the emotional moments in these videos"

session_id
string
Example:

"session-123"

unique_id
string
default:default

Response

200 - application/json

Successful response

code
Example:

"0000"

msg
string
Example:

"success"

data
success
boolean
Example:

true

failed
boolean
Example:

false