Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
163 changes: 163 additions & 0 deletions core/llm/llms/Slng.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
/**
* SLNG Provider for Continue.dev
*
* This provider enables access to 19 SLNG voice AI models (11 TTS + 8 STT)
* across EU, AU, and Asia regions.
*
* Documentation: https://docs.slng.ai
* Models: https://docs.slng.ai/models
*/

import { LLM } from "../../index.js";
import { CompletionOptions, LLMOptions, ModelProvider } from "../../index.js";

class Slng implements LLM {
static providerName: ModelProvider = "slng";
static defaultOptions: Partial<LLMOptions> = {
apiBase: "https://api.slng.ai/v1",
};

private apiKey: string;
private apiBase: string;

constructor(options: LLMOptions) {
this.apiKey = options.apiKey || "";
this.apiBase = options.apiBase || "https://api.slng.ai/v1";

if (!this.apiKey) {
throw new Error(
"SLNG API key is required. Set it in your Continue config or via SLNG_API_KEY environment variable."
);
}
}

async *streamComplete(
prompt: string,
options: CompletionOptions
): AsyncGenerator<string> {
const endpoint = this.getEndpoint(options.model);

const response = await fetch(`${this.apiBase}${endpoint}`, {
method: "POST",
headers: {
Authorization: `Bearer ${this.apiKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
input: prompt,
model: options.model,
stream: true,
temperature: options.temperature,
max_tokens: options.maxTokens,
}),
});

if (!response.ok) {
throw new Error(
`SLNG API error: ${response.status} ${response.statusText}`
);
}

const reader = response.body?.getReader();
if (!reader) {
throw new Error("No response body");
}

const decoder = new TextDecoder();

while (true) {
const { done, value } = await reader.read();
if (done) break;

const chunk = decoder.decode(value);
const lines = chunk.split("\n").filter((line) => line.trim() !== "");

for (const line of lines) {
if (line.startsWith("data: ")) {
const data = line.slice(6);
if (data === "[DONE]") continue;

try {
const parsed = JSON.parse(data);
const text = parsed.text || parsed.delta?.text || "";
if (text) yield text;
} catch (e) {
// Skip invalid JSON
console.warn("Failed to parse SSE data:", data);
}
}
}
}
}

async complete(prompt: string, options: CompletionOptions): Promise<string> {
const endpoint = this.getEndpoint(options.model);

const response = await fetch(`${this.apiBase}${endpoint}`, {
method: "POST",
headers: {
Authorization: `Bearer ${this.apiKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
input: prompt,
model: options.model,
temperature: options.temperature,
max_tokens: options.maxTokens,
}),
});

if (!response.ok) {
throw new Error(
`SLNG API error: ${response.status} ${response.statusText}`
);
}

const data = await response.json();
return data.text || data.transcript || "";
}

listModels(): string[] {
return [
// TTS Models (11)
"deepgram-aura-2",
"bulbul-v3",
"cartesia-sonic-3",
"cartesia-sonic-3-5",
"fish-tts-s2-1-pro",
"gradium-tts",
"inworld-max-1-5",
"kugel-2",
"murf-falcon",
"sarvam-saaras",
"soniox-tts-rt-v1",
// STT Models (8)
"deepgram-nova-3",
"deepgram-nova-3-medical",
"deepgram-nova-3-multi",
"fish-audio-asr",
"gradium-stt",
"reson8-stt-v1",
"soniox-speech-ai-rt-v5",
"speechmatics-realtime-v2",
];
}

private getEndpoint(model: string): string {
// Determine if TTS or STT based on model name
const sttKeywords = ["nova", "asr", "stt", "speechmatics", "soniox-speech"];
const isSTT = sttKeywords.some((keyword) => model.includes(keyword));

if (isSTT) {
return `/stt/slng/${model}`;
} else {
return `/tts/slng/${model}`;
}
}

supportsFim(): boolean {
return false;
}
}

