Speechmatics Python API Docs | dltHub
Build a Speechmatics-to-database pipeline in Python using dlt with AI Workbench support for Claude Code, Cursor, and Codex.
Last updated:
Speechmatics is a speech-to-text and Voice AI platform providing REST and WebSocket APIs for batch transcription, real-time (realtime) transcription, and Flow Voice AI agents. The REST API base URL is Batch/Jobs REST: https://{region}.asr.api.speechmatics.com/v2 (examples: https://eu1.asr.api.speechmatics.com/v2) Realtime (websocket) base: wss://{region}.rt.speechmatics.com/v2 Flow Voice AI websocket base: wss://flow.api.speechmatics.com/ and all requests require a Bearer API key (or temporary JWT) for authentication..
dlt is an open-source Python library that handles authentication, pagination, and schema evolution automatically. dlthub provides AI context files that enable code assistants to generate production-ready pipelines. Install with uv pip install "dlt[workspace]" and start loading Speechmatics data in under 10 minutes.
What data can I load from Speechmatics?
Here are some of the endpoints you can load from Speechmatics:
| Resource | Endpoint | Method | Data selector | Description |
|---|---|---|---|---|
| batch_jobs | /v2/jobs/ | GET | jobs | List jobs for the account/region (response has "jobs" array) |
| batch_job | /v2/jobs/{job_id}/ | GET | job | Retrieve a single job (response contains "job" object) |
| batch_transcripts | /v2/jobs/{job_id}/transcript/ | GET | (top-level JSON or specific format key varies by format) | Download job transcript/result (response body is transcript JSON or file) |
| usage | /v2/usage/ | GET | usage | Account usage statistics (response contains "usage") |
| models | /v2/models/ | GET | models | List available language/models (response contains "models") |
| flow_sessions_ws | (websocket) wss://flow.api.speechmatics.com/ | WS | N/A | Flow Voice AI websocket connection (message protocol; not a REST endpoint) |
| realtime_ws | (websocket) wss://{region}.rt.speechmatics.com/v2 | WS | N/A | Realtime transcription websocket API |
| api_keys_mgmt | /v1/api_keys | POST/GET | api_keys (for management) | Create/list temporary API keys (management API at mp.speechmatics.com) |
How do I authenticate with the Speechmatics API?
Long-lived API keys are supplied in the Authorization header as: Authorization: Bearer <API_KEY>. Temporary keys (JWTs) can be created and used in place of the API key for short-lived client or browser access and may be passed in the Authorization header or as a query parameter for WebSocket connections.
1. Get your credentials
- Sign in to the Speechmatics Portal (https://portal.speechmatics.com). 2. Go to Settings -> API Keys. 3. Create a new API key (name it, choose type if prompted) and copy the key_value. Store securely. 4. Optionally create temporary keys via the management endpoint (POST https://mp.speechmatics.com/v1/api_keys?type=batch or ?type=rt) using your long-lived key.
2. Add them to .dlt/secrets.toml
[sources.speechmatics_flow_voice_ai_source] api_key = "your_api_key_here"
dlt reads this automatically at runtime — never hardcode tokens in your pipeline script. For production environments, see setting up credentials with dlt for environment variable and vault-based options.
How do I set up and run the pipeline?
Set up a virtual environment and install dlt:
uv venv && source .venv/bin/activate uv pip install "dlt[workspace]"
1. Install the dlt AI Workbench:
dlt ai init --agent <your-agent> # <agent>: claude | cursor | codex
This installs project rules, a secrets management skill, appropriate ignore files, and configures the dlt MCP server for your agent. Learn more →
2. Install the rest-api-pipeline toolkit:
dlt ai toolkit rest-api-pipeline install
This loads the skills and context about dlt the agent uses to build the pipeline iteratively, efficiently, and safely. The agent uses MCP tools to inspect credentials — it never needs to read your secrets.toml directly. Learn more →
3. Start LLM-assisted coding:
Use /find-source to load data from the Speechmatics API into DuckDB.
The rest-api-pipeline toolkit takes over from here — it reads relevant API documentation, presents you with options for which endpoints to load, and follows a structured workflow to scaffold, debug, and validate the pipeline step by step.
4. Run the pipeline:
python speechmatics_flow_voice_ai_pipeline.py
If everything is configured correctly, you'll see output like this:
Pipeline speechmatics_flow_voice_ai_pipeline load step completed in 0.26 seconds 1 load package(s) were loaded to destination duckdb and into dataset speechmatics_flow_voice_ai_data The duckdb destination used duckdb:/speechmatics_flow_voice_ai.duckdb location to store data Load package 1749667187.541553 is LOADED and contains no failed jobs
Inspect your pipeline and data:
dlt pipeline speechmatics_flow_voice_ai_pipeline show
This opens the Pipeline Dashboard where you can verify pipeline state, load metrics, schema (tables, columns, types), and query the loaded data directly.
Python pipeline example
This example loads batch_jobs and models from the Speechmatics API into DuckDB. It mirrors the endpoint and data selector configuration from the table above:
import dlt from dlt.sources.rest_api import RESTAPIConfig, rest_api_resources @dlt.source def speechmatics_flow_voice_ai_source(api_key=dlt.secrets.value): config: RESTAPIConfig = { "client": { "base_url": "Batch/Jobs REST: https://{region}.asr.api.speechmatics.com/v2 (examples: https://eu1.asr.api.speechmatics.com/v2) Realtime (websocket) base: wss://{region}.rt.speechmatics.com/v2 Flow Voice AI websocket base: wss://flow.api.speechmatics.com/", "auth": { "type": "bearer", "api_key": api_key, }, }, "resources": [ {"name": "batch_jobs", "endpoint": {"path": "v2/jobs/", "data_selector": "jobs"}}, {"name": "models", "endpoint": {"path": "v2/models/", "data_selector": "models"}} ], } yield from rest_api_resources(config) def get_data() -> None: pipeline = dlt.pipeline( pipeline_name="speechmatics_flow_voice_ai_pipeline", destination="duckdb", dataset_name="speechmatics_flow_voice_ai_data", ) load_info = pipeline.run(speechmatics_flow_voice_ai_source()) print(load_info)
To add more endpoints, append entries from the resource table to the "resources" list using the same name, path, and data_selector pattern.
How do I query the loaded data?
Once the pipeline runs, dlt creates one table per resource. You can query with Python or SQL.
Python (pandas DataFrame):
import dlt data = dlt.pipeline("speechmatics_flow_voice_ai_pipeline").dataset() sessions_df = data.batch_jobs.df() print(sessions_df.head())
SQL (DuckDB example):
SELECT * FROM speechmatics_flow_voice_ai_data.batch_jobs LIMIT 10;
In a marimo or Jupyter notebook:
import dlt data = dlt.pipeline("speechmatics_flow_voice_ai_pipeline").dataset() data.batch_jobs.df().head()
See how to explore your data in marimo Notebooks and how to query your data in Python with dataset.
What destinations can I load Speechmatics data to?
dlt supports loading into any of these destinations — only the destination parameter changes:
| Destination | Example value |
|---|---|
| DuckDB (local, default) | "duckdb" |
| PostgreSQL | "postgres" |
| BigQuery | "bigquery" |
| Snowflake | "snowflake" |
| Redshift | "redshift" |
| Databricks | "databricks" |
| Filesystem (S3, GCS, Azure) | "filesystem" |
Change the destination in dlt.pipeline(destination="snowflake") and add credentials in .dlt/secrets.toml. See the full destinations list.
Troubleshooting
Authentication failures
Requests without a valid region-scoped API key return HTTP 401 Unauthorized. Ensure you use the API key for the region your account is provisioned in (e.g., eu1) and include the header: Authorization: Bearer <API_KEY>.
Temporary key / permissions issues
Temporary keys created without appropriate client_ref may be restricted (403) from accessing some endpoints (e.g., Usage). Use the correct token type (batch vs rt) and include client_ref when exposing tokens to end users.
Rate limits and wrong region
The docs indicate region-specific endpoints; using the wrong regional host will yield authorization or 401 errors. Follow retry/backoff on transient errors and confirm region in your Portal/API key settings.
Ensure that the API key is valid to avoid 401 Unauthorized errors. Also, verify endpoint paths and parameters to avoid 404 Not Found errors.
Next steps
Continue your data engineering journey with the other toolkits of the dltHub AI Workbench:
data-exploration— Build custom notebooks, charts, and dashboards for deeper analysis with marimo notebooks.dlthub-runtime— Deploy, schedule, and monitor your pipeline in production.
dlt ai toolkit data-exploration install dlt ai toolkit dlthub-runtime install
Was this page helpful?
Community Hub
Need more dlt context for Speechmatics?
Request dlt skills, commands, AGENT.md files, and AI-native context.