Prompt: a cyberpunk movie still of a dog recording a podcast in a studio. Model: Playground 2.

Suno AI logoBark

A text-to-audio model for creating speech snippets and sound effects like laughter and music.

Deploy Bark behind an API endpoint in seconds.

Deploy model

Example usage

This code example shows how to invoke the model using the requests library in Python. The model has one input:

prompt: Input text provided by the user

The output of the model is a JSON object that contains a key called output which has the output audio stored as a base64 string.

Input
1import requests
2import os
3
4# Replace the empty string with your model id below
5model_id = ""
6baseten_api_key = os.environ["BASETEN_API_KEY"]
7
8data = {
9    "prompt": "Do not go where the path may lead, go instead where there is no path and leave a trail."
10}
11
12# Call model endpoint
13res = requests.post(
14    f"https://model-{model_id}.api.baseten.co/production/predict",
15    headers={"Authorization": f"Api-Key {baseten_api_key}"},
16    json=data
17)
18
19# Convert the base64 output to an audio file
20res = res.json()
21output = res.get("output")
22base64_to_wav(output, "bark_output.wav")
JSON output
1{
2    "output": "iVBORw0KGgoAAAANSUhEUgAABAAAAAQACAIAAA..."
3}
Preview
00:00/00:00

Deploy any model in just a few commands

Avoid getting tangled in complex deployment processes. Deploy best-in-class open-source models and take advantage of optimized serving for your own models.

$

truss init -- example stable-diffusion-2-1-base ./my-sd-truss

$

cd ./my-sd-truss

$

export BASETEN_API_KEY=MdNmOCXc.YBtEZD0WFOYKso2A6NEQkRqTe

$

truss push

INFO

Serializing Stable Diffusion 2.1 truss.

INFO

Making contact with Baseten 👋 👽

INFO

🚀 Uploading model to Baseten 🚀

Upload progress: 0% | | 0.00G/2.39G