Langsung ke konten utama
POST
/
v1
/
responses
curl https://api.apimart.ai/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <token>" \
  -d '{
    "model": "gpt-5",
    "input": [
      {
        "role": "user",
        "content": [
          {
            "type": "input_text",
            "text": "What is in this image?"
          },
          {
            "type": "input_image",
            "image_url": "https://openai-documentation.vercel.app/images/cat_and_otter.png"
          }
        ]
      }
    ]
  }'
{
  "code": 200,
  "data": {
    "id": "resp-9876543210",
    "object": "response",
    "created": 1677652288,
    "model": "gpt-5",
    "choices": [
      {
        "index": 0,
        "message": {
          "role": "assistant",
          "content": "This image shows a cat and an otter. They appear to be interacting with each other in a very cute and heartwarming scene. The cat and otter seem to be getting along well."
        },
        "finish_reason": "stop"
      }
    ],
    "usage": {
      "prompt_tokens": 156,
      "completion_tokens": 45,
      "total_tokens": 201
    }
  }
}

Documentation Index

Fetch the complete documentation index at: https://docs.apimart.ai/llms.txt

Use this file to discover all available pages before exploring further.

curl https://api.apimart.ai/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <token>" \
  -d '{
    "model": "gpt-5",
    "input": [
      {
        "role": "user",
        "content": [
          {
            "type": "input_text",
            "text": "What is in this image?"
          },
          {
            "type": "input_image",
            "image_url": "https://openai-documentation.vercel.app/images/cat_and_otter.png"
          }
        ]
      }
    ]
  }'
{
  "code": 200,
  "data": {
    "id": "resp-9876543210",
    "object": "response",
    "created": 1677652288,
    "model": "gpt-5",
    "choices": [
      {
        "index": 0,
        "message": {
          "role": "assistant",
          "content": "This image shows a cat and an otter. They appear to be interacting with each other in a very cute and heartwarming scene. The cat and otter seem to be getting along well."
        },
        "finish_reason": "stop"
      }
    ],
    "usage": {
      "prompt_tokens": 156,
      "completion_tokens": 45,
      "total_tokens": 201
    }
  }
}

Otorisasi

Authorization
string
wajib
##Semua API memerlukan autentikasi Bearer Token##Dapatkan API Key:Kunjungi Halaman Manajemen API Key untuk mendapatkan API Key AndaTambahkan ke header request:
Authorization: Bearer YOUR_API_KEY

Body

model
string
default:"gpt-5"
wajib
Nama modelModel yang didukung meliputi:
  • gpt-5 - Model multimodal terbaru OpenAI
  • GPT-4o-image - Model multimodal GPT-4 yang dioptimalkan
  • gpt-4-vision - Model GPT-4 untuk pemahaman vision
  • Model lainnya segera hadir…
input
array
wajib
Daftar konten inputArray input; setiap item berisi field role dan content.💡 Pengisian cepat (area Try it):
  1. Klik ”+ Add an item” untuk menambahkan item input
  2. Input role: user (pesan pengguna), assistant (respons AI), atau system (prompt sistem)
  3. Tambahkan blok konten di content (dapat mencakup teks dan gambar)
temperature
number
Mengontrol keacakan output, rentang 0-2
  • Nilai yang lebih rendah (misalnya 0,2) membuat output lebih deterministik
  • Nilai yang lebih tinggi (misalnya 1,8) membuat output lebih acak
Default: 1.0
max_tokens
integer
Jumlah maksimum token yang akan dibuatSetiap model memiliki batas maksimum yang berbeda; lihat dokumentasi model terkait
stream
boolean
Apakah akan menggunakan output streaming
  • true: Respons streaming (format SSE)
  • false: Mengembalikan respons lengkap sekaligus
Default: false
top_p
number
Parameter nucleus sampling, rentang 0-1Mengontrol keragaman teks yang dihasilkan; sebaiknya digunakan sebagai alternatif temperatureDefault: 1.0
tools
array
Daftar tool untuk memperluas kemampuan modelJenis tool yang didukung:
  • Web Search (web_search): Pencarian informasi internet real-time
  • File Search (file_search): Mencari konten file yang diunggah
  • Function Calling (function): Memanggil fungsi kustom
  • Remote MCP (remote_mcp): Terhubung ke layanan Model Context Protocol jarak jauh
Contoh: [{"type": "web_search"}]

Respons

