v1

latestOpenAPI 3.1.02026-07-1381127211.1 KB
Insights API

Send message to Insights

Send a message to Insights and receive an AI-generated response about the media's emotional analysis.

Streaming (Recommended)

Set stream=true (default) to receive the response as Server-Sent Events (SSE) with progressive text chunks. This is the recommended approach as it provides real-time feedback and avoids potential timeout issues with longer responses.

SSE Events:

  • stream_start: Initial event confirming the connection
  • metadata: Contains conversation_id and message_id
  • stream_chunk: Progressive text chunks from AI
  • stream_end: Final event with full_text, token_usage, and credits_charged (flat per-reasoning-mode rate billed for this turn)
  • done: Completion signal
  • error: Error event if processing fails (includes error_id and message). Insufficient-credits failures use error_id: 1402 (matches HTTP 402 in non-streaming mode)

Error Handling in Streaming Mode:

  • Errors that occur before the stream starts (e.g., authentication failures, validation errors) are returned as standard HTTP 4xx/5xx responses with JSON bodies.
  • Errors that occur after the stream has started (e.g., during AI processing) are delivered as SSE error events.

Non-Streaming

Set stream=false to receive the complete response as JSON. Note: This mode waits for the full AI response before returning, which may result in longer response times or timeouts for complex queries. Use streaming mode for a better experience.

Requirements

  • Message Length: Maximum 10,000 characters
  • Media Status: Media processing must be completed (status: "completed")
  • Analysis Data: Emotional analysis data must be available. If not yet ready, you'll receive error code 1601 — retry after 30–60 seconds.

Conversation Management

The system maintains one conversation per user per media item. Your conversation history is preserved across multiple requests — no need to manage conversation IDs manually.

Supported Media Types

video, audio, image, text

post/v2/{media_type}/{media_id}/insights

Path parameters

media_typestring required
media_idstring required

Query parameters

streamboolean

Enable SSE streaming (true) or return full JSON response (false)

Enable SSE streaming (true) or return full JSON response (false)

Request body

messagestring required

User's question or message about the media content

Response

AI response (SSE stream or JSON)

conversation_idstring required

Conversation session ID

message_idinteger required

Message ID within conversation

responsestring required

AI assistant's complete response

token_usageobject nullable

Token usage (input_tokens, output_tokens)

is_quota_exceededboolean

Whether LLM quota exceeded

credits_chargedinteger nullable

Credits deducted for this turn. Flat per-reasoning-mode rate from ai_insights_credit_policy; null if charging was skipped (e.g. error path before stream completed).