# TikTok Publish > Integreer het tiktok-publish AI-model via krachtige API's met lage latentie en betalen naar verbruik. ## Overview - **Eindpunt**: `POST https://api.muapi.ai/api/v1/tiktok-publish` - **Model ID**: `tiktok-publish` - **Categorie**: other - **Variant**: TikTok Publish - **Familie**: social - **Cost**: 0.02 credits per call (some modellen compute cost dynamically based on params) ## API Usage MuApi gebruikt het patroon **verzenden-dan-poll**: dien een taak in, verkrijg een `request_id` en peil vervolgens het eindpunt van de voorspellingen totdat `status` `voltooid` is. Optioneel kunt u `?webhook=YOUR_URL` doorgeven bij de submission-aanroep om een ​​POST-callback te ontvangen wanneer de taak is voltooid (polling overslaan). **Authenticatie**: stuur uw MuApi-sleutel in de `x-api-key` header. Koop er een op https://muapi.ai/access-keys. ### 1. Submit a job ```http POST https://api.muapi.ai/api/v1/tiktok-publish Content-Type: application/json x-api-key: YOUR_API_KEY ``` **Minimum (alleen vereist):** ```json { "account_id": 0, "media_url": "https://example.com/your-media_url" } ``` **Volledig voorbeeld (alle parameters):** ```json { "account_id": 0, "media_url": "https://example.com/your-media_url", "title": "", "privacy_level": "PUBLIC_TO_EVERYONE", "allow_comment": true, "allow_duet": true, "allow_stitch": true, "is_ai_generated": false } ``` **Response:** ```json { "request_id": "abc123", "status": "processing" } ``` ### 2. Poll voor het resultaat ```http GET https://api.muapi.ai/api/v1/predictions/{request_id}/result x-api-key: YOUR_API_KEY ``` Mogelijke `status`-waarden: `in wachtrij geplaatst`, `in behandeling`, `verwerking`, `voltooid`, `mislukt`, `geannuleerd`. Poll elke 2-5 seconden tot de terminal. Wanneer 'voltooid', bevinden de resultaat-URL's zich in de array 'outputs'. **Voorbeeldreactie bij 'voltooid':** ```json { "id": "abc123", "status": "completed", "outputs": [ "https://cdn.muapi.ai/.../output.png" ], "urls": { "get": "https://api.muapi.ai/api/v1/predictions/abc123/result" }, "created_at": "2026-05-08T12:34:56Z", "has_nsfw_contents": [] } ``` ### krul ```bash 1. Submit REQUEST_ID=$(curl -s -X POST https://api.muapi.ai/api/v1/tiktok-publish \ -H "x-api-key: $MUAPI_API_KEY" \ -H "Content-Type: application/json" \ -d '{"account_id":0,"media_url":"https://example.com/your-media_url"}' | jq -r .request_id) 2. Poll tot voltooid while :; do RESP=$(curl -s https://api.muapi.ai/api/v1/predictions/$REQUEST_ID/result -H "x-api-key: $MUAPI_API_KEY") STATUS=$(echo "$RESP" | jq -r .status) [ "$STATUS" = "completed" ] && echo "$RESP" | jq .outputs && break [ "$STATUS" = "failed" ] && echo "$RESP" && exit 1 sleep 3 done ``` ### Python ```python import os, time, requests API = "https://api.muapi.ai/api/v1" headers = {"x-api-key": os.environ["MUAPI_API_KEY"]} r = requests.post(f"{API}/tiktok-publish", headers=headers, json={"account_id":0,"media_url":"https://example.com/your-media_url"}) request_id = r.json()["request_id"] while True: res = requests.get(f"{API}/predictions/{request_id}/result", headers=headers).json() if res["status"] == "completed": print(res["outputs"]); break if res["status"] == "failed": raise RuntimeError(res.get("error")); time.sleep(3) ``` ## Input Schema De API accepteert de volgende invoerparameters: - **`account_id`** (`integer`, _required_): TikTok-ID. - **`media_url`** (`string`, _required_): URL-video. - **`title`** (`string`, _optional_): filmpje (150). - Default: `""` - **`privacy_level`** (`string`, _optional_): No description. - Default: `"PUBLIC_TO_EVERYONE"` - Options: `"PUBLIC_TO_EVERYONE"`, `"MUTUAL_FOLLOW_FRIENDS"`, `"FOLLOWER_OF_CREATOR"`, `"SELF_ONLY"` - **`allow_comment`** (`boolean`, _optional_): No description. - Default: `true` - **`allow_duet`** (`boolean`, _optional_): No description. - Default: `true` - **`allow_stitch`** (`boolean`, _optional_): No description. - Default: `true` - **`is_ai_generated`** (`boolean`, _optional_): AI. - Default: `false` ## Resultaat Schema Het polling-eindpunt retourneert de volgende velden: - **`id`** (`string`): De aanvraag-ID. - **`status`** (`string`): Eén van de opties 'in wachtrij', 'in behandeling', 'bezig met verwerken', 'voltooid', 'mislukt', 'geannuleerd'. - **`outputs`** (`array`): URL's naar gegenereerde afbeeldingen/video's/audio. Leeg totdat `status` `voltooid` is. - **`urls.get`** (`string`): Zelfkoppeling om deze voorspelling opnieuw op te halen. - **`error`** (`string` | `null`): Foutmelding als `status` `mislukt` is. - **`created_at`** (`string`): ISO-8601-tijdstempel van het moment waarop de aanvraag is gemaakt. - **`has_nsfw_contents`** (`array of boolean`): NSFW-detectievlaggen per uitgang. ## Webhooks (optional) Voeg `?webhook=https://uw-server/pad` toe aan de verzend-URL. Wanneer de taak een eindstatus bereikt, POST MuApi dezelfde vorm als het polling-antwoord op uw URL - geen polling nodig. ## Agent Integration MuApi levert een MCP-server en CLI zodat agenten (Claude Code, Cursor, aangepast) dit eindpunt kunnen aanroepen zonder HTTP-code te schrijven: ```bash # Installeer de CLI npm install -g muapi-cli # Authenticate once muapi auth login # Expose all MuApi modellen as MCP tools to your agent muapi mcp serve ``` De MCP-server stelt tools beschikbaar die verzend + poll voor elk model inpakken, inclusief `tiktok-publish`. Zie `muapi --help` voor categoriespecifieke snelkoppelingen (`muapi image genereren`, `muapi video from-image`, etc.). ## Related Models - [YouTube Publish](https://muapi.ai/nl/playground/youtube-publish) - [TikTok Publish](https://muapi.ai/nl/playground/tiktok-publish) - [Instagram Publish](https://muapi.ai/nl/playground/instagram-publish) - [LinkedIn Publish](https://muapi.ai/nl/playground/linkedin-publish) - [Facebook Publish](https://muapi.ai/nl/playground/facebook-publish) - [X Publish](https://muapi.ai/nl/playground/x-publish) - [Threads Publish](https://muapi.ai/nl/playground/threads-publish) - [Pinterest Publish](https://muapi.ai/nl/playground/pinterest-publish) - [YouTube Set Thumbnail](https://muapi.ai/nl/playground/youtube-set-thumbnail) - [YouTube Update Metadata](https://muapi.ai/nl/playground/youtube-update-metadata) ## Bronnen - [Playground Page](https://muapi.ai/nl/playground/tiktok-publish) - [API Reference](https://muapi.ai/nl/playground/tiktok-publish/api) - [Global llms.txt](https://muapi.ai/nl/llms.txt)