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

# Connect your application

> Send your first verified request through the Model Distillation proxy.

ほとんどのチャット補完アプリケーションでは、新しいベース URL、APIキー、モデル名を指定するだけで利用できます。それ以外のリクエストと応答の処理は変わりません。

<h2 id="before-you-begin">
  始める前に
</h2>

W\&B APIキー、ルーティングが適用された project、およびその project の W\&B entity が必要です。

<Tabs>
  <Tab title="Python">
    ```python theme={"system"}
    import os

    from openai import OpenAI

    client = OpenAI(
        base_url="https://proxy.training.wandb.ai/v1",
        api_key=os.environ["WANDB_API_KEY"],
    )

    response = client.chat.completions.create(
        model="ticket-classifier",
        messages=[
            {"role": "user", "content": "My package arrived damaged. What should I do?"}
        ],
        extra_body={
            "metadata": {
                "wandb.entity": "your-team",
                "wandb.thread_id": "customer-4827",
            }
        },
    )

    print(response.choices[0].message.content)
    ```
  </Tab>

  <Tab title="JavaScript">
    ```javascript theme={"system"}
    import OpenAI from "openai";

    const client = new OpenAI({
      baseURL: "https://proxy.training.wandb.ai/v1",
      apiKey: process.env.WANDB_API_KEY,
    });

    const response = await client.chat.completions.create({
      model: "ticket-classifier",
      messages: [
        { role: "user", content: "My package arrived damaged. What should I do?" },
      ],
      metadata: {
        "wandb.entity": "your-team",
        "wandb.thread_id": "customer-4827",
      },
    });

    console.log(response.choices[0].message.content);
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={"system"}
    curl https://proxy.training.wandb.ai/v1/chat/completions \
      -H "Authorization: Bearer $WANDB_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "model": "ticket-classifier",
        "messages": [
          {"role": "user", "content": "My package arrived damaged. What should I do?"}
        ],
        "metadata": {
          "wandb.entity": "your-team",
          "wandb.thread_id": "customer-4827"
        }
      }'
    ```
  </Tab>
</Tabs>

project が APIキーのデフォルトの entity に属する場合にのみ、`wandb.entity` を省略してください。

<h2 id="verify-the-integration">
  インテグレーションを確認する
</h2>

リクエストを送信した後、project の概要に戻ります。次の点を確認してください。

* リクエスト数が増えていること;
* 想定したモデルがリクエストを処理したこと;
* 保存された入力と回答が正しいこと。

プロキシが個人の entity に project が存在しないと表示した場合は、`metadata["wandb.entity"]` にチーム名を追加してください。

<h2 id="preserve-conversation-identity">
  会話のアイデンティティを保持する
</h2>

1 つの会話内のすべてのリクエストで同じ `wandb.thread_id` を使用します。これにより、段階的なロールアウト中も会話で同じモデルが使用され、データの準備時に関連するサンプルがまとめられます。

<Card title="チャット補完の詳細" href="/ja/model-distillation/proxy/chat-completions" arrow="true">
  ストリーミング、ツール、構造化出力、プロバイダーのパラメーター、リクエストの優先順位について説明します。
</Card>