id
string
Pengidentifikasi unik untuk respons
object
string
Jenis objek, tetap sebagai response
created
integer
Timestamp pembuatan
model
string
Nama model aktual yang digunakan
choices
array
Daftar balasan yang dihasilkan
usage
object
Statistik penggunaan token

Contoh Penggunaan

Input Teks Saja

{
  "model": "gpt-5",
  "input": [
    {
      "role": "user",
      "content": [
        {
          "type": "input_text",
          "text": "Hello, introduce artificial intelligence"
        }
      ]
    }
  ]
}
{
  "model": "gpt-5",
  "tools": [{"type": "web_search"}],
  "input": "What positive news is there today?"
}
cURL Example
curl "https://api.apimart.ai/v1/responses" \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer <token>" \
    -d '{
        "model": "gpt-5",
        "tools": [{"type": "web_search"}],
        "input": "What positive news is there today?"
    }'

Pemahaman Gambar

{
  "model": "gpt-5",
  "input": [
    {
      "role": "user",
      "content": [
        {
          "type": "input_text",
          "text": "Describe this image"
        },
        {
          "type": "input_image",
          "image_url": "https://example.com/image.jpg"
        }
      ]
    }
  ]
}

Analisis Multi-Gambar

{
  "model": "gpt-5",
  "input": [
    {
      "role": "user",
      "content": [
        {
          "type": "input_text",
          "text": "Compare the similarities and differences of these two images"
        },
        {
          "type": "input_image",
          "image_url": "https://example.com/image1.jpg"
        },
        {
          "type": "input_image",
          "image_url": "https://example.com/image2.jpg"
        }
      ]
    }
  ]
}

Gambar yang Dikodekan Base64

{
  "model": "gpt-5",
  "input": [
    {
      "role": "user",
      "content": [
        {
          "type": "input_text",
          "text": "Analyze this image"
        },
        {
          "type": "input_image",
          "image_url": "data:image/jpeg;base64,/9j/4AAQSkZJRg..."
        }
      ]
    }
  ]
}
{
  "model": "gpt-5",
  "tools": [{"type": "file_search"}],
  "input": "Based on uploaded documents, summarize the company's quarterly performance"
}

Menggunakan Function Calling

{
  "model": "gpt-5",
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "get_weather",
        "description": "Get weather information for a specified city",
        "parameters": {
          "type": "object",
          "properties": {
            "city": {
              "type": "string",
              "description": "City name, e.g.: Beijing"
            },
            "unit": {
              "type": "string",
              "enum": ["celsius", "fahrenheit"],
              "description": "Temperature unit"
            }
          },
          "required": ["city"]
        }
      }
    }
  ],
  "input": "What's the weather like in Beijing today?"
}

Menggunakan Remote MCP

{
  "model": "gpt-5",
  "tools": [
    {
      "type": "remote_mcp",
      "remote_mcp": {
        "url": "https://mcp.example.com/api",
        "auth_token": "your_mcp_token"
      }
    }
  ],
  "input": "Query user information in the database"
}

Menggabungkan Beberapa Tool

{
  "model": "gpt-5",
  "tools": [
    {"type": "web_search"},
    {"type": "file_search"},
    {
      "type": "function",
      "function": {
        "name": "calculate",
        "description": "Perform mathematical calculations",
        "parameters": {
          "type": "object",
          "properties": {
            "expression": {
              "type": "string",
              "description": "Mathematical expression"
            }
          },
          "required": ["expression"]
        }
      }
    }
  ],
  "input": "Search for the latest Bitcoin price and calculate the total value of 100 Bitcoins"
}

Spesifikasi Jenis Konten

input_text

Jenis input teks Properti:
  • type: Tetap sebagai "input_text"
  • text: Konten teks (string)

input_image

Jenis input gambar Properti:
  • type: Tetap sebagai "input_image"
  • image_url: URL gambar atau data URI yang dikodekan Base64
Format gambar yang didukung:
  • JPEG
  • PNG
  • GIF
  • WebP
Batas ukuran gambar:
  • Ukuran file maksimum: 20MB
  • aspect_ratio yang disarankan: tidak lebih dari 2048x2048 piksel

Detail Penggunaan Tool

Tool web search memungkinkan model mengakses informasi internet real-time. Contoh konfigurasi:
{
  "tools": [{"type": "web_search"}]
}
Kasus penggunaan:
  • Menanyakan berita terbaru dan peristiwa terkini
  • Mendapatkan data real-time (saham, cuaca, nilai tukar, dan sebagainya)
  • Mencari dokumentasi teknis terbaru
  • Memverifikasi informasi faktual
