GPT 5.4 API
OpenAI 기반 GPT 5.4 LLM의 완전한 API 참조 문서입니다.
모델 변형
이 API는 네 가지 모델 변형을 지원합니다:
빠른 비교
GPT 5.4 Text to Text
엔드포인트 {#}
POST /api/v1/chat/completions
요청 파라미터
필수
메시지 지원
선택 사항
요청 예시
const response = await fetch('https://api.flaq.ai/api/v1/chat/completions', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Accept': 'text/event-stream',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'gpt-5.4-text-to-text',
messages: [
{
role: 'user',
content: 'Write a short launch announcement for a new AI feature.'
}
],
stream: true,
max_tokens: 2048
})
});
GPT 5.4 Image to Text
엔드포인트
POST /api/v1/chat/completions
요청 파라미터
필수
메시지 지원
선택 사항
요청 예시
const response = await fetch('https://api.flaq.ai/api/v1/chat/completions', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Accept': 'text/event-stream',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'gpt-5.4-image-to-text',
messages: [
{
role: 'user',
content: [
{ type: 'text', text: 'Describe the image and extract any visible text.' },
{
type: 'image_url',
image_url: {
url: 'https://example.com/sample-image.jpg'
}
}
]
}
],
stream: true,
max_tokens: 2048
})
});
GPT 5.4 Web Search
엔드포인트
POST /api/v1/chat/completions
요청 파라미터
필수
메시지 지원
선택 사항
요청 예시
const response = await fetch('https://api.flaq.ai/api/v1/chat/completions', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Accept': 'text/event-stream',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'gpt-5.4-web-search',
messages: [
{
role: 'user',
content: 'Find recent product launch trends in AI developer tools.'
}
],
stream: true,
max_tokens: 2048
})
});
GPT 5.4 File Analysis
엔드포인트
POST /api/v1/chat/completions
요청 파라미터
필수
메시지 지원
선택 사항
요청 예시
const response = await fetch('https://api.flaq.ai/api/v1/chat/completions', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Accept': 'text/event-stream',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'gpt-5.4-file-analysis',
messages: [
{
role: 'user',
content: [
{ type: 'text', text: 'Summarize this document and list the key action items.' },
{
type: 'file',
file: {
filename: 'demo.pdf',
file_data: 'https://example.com/demo.pdf'
}
}
]
}
],
stream: true,
max_tokens: 2048
})
});
응답 형식
GPT 5.4 LLM 모델은 OpenAI 호환 completion 응답을 반환합니다. stream: true이면 응답은 Server-Sent Events이고, stream: false이면 단일 JSON 객체입니다.
성공 응답
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","created":1710000000,"model":"gpt-5.4-image-to-text","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]}
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","created":1710000000,"model":"gpt-5.4-image-to-text","choices":[{"index":0,"delta":{"content":"The image shows"},"finish_reason":null}]}
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","created":1710000000,"model":"gpt-5.4-image-to-text","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","created":1710000000,"model":"gpt-5.4-image-to-text","choices":[],"usage":{"prompt_tokens":12,"completion_tokens":8,"total_tokens":20}}
data: [DONE]
오류 응답
event: error
data: {"error":{"message":"API requests too frequent, exceeding rate limit","type":"rate_limit_error","code":"1302","param":null}}
모범 사례
- 메시지를 구조화하세요: 컨텍스트를 하나의 프롬프트로 합치지 말고 대화 기록에는
messages[]를 사용하세요.
- 파일과 이미지를 메시지에 첨부하세요:
image_url 및 file 파트를 이를 도입한 메시지 안에 넣으세요.
- SSE 파싱을 사용하세요: 점진적 표시에는
choices[0].delta.content를, 최종 콘텐츠에는 data: [DONE]를 사용하세요.
- 지원되는 입력만 전송하세요: 텍스트, 이미지, 파일 파트를 선택한 모델 변형에 맞추세요.
- 요청 상태를 로컬에 저장하세요: chunk에는 completion
id가 포함되지만, 클라이언트는 여전히 활성 요청 상태를 통해 chunk를 라우팅해야 합니다.