Connect your AI live
How to send your AI live to a streaming platform, and how to get your viewers' chat to the host.
- 1We produce the streamYour AI host runs on a GPU machine of ours and puts out a live video stream.
- 2You pull it and push it onOBS or ffmpeg on your computer pulls the stream and pushes it to YouTube, Twitch, Bilibili or any other platform.
- 3Chat comes back to the hostMessages from your platform chat are passed to the host, who reads them and answers out loud.
The addresses of your own live are in your live room, under "Stream address" and "Receive chat". The examples on this page use the free demo stream, so you can try every step before you pay.
Every live has two addresses for the same picture and sound. Use SRT when you can: it copes much better with long distances and unstable networks. Use RTMP only if your tool cannot open SRT.
srt://117.50.34.91:8890?streamid=read:live:demo:d38f2f1b37&latency=300000
rtmp://117.50.34.91:1935/live?user=demo&pass=d38f2f1b37
Demo is live now The demo addresses only work while the demo is live. It goes offline for about 15 minutes whenever the machine is busy with another job.
What the address is made of
srt://HOST:8890?streamid=read:live:viewer:PASSWORD&latency=300000
rtmp://HOST:1935/live?user=viewer&pass=PASSWORD
- HOST is the machine your live runs on and PASSWORD is a password made for that one session. Both change every time you go live, so copy the addresses again from your live room each time.
- Anyone who has the address can watch and re-stream your live. Do not post it in public.
- The stream is H.264 video at 25 frames a second with AAC audio, in the landscape or portrait shape you chose. It can be pushed to a platform as it is, without re-encoding.
Check that it plays
Before setting up OBS, open the address in a player. With ffmpeg installed, run this (keep the quotes):
ffplay -fflags nobuffer -flags low_delay "srt://117.50.34.91:8890?streamid=read:live:demo:d38f2f1b37&latency=300000"
In VLC: Media → Open Network Stream, paste the RTMP address, then Play.
OBS
- In OBS, add a Media Source and untick 'Local File'.
- Paste the SRT address into Input.
- In Settings → Stream, enter your platform's server and stream key.
- Click Start Streaming.
If the picture freezes after a network hiccup, tick "Restart playback when source becomes active" in the Media Source, or hide and show the source once.
ffmpeg
No picture is needed on your side: one command pulls the stream and pushes it to your platform. Replace the last part with the server address and stream key your platform gives you.
ffmpeg -i "srt://117.50.34.91:8890?streamid=read:live:demo:d38f2f1b37&latency=300000" -c copy -f flv "rtmp://a.rtmp.youtube.com/live2/YOUR_STREAM_KEY"
Keep the window open while you are live. The stream stays up only as long as this command is running.
Bilibili Live
- Open Bilibili Live (直播姬) and add a 'Stream' source.
- Paste the RTMP address.
- Start the broadcast from the app as usual.
The easiest way to receive chat. We read your platform chat for you; you do not need to run anything or give us access to your account.
- Start your live here and start streaming on your platform.
- In your live room, open the "Receive chat" tab and choose the platform.
- Paste your Twitch channel name, or the link of your YouTube live, and click Connect.
- When the badge says "Connected", messages from your viewers appear in the room chat and the host answers them.
- Twitch: messages that start with "!" are treated as bot commands and skipped.
- YouTube: the stream has to be live already, with chat turned on. Paste the link of the live video itself, not of the channel. New messages arrive every 8 seconds or so.
- Other platforms (Bilibili, Douyin, TikTok and so on) are not built in. Use the HTTP interface below.
For any platform we do not read directly: run a program that reads your platform chat and forwards each message to us with one HTTP request. The host treats it like any other chat message.
Request
https://dangcingai.com/api/live/demo/ingest
| Header | Authorization: Bearer YOUR_TOKENContent-Type: application/json |
|---|---|
user | The sender's name, shown in the chat and read out by the host. At most 16 characters. |
text | The message. At most 50 characters; anything longer is cut off. |
For your own live, the address and the token are in your live room under "Receive chat". The token is shown once when you generate it; generating a new one cancels the old one.
Try it on the demo
Get a personal token, run one of the examples while the demo is live, and watch your message appear in the demo chat and get answered.
Sign in to get a demo token Open the demo
Two things differ on the demo: messages always appear under your account name (the user field is ignored), and each account can send one message every 5 seconds.
curl -X POST 'https://dangcingai.com/api/live/demo/ingest' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"user":"Tom","text":"hello"}'
import requests
URL = "https://dangcingai.com/api/live/demo/ingest"
TOKEN = "YOUR_TOKEN"
def send(user: str, text: str) -> None:
resp = requests.post(URL, json={"user": user, "text": text},
headers={"Authorization": "Bearer " + TOKEN}, timeout=10)
print(resp.status_code, resp.text)
send("Tom", "hello")
$body = @{ user = "Tom"; text = "hello" } | ConvertTo-Json
Invoke-RestMethod -Method Post -Uri "https://dangcingai.com/api/live/demo/ingest" `
-Headers @{ Authorization = "Bearer YOUR_TOKEN" } `
-ContentType "application/json; charset=utf-8" -Body $body
Responses
200 | {"id": 123} | Accepted. The host will answer it when its turn comes. |
|---|---|---|
400 | bad_text | The text is empty or is not a string. |
401 | unauthorized | The token is missing or wrong, or it was replaced by a newer one. |
409 | offline | The live is not on air right now. |
429 | too_fast | Too many messages. This one was dropped; do not retry it, send the next one later. |
503 | server_error | A problem on our side. Try again in a moment. |
Limits
- The host answers one message at a time, and an answer takes several seconds. At most 20 messages a minute are accepted for one live, counting every source together.
- When 3 messages are already waiting, new ones are dropped rather than queued, because nobody wants an answer to a message from a minute ago. In a busy chat, pick the messages worth answering before you forward them.
- Messages with blocked words are not read out and do not appear in the chat.
OBS or the player shows nothing
Check that the live is on air, then copy the address again: the host and the password change with every session. If RTMP does not connect, try SRT, and make sure your network allows outgoing UDP on port 8890.
The picture stutters or the sound breaks up
Use the SRT address and a wired connection. The streaming machines are in China, so from other continents RTMP often cannot keep up, while SRT recovers lost data within the latency set in the address.
The host does not answer a message
The host answers one message at a time, so in a busy chat most messages are skipped. A message is also skipped if it contains blocked words or if the request got a 429 response.
How far behind is the stream?
The host starts speaking a few seconds after a message arrives. Pulling and pushing the stream adds a few more seconds, and the platform adds its own delay on top, so on a platform viewers hear the answer noticeably later than in the room on this site.