curl
Node.js
Ruby
Go
复制
curl -X POST https://runapi.ai/api/v1/elevenlabs/text_to_sound \
-H "Authorization: Bearer $RUNAPI_KEY" \
-H "Content-Type: application/json" \
--data-binary @- <<'JSON'
{
"model": "sound-effect-v2",
"text": "Warm vinyl crackle for a nostalgic ambiance"
}
JSON
复制
import { ElevenlabsClient } from "@runapi.ai/elevenlabs";
const client = new ElevenlabsClient({
apiKey: process.env.RUNAPI_API_KEY,
});
const result = await client.textToSound.run({
"model": "sound-effect-v2",
"text": "Warm vinyl crackle for a nostalgic ambiance"
});
console.log(result.id);
复制
require "runapi/elevenlabs"
client = RunApi::Elevenlabs::Client.new
result = client.text_to_sound.run(
model: "sound-effect-v2",
text: "Warm vinyl crackle for a nostalgic ambiance"
)
puts result.id
复制
package main
import (
"context"
"fmt"
"log"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader("{\"model\":\"sound-effect-v2\",\"text\":\"Warm vinyl crackle for a nostalgic ambiance\"}")
req, err := http.NewRequestWithContext(context.Background(), http.MethodPost, "https://runapi.ai/api/v1/elevenlabs/text_to_sound", body)
if err != nil {
log.Fatal(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("RUNAPI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}