What a TikTok stream key is
A stream key is how streaming software sends video to a TikTok LIVE. It comes in two parts: a server URL (an RTMP or RTMPS address on TikTok’s ingest servers) and a key that identifies one specific LIVE room on one account. Paste both into OBS, Streamlabs or ffmpeg and whatever your software outputs goes out as that LIVE.
Streaming this way instead of from your phone is what makes professional TikTok LIVEs possible: several cameras, screen and game capture, overlays and alerts, pre-recorded segments, a proper microphone, and scenes you switch between. The hard part is getting the key in the first place.
Why many accounts cannot find a stream key
TikTok does not show a stream key to everyone. First, the account has to be allowed to go LIVE at all: TikTok requires LIVE hosts to be at least 18, and in many regions to have reached a follower threshold. Second, even accounts that can go LIVE from the phone often do not see the option to stream from a computer. TikTok has moved most desktop streaming to its own app, LIVE Studio, and only offers server URLs and keys to some accounts.
That leaves three ways to stream to TikTok from a computer:
| Way | What you get | Limits |
|---|---|---|
| Stream key in the app | Server URL and key on the LIVE setup screen, for use in OBS or Streamlabs | Only shown to some accounts; you copy a new key by hand for each stream |
| TikTok LIVE Studio | TikTok’s own desktop streaming app with scenes and sources | Its own feature set; no OBS plugins, custom encoders or automation |
| Stream key by API | A room, server URL and key created from code for your connected account | The account still has to be allowed to go LIVE |
Get a stream key by API
- 1Connect your account
Connect the TikTok account once as a managed account, with an email code or by importing a session. You get an
account_id. - 2Create the room
POST
/v1/account/live/startwith theaccount_idand a title. TikTok creates the LIVE room on your account. - 3Copy the URL and key
The response has
rtmp_push_url,stream_key,max_bitrate_kbpsandping_interval_sec. - 4Start streaming
Paste the URL and key into OBS, Streamlabs or ffmpeg and start the stream.
- 5Keep it alive, then end it
Send
/v1/account/live/pingeveryping_interval_secseconds. Call/v1/account/live/finishwhen you are done.
POST /v1/account/live/start · 25 reqs per call| Parameter | Type | Required | What it does |
|---|---|---|---|
account_id | string | Yes | A connected account, from /dash/sessions or POST /v1/account/import. e.g. acc_7Hq2 |
title | string | Yes | The room title. e.g. Desk build, part 2 |
{
"status_code": 0,
"account_id": "acc_7Hq2",
"room_id": "7708619922263280397",
"stream_id": "2988475619283746510",
"status": "created",
"title": "Desk build, part 2",
"rtmp_push_url": "rtmps://push-rtmp-f5-tt01.fcdn.us.tiktokcdn.com/game/",
"stream_key": "stream-7708619922263280397?expire=1794527200&sign=8b2f91c4e0",
"max_bitrate_kbps": 6000,
"ping_interval_sec": 15
}max_bitrate_kbps is the highest video bitrate TikTok accepts for that room; set your encoder at or below it. ping_interval_sec is how often to send the heartbeat. The stream key carries an expiry and a signature, so it only works for this room.
A complete go-LIVE script
This script creates the room, prints the server and key for OBS, sends the heartbeat in the background, and ends the LIVE cleanly when you press Ctrl+C, printing the stream’s results.
import threading, time
from tikultra import TikUltra
client = TikUltra()
ACCOUNT = "acc_7Hq2" # from /v1/account/sessions
room = client.account.live_start(ACCOUNT, "Desk build, part 2")
room_id = room["room_id"]
print("Server: ", room["rtmp_push_url"])
print("Stream key:", room["stream_key"])
print("Max video bitrate:", room["max_bitrate_kbps"], "kbps")
stop = threading.Event()
def heartbeat():
while not stop.wait(room["ping_interval_sec"]):
p = client.account.live_ping(ACCOUNT, room_id)
print(f'{p["viewer_count"]} watching, {p["like_count"]} likes')
threading.Thread(target=heartbeat, daemon=True).start()
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
stop.set()
done = client.account.live_finish(ACCOUNT, room_id)
print(f'Ended after {done["duration_sec"] // 60} min, peak {done["peak_viewers"]} viewers, '
f'{done["new_followers"]} new followers'){
"status_code": 0,
"account_id": "acc_7Hq2",
"room_id": "7708619922263280397",
"status": "finished",
"duration_sec": 3920,
"peak_viewers": 2410,
"total_viewers": 29410,
"diamonds_earned": 4820,
"new_followers": 312
}Set up OBS for TikTok
- 1Make the canvas vertical
Settings → Video. Set Base (Canvas) Resolution and Output (Scaled) Resolution to 1080×1920, and FPS to 30. TikTok is watched on phones, so a vertical canvas fills the screen.
- 2Add the server and key
Settings → Stream. Service: Custom. Server: the
rtmp_push_url. Stream Key: thestream_key. - 3Set the encoder
Settings → Output → Output Mode: Advanced. Use the settings in the table below.
- 4Build your scenes
Add your camera, screen or game capture, overlays and audio. Keep text away from the bottom quarter, where TikTok shows comments.
- 5Start streaming
Click Start Streaming. The LIVE appears on your account within a few seconds.
| Setting | Value | Why |
|---|---|---|
| Resolution | 1080×1920 (or 720×1280 on weak uploads) | Vertical, full-screen on phones |
| Frame rate | 30 fps | Smooth for talking and products; use 60 only for fast games |
| Video encoder | NVENC, Apple VT or AMD if available, otherwise x264 | Hardware encoders leave the CPU for your scenes |
| Rate control | CBR | Constant bitrate is what RTMP ingest expects |
| Video bitrate | 4,000–6,000 kbps, never above max_bitrate_kbps | Higher is sharper; stay under about 75% of your upload speed |
| Keyframe interval | 2 seconds | Lets viewers join quickly and keeps the stream stable |
| Audio | AAC, 128–160 kbps, 48 kHz | Clear voice without wasting bandwidth |
Streamlabs works the same way: Settings → Stream → Stream Type: Custom Ingest, then paste the URL and key. Most other tools with a “custom RTMP” option work too.
Stream with ffmpeg
For automated streams, such as a pre-recorded show, a 24/7 loop or a restream from another source, skip OBS and push with ffmpeg. The full ingest address is the server URL followed by the key.
RTMP="rtmps://push-rtmp-f5-tt01.fcdn.us.tiktokcdn.com/game/"
KEY="stream-7708619922263280397?expire=1794527200&sign=8b2f91c4e0"
ffmpeg -re -stream_loop -1 -i show.mp4 \
-vf "scale=1080:1920:force_original_aspect_ratio=decrease,pad=1080:1920:(ow-iw)/2:(oh-ih)/2" \
-c:v libx264 -preset veryfast -b:v 4500k -maxrate 4500k -bufsize 9000k -g 60 -r 30 \
-c:a aac -b:a 128k -ar 48000 \
-f flv "$RTMP$KEY"-re sends the file at real-time speed, -stream_loop -1 repeats it, the filter fits any video into a 1080×1920 frame, and -g 60 gives a keyframe every 2 seconds at 30 fps. Quote the key: it contains ? and &. Your ffmpeg needs TLS support for rtmps:// addresses; standard builds have it.
Streaming setups that work
Most TikTok LIVEs streamed from a computer fall into one of three setups. Each has its own layout rules, because viewers watch on a phone held upright with the comments and buttons over the bottom of the picture.
| Setup | Layout | Tips |
|---|---|---|
| Talking head or product demo | Camera full frame, vertical; product close-ups as a second scene | Light your face, frame from the chest up, keep the product in the middle third |
| Gaming | Game capture in the top two thirds, camera below or in a corner | Crop the game rather than shrinking it to a letterbox; text in games is small on phones |
| Screen share or tutorial | The part of the screen that matters, zoomed, with the camera in a corner | Increase font sizes before you go live; 1080 pixels wide is narrow |
Pre-recorded loops are possible with the ffmpeg command above, but TikTok’s LIVE rules expect LIVE to be live: streams that only replay recorded video can be cut off or restricted. Use recordings for segments inside a real show, not as the whole stream.
Stream to TikTok and other platforms at once
TikTok needs a vertical picture while YouTube and Twitch want horizontal, so multistreaming to TikTok works best with two canvases. In OBS, the free Aitum Vertical plugin adds a second, vertical canvas with its own scenes and its own stream output: point that output at the TikTok URL and key, and keep your normal horizontal output for the other platforms. Restreaming services work too, as long as they let you send a separate vertical feed with a custom RTMP destination.
Check your upload speed first. Two outputs at 6,000 kbps each need a stable upload of well over 12 Mbps; if you do not have it, lower the bitrate on the less important stream.
Run the LIVE from code
Once you are streaming, the same account can run the room:
| Action | Endpoint | Cost |
|---|---|---|
| Keep the room open, read viewers and likes | /v1/account/live/ping | 1 req |
| Post, pin or delete a comment, mute a viewer | /v1/account/live/moderate | 10 reqs |
| Invite a co-host | /v1/account/live/cohost | 3 reqs |
| Read the chat | /v1/live/chat | 2 reqs |
| End the LIVE and get its stats | /v1/account/live/finish | 1 req |
POST /v1/account/live/moderate · 10 reqs per call| Parameter | Type | Required | What it does |
|---|---|---|---|
account_id | string | Yes | A connected account, from /dash/sessions or POST /v1/account/import. e.g. acc_7Hq2 |
room_id | string | Yes | The numeric LIVE room ID. e.g. 7708619922263280397 |
action | string | Yes | comment, pin, delete or mute. e.g. comment |
text | string | No | For comment. e.g. Welcome in! |
target_id | string | No | The comment or viewer to act on. |
# pin a welcome message
msg = client.request("POST", "/v1/account/live/moderate", json_body={
"account_id": ACCOUNT, "room_id": room_id, "action": "comment", "text": "Welcome in! Links are in bio",
})
client.request("POST", "/v1/account/live/moderate", json_body={
"account_id": ACCOUNT, "room_id": room_id, "action": "pin", "target_id": msg["msg_id"],
})Combine this with the chat loop from the LIVE API guide and you have a moderation bot for your own stream: read new comments, delete links and spam, mute repeat offenders and pin answers to common questions. The LIVE bot guide builds one end to end.
Troubleshooting
| Problem | Likely cause | Fix |
|---|---|---|
| OBS: “Failed to connect to server” | Wrong URL or key, key from an older room, or extra spaces | Create a new room and paste both values again |
| The LIVE ends after a minute or two | No heartbeat | Send /v1/account/live/ping every ping_interval_sec seconds |
| The video is sideways or has black bars | A 16:9 canvas | Set the canvas and output to 1080×1920 |
| Dropped frames, buffering for viewers | Bitrate too high for your upload | Lower the bitrate, or use 720×1280 |
live/start returns 403 or an eligibility error | TikTok does not allow this account to go LIVE | Check the account’s age and LIVE eligibility in the app |
session_expired (409) | The account was logged out | Reconnect it with an email code; the account_id stays the same |
What it costs
Creating a room is 25 reqs, each heartbeat 1 req and ending it 1 req. A two-hour stream with a heartbeat every 15 seconds is about 506 requests; twenty such streams a month is 10,120 requests, $12.40 at Starter’s rate and well inside Starter’s 40,000 included requests.
| Plan | Monthly price | Requests included | Per 1,000 calls | Rate limit |
|---|---|---|---|---|
| Starter | $49 | 40,000 | $30.63 | 20 req/s |
| Growth | $159 | 175,000 | $22.71 | 75 req/s |
| Scale | $499 | 750,000 | $16.63 | 250 req/s |
| Status | Code | Meaning | Retry? |
|---|---|---|---|
| 400 | invalid_request | A parameter is missing or malformed. | No. Fix the request. |
| 401 | unauthorized | The key is missing, wrong or revoked. | No. |
| 402 | out_of_credits | Your balance can’t cover this call. | After a top-up. |
| 403 | forbidden | Your plan doesn’t include this endpoint. | No. Upgrade. |
| 404 | not_found | The video, profile or product doesn’t exist or isn’t visible. | No. |
| 409 | session_expired | A connected account needs to sign in again. | After re-connecting. |
| 429 | rate_limited | Over your plan’s requests per second. | Yes, after retry-after. |
| 502 | upstream_error | TikTok returned an error after our retries. | Yes, with backoff. |
| 504 | upstream_timeout | TikTok didn’t answer in time. | Yes, with backoff. |
Keep your stream key private
Anyone with the server URL and key can stream to your LIVE for as long as the room is open. Do not show it on screen, paste it in chats or commit it to a repository. Because each key belongs to one room and expires, a leaked key stops working once you end that LIVE: call /v1/account/live/finish and start a new room.