### Install Flux MCP Server from Source Source: https://github.com/acedatacloud/docs/blob/main/mcp/flux.mdx Installs the Flux MCP Server by cloning the GitHub repository and installing it locally. This method is useful for development or when needing the latest unreleased features. ```bash git clone https://github.com/AceDataCloud/MCPFlux.git cd MCPFlux pip install -e . ``` -------------------------------- ### Install mcp-suno using pip Source: https://github.com/acedatacloud/docs/blob/main/zh-TW/mcp/suno.mdx Installs the mcp-suno package using pip, which is the recommended installation method. This command fetches and installs the latest version of the Suno MCP server client. ```bash pip install mcp-suno ``` -------------------------------- ### Install Luma MCP Server from Source Source: https://github.com/acedatacloud/docs/blob/main/mcp/luma.mdx Installs the Luma MCP Server by cloning the GitHub repository and installing it in editable mode. This method is useful for development or if you need the latest unreleased features. Requires Git and pip. ```bash git clone https://github.com/AceDataCloud/MCPLuma.git cd MCPLuma pip install -e . ``` -------------------------------- ### Install mcp-suno from Source Source: https://github.com/acedatacloud/docs/blob/main/zh-TW/mcp/suno.mdx Installs the mcp-suno package from its source code repository. This involves cloning the GitHub repository and then performing a local installation. This method is useful for developers who want to contribute to the project or use the latest development version. ```bash git clone https://github.com/AceDataCloud/MCPSuno.git cd MCPSuno pip install -e . ``` -------------------------------- ### Install MCP Veo from Source Source: https://github.com/acedatacloud/docs/blob/main/zh-TW/mcp/veo.mdx Install the MCP Veo package from its source code. This method is useful for development or when the latest changes are needed. ```bash git clone https://github.com/AceDataCloud/MCPVeo.git cd MCPVeo pip install -e . ``` -------------------------------- ### Install MCP Veo Package Source: https://github.com/acedatacloud/docs/blob/main/zh-TW/mcp/veo.mdx Install the MCP Veo package using pip for easy integration. This is the recommended installation method. ```bash pip install mcp-veo ``` -------------------------------- ### Java Example Source: https://github.com/acedatacloud/docs/blob/main/guides/kimi/kimi_chat_completions.mdx Example of how to call the Kimi Chat Completions API using Java with OkHttp and JSON handling. ```APIDOC ## Java Example ### Description Example of how to call the Kimi Chat Completions API using Java with OkHttp and JSON handling. ### Method POST ### Endpoint https://api.acedata.cloud/kimi/chat/completions ### Code Example ```java // Assuming you have OkHttp and a JSON library (like org.json) set up import okhttp3.*; import okhttp3.MediaType; import okhttp3.RequestBody; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; import org.json.JSONObject; // ... inside your method ... JSONObject jsonObject = new JSONObject(); jsonObject.put("model", "kimi-k2.5"); // Note: In a real Java scenario, you'd construct the messages array properly, e.g., using JSONArray // For simplicity, this example uses a placeholder that might need adjustment based on your JSON library. jsonObject.put("messages", "[{"role":"user","content":"Hello"}]"); jsonObject.put("stream", true); MediaType mediaType = MediaType.parse("application/json; charset=utf-8"); RequestBody body = RequestBody.create(jsonObject.toString(), mediaType); Request request = new Request.Builder() .url("https://api.acedata.cloud/kimi/chat/completions") .post(body) .addHeader("accept", "application/json") .addHeader("authorization", "Bearer {token}") .addHeader("content-type", "application/json") .build(); OkHttpClient client = new OkHttpClient(); Response response = client.newCall(request).execute(); System.out.print(response.body().string()); ``` ``` -------------------------------- ### Install Luma MCP Server via pip Source: https://github.com/acedatacloud/docs/blob/main/mcp/luma.mdx Installs the Luma MCP Server package using pip. This is the recommended installation method. Ensure you have Python and pip installed. ```bash pip install mcp-luma ``` -------------------------------- ### JavaScript (Node.js) Example Source: https://github.com/acedatacloud/docs/blob/main/guides/kimi/kimi_chat_completions.mdx Example of how to call the Kimi Chat Completions API using Node.js `fetch` with streaming enabled. ```APIDOC ## JavaScript (Node.js) Example ### Description Example of how to call the Kimi Chat Completions API using Node.js `fetch` with streaming enabled. ### Method POST ### Endpoint https://api.acedata.cloud/kimi/chat/completions ### Code Example ```javascript const options = { method: "post", headers: { "accept": "application/json", "authorization": "Bearer {token}", "content-type": "application/json" }, body: JSON.stringify({ "model": "kimi-k2.5", "messages": [{"role":"user","content":"Hello"}], "stream": true }) }; fetch("https://api.acedata.cloud/kimi/chat/completions", options) .then(response => response.json()) .then(response => console.log(response)) .catch(err => console.error(err)); ``` ``` -------------------------------- ### Pay Order with Fetch API (JavaScript) Source: https://github.com/acedatacloud/docs/blob/main/ja/guides/x402.mdx This example shows how to pay for an order using the X402 payment method with the Fetch API in JavaScript. It utilizes the 'x402-fetch' library to wrap the native fetch function, simplifying the X402 payment process. Environment variables for private key, platform token, and order ID are required. The function sends a POST request to the payment endpoint and logs the decoded receipt from the response headers. ```javascript import { wrapFetchWithPayment, decodePaymentResponse } from "x402-fetch"; import { privateKeyToAccount } from "viem/accounts"; const account = privateKeyToAccount(process.env.ACE_X402_PRIVATE_KEY!); const platformToken = process.env.ACE_PLATFORM_TOKEN!; const orderId = process.env.ACE_X402_ORDER_ID!; const fetchWithPayment = wrapFetchWithPayment(fetch, account); async function payOrder() { const url = `https://platform.acedata.cloud/api/v1/orders/${orderId}/pay/`; const response = await fetchWithPayment(url, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${platformToken}`, }, body: JSON.stringify({ pay_way: "X402" }), }); if (!response.ok) { const errorBody = await response.text(); throw new Error(`x402 支払い失敗: ${response.status} ${errorBody}`); } const receipt = decodePaymentResponse( response.headers.get("x-payment-response")! ); console.log("x402 レシート", receipt); } payOrder().catch(console.error); ``` -------------------------------- ### Install Flux MCP Server using pip Source: https://github.com/acedatacloud/docs/blob/main/mcp/flux.mdx Installs the Flux MCP Server package using pip. This is the recommended installation method for ease of use and updates. ```bash pip install mcp-flux-pro ``` -------------------------------- ### Initiate Asynchronous Video Generation with Callback URL Source: https://github.com/acedatacloud/docs/blob/main/guides/kling/kling_videos.mdx This example shows how to initiate a video generation task with an asynchronous callback. By providing a `callback_url`, the API will send the results to this URL once the task is complete, returning a `task_id` immediately. This is useful for long-running generation processes. ```json { "action": "extend", "model": "kling-v1", "video_id": "030bb06d-98d4-4044-9042-0aa0822e8c8c", "prompt": "A futuristic cityscape at sunset with flying vehicles.", "duration": 5, "callback_url": "https://webhook.site/624b2c78-6dbd-4618-9d2b-b32eade6d8c3" } ``` -------------------------------- ### Use Proxy via Shell and Python Source: https://github.com/acedatacloud/docs/blob/main/guides/adsl-http-proxy/adsl_extract_proxy.mdx Demonstrates how to utilize extracted proxy IPs using curl for quick testing and Python for programmatic HTTP and SOCKS proxy integration. ```shell curl -x 115.219.4.171:23456 myip.vpsnb.net # http proxy curl --socks5 115.219.3.54:23457 myip.vpsnb.net # socks proxy ``` ```python import requests import socks import socket import time def test_http_proxy(proxy): try: start_time = time.time() response = requests.get( 'http://httpbin.org/ip', proxies={'http': proxy, 'https': proxy}, timeout=100) elapsed_time = time.time() - start_time print(response) if response.status_code == 200: print(f"HTTP Proxy {proxy} success. time: {elapsed_time:.2f} s") print(f"IP: {response.json()['origin']}") else: print(f"HTTP Proxy {proxy} failed. code: {response.status_code}") except Exception as e: print(f"HTTP Proxy {proxy} failed: {str(e)}") def test_socks_proxy(proxy): proxy_parts = proxy.split(':') if len(proxy_parts) != 2: print(f"SOCKS failed: {proxy}") return host, port = proxy_parts port = int(port) try: start_time = time.time() socks.set_default_proxy(socks.SOCKS5, host, port) socket.socket = socks.socksocket response = requests.get('http://httpbin.org/ip', timeout=10) elapsed_time = time.time() - start_time if response.status_code == 200: print(f"SOCKS Proxy {proxy} success. time: {elapsed_time:.2f} s") print(f"IP: {response.json()['origin']}") else: print(f"SOCKS Proxy {proxy} failed. code: {response.status_code}") except Exception as e: print(f"SOCKS Proxy {proxy} failed: {str(e)}") finally: socks.set_default_proxy() socket.socket = socket.socket if __name__ == "__main__": http_proxy = "http://115.219.4.171:23456" test_http_proxy(http_proxy) socks_proxy = "115.219.3.54:23457" test_socks_proxy(socks_proxy) ``` -------------------------------- ### Java Streaming Example Source: https://github.com/acedatacloud/docs/blob/main/de/guides/kimi/kimi_chat_completions.mdx Example code demonstrating how to use the Kimi Chat Completions API with streaming enabled using Java and OkHttp. ```APIDOC ## Java Streaming Example ### Description This example demonstrates how to make a POST request to the Kimi Chat Completions API using Java and the OkHttp library, with `stream: true` enabled for chunked responses. ### Code ```java // Assuming you have JSONObject and OkHttpClient set up // import org.json.JSONObject; // import okhttp3.*; JSONObject jsonObject = new JSONObject();jsonObject.put("model", "kimi-k2.5"); jsonObject.put("messages", new JSONArray("[{"role":"user","content":"Hello"}]")); // Note: JSONArray usage might vary based on your JSON library jsonObject.put("stream", true); MediaType mediaType = "application/json; charset=utf-8".toMediaType(); // Extension function or equivalent RequestBody body = jsonObject.toString().toRequestBody(mediaType); // Extension function or equivalent Request request = new Request.Builder() .url("https://api.acedata.cloud/kimi/chat/completions") .post(body) .addHeader("accept", "application/json") .addHeader("authorization", "Bearer {token}") .addHeader("content-type", "application/json") .build(); OkHttpClient client = new OkHttpClient(); Response response = client.newCall(request).execute(); System.out.print(response.body().string()); // Use .body()!! for non-null assertion if needed ``` **Note:** The exact syntax for `toMediaType()` and `toRequestBody()` might depend on the specific OkHttp version or extensions you are using. Ensure your JSON library is correctly handling the `messages` array. ``` -------------------------------- ### GET /tasks/batch Source: https://github.com/acedatacloud/docs/blob/main/el/guides/producer/producer_tasks.mdx Retrieves the detailed status and results for a collection of batch tasks. ```APIDOC ## GET /tasks/batch ### Description Fetches the comprehensive details of batch tasks, including request parameters, processing state, and generated output data such as audio URLs and task progress. ### Method GET ### Endpoint /tasks/batch ### Parameters #### Query Parameters - **page** (integer) - Optional - Page number for pagination - **limit** (integer) - Optional - Number of items per page ### Response #### Success Response (200) - **items** (array) - List of batch task objects - **items._id** (string) - Internal database identifier - **items.id** (string) - Unique task identifier - **items.request** (object) - Original request parameters including model and lyrics - **items.response** (object) - Processing results including audio_url and state #### Response Example { "items": [ { "id": "1a6ac2ad-10f2-4e2b-b500-66ec27fe82ad", "request": { "action": "generate", "model": "FUZZ-2.0 Pro" }, "response": { "task_id": "1a6ac2ad-10f2-4e2b-b500-66ec27fe82ad", "data": [ { "state": "succeeded", "audio_url": "https://storage.googleapis.com/example/audio.m4a", "progress": "100%" } ] } } ] } ``` -------------------------------- ### Face Swap API Response Example Source: https://github.com/acedatacloud/docs/blob/main/guides/face-change/face_swap.mdx An example of a successful JSON response from the Face Swap API. It includes the URL of the generated image, its dimensions, size, and a unique task ID for tracking. ```json { "image_url": "https://platform.cdn.acedata.cloud/face/4b13bdeb-1b19-4ea5-bddf-c2da14ba72e3.png", "image_width": 2008, "image_height": 1942, "image_size": 4006213, "task_id": "4b13bdeb-1b19-4ea5-bddf-c2da14ba72e3" } ``` -------------------------------- ### Initiate Asynchronous Audio Generation with Callback URL Source: https://github.com/acedatacloud/docs/blob/main/ja/guides/producer/producer_audios.mdx This example shows how to initiate an audio generation task using the Acedata Cloud API with an asynchronous callback. A `callback_url` is provided, to which the API will send the task results once completed. The initial response contains a `task_id` for tracking. ```json { "action": "generate", "prompt": "太陽の光で目が覚めた", "callback_url": "https://webhook.site/0d73431d-f833-4be4-9276-b6e1690d55c1" } ``` -------------------------------- ### GET /batch_song_tasks Source: https://github.com/acedatacloud/docs/blob/main/zh-TW/guides/suno/suno_tasks.mdx Fetches a list of all batch song tasks with their respective song details. ```APIDOC ## GET /batch_song_tasks ### Description Retrieves a list of all batch song tasks, including detailed information for each song generated within those tasks. ### Method GET ### Endpoint /batch_song_tasks ### Parameters #### Query Parameters - **count** (integer) - Optional - The number of batch tasks to retrieve. ### Request Example ```json { "message": "GET request to retrieve batch song tasks" } ``` ### Response #### Success Response (200) - **items** (array) - A list of batch song task objects. - **_id** (string) - Unique identifier for the batch task. - **id** (string) - Unique identifier for the task. - **api_id** (string) - Identifier for the API used. - **application_id** (string) - Identifier for the application. - **created_at** (number) - Timestamp of task creation. - **credential_id** (string) - Identifier for the credential used. - **request** (object) - Details of the request made. - **action** (string) - The action performed (e.g., "generate"). - **prompt** (string) - The prompt used for song generation. - **trace_id** (string) - Identifier for tracing the request. - **user_id** (string) - Identifier for the user. - **response** (object) - Details of the API response. - **success** (boolean) - Indicates if the task was successful. - **task_id** (string) - Identifier for the task. - **data** (array) - A list of song objects generated. - **id** (string) - Unique identifier for the song. - **title** (string) - Title of the song. - **image_url** (string) - URL to the song's associated image. - **lyric** (string) - Lyrics of the song. - **audio_url** (string) - URL to the song's audio file. - **video_url** (string) - URL to the song's video file. - **created_at** (string) - Timestamp of song creation. - **model** (string) - The model used for generation. - **prompt** (string) - The prompt used for this specific song. - **style** (string) - The style of the song. - **duration** (number) - Duration of the song in seconds. - **count** (integer) - The total number of batch tasks returned. #### Response Example ```json { "items": [ { "_id": "66d2add5550a4144a5a88dfe", "id": "eae26f89-b64b-404d-a80c-761996660b1c", "api_id": "09a26295-5972-4392-9318-dcd9b218f90d", "application_id": "ab46a066-ad82-4180-b66b-49dedf8e8a2f", "created_at": 1725083093.077, "credential_id": "66614a7e-e624-494e-87a3-387099b8cbb4", "request": { "action": "generate", "prompt": "聖誕節的歌曲" }, "trace_id": "e13d385a-077e-4376-be01-3465b61ca0fd", "user_id": "ad7afe47-cea9-4cda-980f-2ad8810e51cf", "response": { "success": true, "task_id": "eae26f89-b64b-404d-a80c-761996660b1c", "data": [ { "id": "b8a4f691-4b14-4120-a7e1-a54a27a0e57e", "title": "假日祝福", "image_url": "https://cdn2.suno.ai/image_b8a4f691-4b14-4120-a7e1-a54a27a0e57e.jpeg", "lyric": "[Verse]\n雪花輕柔地飄落\n燈光閃爍如此明亮\n孩子們笑聲滿滿\n聖誕節終於來臨\n[Verse 2]\n鈴聲在夜裡響起\n壁爐溫暖而明亮\n樹下唱著聖誕頌歌\n大家聚在一起我們同意\n[Chorus]\n假日的祝福成真\n是時候與你分享快樂\n每個人都笑著擁抱\n聖誕快樂讓我們一起玩\n[Verse 3]\n禮物包裝得充滿愛\n魔法在空氣中飄浮\n餅乾在烤箱裡烘焙\n聖誕的愛要被給予\n[Chorus]\n假日的祝福成真\n是時候與你分享快樂\n每個人都笑著擁抱\n聖誕快樂讓我們一起玩\n[Bridge]\n星星在天空中閃耀\n緊緊抱住你所愛的人不要問為什麼\n心與心我們都團結在一起\n在這個夜晚我們感到高興", "audio_url": "https://cdn1.suno.ai/b8a4f691-4b14-4120-a7e1-a54a27a0e57e.mp3", "video_url": "https://cdn1.suno.ai/b8a4f691-4b14-4120-a7e1-a54a27a0e57e.mp4", "created_at": "2024-08-31T05:44:54.806Z", "model": "chirp-v3.5", "prompt": "一首聖誕歌曲", "style": "流行", "duration": 154.44 }, { "id": "1a3343b2-2c24-4584-a2a7-687e2f97f09e", "title": "假日祝福", "image_url": "https://cdn2.suno.ai/image_1a3343b2-2c24-4584-a2a7-687e2f97f09e.jpeg", "lyric": "[Verse]\n雪花輕柔地飄落\n燈光閃爍如此明亮\n孩子們笑聲滿滿\n聖誕節終於來臨\n[Verse 2]\n鈴聲在夜裡響起\n壁爐溫暖而明亮\n樹下唱著聖誕頌歌\n大家聚在一起我們同意\n[Chorus]\n假日的祝福成真\n是時候與你分享快樂\n每個人都笑著擁抱\n聖誕快樂讓我們一起玩\n[Verse 3]\n禮物包裝得充滿愛\n魔法在空氣中飄浮\n餅乾在烤箱裡烘焙\n聖誕的愛要被給予\n[Chorus]\n假日的祝福成真\n是時候與你分享快樂\n每個人都笑著擁抱\n聖誕快樂讓我們一起玩\n[Bridge]\n星星在天空中閃耀\n緊緊抱住你所愛的人不要問為什麼\n心與心我們都團結在一起\n在這個夜晚我們感到高興", "audio_url": "https://cdn1.suno.ai/1a3343b2-2c24-4584-a2a7-687e2f97f09e.mp3", "video_url": "https://cdn1.suno.ai/1a3343b2-2c24-4584-a2a7-687e2f97f09e.mp4", "created_at": "2024-08-31T05:44:54.806Z", "model": "chirp-v3.5", "prompt": "一首聖誕歌曲", "style": "流行", "duration": 147.16 } ] } }, { "_id": "66d2b03c550a4144a5a8d93d", "id": "0d3ed03b-912b-4f7d-941b-8441323cb77b", "api_id": "09a26295-5972-4392-9318-dcd9b218f90d", "application_id": "ab46a066-ad82-4180-b66b-49dedf8e8a2f", "created_at": 1725083708.53, "credential_id": "66614a7e-e624-494e-87a3-387099b8cbb4", "request": { "action": "generate", "prompt": "啦啦啦" }, "trace_id": "29ebb919-1126-4156-86cc-4ad899432a8c", "user_id": "ad7afe47-cea9-4cda-980f-2ad8810e51cf", "response": { "success": true, "task_id": "0d3ed03b-912b-4f7d-941b-8441323cb77b", "data": [ { "id": "b4f498b2-e86f-4172-926a-39da9df84dd3", "title": "啦啦啦", "image_url": "https://cdn2.suno.ai/image_b4f498b2-e86f-4172-926a-39da9df84dd3.jpeg", "lyric": "[Verse]\n我每天早上醒來\n透過窗戶看外面\n陽光明亮而耀眼\n新一天的開始\n[Verse 2]\n鳥兒快樂地歌唱\n我在花園裡跳舞\n美麗的花圍繞著我\n每一刻都是我的\n[Chorus]\n啦啦啦啦啦啦\n和我一起唱\n不要停\n啦啦啦啦啦啦\n享受生活的快樂\n[Verse 3]\n海洋藍而廣闊\n波浪甜美地拍打\n我們在沙灘上散步\n不管天氣如何\n[Bridge]\n抓住每一個時刻\n聽我的歌唱\n感受自由\n快樂\n現在隨著節奏跳舞\n[Chorus]\n啦啦啦啦啦啦\n和我一起唱\n不要停\n啦啦啦啦啦啦\n享受生活的快樂", "audio_url": "https://cdn1.suno.ai/b4f498b2-e86f-4172-926a-39da9df84dd3.mp3", "video_url": "https://cdn1.suno.ai/b4f498b2-e86f-4172-926a-39da9df84dd3.mp4", "created_at": "2024-08-31T05:55:09.345Z", "model": "chirp-v3.5", "prompt": "啦啦啦", "style": "流行", "duration": 154.32 }, { "id": "8b44fdf1-3b88-47ac-a351-7c4b4de60549", "title": "啦啦啦", "image_url": "https://cdn2.suno.ai/image_8b44fdf1-3b88-47ac-a351-7c4b4de60549.jpeg", "lyric": "[Verse]\n我每天早上醒來\n透過窗戶看外面\n陽光閃耀明亮\n新一天的開始\n[Verse 2]\n鳥兒快樂地唱著\n我在花園裡跳舞\n美麗的花圍繞著我\n每一刻都是我的\n[Chorus]\n啦啦啦啦啦啦\n和我一起唱\n不要停\n啦啦啦啦啦啦\n享受生活的快樂\n[Verse 3]\n藍色而廣闊的海洋\n波浪甜美地拍打\n我們在沙灘上散步\n不管天氣如何\n[Bridge]\n抓住每一個時刻\n聽我的歌唱\n感受自由\n快樂\n現在隨著節奏跳舞\n[Chorus]\n啦啦啦啦啦啦\n和我一起唱\n不要停\n啦啦啦啦啦啦\n享受生活的快樂", "audio_url": "https://cdn1.suno.ai/8b44fdf1-3b88-47ac-a351-7c4b4de60549.mp3", "video_url": "https://cdn1.suno.ai/8b44fdf1-3b88-47ac-a351-7c4b4de60549.mp4", "created_at": "2024-08-31T05:55:09.345Z", "model": "chirp-v3.5", "prompt": "啦啦啦", "style": "流行", "duration": 177.36 } ] } } ], "count": 2 } ``` ``` -------------------------------- ### Generate Video via API Source: https://github.com/acedatacloud/docs/blob/main/ar/guides/wan/wan_videos.mdx Demonstrates how to initiate a video generation request. The CURL example shows a basic text-to-video request, while the Python example demonstrates an image-to-video request with a callback URL. ```shell curl -X POST 'https://api.acedata.cloud/wan/videos' \ -H 'accept: application/json' \ -H 'authorization: Bearer {token}' \ -H 'content-type: application/json' \ -d '{ "action": "text2video", "model": "wan2.6-t2v", "prompt": "Astronauts shuttle from space to volcano", "duration": 5 }' ``` ```python import requests url = "https://api.acedata.cloud/wan/videos" headers = { "accept": "application/json", "authorization": "Bearer {token}", "content-type": "application/json" } payload = { "action": "image2video", "model": "wan2.6-i2v", "prompt": "Astronauts shuttle from space to volcano", "duration": 5, "image_url": "https://cdn.acedata.cloud/r9vsv9.png", "callback_url": "https://www.baidu.com/" } response = requests.post(url, json=payload, headers=headers) print(response.text) ``` -------------------------------- ### API Response and Error Handling Examples Source: https://github.com/acedatacloud/docs/blob/main/zh-TW/guides/sora/sora_tasks.mdx Provides examples of successful batch task response structures and the standard error response format returned by the API when a request fails. ```json { "items": [ { "id": "b8976e18-32dc-4718-9ed8-1ea090fcb6ea", "response": { "success": true, "data": [{"id": "sora-2:task_01k777hjrbfrgs2060q5zvf2a5", "state": "succeeded"}] } } ], "count": 1 } ``` ```json { "success": false, "error": { "code": "api_error", "message": "fetch failed" }, "trace_id": "2cf86e86-22a4-46e1-ac2f-032c0f2a4e89" } ``` -------------------------------- ### Asynchronous Callback Request Example Source: https://github.com/acedatacloud/docs/blob/main/zh-TW/guides/midjourney/midjourney_edits.mdx This example demonstrates how to initiate an asynchronous request to the Midjourney Edits API by providing a `callback_url`. The API will immediately return a `task_id`, and the results will be sent to the specified callback URL upon completion. ```json { "prompt": "a cat sitting on a table", "callback_url": "https://webhook.site/556e6971-b41f-4fa8-9151-6e91acd0399f", "width": 960, "height": 1200 } ``` -------------------------------- ### Error Handling Source: https://github.com/acedatacloud/docs/blob/main/zh-TW/guides/seedance/seedance_videos.mdx Details common error codes and provides an example of an error response structure. ```APIDOC ## Error Handling ### Description This section outlines common error codes returned by the API and provides an example of the error response format. ### Common Error Codes - `400 token_mismatched`: Bad Request. Possible cause: missing or invalid parameters. - `400 api_not_implemented`: Bad Request. Possible cause: missing or invalid parameters. - `401 invalid_token`: Unauthorized. The provided authentication token is invalid or missing. - `429 too_many_requests`: Too Many Requests. You have exceeded the rate limit. - `500 api_error`: Internal Server Error. An issue occurred on the server. ### Error Response Example ```json { "success": false, "error": { "code": "api_error", "message": "获取失败" }, "trace_id": "2cf86e86-22a4-46e1-ac2f-032c0f2a4e89" } ``` ``` -------------------------------- ### JavaScript (Node.js) Streaming Example Source: https://github.com/acedatacloud/docs/blob/main/de/guides/kimi/kimi_chat_completions.mdx Example code demonstrating how to use the Kimi Chat Completions API with streaming enabled using JavaScript's fetch API. ```APIDOC ## JavaScript (Node.js) Streaming Example ### Description This example shows how to make a POST request to the Kimi Chat Completions API using `fetch` in Node.js, with `stream: true` enabled to receive responses in chunks. ### Code ```javascript const options = { method: "post", headers: { "accept": "application/json", "authorization": "Bearer {token}", "content-type": "application/json" }, body: JSON.stringify({ "model": "kimi-k2.5", "messages": [{"role":"user","content":"Hello"}], "stream": true }) }; fetch("https://api.acedata.cloud/kimi/chat/completions", options) .then(response => response.json()) .then(response => console.log(response)) .catch(err => console.error(err)); ``` ``` -------------------------------- ### Pay Order with Python httpx (Async) Source: https://github.com/acedatacloud/docs/blob/main/ja/guides/x402.mdx This asynchronous Python example uses the 'httpx' library with the 'x402.clients.httpx' wrapper to perform X402 payments. It requires environment variables for order ID, platform token, and private key. The code defines an async function that creates an httpx client configured for X402 payments, sends a POST request to the payment endpoint, and prints the decoded receipt from the response headers. ```python import asyncio import os from eth_account import Account from x402.clients.httpx import x402HttpxClient from x402.clients.base import decode_x_payment_response async def pay_order() -> None: order_id = os.environ["ACE_X402_ORDER_ID"] platform_token = os.environ["ACE_PLATFORM_TOKEN"] account = Account.from_key(os.environ["ACE_X402_PRIVATE_KEY"]) async with x402HttpxClient( account=account, base_url="https://platform.acedata.cloud", headers={"Authorization": f"Bearer {platform_token}"}, payment_requirements_selector=lambda accepts, **_: next( req for req in accepts if req.network == "base" ), ) as client: response = await client.post( f"/api/v1/orders/{order_id}/pay/", json={"pay_way": "X402"}, ) response.raise_for_status() receipt_header = response.headers.get("X-PAYMENT-RESPONSE") if receipt_header: print("x402 レシート:", decode_x_payment_response(receipt_header)) asyncio.run(pay_order()) ```