=== URL: https://useapi.net/docs/start-here/setup-pika === Document URL: https://useapi.net/docs/start-here/setup-pika --- layout: default title: Setup Pika nav_order: 600 nav_exclude: true --- # Setup Pika {: .no_toc } ## Table of contents {: .no_toc .text-delta } 1. TOC {:toc} Approximately 3 minutes to complete setup steps. --- ## Create Discord account You need a [Discord](https://discord.com) account to interact with [Pika Discord Bot](http://discord.gg/pika). Create a [new account](https://discord.com/register) if you don't have one already. Please note even if you have an existing Discord account we are **strongly** recommending creating a separate Discord account specifically designated to be used with useapi.net API. ## Join Pika Discord Server Follow Pika Labs [instructions](https://pikalabsai.org/pika-labs-discord-server-guide/) and join official [Pika Discord Server](http://discord.gg/pika). ## Add Pika Bot to your Direct Messages channel Please follow [youtube video](https://www.youtube.com/watch?v=moxSKVcQt6c) to add Pika Bot to your Direct Messages channel. ## Make a note of your Direct Messages Pika channel id Your Discord URL looks like `https://discord.com/channels/@me/`. ![](../../assets/images/pika_dm_channel_setup.png) ## Obtain Discord token There are many tutorials describing how to obtain Discord tokens. Please refer to the following links bellow for additional guidance: - [How to Find Your Discord Token](https://discordhelp.net/discord-token) - [How To Get Your Discord Token](https://pcstrike.com/how-to-get-discord-token/) - [How to get Discord Token](https://linuxhint.com/get-discord-token/) Keep in mind that anyone with a Discord token can have **full access** to your Discord account so please keep it **safe** and **secure**. To reset your Discord token simply change your Discord password. ## Verify Discord access Once all the above steps are completed you should have the following: - Pika Direct Message channel id number - Discord token This only verifies that token and channel id values are correct. To complete setup, you **MUST** proceed to [POST account/`channel`](../api-pika-v1/post-pika-account-channel) and complete the configuration of the Pika API account using the token and channel id values retrieved above. ##### Channel {: .no_toc }
=== URL: https://useapi.net/docs/api-pika-v1 === Document URL: https://useapi.net/docs/api-pika-v1 --- layout: default title: Pika API v1 nav_order: 11000 has_children: true permalink: /docs/api-pika-v1 nav_exclude: true --- # Pika API v1 January 2024 (December 15, 2025) Pika Discord bot API has been decommissioned and no longer available. This is [experimental](../../docs/legal) API for [Pika Discord Bot](http://discord.gg/pika) by [Pika.art](https://pika.art). Pika currently support text and images as input for video generation, and private generations by directly messaging the bot. [Setup Pika](../../docs/start-here/setup-pika) [Postman collection](https://www.postman.com/useapinet/useapi-net/collection) (January 20, 2026) #### Example source code on GitHub * [Face swap and animate images generated by Midjourney using InsightFaceSwap and Pika (using webhook)](https://github.com/useapi/examples/tree/main/imagine-faceswap-animate) February 19, 2024 * [Animate images generated by Midjourney using Pika (using webhook)](https://github.com/useapi/examples/tree/main/animate-midjourney-images-with-pika) January 29, 2024 Developer Community: * Discord Server * Telegram Channel * Reddit Group === URL: https://useapi.net/docs/api-pika-v1/del-pika-account-channel === Document URL: https://useapi.net/docs/api-pika-v1/del-pika-account-channel --- layout: default title: DEL pika/account/channel parent: Pika API v1 nav_order: 400 nav_exclude: true --- ## Delete Pika account {: .no_toc } Pika Discord bot API has been decommissioned and no longer available. ## Table of contents {: .no_toc .text-delta } 1. TOC {:toc} --- {: .delete } > **https://api.useapi.net/v1/pika/account/`channel`** The `channel` value should correspond to an account configured previously via a [POST](post-pika-account-channel) request. ##### Request Headers ``` yaml Authorization: Bearer {API token} ``` - `API token` is **required**, see [Setup useapi.net](../start-here/setup-useapi) for details. ##### Responses {% tabs del_account_Pika_response %} {% tab del_account_Pika_response 204 %} 204 No Content {% endtab %} {% tab del_account_Pika_response 401 %} 401 Unauthorized ```json { "error": "Unauthorized", "code": 401 } ``` {% endtab %} {% tab del_account_Pika_response 404 %} 404 Not Found {% endtab %} {% endtabs %} ##### Model ```typescript { // TypeScript, all fields are optional error: string, errorDetails: string, code: number } ``` ##### Examples {% tabs del_account_Pika_example %} {% tab del_account_Pika_example Curl %} ``` bash curl -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer …" \ -X DELETE https://api.useapi.net/v1/pika/account/ ``` {% endtab %} {% tab del_account_Pika_example JavaScript %} ``` javascript const channel = "Previously configured channel id"; const apiUrl = `https://api.useapi.net/v1/pika/account/${channnel}`; const token = "API token"; const data = { method: 'DELETE', headers: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' } }; const response = await fetch(apiUrl, data); const result = await response.json(); console.log("response", {response, result}); ``` {% endtab %} {% tab del_account_Pika_example Python %} ``` python import requests channel = "Previously configured channel id" apiUrl = f"https://api.useapi.net/v1/pika/account/{channel}" token = "API token" headers = { "Content-Type": "application/json", "Authorization" : f"Bearer {token}" } response = requests.delete(apiUrl, headers=headers) print(response, response.json()) ``` {% endtab %} {% endtabs %} === URL: https://useapi.net/docs/api-pika-v1/get-pika-account-channel === Document URL: https://useapi.net/docs/api-pika-v1/get-pika-account-channel --- layout: default title: GET pika/account/channel parent: Pika API v1 nav_order: 200 nav_exclude: true --- ## Retrieve Pika configuration for `channel` {: .no_toc } Pika Discord bot API has been decommissioned and no longer available. ## Table of contents {: .no_toc .text-delta } 1. TOC {:toc} --- {: .get } > **https://api.useapi.net/v1/pika/account/`channel`** The `channel` value should correspond to an account configured previously via a [POST](post-pika-account-channel) request. ##### Request Headers ``` yaml Authorization: Bearer {API token} Content-Type: application/json ``` - `API token` is **required**, see [Setup useapi.net](../start-here/setup-useapi) for details. ##### Responses {% tabs get_account_Pika_channel_response %} {% tab get_account_Pika_channel_response 200 %} 200 OK ```json { "channel": "Discord channel id", "discord": "Discord token", "maxJobs": 1-10 } ``` {% endtab %} {% tab get_account_Pika_channel_response 401 %} 401 Unauthorized ```json { "error": "Unauthorized", "code": 401 } ``` {% endtab %} {% tab get_account_Pika_channel_response 404 %} 404 Not Found Configuration not found. To create configuration use [pika/account/`channel`](https://useapi.net/docs/api-pika-v1/post-pika-account-channel). {% endtab %} {% endtabs %} ##### Model ```typescript { // TypeScript, all fields are optional discord: string, channel: string, maxJobs: number, } ``` ##### Examples {% tabs get_account_Pika_channel_example %} {% tab get_account_Pika_channel_example Curl %} ``` bash curl https://api.useapi.net/v1/pika/account/ \ -H "Accept: application/json" \ -H "Authorization: Bearer …" ``` {% endtab %} {% tab get_account_Pika_channel_example JavaScript %} ``` javascript const token = "API token"; const channel = "Previously configured channel id"; const apiUrl = `https://api.useapi.net/v1/pika/account/${channel}`; const response = await fetch(apiUrl, { headers: { "Authorization": `Bearer ${token}`, }, }); const result = await response.json(); console.log("response", {response, result}); ``` {% endtab %} {% tab get_account_Pika_channel_example Python %} ``` python import requests token = "API token" channel = "Previously configured channel id" apiUrl = f"https://api.useapi.net/v1/pika/account/{channel}" headers = { "Content-Type": "application/json", "Authorization" : f"Bearer {token}" } response = requests.get(apiUrl, headers=headers) print(response, response.json()) ``` {% endtab %} {% endtabs %} === URL: https://useapi.net/docs/api-pika-v1/get-pika-account === Document URL: https://useapi.net/docs/api-pika-v1/get-pika-account --- layout: default title: GET pika/account parent: Pika API v1 nav_order: 100 nav_exclude: true --- ## Retrieve Pika accounts information {: .no_toc } Pika Discord bot API has been decommissioned and no longer available. ## Table of contents {: .no_toc .text-delta } 1. TOC {:toc} --- For your convenience, you can specify your Pika configuration values under your Pika account. If you specify multiple Pika accounts, the API will automatically perform load balancing by randomly selecting an account with available capacity before making calls to Discord / Pika. This endpoint retrieves the complete list of configured accounts for Pika. {: .get } > **https://api.useapi.net/v1/pika/account** ##### Request Headers ``` yaml Authorization: Bearer {API token} Content-Type: application/json ``` - `API token` is **required**, see [Setup useapi.net](../start-here/setup-useapi) for details. ##### Responses {% tabs account_Pika_response %} {% tab account_Pika_response 200 %} 200 OK ```json { "Discord channel A": { "channel": "Discord channel A", "discord": "Discord token A", "maxJobs": 1-10 }, "Discord channel B": { "channel": "Discord channel B", "discord": "Discord token B", "maxJobs": 1-10 }, "Discord channel N": { "channel": "Discord channel N", "discord": "Discord token N", "maxJobs": 1-10 } } ``` {% endtab %} {% tab account_Pika_response 401 %} 401 Unauthorized ```json { "error": "Unauthorized", "code": 401 } ``` {% endtab %} {% tab account_Pika_response 404 %} 404 Not Found Configuration not found. To create configuration use [pika/account/`channel`](https://useapi.net/docs/api-pika-v1/post-pika-account-channel). {% endtab %} {% endtabs %} ##### Model ```typescript { // TypeScript, all fields are optional [channel: string]: { discord: string, channel: string, maxJobs: number } } ``` ##### Examples {% tabs account_Pika_example %} {% tab account_Pika_example Curl %} ``` bash curl https://api.useapi.net/v1/pika/account \ -H "Accept: application/json" \ -H "Authorization: Bearer …" ``` {% endtab %} {% tab account_Pika_example JavaScript %} ``` javascript const token = "API token"; const apiUrl = "https://api.useapi.net/v1/pika/account"; const response = await fetch(apiUrl, { headers: { "Authorization": `Bearer ${token}`, }, }); const result = await response.json(); console.log("response", {response, result}); ``` {% endtab %} {% tab account_Pika_example Python %} ``` python import requests token = "API token" apiUrl = "https://api.useapi.net/v1/pika/account" headers = { "Content-Type": "application/json", "Authorization" : f"Bearer {token}" } response = requests.get(apiUrl, headers=headers) print(response, response.json()) ``` {% endtab %} {% endtabs %} === URL: https://useapi.net/docs/api-pika-v1/get-pika-jobid === Document URL: https://useapi.net/docs/api-pika-v1/get-pika-jobid --- layout: default title: GET pika/jobs/?jobid=jobid parent: Pika API v1 nav_order: 1000 nav_exclude: true --- ## Retrieve Pika job status and results {: .no_toc } Pika Discord bot API has been decommissioned and no longer available. ## Table of contents {: .no_toc .text-delta } 1. TOC {:toc} --- Use this endpoint to retrieve status and results of - [pika/create](../api-pika-v1/post-pika-create) - [pika/animate](../api-pika-v1/post-pika-animate) - [pika/encrypt_text](../api-pika-v1/post-pika-encrypt_text) - [pika/encrypt_image](../api-pika-v1/post-pika-encrypt_image) - [pika/button](../api-pika-v1/post-pika-button) If you specified optional parameter [`replyUrl`](../api-pika-v1/post-pika-create#request-body) you technically do not need to use this endpoint to retrieve results since API will call provided `replyUrl` once job generation completed. **Important** API periodically polls (checks) Discord every 15 to 60 seconds (depending on the load) and updates all currently executed jobs statuses and results. Polling interval is used for safety reasons, aiming to prevent any potential issues with Discord and Pika, such as bans or excessive requests. Jobs lifespan guaranteed to be at least 31 days, after that they will be expired and may be recycled. {: .get } > **https://api.useapi.net/v1/pika/jobs/?jobid=`jobid`** ##### Request Headers ``` yaml Authorization: Bearer {API token} ``` - `API token` is **required**, see [Setup useapi.net](../start-here/setup-useapi) for details. ##### Query Parameter `jobid` is **required**, use value returned by - [pika/create](../api-pika-v1/post-pika-create) - [pika/animate](../api-pika-v1/post-pika-animate) - [pika/encrypt_text](../api-pika-v1/post-pika-encrypt_text) - [pika/encrypt_image](../api-pika-v1/post-pika-encrypt_image) - [pika/button](../api-pika-v1/post-pika-button) ##### Responses {:toc} {% tabs get_pika_jobid_response %} {% tab get_pika_jobid_response 200 %} 200 OK If field `status` value is *created*, *started* or *progress* wait in a loop for **at least** 10..30 seconds and retry again. When completed retrieve generated video from `attachments` field. Field `content` contains message generated by Pika reflecting current generation parameters and progress. Optional array `embeds` contains additional information. ```json { "jobid": "", "verb": "pika-create", "status": "completed", "created": "2023-09-09T02:04:49.667Z", "updated": "2023-09-09T02:19:20.256Z", "prompt": "smiling and blinking", "buttons": [ "retry" ], "image": { "size": 1628384, "type": "image/png" }, "discord": "", "channel": "", "maxJobs": 10, "messageId": "", "content": "<@Discord user id> Prompt: smiling and blinking --size 100 Image: 1 Attachment Author: <@Discord user id>)", "timestamp": "2023-09-09T02:05:24.991000+00:00", "attachments": [ { "url": "", "proxy_url": "", "width": 768, "height": 768, "content_type": "", "id": "", "filename": "", "size": 7204115 } ], "code": 200 } ``` {% endtab %} {% tab get_pika_jobid_response 400 %} 400 Bad Request ```json { "error": "Query param jobid not provided", "code": 400 } ``` {% endtab %} {% tab get_pika_jobid_response 401 %} 401 Unauthorized ```json { "error": "Unauthorized", "code": 401 } ``` {% endtab %} {% tab get_pika_jobid_response 402 %} 402 Payment Required ```json { "error": "Account has no subscription or subscription expired", "code": 402 } ``` {% endtab %} {% tab get_pika_jobid_response 404 %} 404 Not Found ```json { "error": "Unable to locate job ", "code": 404 } ``` {% endtab %} {% tab get_pika_jobid_response 410 %} 410 Gone ```json { "error": "Job has expired", "code": 410 } ``` {% endtab %} {% endtabs %} ##### Model ```typescript { // TypeScript, all fields are optional jobid: string, parentJobId: string, verb: 'pika-create' | 'pika-animate' | 'pika-encrypt_text' | 'pika-encrypt_image' | 'pika-button', status: 'created' | 'started' | 'moderated' | 'progress' | 'completed' | 'failed' | 'cancelled', created: string, // YYYY-MM-DDTHH:mm:ss.sssZ, IS0 8601, UTC updated: string, // YYYY-MM-DDTHH:mm:ss.sssZ, IS0 8601, UTC prompt: string, font: 'MODERN' | 'COMICS' | 'SANS SERIF' | 'BAUHAUS' | 'RETRO', message: string | { size: number, type: string }, image: { size: number, type: string }, button: 'retry', buttons: [ 'retry' ], discord: string, // Provided for debugging purposes only, contains the first 3 and the last 3 characters of the original value channel: string, maxJobs: number, messageId: string, content: string, // Contains message generated by Pika reflecting current generation parameters and progress timestamp: string, attachments: [ { id: string, content_type: string, filename: string, url: string, proxy_url: string, size: number, width: number, height: number } ], embeds: [ { type: string, description: string, image: { url: string, proxy_url: string, width: number, height: number } } ], error: string, errorDetails: string, code: 200 } ``` ##### Examples {% tabs pika_jobid_example %} {% tab pika_jobid_example Curl %} ``` bash curl https://api.useapi.net/v1/pika/jobs/?jobid=… \ -H "Accept: application/json" \ -H "Authorization: Bearer …" ``` {% endtab %} {% tab pika_jobid_example JavaScript %} ``` javascript const token = "API token"; const jobid = "jobid returned by pika/create, pika/animate, pika/encrypt_text, pika/encrypt_image' or pika/button"; const apiUrl = `https://api.useapi.net/v1/pika/jobs/?jobid=${jobid}`; const response = await fetch(apiUrl, { headers: { "Authorization": `Bearer ${token}`, }, }); const result = await response.json(); console.log("response", {response, result}); ``` {% endtab %} {% tab pika_jobid_example Python %} ``` python import requests token = "API token" jobid = "jobid returned by pika/create, pika/animate, pika/encrypt_text, pika/encrypt_image' or pika/button" apiUrl = f"https://api.useapi.net/v1/pika/jobs/?jobid={jobid}" headers = { "Content-Type": "application/json", "Authorization" : f"Bearer {token}" } response = requests.get(apiUrl, headers=headers) print(response, response.json()) ``` {% endtab %} {% endtabs %} === URL: https://useapi.net/docs/api-pika-v1/get-pika-jobs-cancel === Document URL: https://useapi.net/docs/api-pika-v1/get-pika-jobs-cancel --- layout: default title: GET …/cancel/?jobid=jobid parent: Pika API v1 nav_order: 2000 nav_exclude: true --- ## Cancel Pika job {: .no_toc } Pika Discord bot API has been decommissioned and no longer available. ✔️ Added May 27, 2024 ## Table of contents {: .no_toc .text-delta } 1. TOC {:toc} --- Cancel execution of job created by - [pika/create](post-pika-create) - [pika/animate](post-pika-animate) - [pika/encrypt_text](post-pika-encrypt_text) - [pika/encrypt_image](post-pika-encrypt_image) - [pika/button](post-pika-button) {: .get } > **https://api.useapi.net/v1/pika/jobs/cancel/?jobid=`jobid`** ##### Request Headers ``` yaml Authorization: Bearer {API token} ``` - `API token` is **required**, see [Setup useapi.net](../start-here/setup-useapi) for details. ##### Query Parameter `jobid` is **required**, use value returned by - [pika/create](post-pika-create) - [pika/animate](post-pika-animate) - [pika/encrypt_text](post-pika-encrypt_text) - [pika/encrypt_image](post-pika-encrypt_image) - [pika/button](post-pika-button) ##### Responses {:toc} {% tabs post_pika_cancel_response %} {% tab post_pika_cancel_response 200 %} ```json { "jobid": "", "status": "cancelled" } "code": 200 ``` {% endtab %} {% tab post_pika_cancel_response 400 %} 400 Bad Request ```json { "error": "Query param jobid not provided", "code": 400 } ``` {% endtab %} {% tab post_pika_cancel_response 401 %} 401 Unauthorized ```json { "error": "Unauthorized", "code": 401 } ``` {% endtab %} {% tab post_pika_cancel_response 402 %} 402 Payment Required ```json { "error": "Account has no subscription or subscription expired", "code": 402 } ``` {% endtab %} {% tab post_pika_cancel_response 404 %} 404 Not Found ```json { "error": "Unable to locate job ", "code": 404 } ``` {% endtab %} {% endtabs %} ##### Model ```typescript { // TypeScript, all fields are optional jobid: string, status: 'created' | 'started' | 'moderated' | 'progress' | 'completed' | 'failed' | 'cancelled', error: string, errorDetails: string, code: number } ``` ##### Examples {% tabs pika_cancel_example %} {% tab pika_cancel_example Curl %} ``` bash curl https://api.useapi.net/v1/pika/jobs/cancel/?jobid=… \ -H "Accept: application/json" \ -H "Authorization: Bearer …" ``` {% endtab %} {% tab pika_cancel_example JavaScript %} ``` javascript const token = "API token"; const jobid = "jobid returned by pika/create, pika/animate, pika/encrypt_text, pika/encrypt_image or pika/button"; const apiUrl = `https://api.useapi.net/v1/pika/jobs/cancel/?jobid=${jobid}`; const response = await fetch(apiUrl, { headers: { "Authorization": `Bearer ${token}`, }, }); const result = await response.json(); console.log("response", {response, result}); ``` {% endtab %} {% tab pika_cancel_example Python %} ``` python import requests token = "API token" jobid = "jobid returned by pika/create, pika/animate, pika/encrypt_text, pika/encrypt_image or pika/button" apiUrl = f"https://api.useapi.net/v1/pika/jobs/cancel/?jobid={jobid}" headers = { "Content-Type": "application/json", "Authorization" : f"Bearer {token}" } response = requests.get(apiUrl, headers=headers) print(response, response.json()) ``` {% endtab %} {% endtabs %} === URL: https://useapi.net/docs/api-pika-v1/get-pika-jobs === Document URL: https://useapi.net/docs/api-pika-v1/get-pika-jobs --- layout: default title: GET pika/jobs parent: Pika API v1 nav_order: 3000 nav_exclude: true --- ## Get list of currently executing Pika jobs {: .no_toc } Pika Discord bot API has been decommissioned and no longer available. ✔️ Added May 27, 2024 ## Table of contents {: .no_toc .text-delta } 1. TOC {:toc} --- {: .get } > **https://api.useapi.net/v1/pika/jobs** ##### Request Headers ``` yaml Authorization: Bearer {API token} ``` - `API token` is **required**, see [Setup useapi.net](../start-here/setup-useapi) for details. ##### Responses {:toc} {% tabs post_pika_jobs_response %} {% tab post_pika_jobs_response 200 %} 200 OK ```json [ "", "", "" ] ``` {% endtab %} {% tab post_pika_jobs_response 401 %} 401 Unauthorized ```json { "error": "Unauthorized", "code": 401 } ``` {% endtab %} {% tab post_pika_jobs_response 402 %} 402 Payment Required ```json { "error": "Account has no subscription or subscription expired", "code": 402 } ``` {% endtab %} {% endtabs %} ##### Model ```typescript // TypeScript string[] ``` ##### Examples {% tabs pika_jobs_example %} {% tab pika_jobs_example Curl %} ``` bash curl https://api.useapi.net/v1/pika/jobs \ -H "Accept: application/json" \ -H "Authorization: Bearer …" ``` {% endtab %} {% tab pika_jobs_example JavaScript %} ``` javascript const token = "API token"; const apiUrl = `https://api.useapi.net/v1/pika/jobs`; const response = await fetch(apiUrl, { headers: { "Authorization": `Bearer ${token}`, }, }); const result = await response.json(); console.log("response", {response, result}); ``` {% endtab %} {% tab pika_jobs_example Python %} ``` python import requests token = "API token" apiUrl = f"https://api.useapi.net/v1/pika/jobs" headers = { "Content-Type": "application/json", "Authorization" : f"Bearer {token}" } response = requests.get(apiUrl, headers=headers) print(response, response.json()) ``` {% endtab %} {% endtabs %} === URL: https://useapi.net/docs/api-pika-v1/post-pika-account-channel === Document URL: https://useapi.net/docs/api-pika-v1/post-pika-account-channel --- layout: default title: POST pika/account/channel parent: Pika API v1 nav_order: 300 nav_exclude: true --- ## Create or update Pika account information {: .no_toc } Pika Discord bot API has been decommissioned and no longer available. ## Table of contents {: .no_toc .text-delta } 1. TOC {:toc} --- For your convenience, you can specify your Pika configuration values under your account. If you specify multiple Pika accounts, the API will automatically perform load balancing by randomly selecting an account with available capacity before making calls to Discord / Pika. {: .post } > **https://api.useapi.net/v1/pika/account/`channel`** ##### Request Headers ``` yaml Authorization: Bearer {API token} Content-Type: application/json ``` - `API token` is **required**, see [Setup useapi.net](../start-here/setup-useapi) for details. ##### Request Body ```json { "discord": "Discord token", "channel": "Discord channel id", "maxJobs": 1-10, } ``` - `discord`, `channel` are **required**. Please see [Setup Pika](../start-here/setup-pika) for details. - `channel` value specified in the request body **must match** the channel value specified in the URL path https://api.useapi.net/v1/pika/account/`channel`. - `maxJobs` is **required**. Currently, it should be between 1 and 10. ##### Responses {% tabs post_account_Pika_response %} {% tab post_account_Pika_response 204 %} 204 No Content {% endtab %} {% tab post_account_Pika_response 400 %} 400 Bad Request ```json { "error": "Required param discord is missing or empty" "Required param channel is missing or empty" "Required param channel () is not valid Discord channel id" "Required param channel () not matching to /pika/account/" "Required param maxJobs is missing or empty" "Required param maxJobs can't be more that " "Channel configuration has same discord value" "code": 400 } ``` {% endtab %} {% tab post_account_Pika_response 401 %} 401 Unauthorized ```json { "error": "Unauthorized", "code": 401 } ``` {% endtab %} {% endtabs %} ##### Model ```typescript { // TypeScript, all fields are optional discord: string, channel: string, maxJobs: number, error: string, errorDetails: string, code: number } ``` ##### Examples {% tabs post_account_Pika_example %} {% tab post_account_Pika_example Curl %} ``` bash curl -H "Accept: application/json" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer …" \ -X POST https://api.useapi.net/v1/pika/account/ \ -d '{"discord": "…", "channel": "…", "maxJobs": …}' ``` {% endtab %} {% tab post_account_Pika_example JavaScript %} ``` javascript const channel = "Discord channel id"; const apiUrl = `https://api.useapi.net/v1/pika/account/${channel}`; const token = "API token"; const discord = "Discord token"; const maxJobs = 10; const data = { method: 'POST', headers: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' } }; data.body = JSON.stringify({ discord, channel, maxJobs }); const response = await fetch(apiUrl, data); const result = await response.json(); console.log("response", {response, result}); ``` {% endtab %} {% tab post_account_Pika_example Python %} ``` python import requests channel = "Discord channel id" apiUrl = f"https://api.useapi.net/v1/pika/account/{channel}" token = "API token" discord = "Discord token" maxJobs = 10 headers = { "Content-Type": "application/json", "Authorization" : f"Bearer {token}" } body = { "discord": f"{discord}", "channel": f"{channel}", "maxJobs": maxJobs } response = requests.post(apiUrl, headers=headers, json=body) print(response, response.json()) ``` {% endtab %} {% endtabs %} === URL: https://useapi.net/docs/api-pika-v1/post-pika-animate === Document URL: https://useapi.net/docs/api-pika-v1/post-pika-animate --- layout: default title: POST pika/animate parent: Pika API v1 nav_order: 600 nav_exclude: true --- ## Pika [/animate](https://pikalabsai.org/pika-labs-commands-and-parameters) command {: .no_toc } Pika Discord bot API has been decommissioned and no longer available. ## Table of contents {: .no_toc .text-delta } 1. TOC {:toc} --- Use this endpoint to submit the Pika [/animate](https://pikalabsai.org/pika-labs-commands-and-parameters) command to your [Discord Pika channel](../start-here/setup-pika). Results obtained as a callback via optional parameter [`replyUrl`](#request-body) or by querying [pika/jobs/?jobid=jobid](../api-pika-v1/get-pika-jobid) endpoint. It is **important** not to use the Pika account setup for API access for any purposes other than its intended use, such as executing `/animate` or any other Pika commands _manually_ or in conjunction with _any other_ automation tools. The useapi.net API internally tracks the usage of the Pika account, including the number of currently active executions. Using it for other activities may cause API to function incorrectly. {: .post } > **https://api.useapi.net/v1/pika/animate** ##### Request Headers ``` yaml Authorization: Bearer {API token} Content-Type: multipart/form-data ``` - `API token` is **required**, see [Setup useapi.net](../start-here/setup-useapi) for details. ##### Request Body ```json { "image": "Pika image File or Blob", "prompt": "Pika prompt", "discord": "Discord token", "channel": "Discord channel id", "maxJobs": 10, "replyUrl": "Place your call back URL here", "replyRef": "Place your reference id here" } ``` - `image` is **required**, use it to prompt the Pika Bot to begin your video with the provided image. Must be either a [File](https://developer.mozilla.org/en-US/docs/Web/API/File) or [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob) object when included in this [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData) POST request. - `prompt` is optional, must contain Pika [/animate](https://pikalabsai.org/pika-labs-commands-and-parameters) prompt. Maximum length 1500 characters. - `discord`, `channel` are optional, if not provided randomly selected available account from [pika/account](../api-pika-v1/get-pika-account) will be used. See [Setup Pika](../start-here/setup-pika) for details. **Note** You may specify the `channel` value alone (omitting `discord`) when you wish to use a specific account from the configured list at [pika/account](../api-pika-v1/get-pika-account). - `maxJobs` is optional, if not provided value for `channel` account selected above will be used, if not provided defaulted to 10. - `replyUrl` is optional, if not provided value from [useapi.net account](../account-management/get-account) will be used. Place here your callback URL. API will call the provided `replyUrl` once job completed or failed. Maximum length 1024 characters. We recommend using sites like [webhook.site](https://webhook.site) to test callback URL functionality. - `replyRef` is optional, place here your reference id which will be stored and returned along with this job response / result. Maximum length 1024 characters. ##### Responses {% tabs post_pika-animate_response %} {% tab post_pika-animate_response 200 %} 200 OK Use returned `jobid` to [retrieve Pika job status and results](../api-pika-v1/get-pika-jobid). `content` contains message generated by Pika reflecting current generation parameters and progress. ```json { "jobid": "", "verb": "pika-animate", "status": "started", "created": "2023-09-09T02:04:49.667Z", "updated": "2023-09-09T02:04:53.490Z", "image": { "size": 1628384, "type": "image/png" }, "prompt": "smiling and blinking", "discord": "", "channel": "", "maxJobs": 10, "replyUrl": "https://webhook.site/abc", "replyRef": "", "messageId": "", "content": "<@Discord user id> Creation job queued. (Prompt: smiling and blinking Image: 1 Attachment Author: <@Discord user id>)", "timestamp": "2023-09-09T02:04:51.926000+00:00", "code": 200 } ``` {% endtab %} {% tab post_pika-animate_response 400 %} 400 Bad Request ```json { "error": "image, discord or channel value is missing" "prompt, replyRef or replyUrl is too long" "image is not File or Blob" "code": 400 } ``` {% endtab %} {% tab post_pika-animate_response 401 %} 401 Unauthorized ```json { "error": "Unauthorized", "code": 401 } ``` {% endtab %} {% tab post_pika-animate_response 402 %} 402 Payment Required ```json { "error": "Account has no subscription or subscription expired", "code": 402 } ``` {% endtab %} {% tab post_pika-animate_response 422 %} 422 Unprocessable Content Moderated message or invalid prompt params. ```json { "error": "Sorry, your input may be inconsistent with server rules.", "jobid": "", "status": "moderated", "code": 422 } ``` ```json { "error": "Invalid parameter", "errorDetails": "Unrecognized parameter(s): `size`", "jobid": "", "status": "moderated", "code": 422 } ``` {% endtab %} {% tab post_pika-animate_response 429 %} 429 Too Many Requests Wait in a loop for **at least** 10..30 seconds and retry again. There are two possible cases for API response 429. 1. API query is full and can not accept new [pika/animate](#pika-animate-command) requests. Size of query defined by [`maxJobs` optional parameter](#request-body). Wait in a loop for **at least** 10..30 seconds and retry again. ```json { "error": "Maximum of jobs executing in parallel supported", "executingJobs": [ "", "", "" ], "code": 429 } ``` 2. The API received an HTTP status 429 from the Discord API when it attempted to POST to the `/interactions` endpoint. Under normal circumstances, this should be a rare occurrence because the API is designed to strictly adhere to Discord rate limits. However, in certain scenarios, Discord may still issue a 429 response. ```json { "error": "Discord /interactions failed with HTTP status 429", "errorDetails": "{\"global\":true,\"message\":\"You are being rate limited.\",\"retry_after\":10}", "code": 429 } ``` {% endtab %} {% endtabs %} ##### Model ```typescript { // TypeScript, all fields are optional jobid: string, // Use returned jobid value to retrieve job status and results verb: 'pika-animate', status: 'started' | 'moderated' | 'failed', created: string, // YYYY-MM-DDTHH:mm:ss.sssZ, IS0 8601, UTC updated: string, // YYYY-MM-DDTHH:mm:ss.sssZ, IS0 8601, UTC image: { size: number, type: string }, prompt: string, discord: string, // Provided for debugging purposes only, contains the first 3 and the last 3 characters of the original value channel: string, maxJobs: number, replyUrl: string, replyRef: string, messageId: string, content: string, // Contains message generated by Pika reflecting current generation parameters and progress timestamp: string, error: string, errorDetails: string, executingJobs: string[], code: number } ``` ##### Examples {% tabs pika-animate_example %} {% tab pika-animate_example Curl %} ``` bash curl -H "Accept: application/json" \ -H "Authorization: Bearer …" \ -X POST https://api.useapi.net/v1/pika/animate \ -F "discord=" \ -F "channel=" \ -F 'image=@""' \ -F "prompt=" ``` {% endtab %} {% tab pika-animate_example JavaScript %} ``` javascript const main = async () => { const apiUrl = "https://api.useapi.net/v1/pika/animate"; const token = "API token"; const prompt = "Pika prompt"; const discord = "Discord token"; const channel = "Discord channel"; const data = { method: 'POST', headers: { 'Authorization': `Bearer ${token}` } }; const formData = new FormData(); formData.append("prompt", prompt); formData.append("discord", discord); formData.append("channel", channel); /* // Example 1: Fetch image from URL const imageUrl = "https://upload.wikimedia.org/wikipedia/commons/7/7d/Mona_Lisa_color_restoration.jpg"; const responseImage = await fetch(imageUrl); formData.append("image", await responseImage.blob()); */ /* // Example 2: Load image from local file (Blob) const fsp = require('fs').promises; const imageFileName = "./pika.webp"; const blob = new Blob([await fsp.readFile(imageFileName)]); formData.append("image", blob); */ /* // Example 3: Load from input file html element // const imageFile = document.getElementById(`pika-animate-image-file`); if (imageFile.files[0]) formData.append("image", imageFile.files[0]); */ data.body = formData; const response = await fetch(apiUrl, data); const result = await response.json(); console.log("response", { response, result }); }; main() ``` {% endtab %} {% tab pika-animate_example Python %} ``` python import requests api_url = "https://api.useapi.net/v1/pika/animate" token = "API token" prompt = "Pika prompt" discord = "Discord token" channel = "Discord channel" headers = { 'Authorization': f'Bearer {token}' } files = { 'prompt': (None, prompt), 'discord': (None, discord), 'channel': (None, channel) } # # Example 1: Fetch image from URL # image_url = "https://upload.wikimedia.org/wikipedia/commons/7/7d/Mona_Lisa_color_restoration.jpg" # response_image = requests.get(image_url) # image_content = response_image.content # files['image'] = ('image.jpg', image_content, 'image/jpeg') # # Example 2: Load image from local file # image_file_path = "./pika.webp" # with open(image_file_path, 'rb') as image_file: # files['image'] = ('pika.webp', image_file.read(), 'image/webp') response = requests.post(api_url, headers=headers, files=files) print(response, response.json()) ``` {% endtab %} {% endtabs %} === URL: https://useapi.net/docs/api-pika-v1/post-pika-button === Document URL: https://useapi.net/docs/api-pika-v1/post-pika-button --- layout: default title: POST pika/button parent: Pika API v1 nav_order: 900 nav_exclude: true --- ## [Pika](https://pikalabsai.org/pika-labs-commands-and-parameters) button command {: .no_toc } Pika Discord bot API has been decommissioned and no longer available. ## Table of contents {: .no_toc .text-delta } 1. TOC {:toc} --- Use this endpoint to submit the Pika button command to your [Discord Pika channel](../start-here/setup-pika). Results obtained as a callback via optional parameter [`replyUrl`](#request-body) or by querying [pika/jobs/?jobid=jobid](../api-pika-v1/get-pika-jobid) endpoint. Currently only the `retry` button is supported. The API does not support the `remix` button. Since both buttons simply offer a convenient way of rerunning a job without the need to re-upload content, this limitation does not result in any loss of functionality. It is **important** not to use the Pika account setup for API access for any purposes other than its intended use, such as executing `/button` or any other Pika commands _manually_ or in conjunction with _any other_ automation tools. The useapi.net API internally tracks the usage of the Pika account, including the number of currently active executions. Using it for other activities may cause API to function incorrectly. {: .post } > **https://api.useapi.net/v1/pika/button** ##### Request Headers ``` yaml Authorization: Bearer {API token} Content-Type: multipart/form-data ``` - `API token` is **required**, see [Setup useapi.net](../start-here/setup-useapi) for details. ##### Request Body ```json { "jobid": "jobid", "button": "button", "discord": "Discord token", "maxJobs": 10, "replyUrl": "Place your call back URL here", "replyRef": "Place your reference id here" } ``` - `jobid` is **required**, `jobid` of successfully completed (`status` set to [*completed*](../api-pika-v1/get-pika-jobid#model) [pika/create](../api-pika-v1/post-pika-create), [pika/animate](../api-pika-v1/post-pika-animate), [pika/encrypt_text](../api-pika-v1/post-pika-encrypt_text), [pika/encrypt_image](../api-pika-v1/post-pika-encrypt_image) or [pika/button](../api-pika-v1/post-pika-button) job. - `button` is **required**, button from buttons array of job referenced via `jobid` above, see [*button*](#model). - `discord` is optional, if provided will override `discord` value of referenced above `jobid`, see [Setup Pika](../start-here/setup-pika) for details. If the `channel` corresponding to the `jobid` mentioned above has an account configured under [pika/account](../api-pika-v1/get-pika-account), the current account's `discord` value will be used if it is not explicitly provided. This ensures that even jobs executed some time ago can still be successfully executed by this endpoint, even after possible changes to the account's `discord` value. - `maxJobs` is optional, if provided will override `maxJobs` value of referenced above `jobid`, if not provided defaulted to 10. - `replyUrl` is optional, if not provided value from [useapi.net account](../account-management/get-account) will be used. Place here your callback URL. API will call the provided `replyUrl` once job completed or failed. Maximum length 1024 characters. We recommend using sites like [webhook.site](https://webhook.site) to test callback URL functionality. - `replyRef` is optional, place here your reference id which will be stored and returned along with this job response / result. Maximum length 1024 characters. ##### Responses {% tabs post_pika-button_response %} {% tab post_pika-button_response 200 %} 200 OK Use returned `jobid` to [retrieve Pika job status and results](../api-pika-v1/get-pika-jobid). `content` contains message generated by Pika reflecting current generation parameters and progress. ```json { "jobid": "", "verb": "pika-button", "status": "started", "created": "2023-09-09T02:04:49.667Z", "updated": "2023-09-09T02:04:53.490Z", "button": "retry", "parentJobId": "", "discord": "", "channel": "", "maxJobs": 10, "replyUrl": "https://webhook.site/abc", "replyRef": "", "messageId": "", "content": "<@Discord user id> Creation job queued. (Prompt: waves crashing over the sandy beach, overhead shot -w 2 -size 100 Message: 1 Attachment Image: 1 Attachment Author: <@Discord user id>)", "timestamp": "2023-09-09T02:04:51.926000+00:00", "code": 200 } ``` {% endtab %} {% tab post_pika-button_response 400 %} 400 Bad Request ```json { "error": "jobid or button value is missing" "button