> ## 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.

# JSON 모드 활성화

> Serverless Inference에서 JSON 모드를 설정하면 모델 응답을 구조화된 JSON 출력으로 받아 더 쉽게 파싱할 수 있습니다.

JSON 모드는 자유 형식 텍스트를 다룰 필요 없이 모델 응답을 프로그래밍 방식으로 파싱해야 할 때 유용합니다. JSON 모드를 활성화하면 모델이 유효한 JSON 형식으로 응답을 반환하므로 다운스트림 코드에서 출력을 더 쉽게 활용할 수 있습니다. 다만 응답의 스키마가 항상 일관되거나 특정 구조를 따른다는 보장은 없습니다. 일관되고 구조화된 JSON 응답이 필요하다면 가능한 한 [구조화된 출력](/ko/products/inference/serverless/response-settings/structured-output)을 사용하는 것이 좋습니다.

JSON 모드를 활성화하려면 요청의 `response_format`에 JSON 모드를 지정하세요.

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

    client = openai.OpenAI(
        base_url='https://api.inference.wandb.ai/v1',
        api_key="[YOUR-API-KEY]",  # https://forge.coreweave.com/settings 에서 API 키를 생성하세요
    )

    response = client.chat.completions.create(
        model="openai/gpt-oss-20b",
        messages=[
            {"role": "system", "content": "You are a helpful assistant that outputs JSON."},
            {"role": "user", "content": "Give me a list of three fruits with their colors."},
        ],
        response_format={"type": "json_object"}  # JSON 모드를 활성화합니다
    )

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

  <Tab title="Bash">
    ```bash theme={"system"}
    curl https://api.inference.wandb.ai/v1/chat/completions \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer [YOUR-API-KEY]" \
      -d '{
        "model": "openai/gpt-oss-20b",
        "messages": [
            {"role": "system", "content": "You are a helpful assistant that outputs JSON."},
            {"role": "user", "content": "Give me a list of three fruits with their colors."},
        ],
        "response_format": {"type": "json_object"}
      }'
    ```
  </Tab>
</Tabs>
