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

# 트레이닝된 모델 사용하기

> 트레이닝한 모델에 추론 요청 보내기

Serverless RL로 모델을 트레이닝하면 자동으로 추론에 사용할 수 있습니다. 이 페이지에서는 트레이닝된 모델의 엔드포인트를 구성하고 해당 엔드포인트로 추론 요청을 보내는 방법을 설명합니다. 이 엔드포인트를 사용해 모델을 애플리케이션이나 평가 워크플로에 통합하세요.

트레이닝된 모델에 요청을 보내려면 다음이 필요합니다.

* [W\&B API 키](https://wandb.ai/settings)
* [Serverless Training API](/ko/serverless-training/api-reference)의 base URL, `https://api.training.wandb.ai/v1/`
* 모델의 엔드포인트

모델 엔드포인트는 다음 스키마를 사용합니다.

```text theme={null}
wandb-artifact:///[ENTITY]/[PROJECT]/[MODEL-NAME]:[STEP]
```

스키마는 다음으로 구성됩니다:

* W\&B entity의 (팀) 이름
* 모델과 연결된 프로젝트 이름
* 트레이닝된 모델 이름
* 배포하려는 모델의 트레이닝 step. 일반적으로 평가에서 모델 성능이 가장 좋았던 step입니다.

예를 들어, W\&B 팀 이름이 `email-specialists`이고 프로젝트 이름이 `mail-search`이며 트레이닝된 모델 이름이 `agent-001`이고 step 25에서 배포하려는 경우, 엔드포인트는 다음과 같습니다:

```text theme={null}
wandb-artifact:///email-specialists/mail-search/agent-001:step25
```

엔드포인트가 준비되면 이를 일반적인 추론 워크플로에 통합할 수 있습니다. 다음 예시에서는 cURL 요청 또는 [Python OpenAI SDK](https://github.com/openai/openai-python)를 사용해 트레이닝된 모델에 추론 요청을 보내는 방법을 보여줍니다. 사용 중인 환경에 맞는 예시를 선택하세요.

<div id="curl">
  ## cURL
</div>

```bash theme={null}
curl https://api.training.wandb.ai/v1/chat/completions \
    -H "Authorization: Bearer $WANDB_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
            "model": "wandb-artifact://[ENTITY]/[PROJECT]/[MODEL-NAME]:[STEP]",
            "messages": [
            {"role": "system", "content": "You are a helpful assistant."},
            {"role": "user", "content": "Summarize our training run."}
            ],
            "temperature": 0.7,
            "top_p": 0.95
        }'
```

<div id="openai-sdk">
  ## OpenAI SDK
</div>

```python theme={null}
from openai import OpenAI

WANDB_API_KEY = "your-wandb-api-key"
ENTITY = "my-entity"
PROJECT = "my-project"

client = OpenAI(
    base_url="https://api.training.wandb.ai/v1",
    api_key=WANDB_API_KEY
)

response = client.chat.completions.create(
    model=f"wandb-artifact:///{ENTITY}/{PROJECT}/my-model:step100",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Summarize our training run."},
    ],
    temperature=0.7,
    top_p=0.95,
)

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