Install and configure the official Gladia SDKs (@gladiaio/sdk for JS/TS, gladiaio-sdk for Python). Use when the user asks about SDK setup, client initializat...
---
name: sdk-integration
description: Install and configure the official Gladia SDKs (@gladiaio/sdk for JS/TS, gladiaio-sdk for Python). Use when the user asks about SDK setup, client initialization, API key configuration, choosing between JS and Python, browser usage, retry/timeout settings, error handling, or SDK vs raw API decisions. The SDK is the recommended default for all Gladia integrations.
license: MIT
---
# SDK Integration
Official SDKs for integrating Gladia's speech-to-text API. Both SDKs share the same design and are generated from the Gladia OpenAPI schema.
> **The SDK is the default for all Gladia integrations.** Always use the SDK unless there is a specific, documented reason not to (see decision guide below).
## When to Use
- User asks about installing, configuring, or initializing the Gladia SDK
- Setting up API key, region, retry, timeout, or WebSocket configuration
- Questions about SDK architecture, client methods, or type exports
- Choosing between JS/TS and Python SDK, or between SDK and raw API
- Browser-based integration, proxy setup, or bundle format questions
- Error handling patterns for Gladia API responses
**When NOT to use:** If the user is asking about a specific transcription use case (pre-recorded files or live streaming), start with the relevant use-case skill ([pre-recorded-transcription](../pre-recorded-transcription/SKILL.md) or [live-transcription](../live-transcription/SKILL.md)) instead — those skills reference back here for setup details.
## When to Use SDK vs Raw API
| Scenario | Approach |
| ---------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| Any JS/TS or Python project | **SDK** — always |
| Browser app | **SDK** — JS SDK supports ESM/IIFE bundles |
| Need custom HTTP client or middleware | SDK first; use `httpHeaders` / `httpTimeout` config. Fall back to raw REST only if SDK config is insufficient |
| Language without an SDK (Go, Java, etc.) | Raw REST/WebSocket (SDK unavailable) |
| User explicitly requests raw calls | Raw REST/WebSocket |
| CI script or one-off curl test | Raw REST is acceptable |
When in doubt, use the SDK.
## References
Consult these resources as needed:
- ./references/sdk-versions.md -- Current SDK versions (auto-synced by CI)
- ./references/client-config.md -- Full client configuration reference (all options, defaults, timeouts)
- ./references/javascript.md -- JS/TS-specific patterns (browser, proxy, File/Blob, Node requirements)
- ./references/python.md -- Python-specific patterns (sync/async, typed requests, httpx/websockets)
- ../pre-recorded-transcription/SKILL.md -- Pre-recorded transcription options, response structure, and audio intelligence config
- ../live-transcription/SKILL.md -- Live session config, audio streaming, and WebSocket event handling
- ../troubleshooting/SKILL.md -- Common errors, gotchas, and verification checklist
## Installation
### JavaScript / TypeScript
```bash
npm install @gladiaio/sdk
# or
bun add @gladiaio/sdk
# or
yarn add @gladiaio/sdk
```
Requires Node.js 20+ or Bun. Also works in browsers via ESM/IIFE bundles.
### Python
```bash
pip install gladiaio-sdk
# or
uv add gladiaio-sdk
```
Requires Python 3.10+.
## Client Initialization
### JavaScript/TypeScript
```typescript
import { GladiaClient } from "@gladiaio/sdk";
const client = new GladiaClient({
apiKey: "your-api-key", // or set GLADIA_API_KEY env var
region: "eu-west", // or set GLADIA_REGION (eu-west | us-west)
});
```
### Python
```python
from gladiaio_sdk import GladiaClient
client = GladiaClient(
api_key="your-api-key", # or set GLADIA_API_KEY env var
region="eu-west", # or set GLADIA_REGION
)
```
### Environment Variables
| Variable | Purpose | Default |
| ---------------- | -------------------------- | ----------------------- |
| `GLADIA_API_KEY` | API key for authentication | — |
| `GLADIA_API_URL` | Base API URL | `https://api.gladia.io` |
| `GLADIA_REGION` | Datacenter region | — |
## Client Architecture
```
GladiaClient
├── preRecorded() → PreRecordedV2Client (JS)
│ prerecorded() → PreRecordedV2Client (Python)
│
├── liveV2() → LiveV2Client (JS)
│ live() → LiveV2Client (Python)
│
└── (Python only)
├── prerecorded_async() → AsyncPreRecordedV2Client
└── live_async() → AsyncLiveV2Client
```
### Pre-Recorded Client Methods
| Method | Purpose |
| ------------------------------------ | ---------------------------------- |
| `transcribe(audio, options)` | High-level: upload + create + poll |
| `uploadFile(audio)` | Upload local file to `/v2/upload` |
| `create(options)` | Create transcription job |
| `createAndPoll(options)` | Create + poll until done |
| `poll(jobId, { interval, timeout })` | Poll until complete |
| `get(jobId)` | Get job status/results |
| `delete(jobId)` | Delete job and data |
| `getFile(jobId)` | Download original audio |
### Live Client Methods
| Method | Purpose |
| ----------------------- | ------------------------------------ |
| `startSession(options)` | Init session → returns LiveV2Session |
| `get(sessionId)` | Get completed session results |
| `delete(sessionId)` | Delete session and data |
| `getFile(sessionId)` | Download session audio |
### Live Session Methods
| Method | Purpose |
| ------------------ | -------------------------------------- |
| `sendAudio(chunk)` | Stream audio bytes to the session |
| `stopRecording()` | End recording, trigger post-processing |
| `endSession()` | Force close without post-processing |
| `getSessionId()` | Await session ID (async) |
## Configuration Options
Key client options: `apiKey`, `apiUrl`, `region`, `httpTimeout`, `httpRetry`, `wsRetry`, `wsTimeout`, `prerecordedTimeouts`, `liveTimeouts`.
For the full config reference with all options and defaults, see [./references/client-config.md](./references/client-config.md).
## Audio Input Types
| Input | JS/TS | Python |
| ------------------------------- | :-------: | :----: |
| Local file path (string) | Node only | Yes |
| `Path` object | — | Yes |
| HTTP(S) URL | Yes | Yes |
| `File` / `Blob` | Browser | — |
| Binary file object (`BinaryIO`) | — | Yes |
URLs are passed directly as `audio_url` without upload. Local files are automatically uploaded via `/v2/upload`.
## Error Handling
### JavaScript/TypeScript
```typescript
try {
const result = await client.preRecorded().transcribe("./audio.mp3", options);
} catch (error) {
if (error.message.includes("401")) {
console.error("Invalid API key");
} else if (error.message.includes("timeout")) {
console.error("Request timed out");
}
}
```
### Python
```python
from gladiaio_sdk import GladiaClient
try:
result = client.prerecorded().transcribe("audio.mp3", options)
except Exception as e:
print(f"Error: {e}")
```
Python exports `HttpError` and `TimeoutError` for specific error handling.
## Key Differences Between JS and Python
| Aspect | JavaScript/TypeScript | Python |
| --------------- | ------------------------------------------- | ---------------------------------------- |
| Async model | Promise-based (async only) | Sync + async (separate clients) |
| Naming | camelCase (`preRecorded`, `sendAudio`) | snake_case (`prerecorded`, `send_audio`) |
| Browser support | Yes (ESM, CJS, IIFE) | No (server only) |
| Runtime | Node 20+, Bun, browsers | Python 3.10+ |
| Dependencies | 0 runtime deps (optional `ws` for Node <22) | httpx, websockets, pyee |
| Options format | Plain objects (snake_case keys) | Dataclasses or dicts |
| Untyped API | `transcribeUntyped()`, `createUntyped()` | Dict accepted on most methods |
## Type Exports
Both SDKs export all request/response types from the main package:
```typescript
import type {
LiveV2InitRequest,
LiveV2WebSocketMessage,
PreRecordedV2Response,
PreRecordedV2TranscriptionOptions,
} from "@gladiaio/sdk";
```
```python
from gladiaio_sdk import (
LiveV2InitRequest,
LiveV2WebSocketMessage,
LiveV2LanguageConfig,
LiveV2MessagesConfig,
PreRecordedV2Response,
)
```
## Common Mistakes
- **Wrong sub-client method name between JS and Python**: JS uses `client.preRecorded()` and `client.liveV2()`; Python uses `client.prerecorded()` and `client.live()`. Mixing the naming conventions causes "is not a function" / `AttributeError` at runtime.
- **Forgetting `await` in JavaScript**: every JS SDK method returns a Promise. Omitting `await` on `transcribe()`, `startSession()`, etc. lets the operation run silently in the background with no result or error surfaced to your code.
- **API key exposed in browser-side code**: never embed the API key directly in front-end JavaScript — it becomes publicly readable. Use a backend proxy that forwards requests with the key server-side. See [./references/javascript.md](./references/javascript.md) for the proxy pattern.
- **Node.js < 22 without the `ws` peer dependency**: the JS SDK requires the `ws` package for WebSocket on Node < 22, which lacks a native WebSocket. Without it, live sessions fail silently. Fix: `npm install ws`.
- **Python async client in sync context**: `client.live_async()` and `client.prerecorded_async()` cannot be called from synchronous code — they require an active event loop. Use the sync client (`client.live()`, `client.prerecorded()`) unless you are inside an `async def`.
## Further Reading
- [SDK integration guide](https://docs.gladia.io/chapters/integrations/sdk)
- [JS SDK on npm](https://www.npmjs.com/package/@gladiaio/sdk)
- [Python SDK on PyPI](https://pypi.org/project/gladiaio-sdk/)
- [SDK source code](https://github.com/gladiaio/sdk)
- [Code samples](https://github.com/gladiaio/gladia-samples)
don't have the plugin yet? install it then click "run inline in claude" again.
restructured into implexa's 6 components (intent, inputs, procedure, decision points, output contract, outcome signal), added explicit edge cases (node < 22 ws requirement, python async context restrictions, api key exposure in browsers, silent failures from missing await), documented all external connections and env vars, extracted decision trees into dedicated section, and clarified success criteria with specific field names and error codes.
Official SDKs for integrating Gladia's speech-to-text API. Both SDKs share the same design and are generated from the Gladia OpenAPI schema.
The SDK is the default for all Gladia integrations. Always use the SDK unless there is a specific, documented reason not to.
this skill walks you through installing, configuring, and initializing the official Gladia SDKs for JavaScript/TypeScript (@gladiaio/sdk) and Python (gladiaio-sdk). use it when someone asks about SDK setup, client initialization, API key configuration, choosing between JS and Python, browser usage, retry/timeout settings, error handling patterns, or whether to use the SDK vs raw API. the SDK is the recommended default for all Gladia integrations because it handles auth, retries, type safety, and WebSocket lifecycle automatically.
external connections:
https://api.gladia.io (configurable via GLADIA_API_URL env var or apiUrl param)GLADIA_API_KEY env var or apiKey parameter in client configGLADIA_REGION env var or region param (values: eu-west, us-west)environment variables (optional):
GLADIA_API_KEY: api authentication keyGLADIA_API_URL: base api endpoint (default: https://api.gladia.io)GLADIA_REGION: datacenter region (default: inferred from API URL)runtime requirements:
ws peer dependencyoptional peer dependencies:
ws package for native websocket supporthttpx, websockets, pyee (bundled with sdk)inputs: your project language (javascript/typescript or python)
javascript/typescript: run one of:
npm install @gladiaio/sdk
bun add @gladiaio/sdk
yarn add @gladiaio/sdk
python: run one of:
pip install gladiaio-sdk
uv add gladiaio-sdk
if on node.js < 22 and planning to use live sessions, also run:
npm install ws
outputs: sdk installed in project dependencies. verify by checking node_modules/@gladiaio/sdk (js) or running pip show gladiaio-sdk (python).
inputs: access to gladia dashboard at https://dashboard.gladia.io
go to your gladia account dashboard and generate or copy your api key. store it securely (never commit to version control). you can either set the GLADIA_API_KEY environment variable or pass it directly in client initialization (step 3).
outputs: api key ready for use in client config
inputs: api key (from step 2), optional region and timeout settings
javascript/typescript:
import { GladiaClient } from "@gladiaio/sdk";
const client = new GladiaClient({
apiKey: "your-api-key", // or omit to read from GLADIA_API_KEY env var
region: "eu-west", // optional: eu-west or us-west
httpTimeout: 30000, // optional: ms timeout for http requests (default: 30000)
httpRetry: { maxRetries: 3, backoffMultiplier: 2 }, // optional retry config
});
python (sync):
from gladiaio_sdk import GladiaClient
client = GladiaClient(
api_key="your-api-key", # or omit to read from GLADIA_API_KEY env var
region="eu-west", # optional: eu-west or us-west
)
python (async):
from gladiaio_sdk import GladiaClient
client = GladiaClient(
api_key="your-api-key",
region="eu-west",
)
# then use client.prerecorded_async() or client.live_async()
outputs: client object ready for pre-recorded or live transcription. verify by checking that client is not null and has methods like preRecorded() (js) or prerecorded() (python).
inputs: client object from step 3, use case (pre-recorded transcription or live streaming)
for pre-recorded transcription:
// JavaScript/TypeScript
const preRecordedClient = client.preRecorded();
# Python (sync)
pre_recorded_client = client.prerecorded()
# Python (async)
pre_recorded_client = client.prerecorded_async()
for live transcription:
// JavaScript/TypeScript
const liveClient = client.liveV2();
# Python (sync)
live_client = client.live()
# Python (async)
live_client = client.live_async()
outputs: sub-client object (PreRecordedV2Client or LiveV2Client) with methods like transcribe(), startSession(), etc.
inputs: audio source (file path, url, or blob/file object), transcription options (language, model, features)
the sdk accepts multiple audio input formats:
/v2/uploadaudio_url, no uploadtranscription options are passed as a dict or object and include language, model, custom_vocabulary, summarization, chaining, etc. see ./references/client-config.md for full list.
outputs: audio input and options ready for step 6
inputs: sub-client (from step 4), audio input and options (from step 5)
pre-recorded (high-level, one-liner):
// JavaScript/TypeScript
const result = await client.preRecorded().transcribe("./audio.mp3", {
language: "en",
model: "nova-2",
});
# Python (sync)
result = client.prerecorded().transcribe("audio.mp3", {
"language": "en",
"model": "nova-2",
})
# Python (async)
result = await client.prerecorded_async().transcribe("audio.mp3", {
"language": "en",
"model": "nova-2",
})
pre-recorded (manual: create, poll, get):
// JavaScript/TypeScript
const job = await client.preRecorded().create({
audio_url: "https://example.com/audio.mp3",
language: "en",
});
const pollResult = await client.preRecorded().poll(job.id, {
interval: 1000, // ms between polls
timeout: 300000, // max time to wait
});
const finalResult = await client.preRecorded().get(job.id);
live (start session and stream):
// JavaScript/TypeScript
const session = await client.liveV2().startSession({
language: "en",
model: "nova-2",
});
// in your audio event loop:
await session.sendAudio(audioChunk); // chunk is bytes/buffer
await session.stopRecording();
// get results:
const results = await client.liveV2().get(session.getSessionId());
outputs: transcription result object (pre-recorded) or session object (live) with transcript, confidence, metadata, etc.
inputs: result or error from step 6
javascript/typescript:
try {
const result = await client.preRecorded().transcribe("audio.mp3", options);
console.log(result.transcription); // access transcript
} catch (error) {
if (error.message.includes("401")) {
console.error("invalid api key");
} else if (error.message.includes("timeout")) {
console.error("request timed out, consider raising httpTimeout");
} else if (error.message.includes("429")) {
console.error("rate limit hit, back off and retry");
} else {
console.error(`sdk error: ${error.message}`);
}
}
python:
try:
result = client.prerecorded().transcribe("audio.mp3", options)
print(result.transcription)
except Exception as e:
print(f"error: {e}")
the sdk raises standard exceptions (HttpError, TimeoutError, AuthenticationError) that you can catch. check the exception message for http status codes (401 = invalid key, 429 = rate limit, 500+ = server error).
outputs: either successfully parsed result with transcription, utterances, confidence fields, or caught error logged/handled.
if using javascript/typescript in a browser (not node.js):
use the esm or iife bundle (distributed automatically via npm). do not try to import node-only modules like fs. if you need to send your api key, use a backend proxy that handles auth server-side, not embedded in front-end code. see ./references/javascript.md.
if on node.js < 22 and planning to use live sessions (websocket):
install the ws peer dependency: npm install ws. without it, websocket calls will fail silently at runtime.
if using python async clients (prerecorded_async(), live_async()):
only call these inside an async def function with an active event loop. if you need synchronous code, use the regular sync clients (prerecorded(), live()).
if you need custom http headers, timeouts, or middleware:
use the sdk config options: httpHeaders, httpTimeout, httpRetry for http; wsRetry, wsTimeout for websockets. if the sdk config is insufficient (e.g., you need a custom http agent or middleware), fall back to raw rest/websocket only as a last resort (see "when not to use" section of intent).
if the user is asking about a specific transcription use case (pre-recorded files or live streaming): start with ../pre-recorded-transcription/SKILL.md or ../live-transcription/SKILL.md instead. those skills reference back here for setup details.
if the user is asking about sdk vs raw api: use the sdk unless: (a) the language has no sdk (go, java, rust, etc.), (b) the user explicitly requests raw calls, or (c) it is a one-off ci script or curl test. in all other cases, default to the sdk.
if api key is missing or invalid (401 error):
verify the key is set via GLADIA_API_KEY env var or passed in client config. regenerate the key in the dashboard if needed. never hardcode keys in source files.
if the request times out (408 or timeout exception):
increase httpTimeout (default 30000 ms) or prerecordedTimeouts.polling (default 600000 ms). check your network connection and the gladia api status page. if timeouts persist, contact gladia support.
if you hit a 429 rate limit error:
back off exponentially and retry. the sdk's httpRetry config handles this automatically with configurable backoffMultiplier and maxRetries.
successful execution produces:
pre-recorded transcription result:
a PreRecordedV2Response object (or dict) with fields:
id: job id (string)status: "done" (string)transcription: full transcript text (string)utterances: array of utterance objects, each with start, end, confidence, speaker, textlanguage: detected or provided language code (string)duration: audio duration in seconds (number)metadata: any custom metadata passed in requestlive transcription session result:
a LiveV2Session object (or dict) with fields:
id: session id (string)status: "done" (string)audio_duration: total audio sent, in seconds (number)utterances: array of utterance objects (same structure as pre-recorded)metadata: any custom metadata from startSession()error output: if the operation fails, the sdk raises an exception with:
error.message: descriptive error string (may include http status code or timeout indicator)error.code: optional error code or http status (e.g., 401, 429, 500)results are returned in-memory (not written to disk). if you need to persist results, save them to your own database or file after step 7.
you know the skill worked when:
401, timeout, or other exceptionsPreRecordedV2Response with a non-null transcription field; in live mode, you receive a session result with utterances arraytranscription field or utterances[].text contains actual speech-to-text output (not empty, not error messages)language, duration, confidence are populated, confirming the api processed your requestawait keywords are present and the code actually pauses for the api call; in python, no AttributeError on method names like prerecorded() vs pre_recorded()if initialization succeeds but transcription fails with a 401, regenerate your api key and reinitialize. if timeouts occur, increase the timeout values and retry. if you see "is not a function" or AttributeError, check the exact method name for your language (js uses camelCase like preRecorded(), python uses snake_case like prerecorded()).
credits: original from clawhub. enriched for implexa's 6-component skill standard with explicit decision points, edge cases (rate limits, timeouts, auth expiry, node version checks), and input/output contracts.