TrueFoundry AI Gateway

View as Markdown

TrueFoundry AI Gateway is the proxy layer that sits between your applications and LLM providers. It is an enterprise-grade platform that enables users to access 1000+ LLMs using a unified interface while taking care of observability and governance.

Once configured, you call TTS and STT through your TrueFoundry gateway URL instead of directly — giving you request tracing and centralised access control across your team.

Setup

Step 1: Navigate to Smallest AI Models

In the TrueFoundry dashboard, go to AI GatewayModels and select Smallest AI.

Smallest AI models on the provider account

Step 2: Add a Smallest AI Account

Click Add Smallest AI Account. Enter a unique account name and your Smallest AI API key. Optionally add collaborators so other users or teams can access this account.

Step 3: Register Models

Click + Add Model and fill in the Display name, Model ID, and Model type (Text to Speech or Audio Transcription).

For Smallest AI, the Model ID and Display name must be identical (e.g. smallest-tts, smallest-stt).

Supported APIs

APIGateway endpointTracingCost tracking
Text-to-Speech/tts/{providerAccountName}/waves/v1/smallest-tts/get_speech
Speech-to-Text/stt/{providerAccountName}/waves/v1/smallest-stt/get_text

Replace {providerAccountName} with the account name you set in Step 2.

Text-to-Speech

1import requests
2
3TFY_API_KEY = "your-truefoundry-api-key"
4GATEWAY_BASE_URL = "your-gateway-base-url"
5PROVIDER_ACCOUNT = "your-provider-account-name"
6
7response = requests.post(
8 f"{GATEWAY_BASE_URL}/tts/{PROVIDER_ACCOUNT}/waves/v1/smallest-tts/get_speech",
9 headers={
10 "Authorization": f"Bearer {TFY_API_KEY}",
11 "Content-Type": "application/json",
12 },
13 json={
14 "text": "Modern problems require modern solutions.",
15 "voice_id": "magnus",
16 "sample_rate": 24000,
17 "speed": 1.0,
18 "language": "en",
19 "output_format": "wav",
20 },
21)
22
23with open("output.wav", "wb") as f:
24 f.write(response.content)
25
26print(f"Saved output.wav ({len(response.content):,} bytes)")

For the full list of voices, sample rates, languages, and output formats, see the Voices & Languages page.

Speech-to-Text

1import requests
2
3TFY_API_KEY = "your-truefoundry-api-key"
4GATEWAY_BASE_URL = "your-gateway-base-url"
5PROVIDER_ACCOUNT = "your-provider-account-name"
6
7response = requests.post(
8 f"{GATEWAY_BASE_URL}/stt/{PROVIDER_ACCOUNT}/waves/v1/smallest-stt/get_text",
9 params={"language": "en"},
10 headers={
11 "Authorization": f"Bearer {TFY_API_KEY}",
12 "Content-Type": "application/json",
13 },
14 json={
15 "url": "https://github.com/smallest-inc/cookbook/raw/main/speech-to-text/getting-started/samples/audio.wav",
16 },
17 timeout=120,
18)
19
20result = response.json()
21print(result["transcription"])

Cost tracking for Smallest AI usage is not metered by the TrueFoundry gateway. Tracing and request logging remain fully functional.