> ## Documentation Index
> Fetch the complete documentation index at: https://docs.arouter.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# クイックスタート

> 2 分以内に ARouter を使い始めましょう。コードの変更は不要——base_url と api_key を置き換えるだけです。

ARouter は主要な LLM プロバイダー向けに統一された API key と単一エンドポイントを提供します。すでに OpenAI 互換クライアントを使用している場合、移行に必要な変更は通常 `base_url`、`api_key`、そして任意でアプリ帰属ヘッダーの変更のみです。

## 1. API Key を取得する

[ARouter ダッシュボード](https://api.arouter.ai) でサインアップして API key を作成します。
key の形式は `lr_live_xxxxxxxxxxxx` のようになります。

## 2. ARouter SDK をインストールする

公式 `@arouter/sdk` は任意の Node.js または TypeScript プロジェクトで動作し、npm、yarn、pnpm に対応しています。

<Tabs>
  <Tab title="npm">
    ```bash theme={null}
    npm install @arouter/sdk
    ```
  </Tab>

  <Tab title="yarn">
    ```bash theme={null}
    yarn add @arouter/sdk
    ```
  </Tab>

  <Tab title="pnpm">
    ```bash theme={null}
    pnpm add @arouter/sdk
    ```
  </Tab>
</Tabs>

```typescript theme={null}
import { ARouter } from "@arouter/sdk";

const client = new ARouter({
  apiKey: "lr_live_xxxx",
  baseURL: "https://api.arouter.ai",
});

const response = await client.chatCompletion({
  model: "openai/gpt-5.4",
  messages: [{ role: "user", content: "こんにちは！" }],
});
console.log(response.choices[0].message.content);
```

ストリーミング、key 管理、x402 支払いの例については [Node.js / TypeScript SDK ガイド](/jp/sdks/node) をご覧ください。

## 3. 既存の SDK を使用する

すでに OpenAI、Anthropic、または Go を使用していますか？変更が必要なのは `base_url` と `api_key` だけです。

<Tabs>
  <Tab title="Python (OpenAI)">
    ```python theme={null}
    from openai import OpenAI

    client = OpenAI(
        base_url="https://api.arouter.ai/v1",
        api_key="lr_live_xxxx",
        default_headers={
            "HTTP-Referer": "https://myapp.com",  # 任意
            "X-Title": "My AI App",               # 任意
        },
    )

    response = client.chat.completions.create(
        model="openai/gpt-5.4",
        messages=[{"role": "user", "content": "こんにちは！"}],
    )
    print(response.choices[0].message.content)
    ```
  </Tab>

  <Tab title="Node.js (OpenAI)">
    ```typescript theme={null}
    import OpenAI from "openai";

    const client = new OpenAI({
      baseURL: "https://api.arouter.ai/v1",
      apiKey: "lr_live_xxxx",
      defaultHeaders: {
        "HTTP-Referer": "https://myapp.com", // 任意
        "X-Title": "My AI App",              // 任意
      },
    });

    const response = await client.chat.completions.create({
      model: "openai/gpt-5.4",
      messages: [{ role: "user", content: "こんにちは！" }],
    });
    console.log(response.choices[0].message.content);
    ```
  </Tab>

  <Tab title="Python (Anthropic)">
    ```python theme={null}
    import anthropic

    client = anthropic.Anthropic(
        base_url="https://api.arouter.ai",
        api_key="lr_live_xxxx",
    )

    message = client.messages.create(
        model="claude-sonnet-4.6",
        max_tokens=1024,
        messages=[{"role": "user", "content": "こんにちは！"}],
    )
    print(message.content[0].text)
    ```
  </Tab>

  <Tab title="Go">
    ```go theme={null}
    package main

    import (
        "context"
        "fmt"
        "log"

        "github.com/arouter-ai/arouter-go"
    )

    func main() {
        client := arouter.NewClient("lr_live_xxxx",
            arouter.WithBaseURL("https://api.arouter.ai/v1"),
            arouter.WithHeader("HTTP-Referer", "https://myapp.com"),
            arouter.WithHeader("X-Title", "My AI App"),
        )

        resp, err := client.CreateChatCompletion(context.Background(), arouter.ChatCompletionRequest{
            Model: "openai/gpt-5.4",
            Messages: []arouter.Message{
                {Role: "user", Content: "こんにちは！"},
            },
        })
        if err != nil {
            log.Fatal(err)
        }

        fmt.Println(resp.Choices[0].Message.Content)
    }
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={null}
    curl https://api.arouter.ai/v1/chat/completions \
      -H "Authorization: Bearer lr_live_xxxx" \
      -H "HTTP-Referer: https://myapp.com" \
      -H "X-Title: My AI App" \
      -H "Content-Type: application/json" \
      -d '{
        "model": "openai/gpt-5.4",
        "messages": [{"role": "user", "content": "こんにちは！"}]
      }'
    ```
  </Tab>

  <Tab title="fetch">
    ```typescript theme={null}
    const response = await fetch('https://api.arouter.ai/v1/chat/completions', {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer lr_live_xxxx',
        'Content-Type': 'application/json',
        'HTTP-Referer': 'https://myapp.com', // 任意：ソーストラッキング
        'X-Title': 'My AI App',              // 任意：表示名
      },
      body: JSON.stringify({
        model: 'openai/gpt-5.4',
        messages: [{ role: 'user', content: 'こんにちは！' }],
      }),
    });

    const data = await response.json();
    console.log(data.choices[0].message.content);
    ```
  </Tab>
</Tabs>

<Note>
  `HTTP-Referer` と `X-Title` は任意です。ARouter ダッシュボードの分析でリクエストを特定のアプリやワークフローに帰属させたい場合は、これらのヘッダーを含めてください。
</Note>

## 4. API を直接呼び出す

SDK をインストールしたくない場合は、任意の HTTP クライアントで ARouter を呼び出せます：

```python theme={null}
import json
import requests

response = requests.post(
    "https://api.arouter.ai/v1/chat/completions",
    headers={
        "Authorization": "Bearer lr_live_xxxx",
        "HTTP-Referer": "https://myapp.com",  # 任意
        "X-Title": "My AI App",               # 任意
        "Content-Type": "application/json",
    },
    data=json.dumps({
        "model": "openai/gpt-5.4",
        "messages": [{"role": "user", "content": "こんにちは！"}],
    }),
)

print(response.json()["choices"][0]["message"]["content"])
```

## 5. 異なるプロバイダーを試す

ARouter では、`model` 文字列を変更するだけでプロバイダーを切り替えられます：

```python theme={null}
# OpenAI
response = client.chat.completions.create(model="openai/gpt-5.4", ...)

# Anthropic（OpenAI SDK 経由！）
response = client.chat.completions.create(model="anthropic/claude-sonnet-4.6", ...)

# Google Gemini
response = client.chat.completions.create(model="google/gemini-2.5-flash", ...)

# DeepSeek
response = client.chat.completions.create(model="deepseek/deepseek-v3.2", ...)
```

<Tip>
  プロバイダープレフィックスを省略した場合（例：`"gpt-5.4"` のみ）、ARouter はデフォルトで OpenAI を使用します。
</Tip>

## 次のステップ

<CardGroup cols={2}>
  <Card title="認証" icon="lock" href="/jp/authentication">
    3 つの認証方法について学ぶ
  </Card>

  <Card title="モデルルーティング" icon="shuffle" href="/jp/model-routing">
    provider/model 形式とマルチモデルルーティングを理解する
  </Card>

  <Card title="請求とクレジット" icon="credit-card" href="/jp/guides/billing-and-credits">
    料金、残高、クレジットルールを確認する
  </Card>

  <Card title="リクエスト帰属" icon="globe" href="/jp/guides/request-attribution">
    ダッシュボード分析でトラフィックをアプリに帰属させる
  </Card>

  <Card title="ストリーミング" icon="wave-sine" href="/jp/guides/streaming">
    リアルタイムストリーミングレスポンスを有効にする
  </Card>

  <Card title="ツール呼び出し" icon="wrench" href="/jp/guides/features/tool-calling">
    モデルに関数へのアクセスを与える
  </Card>

  <Card title="構造化出力" icon="brackets-curly" href="/jp/guides/features/structured-outputs">
    モデルに有効な JSON スキーマを返させる
  </Card>

  <Card title="プロンプトキャッシュ" icon="bolt" href="/jp/guides/features/prompt-caching">
    繰り返しプロンプトのコストとレイテンシを削減する
  </Card>

  <Card title="Key 管理" icon="key" href="/jp/guides/key-management">
    チーム向けにスコープ付き key を作成する
  </Card>

  <Card title="FAQ" icon="circle-question" href="/jp/faq">
    よくある質問への回答
  </Card>
</CardGroup>
