本页还没有译文
本页 25 段还没译成日本語,下面显示的是英文原文。Telnyx
还没翻译译自英文(ai-sdk.dev)本页 25 段都还没译
Telnyx provides an AI SDK provider for the Vercel AI SDK, giving developers access to chat models, embeddings, speech-to-text, and text-to-speech through a single package.
The Telnyx provider is a good fit if you want:
- One package for multiple AI capabilities: chat, embeddings, transcription, and speech generation
- OpenAI-compatible model access: use Telnyx-hosted models through a familiar API pattern
- Speech support in the same provider: combine text and voice workflows in one integration
- Simple setup: standard API key configuration with the AI SDK
Learn more in the Telnyx documentation.
Setup
The @telnyx/ai-sdk-provider package (v2.0.0+) supports AI SDK 7 and the Provider V4 specification.
Install it alongside AI SDK 7:
pnpmnpmyarnbun
pnpm add @telnyx/ai-sdk-provider ai@^7 zodnpm install @telnyx/ai-sdk-provider ai@^7 zodyarn add @telnyx/ai-sdk-provider ai@^7 zodbun add @telnyx/ai-sdk-provider ai@^7 zodSet your Telnyx API key as an environment variable:
export TELNYX_API_KEY="your_api_key_here"Provider Instance
To create a Telnyx provider instance, use the createTelnyx function:
import { createTelnyx } from '@telnyx/ai-sdk-provider';
const telnyx = createTelnyx({
apiKey: process.env.TELNYX_API_KEY,
});You can also use the default telnyx export when TELNYX_API_KEY is set in your environment.
Examples
generateText
import { telnyx } from '@telnyx/ai-sdk-provider';
import { generateText } from 'ai';
const { text } = await generateText({
model: telnyx('Qwen/Qwen3-235B-A22B'),
prompt: 'Explain WebRTC in simple terms.',
});
console.log(text);embed
import { telnyx } from '@telnyx/ai-sdk-provider';
import { embed } from 'ai';
const { embedding } = await embed({
model: telnyx.embeddingModel('thenlper/gte-large'),
value: 'What is WebRTC?',
});
console.log(embedding);transcribe
import { telnyx } from '@telnyx/ai-sdk-provider';
import { transcribe } from 'ai';
import { readFile } from 'node:fs/promises';
const result = await transcribe({
model: telnyx.transcriptionModel('distil-whisper/distil-large-v2'),
audio: await readFile('./audio.wav'),
});
console.log(result.text);generateSpeech
import { telnyx } from '@telnyx/ai-sdk-provider';
import { generateSpeech } from 'ai';
const { audio } = await generateSpeech({
model: telnyx.speech('Telnyx.NaturalHD.astra'),
text: 'Hello from Telnyx!',
voice: 'Telnyx.NaturalHD.astra',
});
await audio.writeToFile('./speech.mp3');Additional Resources
AI 翻译查看英文原文