Tool file search memungkinkan model mencari informasi relevan dalam dokumen yang diunggah. Contoh konfigurasi:
{
  "tools": [{"type": "file_search"}]
}
Kasus penggunaan:
  • Menganalisis dokumen internal perusahaan
  • Mencari spesifikasi teknis dan manual
  • Menanyakan kontrak dan dokumen hukum
  • Sistem tanya jawab basis pengetahuan

Function Calling

Definisikan fungsi kustom agar model dapat memanggil API eksternal atau menjalankan operasi tertentu. Contoh konfigurasi lengkap:
{
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "get_stock_price",
        "description": "Get real-time stock price",
        "parameters": {
          "type": "object",
          "properties": {
            "symbol": {
              "type": "string",
              "description": "Stock symbol, e.g.: AAPL"
            },
            "currency": {
              "type": "string",
              "enum": ["USD", "CNY"],
              "description": "Currency unit",
              "default": "USD"
            }
          },
          "required": ["symbol"]
        }
      }
    }
  ]
}
Deskripsi parameter:
  • name: Nama fungsi (wajib)
  • description: Deskripsi fungsi (wajib)
  • parameters: Definisi parameter menggunakan format JSON Schema
    • type: Jenis parameter
    • properties: Definisi properti parameter
    • required: Daftar parameter wajib
Kasus penggunaan:
  • Memanggil API pihak ketiga
  • Menjalankan kueri basis data
  • Memicu proses bisnis
  • Berintegrasi dengan sistem internal

Remote MCP

Terhubung ke layanan Model Context Protocol (MCP) jarak jauh untuk memperluas kemampuan model. Contoh konfigurasi:
{
  "tools": [
    {
      "type": "remote_mcp",
      "remote_mcp": {
        "url": "https://your-mcp-server.com/api",
        "auth_token": "your_auth_token",
        "timeout": 30
      }
    }
  ]
}
Deskripsi parameter:
  • url: Alamat server MCP (wajib)
  • auth_token: Token autentikasi (opsional)
  • timeout: Timeout dalam detik, default 30 detik
Kasus penggunaan:
  • Terhubung ke layanan AI tingkat enterprise
  • Menggunakan model khusus domain
  • Mengakses sumber data terlindungi
  • Integrasi sistem AI terdistribusi

Format Respons Tool

Saat model menggunakan tool, format respons akan menyertakan informasi pemanggilan tool:
{
  "id": "resp-123456",
  "object": "response",
  "created": 1677652288,
  "model": "gpt-5",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": null,
        "tool_calls": [
          {
            "id": "call_abc123",
            "type": "function",
            "function": {
              "name": "get_weather",
              "arguments": "{\"city\": \"Beijing\"}"
            }
          }
        ]
      },
      "finish_reason": "tool_calls"
    }
  ]
}
Alur kerja pemanggilan tool:
  1. Model menerima input pengguna
  2. Menganalisis apakah tool diperlukan
  3. Jika diperlukan, mengembalikan request pemanggilan tool
  4. Klien menjalankan pemanggilan tool
  5. Mengembalikan hasil tool ke model
  6. Model menghasilkan respons akhir

Catatan Penting

  1. Persyaratan URL gambar:
    • Harus berupa URL yang dapat diakses publik
    • Atau gunakan format Data URI yang dikodekan Base64
  2. Penagihan token:
    • Gambar mengonsumsi token berdasarkan aspect_ratio
    • Gambar dengan aspect_ratio tinggi akan diubah ukurannya secara otomatis untuk mengoptimalkan biaya
    • Pemanggilan tool juga mengonsumsi token tambahan
  3. Urutan konten:
    • Urutan elemen dalam array konten memengaruhi pemahaman model
    • Disarankan menempatkan instruksi teks terlebih dahulu, lalu gambar
  4. Kombinasi multimodal:
    • Dapat mencampur beberapa teks dan gambar dalam satu request
    • Mendukung percakapan multi-giliran dengan koherensi konteks
  5. Batasan penggunaan tool:
    • Saat beberapa tool digunakan sekaligus, model akan memilih tool yang paling sesuai secara cerdas
    • Function calling memerlukan definisi fungsi dan deskripsi parameter yang jelas
    • Hasil web search dapat dibatasi oleh wilayah dan waktu
  6. Kompatibilitas API:
    • Sepenuhnya kompatibel dengan format OpenAI Responses API
    • Memigrasikan kode OpenAI yang sudah ada dengan lancar
    • Mendukung semua fitur ekstensi tool OpenAI