ElevenLabs 音声AI

感情表現が可能で多言語に対応した、最も自然なAI音声。

✓ 自然な音声

✓ 感情制御

✓ 29言語に対応

✓ 音声クローニング

認証

Doitong APIを通じてElevenLabsにアクセスするには、Doitong APIキーを使用してください。GraphQLミューテーションまたはREST APIのヘッダーに含める必要があります。

重要: Doitong APIキーは安全に保管し、クライアント側のコードに含めないでください。API呼び出しは必ずバックエンドサーバーから実行してください。
// GraphQL Header
{
  "Authorization": "Bearer YOUR_API_KEY"
}

// REST Header
"X-API-Key": "YOUR_API_KEY"

クイックスタート

わずか数分でElevenLabs TTS APIを使い始めることができます。以下の手順に従って、最初のttsを生成しましょう。

ステップ1:APIキーの取得

Doitongアカウントを登録し、ダッシュボードからAPIキーを発行します。

ステップ2:最初のリクエストを実行

以下のコード例を使用して、最初のAPI呼び出しを行います。

curl -X POST https://api.doitong.com/graphql \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "query": "mutation Generate($input: GenerateInput!) { generate(input: $input) { id status type provider url metadata creditCost } }",
    "variables": {
      "input": {
        "type": "AUDIO",
        "provider": "elevenlabs",
        "input": {
          "text": "Hello world, this is a text to speech example.",
          "voice": "en-US-neural"
        },
        "options": {
          "speed": 1.0
        }
      }
    }
  }'
const response = await fetch('https://api.doitong.com/graphql', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_API_KEY'
  },
  body: JSON.stringify({
    query: `
      mutation GenerateSpeech($input: TTSInput!) {
        generateSpeech(input: $input) {
          id
          audioUrl
          duration
        }
      }
    `,
    variables: {
      input: {
        service: 'elevenlabs',
        text: 'Hello world, this is a text to speech example.',
        voice: 'en-US-neural',
        speed: 1.0
      }
    }
  })
});

const data = await response.json();
console.log('Result:', data.data.generate);
import requests
import json

url = "https://api.doitong.com/graphql"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_API_KEY"
}

query = """
mutation Generate($input: GenerateInput!) {
  generate(input: $input) {
    id
    status
    type
    provider
    url
    metadata
    creditCost
  }
}
"""

variables = {
    "input": {
        "type": "AUDIO",
        "provider": "elevenlabs",
        "input": {
            "text": "Hello world, this is a text to speech example.",
            "voice": "en-US-neural"
        },
        "options": {
            "speed": 1.0
        }
    }
}

response = requests.post(url, json={
    "query": query,
    "variables": variables
}, headers=headers)

data = response.json()
print("Result:", data["data"]["generate"])
mutation Generate($input: GenerateInput!) {
  generate(input: $input) {
    id
    status
    type
    provider
    url
    metadata
    creditCost
    createdAt
  }
}

# Variables
{
  "input": {
    "type": "AUDIO",
    "provider": "elevenlabs",
    "input": {
      "text": "Hello world, this is a text to speech example.",
      "voice": "en-US-neural"
    },
    "options": {
      "speed": 1.0,
      "pitch": 1.0,
      "language": "en",
      "version": "eleven-turbo-v2"
    }
  }
}

料金体系

ElevenLabs TTS APIはクレジット制の料金モデルを採用しています。クレジットは、生成されるコンテンツの複雑さや長さに応じて消費されます。

機能 クレジット 説明
標準音声 100文字につき1クレジット 基本的なニューラル音声
プレミアム音声 100文字につき2クレジット 感情表現が可能な高度なニューラル音声

APIエンドポイント

ElevenLabs TTS APIは、統合されたGraphQLエンドポイントから利用可能です。

GraphQLエンドポイント

POST https://api.doitong.com/graphql

RESTエンドポイント

POST https://api.doitong.com/v1/tts

パラメータ

ElevenLabs TTS APIのリクエストで使用可能なパラメータ:

パラメータ 必須 説明
service 文字列 Yes サービス識別子: "elevenlabs"
version 文字列 No Model version: "eleven-turbo-v2"
webhookUrl 文字列 No 完了通知を受け取るためのURL

