AssemblyAI

A guide to call and log AssemblyAI speech-to-text model with Respan gateway.

  1. Sign up — Create an account at platform.respan.ai
  2. Create an API key — Generate one on the API keys page
  3. Add credits or a provider key — Add credits on the Credits page or connect your own provider key on the Integrations page

Add the Docs MCP to your AI coding tool to get help building with Respan. No API key needed.

1{
2 "mcpServers": {
3 "respan-docs": {
4 "url": "https://docs.respan.ai/mcp"
5 }
6 }
7}

AssemblyAI is an applied AI company that offers AI models for audio transcription, content moderation, summarization, topic detection, and many other tasks.

In this guide, we will show you how to call and log AssemblyAI speech-to-text model with Respan gateway and log LLM calls.

Prerequisites

  • A Respan account.
  • A Respan API key.
  • An AssemblyAI account.
  • An AssemblyAI API key.

Quickstart

Here’s an example of how to call and log AssemblyAI speech-to-text model with Respan gateway.

The API endpoint for this integration is https://api.respan.ai/api/assemblyai/.

Python
1import os
2from assemblyai import (
3 Transcriber,
4 Client,
5 Settings,
6 TranscriptStatus,
7)
8from base64 import b64encode
9import json
10
11API_KEY = os.getenv("RESPAN_API_KEY")
12BASE_URL = (
13 os.getenv("RESPAN_BASE_URL", "https://api.respan.ai/") + "api/assemblyai/"
14)
15
16
17class RespanAssemblyAIClient(Client):
18 """
19 Define Respan's AssemblyAI client wrapper for passing extra headers containing respan params
20 """
21
22 def __init__(self, respan_api_key: str, headers: dict):
23 settings = Settings(api_key=respan_api_key, base_url=BASE_URL)
24 print(settings)
25 super().__init__(settings=settings)
26 self._http_client.headers.update(headers)
27
28respan_params = {
29 "metadata": {
30 "paid_user": "true",
31 }
32 # other respan parameters...
33}
34
35respan_headers = {
36 "X-Assemblyai-Api-Key": os.getenv("ASSEMBLYAI_API_KEY"), # <-- This is the AssemblyAI API key
37 "X-Data-Respan-Params": b64encode(
38 json.dumps(respan_params).encode()
39 ).decode(),
40}
41
42client = RespanAssemblyAIClient(
43 respan_api_key=API_KEY, # <-- This is the API key for authenticating against Respan, not the AssemblyAI API key (defined above)
44 headers=respan_headers
45)
46
47transcriber = Transcriber(client=client)
48
49transcript = transcriber.transcribe("https://assembly.ai/wildfires.mp3")
50
51if transcript.status == TranscriptStatus.error:
52 print(transcript.error)
53else:
54 print(transcript.text)

Respan params

You can pass any Respan observability parameters in the metadata field.