export default Slng;
114 changes: 114 additions & 0 deletions docs/customize/model-providers/more/slng.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# SLNG

SLNG is a regional voice AI infrastructure provider offering TTS and STT models across EU, AU, and Asia with sub-100ms latency.

## Configuration

Add SLNG to your `~/.continue/config.json`:

```json
{
"models": [
{
"title": "SLNG - Deepgram Aura 2",
"provider": "slng",
"model": "deepgram-aura-2",
"apiKey": "your-slng-api-key"
}
]
}
```

You can also set the API key via environment variable:
```bash
export SLNG_API_KEY="your-slng-api-key"
```

## Available Models

### TTS (Text-to-Speech) - 11 Models

| Model ID | Name | Languages | Use Case |
|----------|------|-----------|----------|
| `deepgram-aura-2` | Deepgram Aura 2 | English, Spanish | Natural voices |
| `bulbul-v3` | Sarvam Bulbul v3 | 23 Indian languages | Regional voices |
| `cartesia-sonic-3` | Cartesia Sonic 3 | Multilingual | Low latency |
| `cartesia-sonic-3-5` | Cartesia Sonic 3.5 | Multilingual | Enhanced quality |
| `fish-tts-s2-1-pro` | Fish TTS S2.1 Pro | EN, ZH, JA | Asian languages |
| `gradium-tts` | Gradium TTS | English | Regional deployment |
| `inworld-max-1-5` | Inworld Max 1.5 | English | Character voices |
| `kugel-2` | KugelAudio Kugel 2 | European languages | EU deployment |
| `murf-falcon` | Murf Falcon | English | Professional narration |
| `sarvam-saaras` | Sarvam AI Saaras | Indian languages | Regional voices |
| `soniox-tts-rt-v1` | Soniox TTS RT v1 | English | Real-time synthesis |

### STT (Speech-to-Text) - 8 Models

| Model ID | Name | Languages | Use Case |
|----------|------|-----------|----------|
| `deepgram-nova-3` | Deepgram Nova 3 | English | Standard transcription |
| `deepgram-nova-3-medical` | Deepgram Nova 3 Medical | English | Medical terminology |
| `deepgram-nova-3-multi` | Deepgram Nova 3 Multi | EN, ES, HI | Multilingual |
| `fish-audio-asr` | Fish Audio ASR | EN, ZH, JA | Asian languages |
| `gradium-stt` | Gradium STT | English | Regional deployment |
| `reson8-stt-v1` | Reson8 STT v1 | English | Enterprise-grade |
| `soniox-speech-ai-rt-v5` | Soniox Speech AI RT v5 | English | High accuracy |
| `speechmatics-realtime-v2` | Speechmatics Realtime v2 | Multilingual | Real-time |

## Regional Deployment

SLNG models are deployed across multiple regions:
- **US:** Central US infrastructure
- **EU:** European data centers
- **AU:** Australia deployment
- **Asia:** India, Singapore, and more

Models automatically route to the nearest region for optimal latency.

## Authentication

Get your API key from [SLNG](https://app.slng.ai/sign-in).

## Example Configurations

### TTS for Documentation
```json
{
"title": "SLNG TTS - Aura 2",
"provider": "slng",
"model": "deepgram-aura-2",
"apiKey": "your-api-key"
}
```

### STT for Transcription
```json
{
"title": "SLNG STT - Nova 3",
"provider": "slng",
"model": "deepgram-nova-3",
"apiKey": "your-api-key"
}
```

### Multilingual Support
```json
{
"title": "SLNG - Indian Languages",
"provider": "slng",
"model": "bulbul-v3",
"apiKey": "your-api-key"
}
```

## Documentation

- [SLNG API Documentation](https://docs.slng.ai)
- [Model Catalog](https://docs.slng.ai/models)
- [API Reference](https://docs.slng.ai/api-reference)

## Support

For issues or questions:
- GitHub: [continuedev/continue](https://github.com/continuedev/continue/issues)
- SLNG Docs: https://docs.slng.ai
Loading