For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to the page URL.
기본 탐색 메뉴
Theme

Chat Completions에서 오디오 사용하기

기존 Chat Completions 애플리케이션에 오디오 입력과 출력을 추가하세요.

Chat Completions 엔드포인트를 사용하는 기존 텍스트 기반 LLM 애플리케이션에 오디오 기능을 추가할 수 있습니다. 예를 들어 텍스트 입력을 지원하는 채팅 애플리케이션에 오디오 입력과 출력을 추가하려면 audio를 modalities 배열에 포함하고 gpt-audio-1.5와 같은 오디오 모델을 사용하세요.

현재 Responses API 문서에서는 텍스트와 이미지를 입력으로 받아 텍스트를 출력하는 방법을 설명합니다. 오디오로 대화를 주고받으려면 Chat Completions에서 오디오를 지원하는 모델을 사용하세요.

프롬프트에 사람이 말하듯 자연스러운 음성으로 응답하기
import { writeFileSync } from "node:fs";
import OpenAI from "openai";

const openai = new OpenAI();

// Generate an audio response to the given prompt
const response = await openai.chat.completions.create({
  model: "gpt-audio-1.5",
  modalities: ["text", "audio"],
  audio: { voice: "alloy", format: "wav" },
  messages: [
    {
      role: "user",
      content: "Is a golden retriever a good family dog?",
    },
  ],
  store: true,
});

// Inspect returned data
console.log(response.choices[0]);

// Write audio data to a file
writeFileSync(
  "dog.wav",
  Buffer.from(response.choices[0].message.audio.data, "base64"),
  { encoding: "utf-8" }
);