Getting error when trying to send the authenticate action

I’m getting this “unsupported operand type(s) for +=: ‘dict’ and ‘bytes’” when trying to send the authenticate action.

Here’s my code:

import alpaca_trade_api as tradeapi
from alpaca_trade_api import StreamConn
import time
import websocket

ALPACA_BASE_URL = "https://paper-api.alpaca.markets";
ALPACA_API_KEY = 'KEY'
ALPACA_SECRET_KEY = 'KEY'
STREAMING_ENDPOINT = "wss://data.alpaca.markets/stream"

stream = websocket.WebSocket()
trade = tradeapi.REST(ALPACA_API_KEY, ALPACA_SECRET_KEY, 
ALPACA_BASE_URL, api_version = 'v2')

stream.connect(STREAMING_ENDPOINT)

stream.send({
    "action": "authenticate",
    "data": {
        "key_id": ALPACA_API_KEY,
        "secret_key": ALPACA_SECRET_KEY
    }
})


trade.submit_order("AAPL", 3, 'buy', 'market', 'day')

Hi,
The proper way to connect to the streaming service is to use StreamConn.
Here’s an example of how to do it:

conn = tradeapi.StreamConn(key_id=_key_id,
                           secret_key=_secret_key)

it will authenticate for you.
for further details, look at the readme of the project: