# Speechmatics (/en/ai/platform/models/asr/speechmatics)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

> Documentation: Conversational AI.
> Documentation version: Preview.
> This document describes only this version. [Version index](/llms/doc-versions-convoai-guides-v2.txt).


Speechmatics provides real-time automatic speech recognition (ASR) with flexible language support and reliable performance for conversational AI applications.

## Sample configuration

The following example shows how to configure Speechmatics as the agent's ASR when you create or update an agent. For a complete example, see [Create an agent and start a session](/en/ai/platform/get-started/start-stop-agent#create-an-agent).

Speechmatics supports BYOK only. It isn't available in managed mode. Store your Speechmatics API key in a secret set, and refer to it from the agent. For details, see [Use your own provider keys](/en/ai/platform/build/use-your-own-keys).

**Python SDK**

```python
from agora_agent import Agent, SpeechmaticsSTT, secret_ref

# client is your configured Agora client
agent = (
    Agent(client=client)
    .with_stt(
        SpeechmaticsSTT(
            api_key=secret_ref("support_prod", "speechmatics"),
            language="en",
        )
    )
    .with_llm(...)  # configure your LLM vendor
    .with_tts(...)  # configure your TTS vendor
)
```

**TypeScript SDK**

```ts
import { Agent, SpeechmaticsSTT, secretRef } from 'agora-agents';

// client is your configured Agora client
const agent = new Agent({ client })
  .withStt(
    new SpeechmaticsSTT({
      apiKey: secretRef('support_prod', 'speechmatics'),
      language: 'en',
    }),
  )
  .withLlm(/* configure your LLM vendor */)
  .withTts(/* configure your TTS vendor */);
```

**Go SDK**

```go
// client is your configured Agora client
agent := agentkit.NewAgent(client).
	WithStt(vendors.NewSpeechmaticsSTT(vendors.SpeechmaticsSTTOptions{
		APIKey:   agentkit.SecretRef("support_prod", "speechmatics"),
		Language: "en",
	})).
	WithLlm( /* configure your LLM vendor */ ).
	WithTts( /* configure your TTS vendor */ )
```

**REST API**

Set `credential.mode` to `byok` and `credential.fields.key` to a reference to your Speechmatics API key in a secret set. In the following example, the key is stored as `speechmatics` in the `support_prod` set:

```json
"asr": {
  "credential": {
    "mode": "byok",
    "fields": {
      "key": "$secrets.support_prod.speechmatics"
    }
  },
  "vendor": "speechmatics",
  "language": "en",
  "url": "wss://eu2.rt.speechmatics.com/v2",
  "params": {
    "language": "en"
  }
}
```

## Key parameters

The `asr` block takes the following fields. In the SDKs, `SpeechmaticsSTT` sets them from its options, and passes any other Speechmatics parameters from its additional parameters option to `params`.

**asr required**

**`vendor` (string) required**

Set to `speechmatics`.

**`credential` (object) required**

How the agent authenticates with Speechmatics. Set `mode` to `byok` and `fields.key` to a `$secrets.<set>.<key>` reference to your Speechmatics API key.

**`language` (string) required**

The language code to use for transcription. For example, use `en` for English.

**`url` (string) optional**

The WebSocket URL for the Speechmatics streaming API. Specify this to target a particular region, for example, `wss://eu2.rt.speechmatics.com/v2`. Omit it to use the default endpoint.

> **Caution**
>
> The parameters listed on this page are validated for use with the Conversational AI Platform. Required parameters must be provided as documented. Any additional parameters in `params` are passed through directly to Speechmatics without validation. For a full list of supported options, refer to the [Speechmatics documentation](https://docs.speechmatics.com/api-ref/realtime-transcription-websocket).
