# GPT 5.4 API Referensi API lengkap untuk model model bahasa besar GPT 5.4 yang didukung oleh OpenAI. ## Varian Model API ini mendukung empat varian model: | Model | ID | Deskripsi | |-------|----|-------------| | **GPT 5.4 Text to Text** | `gpt-5.4-text-to-text` | model bahasa besar teks umum dan penalaran | | **GPT 5.4 Image to Text** | `gpt-5.4-image-to-text` | Pemahaman gambar dengan instruksi teks | | **GPT 5.4 Web Search** | `gpt-5.4-web-search` | model bahasa besar teks dengan kemampuan pencarian web | | **GPT 5.4 File Analysis** | `gpt-5.4-file-analysis` | Analisis file dengan instruksi teks | ## Perbandingan Cepat | Fitur | Text to Text | Image to Text | Web Search | File Analysis | |---------|--------------|---------------|------------|---------------| | Input teks | Wajib ✅ | Opsional | Wajib ✅ | Opsional | | Input gambar | Tidak didukung ❌ | Opsional | Opsional | Opsional | | Input file | Tidak didukung ❌ | Tidak didukung ❌ | Opsional | Opsional | | Respons streaming | SSE | SSE | SSE | SSE | | `max_tokens` | Opsional | Opsional | Opsional | Opsional | ## GPT 5.4 Text to Text ### Endpoint ```http POST /api/v1/chat/completions ``` ### Parameter Permintaan #### Wajib | Parameter | Tipe | Deskripsi | |-----------|------|-------------| | `model` | string | Harus berupa `"gpt-5.4-text-to-text"` | | `messages` | array | Pesan berurutan. Lihat model bahasa besar API untuk struktur pesan. | | `stream` | boolean | `true` untuk SSE, `false` untuk satu respons JSON. | #### Dukungan Pesan | Field | Teks | File | Gambar | |-------|------|------|-------| | `messages` | Wajib ✅ | Tidak didukung ❌ | Tidak didukung ❌ | #### Opsional | Parameter | Tipe | Rentang | Deskripsi | |-----------|------|-------|-------------| | `max_tokens` | integer | `> 1` | Token output maksimum. | ### Contoh Permintaan ```javascript 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 ### Endpoint ```http POST /api/v1/chat/completions ``` ### Parameter Permintaan #### Wajib | Parameter | Tipe | Deskripsi | |-----------|------|-------------| | `model` | string | Harus berupa `"gpt-5.4-image-to-text"` | | `messages` | array | Pesan berurutan. Lihat model bahasa besar API dan model bahasa besar Attachments. | | `stream` | boolean | `true` untuk SSE, `false` untuk satu respons JSON. | #### Dukungan Pesan | Field | Teks | File | Gambar | |-------|------|------|-------| | `messages` | Opsional | Tidak didukung ❌ | Opsional | #### Opsional | Parameter | Tipe | Rentang | Deskripsi | |-----------|------|-------|-------------| | `max_tokens` | integer | `> 1` | Token output maksimum. | ### Contoh Permintaan ```javascript 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 ### Endpoint ```http POST /api/v1/chat/completions ``` ### Parameter Permintaan #### Wajib | Parameter | Tipe | Deskripsi | |-----------|------|-------------| | `model` | string | Harus berupa `"gpt-5.4-web-search"` | | `messages` | array | Pesan berurutan. Lihat model bahasa besar API dan model bahasa besar Attachments. | | `stream` | boolean | `true` untuk SSE, `false` untuk satu respons JSON. | #### Dukungan Pesan | Field | Teks | File | Gambar | |-------|------|------|-------| | `messages` | Wajib ✅ | Opsional | Opsional | #### Opsional | Parameter | Tipe | Rentang | Deskripsi | |-----------|------|-------|-------------| | `max_tokens` | integer | `> 1` | Token output maksimum. | ### Contoh Permintaan ```javascript 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 ### Endpoint ```http POST /api/v1/chat/completions ``` ### Parameter Permintaan #### Wajib | Parameter | Tipe | Deskripsi | |-----------|------|-------------| | `model` | string | Harus berupa `"gpt-5.4-file-analysis"` | | `messages` | array | Pesan berurutan. Lihat model bahasa besar API dan model bahasa besar Attachments. | | `stream` | boolean | `true` untuk SSE, `false` untuk satu respons JSON. | #### Dukungan Pesan | Field | Teks | File | Gambar | |-------|------|------|-------| | `messages` | Opsional | Opsional | Opsional | #### Opsional | Parameter | Tipe | Rentang | Deskripsi | |-----------|------|-------|-------------| | `max_tokens` | integer | `> 1` | Token output maksimum. | ### Contoh Permintaan ```javascript 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 }) }); ``` ## Format Respons Model LLM GPT 5.4 mengembalikan respons completion yang kompatibel dengan OpenAI. Dengan `stream: true`, respons berupa Server-Sent Events; dengan `stream: false`, respons berupa satu objek JSON. ### Respons Berhasil ```text 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] ``` ### Respons Error ```text event: error data: {"error":{"message":"API requests too frequent, exceeding rate limit","type":"rate_limit_error","code":"1302","param":null}} ``` ## Praktik Terbaik 1. **Jaga pesan tetap terstruktur:** Gunakan `messages[]` untuk riwayat percakapan alih-alih meratakan konteks menjadi satu prompt. 2. **Lampirkan file dan gambar ke pesan:** Letakkan bagian `image_url` dan `file` di dalam pesan yang memperkenalkannya. 3. **Gunakan parsing SSE:** Konsumsi `choices[0].delta.content` untuk tampilan bertahap dan `data: [DONE]` untuk konten final. 4. **Kirim hanya input yang didukung:** Cocokkan bagian teks, gambar, dan file dengan varian model yang dipilih. 5. **Simpan status permintaan secara lokal:** Chunk menyertakan `id` completion, tetapi klien tetap harus merutekannya melalui state permintaan aktif.