> This is a page from the ElevenLabs documentation. For a complete page index, fetch https://elevenlabs.io/docs/llms.txt. For the full documentation in a single file, fetch https://elevenlabs.io/docs/llms-full.txt.

# ElevenAPIクイックスタート

このガイドを終える頃には、テキスト文字列をElevenLabs APIに送信し、返された音声をスピーカーで再生するスクリプトが完成します。APIキーによる認証、SDKのインストール、最初のテキスト読み上げリクエストの作成方法を学びます。

ストリーミング、ボイスクローン、スピーチtoテキストなど、その他の機能に関するガイドは、[チュートリアル](/docs/ja/eleven-api/guides/cookbooks)セクションを参照してください。

> **Tip**
>
> [ElevenLabsテキスト読み上げスキル](https://github.com/elevenlabs/skills/tree/main/text-to-speech)を使用して、AIコーディングアシスタントから音声を生成できます。
>
> ```bash
> npx skills add elevenlabs/skills --skill text-to-speech
> ```

## テキスト読み上げAPIを使用する

#### APIキーを作成する

[ダッシュボードでAPIキーを作成](https://elevenlabs.io/app/settings/api-keys)し、安全に[APIへアクセス](/docs/ja/api-reference/authentication)するために使用します。

キーは管理されたシークレットとして保存し、好みに応じて`.env`ファイルによる環境変数として、またはアプリの設定で直接SDKに渡してください。

**`.env`**

```js title=".env"
ELEVENLABS_API_KEY=<your_api_key_here>
```

#### SDKをインストールする

#### SDK

`dotenv`ライブラリも使用して、環境変数からAPIキーを読み込みます。

```python
pip install elevenlabs
pip install python-dotenv
```

```typescript
npm install @elevenlabs/elevenlabs-js
npm install dotenv
```

#### CLI

ElevenLabs CLIをインストールします。Homebrew（macOS）とScoop（Windows）を推奨します。

**`Homebrew (macOS)`**

```bash title="Homebrew (macOS)"
brew install elevenlabs/tap/elevenlabs
```

**`Scoop (Windows)`**

```powershell title="Scoop (Windows)"
scoop bucket add elevenlabs https://github.com/elevenlabs/scoop-bucket
scoop install elevenlabs
```

**`npm`**

```bash title="npm"
npm install -g @elevenlabs/cli
```

**`curl`**

```bash title="curl"
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/elevenlabs/cli/releases/latest/download/elevenlabs-cli-installer.sh | sh
```

> **Tip**
>
> AIコーディングアシスタントを使っていますか？プロジェクトで`elevenlabs generate-skills`を実行すると、各コマンドグループ用の
> `SKILL.md`が`skills/`に作成されます。これにより、ドキュメントを貼り付けなくても、アシスタントがCLIのすべての機能を把握できます。
> 別の場所に配置するには`--output-dir`を使ってください。CLIに組み込まれたAPI定義を読み取るため、APIキーは不要で、オフラインでも動作します。また、
> インストールしているCLIのバージョンに常に対応します。

次に認証します。ブラウザが開き、CLIを承認できます。

```bash
elevenlabs auth login
```

> **Note**
>
> スピーカーから音声を再生するには、[MPV](https://mpv.io/)
> および／または[ffmpeg](https://ffmpeg.org/)のインストールを求められる場合があります。

#### 最初のリクエストを作成する

#### SDK

使用する言語に応じて、`example.py`または`example.mts`という名前の新しいファイルを作成し、次のコードを追加します。

```python
from dotenv import load_dotenv
from elevenlabs.client import ElevenLabs
from elevenlabs.play import play
import os

load_dotenv()

elevenlabs = ElevenLabs(
  api_key=os.getenv("ELEVENLABS_API_KEY"),
)

audio = elevenlabs.text_to_speech.convert(
    text="The first move is what sets everything in motion.",
    voice_id="JBFqnCBsd6RMkjVDRZzb",  # "George" - browse voices at elevenlabs.io/app/voice-library
    model_id="eleven_v4",
    output_format="mp3_44100_128",
)

play(audio)

```

```typescript
import { ElevenLabsClient, play } from "@elevenlabs/elevenlabs-js";
import "dotenv/config";

const elevenlabs = new ElevenLabsClient();
const audio = await elevenlabs.textToSpeech.convert(
	"JBFqnCBsd6RMkjVDRZzb", // "George" - browse voices at elevenlabs.io/app/voice-library
	{
		text: "The first move is what sets everything in motion.",
		modelId: "eleven_v4",
		outputFormat: "mp3_44100_128",
	},
);

await play(audio);

```

次に実行します。

```python
python example.py
```

```typescript
npx tsx example.mts
```

スピーカーから音声が再生されます。

#### CLI

音声を生成し、MP3ファイルに保存します。

```bash
elevenlabs text-to-speech convert \
  --voice-id JBFqnCBsd6RMkjVDRZzb \
  --model-id eleven_v4 \
  --text "The first move is what sets everything in motion." \
  --output-format mp3_44100_128 \
  --output audio.mp3
```

`audio.mp3`を開いて結果を確認します。

## 次のステップ

#### [音声をストリーミング](/docs/ja/eleven-api/guides/how-to/text-to-speech/streaming)

完全なファイルを待つのではなく、生成中の音声をストリーミングしてレイテンシーを削減します。

#### [音声を閲覧](https://elevenlabs.io/app/voice-library)

10,000以上の音声を探索し、サンプルの音声IDをユースケースに合うものに置き換えます。

#### [音声をクローン](/docs/ja/eleven-api/guides/how-to/voices/instant-voice-cloning)

短い音声録音からカスタム音声を作成します。