스트리밍 응답 받기
스트리밍 응답 받기
stream = client.chat.completions.create(
model="openai/gpt-5.2",
messages=[{"role": "user", "content": "RunYour AI를 소개해줘."}],
stream=True # ← 스트리밍 활성화
)
for chunk in stream:
token = chunk.choices[0].delta.content
if token is not None:
print(token, end="", flush=True) # 글자가 생성될 때마다 출력const stream = await client.chat.completions.create({
model: "openai/gpt-5.2",
messages: [{ role: "user", content: "RunYour AI를 소개해줘." }],
stream: true, // ← 스트리밍 활성화
});
for await (const chunk of stream) {
const token = chunk.choices?.[0]?.delta?.content;
if (token) process.stdout.write(token); // 글자가 생성될 때마다 출력
}curl https://api.runyour.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer runyour-v1-YOUR_API_KEY" \
-d '{
"model": "openai/gpt-5.2",
"messages": [{ "role": "user", "content": "RunYour AI를 소개해줘." }],
"stream": true
}'스트리밍 응답 구조 이해하기
Responses API에서 스트리밍 받기
스트리밍 사용 시 유의사항
마지막 업데이트