API reference
@speechineer/js
The configuration and data types every Speechineer package shares. Whichever package you install, these are the same: how you configure the client, how you describe the form to fill, the callbacks that deliver values and progress, the errors and events that report problems, and the state every session reports.
The package for your framework documents its own functions; everything those functions' options are built from is described here, once.
Setup
Create the client once, at app startup, with your credentials — every session
starts from it. Without a baseUrl it talks to the production Speechineer API.
SpeechineerClient
Your connection to Speechineer. Create one with createClient and keep it for the lifetime of your app; every session starts from it.
Methods
speechToForm()
speechToForm(options): SpeechToFormSession;Fill a form by voice. Returns the session; call start() on it when the user is
ready to speak. In React and Angular use useSpeechToForm / injectSpeechToForm
instead — they take the same options and manage the session for you.
Parameters
| Parameter | Type |
|---|---|
options | SpeechToFormOptions |
Returns
SpeechToFormSession
textToForm()
textToForm(options): TextToFormSession;Extract field values from text — no microphone involved. Returns the session;
call extract(text) as often as you like. In React and Angular use
useTextToForm / injectTextToForm.
Parameters
| Parameter | Type |
|---|---|
options | TextToFormOptions |
Returns
TextToFormSession
Properties
| Property | Type | Description |
|---|---|---|
baseUrl | string | The API root this client talks to (no trailing slash). |
ClientOptions
How the SDK reaches Speechineer and on whose behalf. Pass it once to
createClient (or to the React provider / Angular provideSpeechineer).
Fill in one of the two credential styles:
apiKey(+account) — for an Unsigned API key. The SDK builds the token for you. Convenient for development, but the key is readable in your frontend.token— for a Signed API key. Your server signs a short-lived token per user and you hand it over (a string, or a function that fetches one); the SDK forwards it untouched, because signing requires a private key that must never reach the browser. Use this in production.
Properties
| Property | Type | Description |
|---|---|---|
baseUrl? | string | The Speechineer API root, without a trailing slash. Defaults to the production API — set it only to target another environment. |
apiKey? | string | The API key of the workspace this app belongs to. Unsigned mode only — with a signed token the key travels inside the token. |
token? | string | TokenProvider | A token your server signed, or a function that returns one. Takes precedence over apiKey, and is the only option a Signed API key accepts. With a function the SDK asks for a fresh token on every session start, so expiry is never your problem. |
account? | Account | The end user sessions are for, unless a session says otherwise. Required with apiKey; ignored with token (the token carries the account). |
DEFAULT_BASE_URL
const DEFAULT_BASE_URL: "https://ai.speechineer.com/api" = 'https://ai.speechineer.com/api';Where the SDK sends its requests unless createClient({ baseUrl }) says
otherwise — the production Speechineer API.
createClient()
function createClient(options?): SpeechineerClient;Create the client once, at app startup, and create every session from it.
Parameters
| Parameter | Type |
|---|---|
options | ClientOptions |
Returns
Example
import { createClient } from "@speechineer/js";
// Development — an unsigned workspace key + who the end user is:
const speechineer = createClient({ apiKey: "spnr_live_…", account: { key: user.id } });
// Production — your server signs a short-lived token per user:
const speechineer = createClient({ token: () => fetch("/api/speechineer-token").then((r) => r.text()) });Authentication
Who is calling: your workspace's API key plus an identifier for the end user, or a token your server signed (a string, or a function that fetches a fresh one).
Account
The end user a session is for. Usage and per-account limits are tracked against it, so avoid one shared value for everybody.
Properties
| Property | Type | Description |
|---|---|---|
key | string | A stable id for the end user — your own user id works well. |
pseudonym? | string | An optional readable label for that account, shown in your workspace instead of the raw id (for example a team or desk name). |
TokenProvider
type TokenProvider = () => string | Promise<string>;Returns a token your server signed for the current user — called every time a session is created or resumed, so a fresh, short-lived token is always used.
Returns
string | Promise<string>
Forms
Which form to fill and where its definition lives: configured in Speechineer (a workspace form — your code names it) or defined in your code (an inline form — fields, prompts, and model configurations ship with the call).
FormIdentity
The identity every form carries, whichever side defines it.
Extended by
Properties
| Property | Type | Description |
|---|---|---|
key | string | The form's key. For a workspace form: the key shown in Speechineer. For an inline form: your own stable identifier — Speechineer records the form under it so usage is attributed and limited like any other form. |
version | string | Which version of that form. Pin it: your integration keeps working while a new version is drafted, and you move over when ready. |
language | string | The language of the form definition itself — the field labels and prompts (for example 'en', 'de'). Independent of the language the user speaks. |
WorkspaceForm
A form configured in Speechineer. Your code names it, and the fields, prompts and models
come from your workspace — change them there without shipping a release. Individual fields
can be marked in your workspace as set by code, and those arrive through fieldConfigs.
Extends
Properties
| Property | Type | Description |
|---|---|---|
key | string | The form's key. For a workspace form: the key shown in Speechineer. For an inline form: your own stable identifier — Speechineer records the form under it so usage is attributed and limited like any other form. |
version | string | Which version of that form. Pin it: your integration keeps working while a new version is drafted, and you move over when ready. |
language | string | The language of the form definition itself — the field labels and prompts (for example 'en', 'de'). Independent of the language the user speaks. |
source | "workspace" | The definition lives in your Speechineer workspace. |
fieldConfigs? | FieldSpec[] | Configuration for the fields your form marks as set by your code — a choice field whose options come from your own data, for example. Build each one with FormFieldConfig, giving it the same field id it has in your workspace. Only the marked fields are read from here, and one of them missing stops the session from starting. Every other field keeps the definition it has in your workspace. |
Prompts
The prompts an inline form supplies, one per slot: how to transcribe, and how to extract the field values. Each is plain-language instruction text. Omit a slot to use the default.
Properties
| Property | Type | Description |
|---|---|---|
transcription? | string | Guidance for the transcription step (vocabulary, domain, style). |
extraction? | string | Guidance for turning the transcript into field values. |
Models
The model configurations an inline form pins, one per slot, by the keys you gave them in your workspace. Omit a slot to use the workspace default.
Properties
| Property | Type | Description |
|---|---|---|
transcription? | string | The model configuration key for transcription. |
extraction? | string | The model configuration key for extraction. |
InlineForm
A form defined in your code: you declare the fields to extract (build them with
FormField) and, optionally, the prompts and model configurations to use.
Speechineer records it under key / version in your workspace.
Extends
Properties
| Property | Type | Description |
|---|---|---|
key | string | The form's key. For a workspace form: the key shown in Speechineer. For an inline form: your own stable identifier — Speechineer records the form under it so usage is attributed and limited like any other form. |
version | string | Which version of that form. Pin it: your integration keeps working while a new version is drafted, and you move over when ready. |
language | string | The language of the form definition itself — the field labels and prompts (for example 'en', 'de'). Independent of the language the user speaks. |
source | "inline" | The definition lives in your code. |
fields | FieldSpec[] | Fields to extract — build with FormField. |
prompts? | Prompts | Custom prompts per slot. |
models? | Models | Model configurations per slot, by workspace key. |
FormDefinition
type FormDefinition = WorkspaceForm | InlineForm;Where the form comes from: the one configured in Speechineer (source: 'workspace')
or the one your code defines (source: 'inline'). Every capability that fills a
form takes one of these as form.
Fields
What to extract and how to describe it. Build each field of an inline form with
FormField; the prompt is the instruction Speechineer follows for that field.
OptionsFieldConfig
The allowed options of a choice field (select / multiselect).
Properties
| Property | Type | Description |
|---|---|---|
kind | "options" | Marks the options configuration. |
options | string[] | The values the user may choose from. |
appendOptionsToPrompt? | boolean | Append the options to the prompt so the extraction sees them as part of the instruction. |
RangeFieldConfig
The [min, max] range of a slider field.
Properties
| Property | Type | Description |
|---|---|---|
kind | "range" | Marks the range configuration. |
range | [number, number] | The lowest and highest value allowed. |
FieldSpec
One field to extract. Build these with FormField rather than by hand —
the factory picks the right type and validates the options for you.
Properties
| Property | Type | Description |
|---|---|---|
id | string | Your id for the field. It comes back with every value — in values and in onFieldValue. |
prompt | string | What to extract, in plain language — "Extract the patient's full name". This instruction is what makes the difference between a good and a poor result, so be specific about the value you want. |
type | FieldType | The kind of value expected, which also shapes how it is normalized. |
config? | FieldConfig | Extra rules for types that need them: the options of a choice, or a slider range. |
FieldFactory
The field factory surface. Every helper returns a ready FieldSpec.
Methods
text()
text(id, prompt): FieldSpec;Free-form text.
Parameters
| Parameter | Type |
|---|---|
id | string |
prompt | string |
Returns
textarea()
textarea(id, prompt): FieldSpec;Multi-line free-form text; same value semantics as text.
Parameters
| Parameter | Type |
|---|---|
id | string |
prompt | string |
Returns
email()
email(id, prompt): FieldSpec;An email address.
Parameters
| Parameter | Type |
|---|---|
id | string |
prompt | string |
Returns
phone()
phone(id, prompt): FieldSpec;A phone number.
Parameters
| Parameter | Type |
|---|---|
id | string |
prompt | string |
Returns
url()
url(id, prompt): FieldSpec;A URL.
Parameters
| Parameter | Type |
|---|---|
id | string |
prompt | string |
Returns
integer()
integer(id, prompt): FieldSpec;A whole number.
Parameters
| Parameter | Type |
|---|---|
id | string |
prompt | string |
Returns
float()
float(id, prompt): FieldSpec;A decimal number.
Parameters
| Parameter | Type |
|---|---|
id | string |
prompt | string |
Returns
checkbox()
checkbox(id, prompt): FieldSpec;A yes/no value.
Parameters
| Parameter | Type |
|---|---|
id | string |
prompt | string |
Returns
date()
date(id, prompt): FieldSpec;A calendar date.
Parameters
| Parameter | Type |
|---|---|
id | string |
prompt | string |
Returns
time()
time(id, prompt): FieldSpec;A time of day.
Parameters
| Parameter | Type |
|---|---|
id | string |
prompt | string |
Returns
datetime()
datetime(id, prompt): FieldSpec;A date with a time.
Parameters
| Parameter | Type |
|---|---|
id | string |
prompt | string |
Returns
slider()
slider(
id,
prompt,
range): FieldSpec;Ranged numeric field; range is [min, max] with min < max.
Parameters
| Parameter | Type |
|---|---|
id | string |
prompt | string |
range | [number, number] |
Returns
select()
select(
id,
prompt,
options,
appendOptionsToPrompt?): FieldSpec;Single-choice; options must be non-empty.
Parameters
| Parameter | Type |
|---|---|
id | string |
prompt | string |
options | string[] |
appendOptionsToPrompt? | boolean |
Returns
multiselect()
multiselect(
id,
prompt,
options,
appendOptionsToPrompt?): FieldSpec;Multi-choice; options must be non-empty.
Parameters
| Parameter | Type |
|---|---|
id | string |
prompt | string |
options | string[] |
appendOptionsToPrompt? | boolean |
Returns
FieldConfigFactory
The factory surface for configuring a workspace form's code-defined fields. Only the three types that take a configuration appear here — the rest have nothing for code to supply.
Methods
slider()
slider(id, range): FieldSpec;Ranged numeric field; range is [min, max] with min < max.
Parameters
| Parameter | Type |
|---|---|
id | string |
range | [number, number] |
Returns
select()
select(
id,
options,
appendOptionsToPrompt?): FieldSpec;Single-choice; options must be non-empty.
Parameters
| Parameter | Type |
|---|---|
id | string |
options | string[] |
appendOptionsToPrompt? | boolean |
Returns
multiselect()
multiselect(
id,
options,
appendOptionsToPrompt?): FieldSpec;Multi-choice; options must be non-empty.
Parameters
| Parameter | Type |
|---|---|
id | string |
options | string[] |
appendOptionsToPrompt? | boolean |
Returns
FieldConfig
type FieldConfig =
| OptionsFieldConfig
| RangeFieldConfig;The extra configuration a field type may carry: the allowed options of a choice field, or the range of a slider.
FieldType
type FieldType =
| "text"
| "textarea"
| "email"
| "phone"
| "url"
| "integer"
| "float"
| "slider"
| "checkbox"
| "select"
| "multiselect"
| "date"
| "time"
| "datetime"
| "template";FIELD_TYPES
const FIELD_TYPES: readonly ["text", "textarea", "email", "phone", "url", "integer", "float", "slider", "checkbox", "select", "multiselect", "date", "time", "datetime"];The field types you can declare, in presentation order. Use it to build a type picker without redeclaring the list.
FormField
const FormField: FieldFactory;Build the fields of an inline form. A factory object (no new, tree-shakeable)
producing FieldSpecs, with light runtime validation for the config-bearing types.
Example
import { FormField } from "@speechineer/js"; // also exported by @speechineer/react and @speechineer/angular
const fields = [
FormField.text("patientName", "Extract the patient full name"),
FormField.integer("age", "Extract the age in years"),
FormField.select("species", "Extract the species", ["Canine", "Feline", "Equine"]),
FormField.slider("painLevel", "Extract the pain level", [0, 10]),
];FormFieldConfig
const FormFieldConfig: FieldConfigFactory;Configure the fields your workspace form marks as set by your code — a choice field whose
options come from your own data, for example. Pass the results as the form's fields.
Same validation as FormField, without the prompt: what to extract is already written in
your workspace, so only the field id and the configuration come from here.
Example
import { FormFieldConfig } from "@speechineer/js"; // also exported by @speechineer/react and @speechineer/angular
const form = {
source: "workspace",
key: "intake",
version: "1",
language: "en",
fields: [FormFieldConfig.select("species", await loadSpeciesFromMyDatabase())],
} as const;Callbacks
Optional hooks for imperative integrations. Everything they report — values, the transcript, events, errors — is also in the session state.
SessionCallbacks
The callbacks every session accepts. All of them are optional: a session runs without any, and you add the ones your integration reacts to. Everything they report is also visible in the session state, so a UI that renders from the state needs none of them.
Properties
| Property | Type | Description |
|---|---|---|
onSessionStart? | (sessionId) => void | Fires once, as soon as the session exists and work can begin. Receives the session id — keep it if you want to correlate it with your own logs. |
onStateChange? | (state) => void | The session state changed — its lifecycle, its id, a value, the transcript, an error, or the status of one of its connections. Receives the whole new state; render from it. |
onEvent? | (event) => void | Every status event Speechineer emits for this session — progress only: a connection re-establishing itself, a recording gesture, a connection Speechineer refused. Anything that ends the session is not an event at all and arrives through onError instead, so you never have to inspect an event to find out whether the session is still alive. Use this for logging or a live status display. |
onError? | (error) => void | Something failed in a way you should handle: a rejected request, a denied microphone permission, a lost connection, or a failure Speechineer reported while the session ran. Branch on error.code for the exact cause, or on the error's class (SpeechineerQuotaError, SpeechineerSessionEndedError, …) to handle a whole family at once. start() and end() reject with the same error. |
FormValueCallbacks
Field-value callbacks, added by every capability that fills a form. Optional —
the latest value of every field is always available as values in the
session state; use the callback to push values into a form library
imperatively.
Properties
| Property | Type | Description |
|---|---|---|
onFieldValue? | (fieldId, value) => void | One recognized field value. Called repeatedly while the user speaks, and more than once for the same fieldId when a value is refined — always apply the latest. fieldId is the id you gave the field; value is passed through as received, so cast or validate it the way your form expects. |
TranscriptCallbacks
Transcript callbacks, added by every capability that returns the spoken text.
Optional — the transcript so far is always available as transcript in the
session state.
Properties
| Property | Type | Description |
|---|---|---|
onTranscript? | (text) => void | The transcript so far — the full accumulated text, not just the newest words, so you can render it directly without stitching updates together. |
Events and errors
What you receive when something noteworthy or fatal happens during a session: a typed error with a stable code, and the stream of status events.
SpeechineerClientError
Your app's own mistake, caught before anything was sent — missing credentials, an action
before start(), or a microphone the browser would not give up.
Extends
Properties
| Property | Type | Description |
|---|---|---|
type | string | The category. Prefer catching the matching subclass over comparing this yourself. |
code | string | A stable identifier for what went wrong. Branch on this, not on message. |
field | string | null | The field this failure is about, when it is about one. |
meta | Record<string, unknown> | null | Data belonging to this failure — the shape depends on code. |
details | readonly ErrorDetailSdk[] | One atom per cause, when a single failure has several. |
requestId | string | null | Quote this when reporting a problem — it identifies the exact request. |
cause? | unknown | The underlying failure, when there was one. |
name | string | - |
message | string | - |
stack? | string | - |
SpeechineerAuthError
The credentials were missing, malformed, expired, or rejected.
Extends
Properties
| Property | Type | Description |
|---|---|---|
type | string | The category. Prefer catching the matching subclass over comparing this yourself. |
code | string | A stable identifier for what went wrong. Branch on this, not on message. |
field | string | null | The field this failure is about, when it is about one. |
meta | Record<string, unknown> | null | Data belonging to this failure — the shape depends on code. |
details | readonly ErrorDetailSdk[] | One atom per cause, when a single failure has several. |
requestId | string | null | Quote this when reporting a problem — it identifies the exact request. |
cause? | unknown | The underlying failure, when there was one. |
name | string | - |
message | string | - |
stack? | string | - |
SpeechineerQuotaError
A usage allowance is spent. meta carries the ceiling that bound and how much of it was
used — see QuotaMeta.
Extends
Properties
| Property | Type | Description |
|---|---|---|
type | string | The category. Prefer catching the matching subclass over comparing this yourself. |
code | string | A stable identifier for what went wrong. Branch on this, not on message. |
field | string | null | The field this failure is about, when it is about one. |
meta | Record<string, unknown> | null | Data belonging to this failure — the shape depends on code. |
details | readonly ErrorDetailSdk[] | One atom per cause, when a single failure has several. |
requestId | string | null | Quote this when reporting a problem — it identifies the exact request. |
cause? | unknown | The underlying failure, when there was one. |
name | string | - |
message | string | - |
stack? | string | - |
SpeechineerAccessError
The credentials are valid but not allowed to do this.
Extends
Properties
| Property | Type | Description |
|---|---|---|
type | string | The category. Prefer catching the matching subclass over comparing this yourself. |
code | string | A stable identifier for what went wrong. Branch on this, not on message. |
field | string | null | The field this failure is about, when it is about one. |
meta | Record<string, unknown> | null | Data belonging to this failure — the shape depends on code. |
details | readonly ErrorDetailSdk[] | One atom per cause, when a single failure has several. |
requestId | string | null | Quote this when reporting a problem — it identifies the exact request. |
cause? | unknown | The underlying failure, when there was one. |
name | string | - |
message | string | - |
stack? | string | - |
SpeechineerNotFoundError
Something named in the request does not exist — a form, a version, or a session that has expired. Distinct from SpeechineerSessionEndedError, which means it did exist.
Extends
Properties
| Property | Type | Description |
|---|---|---|
type | string | The category. Prefer catching the matching subclass over comparing this yourself. |
code | string | A stable identifier for what went wrong. Branch on this, not on message. |
field | string | null | The field this failure is about, when it is about one. |
meta | Record<string, unknown> | null | Data belonging to this failure — the shape depends on code. |
details | readonly ErrorDetailSdk[] | One atom per cause, when a single failure has several. |
requestId | string | null | Quote this when reporting a problem — it identifies the exact request. |
cause? | unknown | The underlying failure, when there was one. |
name | string | - |
message | string | - |
stack? | string | - |
SpeechineerSessionEndedError
The session existed and is over. details[0] carries what ended it — a failure, or a spent
allowance. Start a new session; this one cannot be resumed.
Extends
Properties
| Property | Type | Description |
|---|---|---|
type | string | The category. Prefer catching the matching subclass over comparing this yourself. |
code | string | A stable identifier for what went wrong. Branch on this, not on message. |
field | string | null | The field this failure is about, when it is about one. |
meta | Record<string, unknown> | null | Data belonging to this failure — the shape depends on code. |
details | readonly ErrorDetailSdk[] | One atom per cause, when a single failure has several. |
requestId | string | null | Quote this when reporting a problem — it identifies the exact request. |
cause? | unknown | The underlying failure, when there was one. |
name | string | - |
message | string | - |
stack? | string | - |
SpeechineerConflictError
The request conflicts with the current state — for example an action whose prerequisite has not happened yet.
Extends
Properties
| Property | Type | Description |
|---|---|---|
type | string | The category. Prefer catching the matching subclass over comparing this yourself. |
code | string | A stable identifier for what went wrong. Branch on this, not on message. |
field | string | null | The field this failure is about, when it is about one. |
meta | Record<string, unknown> | null | Data belonging to this failure — the shape depends on code. |
details | readonly ErrorDetailSdk[] | One atom per cause, when a single failure has several. |
requestId | string | null | Quote this when reporting a problem — it identifies the exact request. |
cause? | unknown | The underlying failure, when there was one. |
name | string | - |
message | string | - |
stack? | string | - |
SpeechineerValidationError
The request was not acceptable. details lists one atom per offending field, so a rejected
form tells you everything that is wrong in one round trip.
Extends
Properties
| Property | Type | Description |
|---|---|---|
type | string | The category. Prefer catching the matching subclass over comparing this yourself. |
code | string | A stable identifier for what went wrong. Branch on this, not on message. |
field | string | null | The field this failure is about, when it is about one. |
meta | Record<string, unknown> | null | Data belonging to this failure — the shape depends on code. |
details | readonly ErrorDetailSdk[] | One atom per cause, when a single failure has several. |
requestId | string | null | Quote this when reporting a problem — it identifies the exact request. |
cause? | unknown | The underlying failure, when there was one. |
name | string | - |
message | string | - |
stack? | string | - |
SpeechineerRateLimitError
Too many requests. Slow down and retry.
Extends
Properties
| Property | Type | Description |
|---|---|---|
type | string | The category. Prefer catching the matching subclass over comparing this yourself. |
code | string | A stable identifier for what went wrong. Branch on this, not on message. |
field | string | null | The field this failure is about, when it is about one. |
meta | Record<string, unknown> | null | Data belonging to this failure — the shape depends on code. |
details | readonly ErrorDetailSdk[] | One atom per cause, when a single failure has several. |
requestId | string | null | Quote this when reporting a problem — it identifies the exact request. |
cause? | unknown | The underlying failure, when there was one. |
name | string | - |
message | string | - |
stack? | string | - |
SpeechineerRuntimeError
A running session stopped because something failed — transcription or field extraction could not be restarted. The session is over; offer the user a fresh start.
Extends
Properties
| Property | Type | Description |
|---|---|---|
type | string | The category. Prefer catching the matching subclass over comparing this yourself. |
code | string | A stable identifier for what went wrong. Branch on this, not on message. |
field | string | null | The field this failure is about, when it is about one. |
meta | Record<string, unknown> | null | Data belonging to this failure — the shape depends on code. |
details | readonly ErrorDetailSdk[] | One atom per cause, when a single failure has several. |
requestId | string | null | Quote this when reporting a problem — it identifies the exact request. |
cause? | unknown | The underlying failure, when there was one. |
name | string | - |
message | string | - |
stack? | string | - |
SpeechineerServiceError
Speechineer could not handle the request, for a reason that is not your app's doing. Retrying the same request may work.
Extends
Properties
| Property | Type | Description |
|---|---|---|
type | string | The category. Prefer catching the matching subclass over comparing this yourself. |
code | string | A stable identifier for what went wrong. Branch on this, not on message. |
field | string | null | The field this failure is about, when it is about one. |
meta | Record<string, unknown> | null | Data belonging to this failure — the shape depends on code. |
details | readonly ErrorDetailSdk[] | One atom per cause, when a single failure has several. |
requestId | string | null | Quote this when reporting a problem — it identifies the exact request. |
cause? | unknown | The underlying failure, when there was one. |
name | string | - |
message | string | - |
stack? | string | - |
SpeechineerUpstreamError
A service Speechineer depends on answered with something unusable. Retrying the same request the same way is unlikely to help.
Extends
Properties
| Property | Type | Description |
|---|---|---|
type | string | The category. Prefer catching the matching subclass over comparing this yourself. |
code | string | A stable identifier for what went wrong. Branch on this, not on message. |
field | string | null | The field this failure is about, when it is about one. |
meta | Record<string, unknown> | null | Data belonging to this failure — the shape depends on code. |
details | readonly ErrorDetailSdk[] | One atom per cause, when a single failure has several. |
requestId | string | null | Quote this when reporting a problem — it identifies the exact request. |
cause? | unknown | The underlying failure, when there was one. |
name | string | - |
message | string | - |
stack? | string | - |
SpeechineerUnavailableError
Speechineer is temporarily unreachable. Nothing is wrong with your request — retry later.
Extends
Properties
| Property | Type | Description |
|---|---|---|
type | string | The category. Prefer catching the matching subclass over comparing this yourself. |
code | string | A stable identifier for what went wrong. Branch on this, not on message. |
field | string | null | The field this failure is about, when it is about one. |
meta | Record<string, unknown> | null | Data belonging to this failure — the shape depends on code. |
details | readonly ErrorDetailSdk[] | One atom per cause, when a single failure has several. |
requestId | string | null | Quote this when reporting a problem — it identifies the exact request. |
cause? | unknown | The underlying failure, when there was one. |
name | string | - |
message | string | - |
stack? | string | - |
SpeechineerTimeoutError
The request took too long to complete. Retrying is reasonable.
Extends
Properties
| Property | Type | Description |
|---|---|---|
type | string | The category. Prefer catching the matching subclass over comparing this yourself. |
code | string | A stable identifier for what went wrong. Branch on this, not on message. |
field | string | null | The field this failure is about, when it is about one. |
meta | Record<string, unknown> | null | Data belonging to this failure — the shape depends on code. |
details | readonly ErrorDetailSdk[] | One atom per cause, when a single failure has several. |
requestId | string | null | Quote this when reporting a problem — it identifies the exact request. |
cause? | unknown | The underlying failure, when there was one. |
name | string | - |
message | string | - |
stack? | string | - |
QuotaMeta
The meta a SpeechineerQuotaError carries: the allowance that bound, and how much
of it was used.
The amounts are decimal strings, not numbers — usage is metered in fractional units and a JSON number would round them.
Properties
| Property | Type | Description |
|---|---|---|
limit | string | The ceiling that bound. |
used | string | How much of it had been used. |
remaining | string | What was left. |
layer | string | Which allowance bound — for example an account's monthly budget. |
SessionEvent
One status event from a running session, delivered to onEvent.
Events are progress, useful for logging or a live status display: a connection
re-establishing itself, a recording gesture, a connection Speechineer refused. Anything
that ends the session is not an event at all — it reaches you as a typed
SpeechineerError through onError and state.error, so you never have to inspect an
event to find out whether the session is still alive.
Properties
| Property | Type | Description |
|---|---|---|
event | string | What happened, as a stable identifier you can branch on. |
level | LogVerbosity | How important this event is — filter your logging with it. |
source | string | Which part of the session reported it. |
data | Record<string, unknown> | Details belonging to this event; the shape depends on event. |
sessionId | string | The session this event belongs to. |
timestamp | string | ISO-8601 UTC timestamp of emission. |
SpeechineerErrorCode
type SpeechineerErrorCode =
| keyof typeof SDK_ERRORS
| string & {
};A stable identifier for what went wrong.
The union lists what this version knows about but stays open on purpose: Speechineer can name a new failure without every app upgrading first, so the type must not claim the list is closed.
EventLevel
type EventLevel = LogVerbosity;How important an event is — from debug chatter to critical failures. Filter
your logging on it.
SpeechineerError
Something Speechineer could not do.
Branch on code — it is stable — or catch a subclass to handle a whole category at once
(SpeechineerQuotaError covers every way an allowance can run out). message is written
for a developer, not an end user: show your own copy to the people using your app.
meta carries the data belonging to this particular failure — the numbers behind a spent
allowance, for instance — and details breaks an aggregated failure into one atom per
cause, which is how a rejected form reports every offending field at once.
Extends
Error
Extended by
SpeechineerAccessErrorSpeechineerAuthErrorSpeechineerClientErrorSpeechineerConflictErrorSpeechineerNotFoundErrorSpeechineerQuotaErrorSpeechineerRateLimitErrorSpeechineerRuntimeErrorSpeechineerServiceErrorSpeechineerSessionEndedErrorSpeechineerTimeoutErrorSpeechineerUnavailableErrorSpeechineerUpstreamErrorSpeechineerValidationError
Constructors
Constructor
new SpeechineerError(options): SpeechineerError;Parameters
| Parameter | Type |
|---|---|
options | SpeechineerErrorOptions |
Returns
Overrides
Error.constructorProperties
type
readonly type: string;The category. Prefer catching the matching subclass over comparing this yourself.
code
readonly code: string;A stable identifier for what went wrong. Branch on this, not on message.
field
readonly field: string | null;The field this failure is about, when it is about one.
meta
readonly meta: Record<string, unknown> | null;Data belonging to this failure — the shape depends on code.
details
readonly details: readonly ErrorDetailSdk[];One atom per cause, when a single failure has several.
requestId
readonly requestId: string | null;Quote this when reporting a problem — it identifies the exact request.
cause?
readonly optional cause?: unknown;The underlying failure, when there was one.
name
name: string;Inherited from
Error.namemessage
message: string;Inherited from
Error.messagestack?
optional stack?: string;Inherited from
Error.stackSession state
What a running session reports about itself — its lifecycle, its id, the last error, the latest values, the transcript, whether it is listening, and whether each of its connections is open. The same shape in every framework: read it, subscribe to it, render from it.
ConnectionState
The state of one connection.
Properties
| Property | Type |
|---|---|
status | ConnectionStatus |
SessionState
Everything a session reports about itself. Read it with getState(), receive it
through subscribe / onStateChange, or — in React and Angular — take it from the
hook / inject result. Render your UI from it. The object is immutable — every change
produces a new one — so it is safe to compare by reference.
Properties
| Property | Type | Description |
|---|---|---|
status | SessionStatus | Where the session is in its life — see SessionStatus. |
sessionId | string | null | The id of the running session, or null before it exists. |
error | SpeechineerError | null | The last error, or null. Cleared when the next start() succeeds. |
connections | SessionConnections | The status of each connection: session always, the others when the capability uses them. |
values | Readonly<Record<string, unknown>> | The latest recognized value of every field, keyed by the field id you gave it. Starts with initialValues (if any) and grows as values are recognized; a refined value replaces the earlier one. |
transcript | string | The spoken text so far (the full accumulated transcript), or '' when the session does not stream it. |
isListening | boolean | The microphone is on and audio is being sent. |
isConnecting | boolean | The session or one of its connections is being established. |
isEnding | boolean | The session is being finished (end()), or the microphone is winding down after stop(). |
SessionStatus
type SessionStatus = "idle" | "starting" | "active" | "recovering" | "ending" | "failed";Where the session is in its life.
idle— nothing started yet (or the session was ended).starting— the session is being created and its connection opened.active— the session exists;isListeningandconnectionstell you what it is doing.recovering— the session vanished on the server and is being resumed.ending—end()is discarding the session.failed— starting or recovering threw; seeerror.start()may be called again.
ConnectionStatus
type ConnectionStatus = "closed" | "connecting" | "open" | "closing";Whether one connection of the session is open. closing is reported by the
microphone connection between stop() and the moment capture has fully wound down.
ConnectionKey
type ConnectionKey = "session" | "audio" | "results" | "transcript";The connections a session may have. session is the main connection every
session has — when it is lost, every other connection is closed as well.
audio carries the microphone, results the recognized values, transcript
the spoken text. A session only lists the connections its capability uses.
SessionConnections
type SessionConnections = {
session: ConnectionState;
} & Readonly<Partial<Record<Exclude<ConnectionKey, "session">, ConnectionState>>>;The connections of a session: session always, the others only when the
capability uses them.
Type Declaration
| Name | Type |
|---|---|
session | ConnectionState |