> ## Documentation Index
> Fetch the complete documentation index at: https://wb-21fd5541-docs-1917.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 스트리밍 응답 활성화

> Serverless Inference에서 스트리밍 출력을 활성화해 생성되는 모델 응답을 점진적으로 받을 수 있습니다.

모델이 응답을 생성하는 데 시간이 걸리는 경우가 있습니다.
`stream` 옵션을 true로 설정하면 응답을 청크 스트림으로 받을 수 있으므로,
전체 응답이 생성될 때까지 기다리지 않고 결과를 점진적으로 표시할 수 있습니다.

스트리밍 출력은 모든 호스팅된 모델에서 지원됩니다. 특히 [추론 모델](./reasoning)과 함께
사용하는 것을 권장합니다. 스트리밍하지 않는 요청은 출력이 시작되기 전에 모델이
너무 오래 생각하면 시간 초과될 수 있기 때문입니다.

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

    client = openai.OpenAI(
        base_url='https://api.inference.wandb.ai/v1',
        api_key="<your-api-key>",  # https://wandb.ai/settings 에서 API 키를 생성하세요
    )

    stream = client.chat.completions.create(
        model="openai/gpt-oss-120b",
        messages=[
            {"role": "user", "content": "Tell me a rambling joke"}
        ],
        stream=True,
    )

    for chunk in stream:
        if chunk.choices:
            print(chunk.choices[0].delta.content or "", end="", flush=True)
        else:
            print(chunk) # CompletionUsage 객체 표시
    ```
  </Tab>

  <Tab title="Bash">
    ```bash theme={null}
    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-120b",
        "messages": [
          { "role": "user", "content": "Tell me a rambling joke" }
        ],
        "stream": true
      }'
    ```
  </Tab>
</Tabs>
