WebSocket API V2 Configuration
Overview
The V2 WebSocket API provides a structured, protocol-versioned messaging system for text-to-sign-language video translation. This is the current recommended protocol.
Connection Details
Connection URL
wss://ai.api.production.signapsesolutions.comAuthentication
- Production: Use platform authentication (API Gateway tokens, cookies, etc.)
Message Schema
Client → Server Request
{
"protocol": {
"name": "string",
"version": "string"
},
"content": {
"type": "text",
"data": "string"
},
"output": {
"format": "hls",
"delivery": {
"method": "stream"
}
},
"context": {
"application": "string"
}
}Server → Client Response
{
"protocol": {
"name": "string",
"version": "string"
},
"success": true,
"message": "string"
}Configuration Options
Required Fields
| Name | Type | Required | Description |
|---|---|---|---|
| protocol | object | required | Protocol identification for version compatibility. |
| name | string | required | Client protocol name (e.g. "signapse-client"). |
| version | string | required | Protocol version (e.g. "2.0"). |
| content | object | required | Content payload to be translated. |
| type | string | required | Content type — currently "text" is supported. |
| data | string | required | The text sentence to translate into sign language video. |
| output | object | required | Output format configuration. |
| format | string | required | Video output format. hlsmp4 |
| delivery | object | required | Delivery method configuration. |
| method | string | required | How the client intends to receive the video. streamdownload |
| context | object | required | Contextual information for routing. |
| application | string | required | Application identifier (e.g. "media", "education"). |
Format Options:
hls: HTTP Live Streaming — suitable for adaptive bitrate streaming, recommended for live translation scenariosmp4: MPEG-4 video file — suitable for download and offline playback
Delivery Methods:
stream: Real-time streaming delivery — recommended for HLS formatdownload: File download delivery — recommended for MP4 format
Internal Metadata (Auto-configured)
The V2 handler automatically configures the following metadata for video processing:
| Metadata Key | Value | Description |
|---|---|---|
type | "live" | Always set to live for V2 protocol |
connection | "websocket" | Connection type identifier |
responseDownloadType | "presignedUrl" | Media delivery method |
responseFormat | From output.format | Video format passed to generation service |
deliveryMethod | From output.delivery.method | Delivery method passed to generation service |
application | From context.application | Application context passed to generation service |
Message Processing
V2 Protocol Detection
The server automatically detects V2 messages by the presence of the top-level "protocol" field. Both V1 and V2 messages can be sent on the same connection.
Live Translation Mode
All V2 messages are processed as live translations, which means:
- No profanity filtering
- No rate limiting
- No word count validation
- Optimized for real-time performance
Complete Example
Request Message
{
"protocol": {
"name": "signapse-client",
"version": "2.0"
},
"content": {
"type": "text",
"data": "Welcome to our text-to-video API service"
},
"output": {
"format": "hls",
"delivery": {
"method": "stream"
}
},
"context": {
"application": "media"
}
}Success Response
{
"protocol": {
"name": "signapse-client",
"version": "2.0"
},
"success": true,
"message": "Video processing for Welcome to our text-to-video API service"
}Error Response
{
"protocol": {
"name": "signapse-client",
"version": "2.0"
},
"success": false,
"message": "Failed to generate picture-in-picture, please try again"
}JavaScript Client Example
const ws = new WebSocket("wss://ai.api.production.signapsesolutions.com");
ws.onopen = () => {
console.log("WebSocket connected");
const message = {
protocol: {
name: "signapse-client",
version: "2.0"
},
content: {
type: "text",
data: "Hello world"
},
output: {
format: "hls",
delivery: {
method: "stream"
}
},
context: {
application: "media"
}
};
ws.send(JSON.stringify(message));
};
ws.onmessage = (event) => {
const response = JSON.parse(event.data);
console.log("Response:", response);
if (response.success) {
console.log("Translation successful:", response.message);
} else {
console.error("Translation failed:", response.message);
}
};
ws.onerror = (error) => {
console.error("WebSocket error:", error);
};
ws.onclose = () => {
console.log("WebSocket connection closed");
};TypeScript Type Definitions
interface ProtocolInfo {
name: string;
version: string;
}
interface Content {
type: "text";
data: string;
}
interface OutputDelivery {
method: "stream" | "download";
}
interface Output {
format: "hls" | "mp4";
delivery: OutputDelivery;
}
interface Context {
application: string;
}
interface WebSocketMessageV2 {
protocol: ProtocolInfo;
content: Content;
output: Output;
context: Context;
}
interface WebSocketResponseV2 {
protocol: ProtocolInfo;
success: boolean;
message: string;
}Media Delivery
Video output is delivered via presigned URLs. The WebSocket connection receives:
- Status acknowledgment messages
- Processing progress updates
- Completion notifications
The actual video media is retrieved through presigned URLs generated by backend services according to the specified output configuration.
Stream Delivery (HLS)
For streaming delivery with HLS format:
- Receive acknowledgment of processing
- Obtain presigned URL for HLS manifest
- Poll or watch the HLS manifest/segments
- Stream video content to client
Recommended for: Live translation, real-time scenarios, adaptive streaming
Download Delivery (MP4)
For download delivery with MP4 format:
- Receive acknowledgment of processing
- Wait for video generation completion
- Obtain presigned URL for complete MP4 file
- Download video file for playback
Recommended for: Archived content, offline viewing, complete file access
Advantages Over V1
| Feature | V1 | V2 |
|---|---|---|
| Protocol versioning | Action-based | Explicit version field |
| Structured format | Flat structure | Nested objects |
| Content typing | Direct sentence field | Typed content object |
| Output configuration | Metadata-based | Dedicated output object |
| Delivery control | Limited | Explicit delivery method |
| Extensibility | Limited | Structured and expandable |
| Future-proof | Legacy | Current standard |
Migration from V1
Key Differences
- Protocol Field: V2 requires explicit protocol identification
- Content Structure:
sentence→content.data - Output Configuration:
metadata.responseFormat→output.format - Context Information: New
contextobject for application routing
Migration Example
V1 message:
{
"action": "LiveTranslation",
"sentence": "Hello world",
"metadata": {
"responseFormat": "hls"
}
}V2 equivalent:
{
"protocol": {
"name": "your-app",
"version": "2.0"
},
"content": {
"type": "text",
"data": "Hello world"
},
"output": {
"format": "hls",
"delivery": {
"method": "stream"
}
},
"context": {
"application": "media"
}
}Best Practices
- Protocol Versioning: Use semantic versioning for your protocol name and version
- Error Handling: Always handle both success and error responses
- Connection Management: Implement reconnection logic for network interruptions
- Format Selection:
- Use HLS with stream delivery for live scenarios
- Use MP4 with download delivery for on-demand content
- Context Information: Provide meaningful application context for analytics and routing
Troubleshooting
| Issue | Solution |
|---|---|
| Message not processed | Ensure all required fields are present |
| Invalid format error | Verify JSON structure matches schema |
| Connection closes unexpectedly | Check authentication and network stability |
| No response received | Verify WebSocket connection is open before sending |
| Video generation fails | Check backend service logs and AWS resources |