レスポンス形式

すべてのAPIレスポンスは、一貫した形式で返されます:

成功レスポンス

{
  "data": {
    "tts": {
      "id": "abc123xyz",
      "status": "processing",
      "url": null,
      "webhookUrl": "https://your-webhook.com/callback",
      "createdAt": "2024-01-01T00:00:00Z"
    }
  }
}

完了レスポンス

{
  "data": {
    "tts": {
      "id": "abc123xyz",
      "status": "completed",
      "url": "https://cdn.doitong.com/outputs/abc123xyz.mp3",
      "duration": null,
      "createdAt": "2024-01-01T00:00:00Z"
    }
  }
}

エラーハンドリング

APIは標準的なHTTPステータスコードを使用し、詳細なエラーメッセージを返します。

一般的なエラーコード

ステータスコード エラータイプ 説明
400 Bad Request Invalid parameters or malformed request
401 Unauthorized Missing or invalid API key
402 Payment Required Insufficient credits
429 Too Many Requests Rate limit exceeded
500 Internal Server Error Server error, please retry

エラーレスポンス形式

{
  "errors": [
    {
      "message": "Insufficient credits for this operation",
      "extensions": {
        "code": "INSUFFICIENT_CREDITS",
        "creditsRequired": 100,
        "creditsAvailable": 50
      }
    }
  ]
}

Webhook

ttsの生成が完了した際に、リアルタイムで通知を受け取ることができます。

Webhookの設定

Include a <code>webhookUrl</code> parameter in your request to receive a POST notification when processing is complete.

Webhookペイロード

{
  "id": "abc123xyz",
  "status": "completed",
  "url": "https://cdn.doitong.com/outputs/abc123xyz.mp3",
  "service": "elevenlabs",
  "createdAt": "2024-01-01T00:00:00Z",
  "completedAt": "2024-01-01T00:01:00Z",
  "metadata": {
    "duration": null,
    "width": null,
    "height": null
  }
}

Webhookのセキュリティ

すべてのWebhookリクエストには、検証用の署名ヘッダーが含まれています:

X-Doitong-Signature: sha256=abc123...

レート制限

公平な利用とシステムの安定性を確保するため、以下のレート制限が適用されます:

プラン リクエスト数/分 同時実行ジョブ数 1日あたりの制限
無料 10 1 100
スターター 30 3 1,000
プロ 60 10 10,000
エンタープライズ カスタム カスタム 無制限
レート制限ヘッダー: 現在の制限状況については、レスポンスヘッダーを確認してください:
  • X-RateLimit-Limit: Maximum requests per window
  • X-RateLimit-Remaining: Requests remaining
  • X-RateLimit-Reset: Window reset timestamp

ベストプラクティス

1. プロンプトの最適化

最高の結果を得るために、明確で具体的なプロンプトを作成してください:

  • Be specific about visual elements, style, and mood
  • Include details about lighting, camera angles, and composition
  • Avoid contradictory or impossible requests

2. 非同期処理のハンドリング

生成は非同期で行われます。適切なポーリングまたはWebhookを実装してください:

// Polling example
async function pollStatus(jobId) {
  let status = 'processing';
  while (status === 'processing') {
    await sleep(2000); // Wait 2 seconds
    const result = await checkJobStatus(jobId);
    status = result.status;
  }
  return result;
}

3. エラーリカバリ

指数バックオフを用いたリトライロジックを実装してください:

async function retryWithBackoff(fn, maxRetries = 3) {
  for (let i = 0; i < maxRetries; i++) {
    try {
      return await fn();
    } catch (error) {
      if (i === maxRetries - 1) throw error;
      await sleep(Math.pow(2, i) * 1000);
    }
  }
}

4. クレジット使用状況の監視

サービスの中断を避けるため、クレジットの消費状況を追跡してください:

  • Check credit balance before large batch operations
  • Set up alerts for low credit thresholds
  • Implement credit-aware request queuing

今すぐ始めましょう

数千人の開発者がElevenLabs TTS APIを使用して素晴らしいコンテンツを作成しています

APIキーを取得する 料金プランを見る