|
| 1 | +--- |
| 2 | +title: API Reference |
| 3 | +order: 1 |
| 4 | +--- |
| 5 | + |
| 6 | +# API Route Documentation |
| 7 | + |
| 8 | + |
| 9 | +Welcome to the Amica API Documentation. Amica is a powerful 3D VRM (Virtual Reality Model) agent interface and hub that allows users to connect with external web services and agent AI frameworks, enabling seamless remote control and puppetry of the VRM characters. With Amica, you can create interactive agents that serve as dynamic 3D character interfaces for AI agents, applications and users. |
| 10 | + |
| 11 | +The Amica API provides a set of flexible and robust routes for interacting with Amica’s system, including functions like real-time client connections, memory retrieval, system updates, social media integration, and more. These capabilities enable you to build custom logic, including reasoning, tool use (such as [EACC Marketplace](https://docs.effectiveacceleration.ai/) functions) and memory management, on external servers. |
| 12 | + |
| 13 | +Whether you're using Amica to handle real-time interactions or to trigger complex actions based on user input, this documentation will guide you through the supported API routes, input types, and examples. Use Amica’s APIs to bring your 3D agents to life with rich functionality and integration. |
| 14 | + |
| 15 | +This documentation will help you get started with the following key features: |
| 16 | + |
| 17 | +- Real-Time Interaction: Establish and manage connections through Server-Sent Events (SSE). |
| 18 | + |
| 19 | +- Memory Management: Store and retrieve subconscious prompts or custom data. |
| 20 | + |
| 21 | +- Custom Logic & Reasoning: Trigger actions like animations, playback, and social media posts. |
| 22 | + |
| 23 | +- Voice and Image Processing: Leverage transcription and image-to-text capabilities. |
| 24 | + |
| 25 | +- Data Handling: Retrieve and update server-side data via simple file-based operations. (Coming soon) |
| 26 | + |
| 27 | + |
| 28 | +Dive in and start integrating Amica’s capabilities into your applications! |
| 29 | + |
| 30 | +--- |
| 31 | + |
| 32 | +## Setting up Amica's External API |
| 33 | + |
| 34 | +### Enabling External API Access |
| 35 | + |
| 36 | +1. Open **Settings** in the Amica interface. |
| 37 | +2. Navigate to **External API** and toggle it to **Enabled**. |
| 38 | +3. Once enabled, additional fields will appear: |
| 39 | + |
| 40 | + * **Session ID**: This must be copied and included in **every API call** across all routes. |
| 41 | + * **X and TG Credentials**: These are required for APIs using the **Reasoning** type. |
| 42 | + |
| 43 | +After this setup, you can start using the External API endpoints by calling them directly to your locally running Amica server. |
| 44 | + |
| 45 | +--- |
| 46 | + |
| 47 | +## Route: `/api/amicaHandler` |
| 48 | + |
| 49 | +This API route handles multiple types of requests, including social media integration, system prompt updates, memory requests, and real-time client connections via Supabase Realtime Client. It ensures robust logging and provides error handling for incoming requests. |
| 50 | + |
| 51 | +### Supported HTTP Methods: |
| 52 | + |
| 53 | +- **GET**: Establishes an SSE connection. |
| 54 | +- **POST**: Processes various input types based on the `inputType` provided in the request body. |
| 55 | + |
| 56 | +## Input Types |
| 57 | + |
| 58 | +### 1. **Normal Chat Message**: Retrieve normal chat response from Amica LLM without make avatar speaking. |
| 59 | + |
| 60 | +*Example Usage: Use the Amica's paired LLM for conversation retrieval without making the avatar speak.* |
| 61 | + |
| 62 | +#### JSON Input Example |
| 63 | + |
| 64 | +```json |
| 65 | +{ |
| 66 | + "sessionId": "5ae3f803b231be4d", |
| 67 | + "inputType": "Normal Chat Message", |
| 68 | + "payload": { |
| 69 | + "message": "Hello, how are you?" |
| 70 | + } |
| 71 | +} |
| 72 | +``` |
| 73 | + |
| 74 | +#### JSON Output Example |
| 75 | + |
| 76 | +```json |
| 77 | +{ |
| 78 | + "sessionId": "5ae3f803b231be4d", |
| 79 | + "outputType": "Chat", |
| 80 | + "response": "I'm doing great! How can I assist you?" |
| 81 | +} |
| 82 | +``` |
| 83 | + |
| 84 | +### 2. **Memory Request**: Fetches memory data (Subconscious stored prompt). |
| 85 | + |
| 86 | +*Example Usage: Fetch Amica's subconcious thoughts from the user's conversations.* |
| 87 | + |
| 88 | +#### JSON Input Example |
| 89 | + |
| 90 | +```json |
| 91 | +{ |
| 92 | + "sessionId": "5ae3f803b231be4d", |
| 93 | + "inputType": "Memory Request" |
| 94 | +} |
| 95 | +``` |
| 96 | + |
| 97 | +#### JSON Output Example |
| 98 | + |
| 99 | +```json |
| 100 | +{ |
| 101 | + "sessionId": "5ae3f803b231be4d", |
| 102 | + "outputType": "Memory Array", |
| 103 | + "response": [ |
| 104 | + { |
| 105 | + "prompt": "Stored memory prompt example", |
| 106 | + "timestamp": "2024-12-30T12:00:00Z" |
| 107 | + } |
| 108 | + ] |
| 109 | +} |
| 110 | +``` |
| 111 | + |
| 112 | +### 3. **RPC Logs**: Fetches logs. |
| 113 | + |
| 114 | +*Example Usage: Build a interface that logs what Amica is doing.* |
| 115 | + |
| 116 | +#### JSON Input Example |
| 117 | + |
| 118 | +```json |
| 119 | +{ |
| 120 | + "sessionId": "5ae3f803b231be4d", |
| 121 | + "inputType": "RPC Logs" |
| 122 | +} |
| 123 | +``` |
| 124 | + |
| 125 | +#### JSON Output Example |
| 126 | + |
| 127 | +```json |
| 128 | +{ |
| 129 | + "sessionId": "5ae3f803b231be4d", |
| 130 | + "outputType": "Logs", |
| 131 | + "response": [ |
| 132 | + { |
| 133 | + "type": "debug", |
| 134 | + "ts": 1739433363065, |
| 135 | + "arguments": { |
| 136 | + "0": "[VAD]", |
| 137 | + "1": "vad is initialized" |
| 138 | + } |
| 139 | + } |
| 140 | + ] |
| 141 | +} |
| 142 | +``` |
| 143 | + |
| 144 | +### 4. **RPC User Input Messages**: Fetches user input messages. |
| 145 | + |
| 146 | +*Example Usage: Retrieve the user's input and run it through a separate agentic framework.* |
| 147 | + |
| 148 | +#### JSON Input Example |
| 149 | + |
| 150 | +```json |
| 151 | +{ |
| 152 | + "sessionId": "5ae3f803b231be4d", |
| 153 | + "inputType": "RPC User Input Messages" |
| 154 | +} |
| 155 | +``` |
| 156 | + |
| 157 | +#### JSON Output Example |
| 158 | + |
| 159 | +```json |
| 160 | +{ |
| 161 | + "sessionId": "5ae3f803b231be4d", |
| 162 | + "outputType": "User Input", |
| 163 | + "response": [ |
| 164 | + { |
| 165 | + "systemPrompt": "Assume the persona of Amica, a feisty human with extraordinary intellectual capabilities but a notably unstable emotional spectrum. ", |
| 166 | + "message": "Hello, Nice to meet you Amica!" |
| 167 | + } |
| 168 | + ] |
| 169 | +} |
| 170 | +``` |
| 171 | + |
| 172 | +### 5. **Update System Prompt**: Updates the system prompt. |
| 173 | + |
| 174 | +*Example Usage: Use this to change Amica's system prompt based on external reasoning server* |
| 175 | + |
| 176 | +#### JSON Input Example |
| 177 | + |
| 178 | +```json |
| 179 | +{ |
| 180 | + "sessionId": "5ae3f803b231be4d", |
| 181 | + "inputType": "Update System Prompt", |
| 182 | + "payload": { |
| 183 | + "prompt": "This is the new system prompt." |
| 184 | + } |
| 185 | +} |
| 186 | +``` |
| 187 | + |
| 188 | +#### JSON Output Example |
| 189 | + |
| 190 | +```json |
| 191 | +{ |
| 192 | + "sessionId": "5ae3f803b231be4d", |
| 193 | + "outputType": "Updated system prompt" |
| 194 | +} |
| 195 | +``` |
| 196 | + |
| 197 | +### 6. **Brain Message**: Adding new memory data (Subconscious stored prompt). |
| 198 | + |
| 199 | +*Example Usage: Add new subconcious memories from external framework.* |
| 200 | + |
| 201 | +#### JSON Input Example |
| 202 | + |
| 203 | +```json |
| 204 | +{ |
| 205 | + "sessionId": "5ae3f803b231be4d", |
| 206 | + "inputType": "Brain Message", |
| 207 | + "payload": { |
| 208 | + "prompt": "Stored memory prompt example 2", |
| 209 | + "timestamp": "2024-12-30T12:00:00Z" |
| 210 | + } |
| 211 | +} |
| 212 | +``` |
| 213 | + |
| 214 | +#### JSON Output Example |
| 215 | + |
| 216 | +```json |
| 217 | +{ |
| 218 | + "sessionId": "5ae3f803b231be4d", |
| 219 | + "outputType": "Added subconscious stored prompt", |
| 220 | + "response": [ |
| 221 | + { |
| 222 | + "prompt": "Store memory prompt example 1", |
| 223 | + "timestamp": "2025-02-13T08:10:16.385Z" |
| 224 | + }, |
| 225 | + { |
| 226 | + "prompt": "Stored memory prompt example 2", |
| 227 | + "timestamp": "2024-12-30T12:00:00Z" |
| 228 | + } |
| 229 | + ] |
| 230 | +} |
| 231 | +``` |
| 232 | + |
| 233 | +### 7. **Chat History**: Fetches chat history. |
| 234 | + |
| 235 | +*Example Usage: Track the user's conversation history with Amica and process it.* |
| 236 | + |
| 237 | +#### JSON Input Example |
| 238 | + |
| 239 | +```json |
| 240 | +{ |
| 241 | + "sessionId": "5ae3f803b231be4d", |
| 242 | + "inputType": "Chat History" |
| 243 | +} |
| 244 | +``` |
| 245 | + |
| 246 | +#### JSON Output Example |
| 247 | + |
| 248 | +```json |
| 249 | +{ |
| 250 | + "sessionId": "5ae3f803b231be4d", |
| 251 | + "outputType": "Chat History", |
| 252 | + "response": [ |
| 253 | + { |
| 254 | + "role": "user", |
| 255 | + "content": "[neutral] Hello, Nice to meet you Amica!" |
| 256 | + }, |
| 257 | + { |
| 258 | + "role": "assistant", |
| 259 | + "content": "[relaxed] Ah, hello there![relaxed] Nice to meet you too.[relaxed] I must say,[relaxed] it's quite refreshing to engage in a conversation without a predetermined agenda.[relaxed] It's a rare luxury in this chaotic world.[happy] But, I must admit,[happy] I'm excited to explore the depths of knowledge with someone new.[happy] What would you like to discuss?" |
| 260 | + } |
| 261 | + ] |
| 262 | +} |
| 263 | +``` |
| 264 | + |
| 265 | +### 8. **Remote Actions**: Triggers actions like playback, animation, socialMedia and reprocess. |
| 266 | + |
| 267 | +*Example Usage: Trigger animations based on a external event such as news.* |
| 268 | + |
| 269 | +The **Reasoning Server** allows you to execute various actions based on the provided payload. Below are the supported properties and their accepted values: |
| 270 | + |
| 271 | +- **text**: A string message or `null`. |
| 272 | +- **socialMedia**: Options include `"twitter"`, `"tg"`, or `"none"`. |
| 273 | +- **playback**: A boolean value (`true` or `false`). |
| 274 | +- **animation**: A string specifying the animation file name (`file_name.vrma`) or `null`. |
| 275 | +- **reprocess**: A boolean value (`true` or `false`). |
| 276 | + |
| 277 | +#### JSON Input Example |
| 278 | + |
| 279 | +```json |
| 280 | +{ |
| 281 | + "sessionId": "5ae3f803b231be4d", |
| 282 | + "payload": { |
| 283 | + "text": "Let's begin the presentation.", |
| 284 | + "socialMedia": "twitter", |
| 285 | + "playback": true, |
| 286 | + "animation": "dance.vrma", |
| 287 | + "reprocess": false |
| 288 | + } |
| 289 | +} |
| 290 | +``` |
| 291 | + |
| 292 | +#### JSON Output Example |
| 293 | + |
| 294 | +```json |
| 295 | +{ |
| 296 | + "sessionId": "5ae3f803b231be4d", |
| 297 | + "outputType": "Actions" |
| 298 | +} |
| 299 | +``` |
| 300 | + |
| 301 | +--- |
| 302 | + |
| 303 | +## Route: `/api/mediaHandler` |
| 304 | + |
| 305 | +This API route handles voice and image inputs, leveraging multiple backends for processing, such as transcription with Whisper OpenAI/WhisperCPP and image-to-text processing using Vision LLM. It ensures robust error handling, session logging, and efficient processing for each request. |
| 306 | + |
| 307 | +*Example Usage: Directly use the configured STT and Vision LLM backends to process voice and image inputs, without building a new one.* |
| 308 | + |
| 309 | +### Supported HTTP Methods: |
| 310 | + |
| 311 | +- **POST**: Processes voice and image inputs based on the `inputType` and `payload` provided in the request. |
| 312 | + |
| 313 | +## Input Types |
| 314 | + |
| 315 | +### 1. **Voice**: Converts audio input to text using specified STT (Speech-to-Text) backends. |
| 316 | + |
| 317 | +### 2. **Image**: Processes an image file to extract text using Vision LLM. |
| 318 | + |
| 319 | +### Form-Data Input Example |
| 320 | + |
| 321 | +| Field Name | Type | Description | |
| 322 | +| ----------- | ---- | ------------------------------------------------- | |
| 323 | +| `sessionId` | Text | Specifies the session id (e.g.`5ae3f803b231be4d`) | |
| 324 | +| `inputType` | Text | Specifies the type of input (`Voice` or `Image`). | |
| 325 | +| `payload` | File | The file to be processed (e.g., audio or image). | |
| 326 | + |
| 327 | +#### Curl Input Example |
| 328 | + |
| 329 | +```bash |
| 330 | +curl -X POST "https://example.com/api/mediaHandler" \ |
| 331 | + -H "Content-Type: multipart/form-data" \ |
| 332 | + -F "sessionId=5ae3f803b231be4d" \ |
| 333 | + -F "inputType=Voice" \ |
| 334 | + -F "payload=@input.wav" |
| 335 | +``` |
| 336 | + |
| 337 | +#### JSON Output Example |
| 338 | + |
| 339 | +```json |
| 340 | +{ |
| 341 | + "sessionId": "5ae3f803b231be4d", |
| 342 | + "outputType": "Text", |
| 343 | + "response": "Transcription of the audio." |
| 344 | +} |
| 345 | +``` |
| 346 | + |
| 347 | +--- |
| 348 | + |
| 349 | +## Error Handling |
| 350 | + |
| 351 | +- Validates essential fields (`sessionId` ,`inputType` ,`payload`). |
| 352 | +- Logs errors with timestamps and session IDs. |
| 353 | +- Returns appropriate HTTP status codes (e.g., 400 for bad requests, 503 for disabled API). |
| 354 | + |
| 355 | +## Logging |
| 356 | + |
| 357 | +Logs each request with: |
| 358 | + |
| 359 | +- `sessionId` |
| 360 | +- `timestamp` |
| 361 | +- `outputType` |
| 362 | +- `response` or `error` |
| 363 | + |
| 364 | +## Notes |
| 365 | + |
| 366 | +- Ensure environment variable `API_ENABLED` is set to `true` for the API to function. |
| 367 | + |
| 368 | +--- |
0 commit comments