Getting Started with Truebar
This guide walks you through the minimal setup required to call Truebar APIs. By the end you will:
- Configure environment variables for the
TRUEBAR_
SDK/plugin ecosystem. - Retrieve an OAuth2 access token from the authentication realm.
- Verify connectivity with the HTTP info endpoint.
- (Optional) Open a streaming session using
wscat
.
#
1. Collect credentials- Vitasis creates a username and password for each project environment.
- Confirm the client ID (defaults to
truebar-client
unless you requested a custom realm configuration). - Note the target environment hostnames (see Overview).
Export the variables once in your shell profile (or .env
file) so you can re-use them across SDKs, CLIs, and tutorials. The snippets below set the playground defaults; update the hostnames as described afterwards if you are targeting production.
- macOS / Linux (bash, zsh)
- Windows PowerShell
- Windows Command Prompt
- Python (.env generator)
export TRUEBAR_USERNAME="alice@example.com"export TRUEBAR_PASSWORD="super-secret-passphrase"export TRUEBAR_CLIENT_ID="truebar-client"export TRUEBAR_AUTH_URL="https://playground-auth.true-bar.si/realms/truebar/protocol/openid-connect/token"export TRUEBAR_API_BASE_URL="https://playground-api.true-bar.si"export TRUEBAR_STT_WS_URL="wss://playground-api.true-bar.si/api/pipelines/stream"export TRUEBAR_TTS_WS_URL="wss://playground-api.true-bar.si/api/pipelines/stream"
$env:TRUEBAR_USERNAME = "alice@example.com"$env:TRUEBAR_PASSWORD = "super-secret-passphrase"$env:TRUEBAR_CLIENT_ID = "truebar-client"$env:TRUEBAR_AUTH_URL = "https://playground-auth.true-bar.si/realms/truebar/protocol/openid-connect/token"$env:TRUEBAR_API_BASE_URL = "https://playground-api.true-bar.si"$env:TRUEBAR_STT_WS_URL = "wss://playground-api.true-bar.si/api/pipelines/stream"$env:TRUEBAR_TTS_WS_URL = "wss://playground-api.true-bar.si/api/pipelines/stream"
set TRUEBAR_USERNAME=alice@example.comset TRUEBAR_PASSWORD=super-secret-passphraseset TRUEBAR_CLIENT_ID=truebar-clientset TRUEBAR_AUTH_URL=https://playground-auth.true-bar.si/realms/truebar/protocol/openid-connect/tokenset TRUEBAR_API_BASE_URL=https://playground-api.true-bar.siset TRUEBAR_STT_WS_URL=wss://playground-api.true-bar.si/api/pipelines/streamset TRUEBAR_TTS_WS_URL=wss://playground-api.true-bar.si/api/pipelines/stream
PLAYGROUND = { "TRUEBAR_USERNAME": "alice@example.com", "TRUEBAR_PASSWORD": "super-secret-passphrase", "TRUEBAR_CLIENT_ID": "truebar-client", "TRUEBAR_AUTH_URL": "https://playground-auth.true-bar.si/realms/truebar/protocol/openid-connect/token", "TRUEBAR_API_BASE_URL": "https://playground-api.true-bar.si", "TRUEBAR_STT_WS_URL": "wss://playground-api.true-bar.si/api/pipelines/stream", "TRUEBAR_TTS_WS_URL": "wss://playground-api.true-bar.si/api/pipelines/stream",}
for key, value in PLAYGROUND.items(): print(f'export {key}="{value}"')print("# Replace playground-* with auth.true-bar.si / api.true-bar.si for production.")
eval "$(python print_exports.py)"
Python runs in a separate process, so it cannot mutate the current shell environment directly. Piping its output through eval
applies the exported values inline.
Hostname primer
Production endpoints follow the https://{service}.true-bar.si
pattern—for example, auth.true-bar.si
for OAuth and api.true-bar.si
for REST/WebSocket calls. To target production instead of the playground, replace the playground-
prefix in each hostname and leave the rest of the URL unchanged.
#
2. Retrieve an access tokenUse the OAuth password grant to exchange your credentials for an access token. The snippets below show the same request across common languages; choose the one that fits your tooling and run it with the TRUEBAR_
environment variables set.
- cURL
- Python
- JavaScript (Node.js)
- Java
curl --fail --location \ --request POST "$TRUEBAR_AUTH_URL" \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'grant_type=password' \ --data-urlencode "username=$TRUEBAR_USERNAME" \ --data-urlencode "password=$TRUEBAR_PASSWORD" \ --data-urlencode "client_id=$TRUEBAR_CLIENT_ID" \ | jq
Store it in an env var for re-use:
export TRUEBAR_ACCESS_TOKEN="$(curl --silent --location --request POST "$TRUEBAR_AUTH_URL" \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'grant_type=password' \ --data-urlencode "username=$TRUEBAR_USERNAME" \ --data-urlencode "password=$TRUEBAR_PASSWORD" \ --data-urlencode "client_id=$TRUEBAR_CLIENT_ID" \ | jq -r '.access_token')"
import osimport sys
import requests
def main() -> None: payload = { "grant_type": "password", "username": os.environ["TRUEBAR_USERNAME"], "password": os.environ["TRUEBAR_PASSWORD"], "client_id": os.getenv("TRUEBAR_CLIENT_ID", "truebar-client"), } resp = requests.post( os.environ["TRUEBAR_AUTH_URL"], data=payload, headers={"Content-Type": "application/x-www-form-urlencoded"}, timeout=10, ) if resp.status_code == 401: raise SystemExit("Authentication failed; check username/password/client ID.") resp.raise_for_status() token = resp.json()["access_token"] print(token)
if __name__ == "__main__": main()
Install dependencies and capture the token:
python -m pip install requestsexport TRUEBAR_ACCESS_TOKEN="$(python fetch_token.py)"
npm init -ynpm pkg set type=modulenpm install undici
import { request } from "undici";
const form = new URLSearchParams({ grant_type: "password", username: process.env.TRUEBAR_USERNAME, password: process.env.TRUEBAR_PASSWORD, client_id: process.env.TRUEBAR_CLIENT_ID ?? "truebar-client",});
const response = await request(process.env.TRUEBAR_AUTH_URL, { method: "POST", body: form.toString(), headers: { "Content-Type": "application/x-www-form-urlencoded" },});
if (response.statusCode === 401) { throw new Error("Authentication failed; verify username/password/client ID.");}
const body = await response.body.json();const token = body.access_token;if (!token) throw new Error(`Missing access_token in response: ${JSON.stringify(body)}`);
console.log(token);
export TRUEBAR_ACCESS_TOKEN="$(node fetch-token.mjs)"
import java.net.URI;import java.net.http.HttpClient;import java.net.http.HttpRequest;import java.net.http.HttpResponse;import java.net.URLEncoder;import java.nio.charset.StandardCharsets;
public class FetchToken { public static void main(String[] args) throws Exception { String form = String.join("&", "grant_type=password", "username=" + URLEncoder.encode(System.getenv("TRUEBAR_USERNAME"), StandardCharsets.UTF_8), "password=" + URLEncoder.encode(System.getenv("TRUEBAR_PASSWORD"), StandardCharsets.UTF_8), "client_id=" + URLEncoder.encode(System.getenv().getOrDefault("TRUEBAR_CLIENT_ID", "truebar-client"), StandardCharsets.UTF_8) );
HttpRequest request = HttpRequest.newBuilder() .uri(URI.create(System.getenv("TRUEBAR_AUTH_URL"))) .header("Content-Type", "application/x-www-form-urlencoded") .POST(HttpRequest.BodyPublishers.ofString(form)) .build();
HttpClient client = HttpClient.newHttpClient(); HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() == 401) { throw new RuntimeException("Authentication failed; check credentials or client permissions."); }
System.out.println(response.body()); }}
Compile and extract the token:
javac FetchToken.javaexport TRUEBAR_ACCESS_TOKEN="$(java FetchToken | jq -r '.access_token')"
Save the response fields:
{ "access_token": "...", "expires_in": 900, "refresh_token": "...", "refresh_expires_in": 1800, "token_type": "Bearer"}
To refresh the token before it expires, call the same endpoint with grant_type=refresh_token
and pass the refresh_token
you received.
#
3. Verify connectivityCall the public /api/info
endpoint to confirm that the API is reachable. It returns metadata about the deployment and provides a link to the OpenAPI specification.
- cURL
- Python
- JavaScript (Node.js)
- Java
curl --fail --location \ --request GET "$TRUEBAR_API_BASE_URL/api/info" \ --header "Authorization: Bearer $TRUEBAR_ACCESS_TOKEN" \ | jq
import os
import requests
response = requests.get( f"{os.environ['TRUEBAR_API_BASE_URL']}/api/info", headers={"Authorization": f"Bearer {os.environ['TRUEBAR_ACCESS_TOKEN']}"}, timeout=10,)response.raise_for_status()print(response.json())
python -m pip install requestspython check_info.py
import { fetch } from "undici";
const response = await fetch( `${process.env.TRUEBAR_API_BASE_URL}/api/info`, { headers: { Authorization: `Bearer ${process.env.TRUEBAR_ACCESS_TOKEN}`, }, },);
if (!response.ok) { throw new Error(`Request failed with status ${response.status}`);}
console.log(await response.json());
node check-info.mjs
import java.net.URI;import java.net.http.HttpClient;import java.net.http.HttpRequest;import java.net.http.HttpResponse;
public class CheckInfo { public static void main(String[] args) throws Exception { HttpRequest request = HttpRequest.newBuilder() .uri(URI.create(System.getenv("TRUEBAR_API_BASE_URL") + "/api/info")) .header("Authorization", "Bearer " + System.getenv("TRUEBAR_ACCESS_TOKEN")) .GET() .build();
HttpClient client = HttpClient.newHttpClient(); HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() >= 400) { throw new RuntimeException("Request failed: " + response.statusCode() + " body=" + response.body()); }
System.out.println(response.body()); }}
javac CheckInfo.javajava CheckInfo
You should see fields such as version
, buildTime
, and openapi
. If you do not, check that:
- The token has the
API
role. - You targeted the correct environment URL.
- Your network allows outbound HTTPS traffic.
#
4. Optional: test a streaming sessionTruebar exposes a WebSocket endpoint for low-latency pipelines. You can perform a smoke test with wscat
(install via npm i -g wscat
):
wscat \ --connect "$TRUEBAR_STT_WS_URL?access_token=$TRUEBAR_ACCESS_TOKEN" \ --execute '{"type":"CONFIG","pipeline":{"task":"ASR","config":{"tag":"en-US","parameters":{"enableInterims":true}}}}'
You should receive STATUS
messages confirming the pipeline configuration. Close the connection with Ctrl+C
once you are done.
#
Next steps- Want a guided workflow? Continue with the streaming quickstarts for STT and TTS.
- Looking for SDK usage? Visit the client libraries page.
- Ready for production? Dive into the API reference and fine-tune your pipelines.