Skip to content
Cette page n’est pas encore disponible dans votre langue ; elle s’affiche donc en anglais.

OpenAI Multimodal Responses API

Fully compatible with OpenAI Responses API format

Toute la documentation
POST/v1/responses
  • Supports multimodal input with text and images
  • Supports tool extensions: web search, file search, function calling, remote MCP

Exemples de requêtes

curl https://api.apisea.ai/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <token>" \
  -d '{
    "model": "gpt-5.2-pro",
    "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"
          }
        ]
      }
    ]
  }'

Authorizations

Authorizationstringrequired

##All APIs require Bearer Token authentication##

Get API Key:

Visit the API Key Management Page to get your API Key

Add to request header:

text
Authorization: Bearer YOUR_API_KEY

Body

modelstringrequireddefault: gpt-5.2-pro

Model name

Supported models include:

  • gpt-5.2-pro
  • gpt-5.2-codex
  • qwen3.8-max
  • More models coming soon...
inputarrayrequired

Input content list

Input array, each item contains role and content fields.

💡 Quick fill (Try it area):

  1. Click "+ Add an item" to add an input item
  2. role input: user (user message), assistant (AI response), or system (system prompt)
  3. content add content blocks (can include text and images)

Field details

rolestringrequireddefault: user

Role type

Options: user (user message), assistant (AI response, for multi-turn), system (system prompt, to set AI behavior)

contentarrayrequired

Content array

Supports multiple types of content blocks, can include text and images.

Content block types

typestringrequired

Content type

Options:

  • input_text: Text input
  • input_image: Image input
textstring

Text content

Used when type is input_text, fill in the text content

prompt_cache_breakpointobject

Mark the end of a reusable input_text block with {"mode": "explicit"}. Without a separate breakpoint TTL, it inherits prompt_cache_options.ttl. The cacheable prefix must contain at least 1,024 tokens.

image_urlstring

Image URL

Used when type is input_image, fill in the image URL or base64 encoding

Supports two formats:

1. Full image URL

  • Publicly accessible image URL (http:// or https://)
  • Example: https://example.com/image.jpg

2. Base64 encoded format

  • Must use the complete Data URI format
  • Format: data:image/{format};base64,{base64_data}
  • Supported image formats: jpeg, png, gif, webp
prompt_cache_optionsobject

OpenAI prompt cache options for GPT-5.6 and later models that support this feature. 12-hour caching is available only through the Responses API.

Cache options

ttlstringdefault: 30m

30m: a minimum lifetime of 30 minutes, the default. 12h: a minimum lifetime of 12 hours.

modestringdefault: implicit

implicit: automatically select cache breakpoints, the default. explicit: use only prompt_cache_breakpoint markers on content blocks; without a marker, no cache reads or writes occur.

For complete requests, see the OpenAI Context Caching Guide.

temperaturenumber

Controls output randomness, range 0-2

  • Lower values (e.g. 0.2) make output more deterministic
  • Higher values (e.g. 1.8) make output more random

Default: 1.0

max_tokensinteger

Maximum number of tokens to generate

Different models have different maximum limits, please refer to specific model documentation

streamboolean

Whether to use streaming output

  • true: Stream response (SSE format)
  • false: Return complete response at once

Default: false

top_pnumber

Nucleus sampling parameter, range 0-1

Controls diversity of generated text, recommended to use with temperature alternatively

Default: 1.0

toolsarray

Tools list for extending model capabilities

Supported tool types:

  • Web Search (web_search): Real-time internet information search
  • File Search (file_search): Search uploaded file content
  • Function Calling (function): Call custom functions
  • Remote MCP (remote_mcp): Connect to remote Model Context Protocol services

Example: [{"type": "web_search"}]

Response

A non-streaming request returns a Response object directly. The main fields are listed below; examples omit unrelated fields. Read generated content from output and usage from the top-level usage object.

idstring

Unique identifier for the response

objectstring

Object type, fixed as response

created_atinteger

Creation timestamp

modelstring

Actual model name used

statusstring

Response status, such as completed, incomplete, or failed.

outputarray

An array of output items that can include messages, reasoning, and tool calls. To read text, select items with type: "message", then read text from their content blocks with type: "output_text". Do not assume the first output item contains text.

Properties

typestring

Output item type, such as message, reasoning, or function_call.

contentarray

Content blocks of a message item. Text blocks contain type: "output_text" and text. Parse other output items according to their own type.

usageobject

Token usage statistics

Properties

input_tokensinteger

Total input tokens, including ordinary input, cache reads, and cache writes.

input_tokens_detailsobject

Input token details. Cache-write and TTL breakdown fields apply to GPT-5.6 and later models that support this feature. Parse the fields available in the actual response.

Properties

cached_tokensinteger

Tokens read from the cache, already included in input_tokens.

cache_write_tokensinteger

Total cache-write tokens, already included in input_tokens. When the TTL breakdown is available, this equals the sum of both write counts.

cache_write_tokens_detailsobject

Cache-write tokens split by TTL. The two counts do not overlap.

Properties

ttl_30m_tokensinteger

Tokens written with a 30-minute TTL.

ttl_12h_tokensinteger

Tokens written with a 12-hour TTL.

output_tokensinteger

Total output tokens.

total_tokensinteger

Total tokens, equal to input_tokens + output_tokens.

Cache usage example and token counting

This response excerpt shows only usage for an OpenAI model that supports caching, with writes at both TTLs. Actual counts depend on the response.

json
{
  "usage": {
    "input_tokens": 12000,
    "input_tokens_details": {
      "cached_tokens": 4000,
      "cache_write_tokens": 7000,
      "cache_write_tokens_details": {
        "ttl_30m_tokens": 5000,
        "ttl_12h_tokens": 2000
      }
    },
    "output_tokens": 1000,
    "total_tokens": 13000
  }
}

Ordinary input tokens:

text
input_tokens - input_tokens_details.cached_tokens - input_tokens_details.cache_write_tokens
text
cache_write_tokens = ttl_30m_tokens + ttl_12h_tokens
total_tokens = input_tokens + output_tokens

Cache reads and writes are already included in input_tokens. The two TTL counts are components of cache_write_tokens: do not add the total and its components again, or add cache reads and writes to total input.

Here, ordinary input is 12000 - 4000 - 7000 = 1000, writes are 5000 + 2000 = 7000, and total tokens are 12000 + 1000 = 13000.

Usage Examples

Text-Only Input

json
{
  "model": "gpt-5.2-pro",
  "input": [
    {
      "role": "user",
      "content": [
        {
          "type": "input_text",
          "text": "Hello, introduce artificial intelligence"
        }
      ]
    }
  ]
}

Using Web Search Tool

json
{
  "model": "gpt-5.2-pro",
  "tools": [{"type": "web_search"}],
  "input": "What positive news is there today?"
}
cURL Example
curl "https://api.apisea.ai/v1/responses" \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer <token>" \
    -d '{
        "model": "gpt-5.2-pro",
        "tools": [{"type": "web_search"}],
        "input": "What positive news is there today?"
    }'

Image Understanding

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

Multi-Image Analysis

json
{
  "model": "gpt-5.2-pro",
  "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"
        }
      ]
    }
  ]
}

Base64 Encoded Image

json
{
  "model": "gpt-5.2-pro",
  "input": [
    {
      "role": "user",
      "content": [
        {
          "type": "input_text",
          "text": "Analyze this image"
        },
        {
          "type": "input_image",
          "image_url": "data:image/jpeg;base64,/9j/4AAQSkZJRg..."
        }
      ]
    }
  ]
}

Using File Search Tool

json
{
  "model": "gpt-5.2-pro",
  "tools": [{"type": "file_search"}],
  "input": "Based on uploaded documents, summarize the company's quarterly performance"
}

Using Function Calling

json
{
  "model": "gpt-5.2-pro",
  "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?"
}

Using Remote MCP

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

Combining Multiple Tools

json
{
  "model": "gpt-5.2-pro",
  "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"
}

Content Type Specifications

input_text

Text input type

Properties:

  • type: Fixed as "input_text"
  • text: Text content (string)

input_image

Image input type

Properties:

  • type: Fixed as "input_image"
  • image_url: Image URL or Base64 encoded data URI

Supported image formats:

  • JPEG
  • PNG
  • GIF
  • WebP

Image size limits:

  • Maximum file size: 20MB
  • Recommended aspect_ratio: No more than 2048x2048 pixels

Tool Usage Details

The web search tool allows the model to access real-time internet information.

Configuration example:

json
{
  "tools": [{"type": "web_search"}]
}

Use cases:

  • Query latest news and current events
  • Get real-time data (stocks, weather, exchange rates, etc.)
  • Search for latest technical documentation
  • Verify factual information

The file search tool allows the model to search for relevant information in uploaded documents.

Configuration example:

json
{
  "tools": [{"type": "file_search"}]
}

Use cases:

  • Analyze internal corporate documents
  • Search technical specifications and manuals
  • Query contracts and legal documents
  • Knowledge base Q&A systems

Function Calling

Define custom functions to enable the model to call external APIs or perform specific operations.

Complete configuration example:

json
{
  "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"]
        }
      }
    }
  ]
}

Parameter descriptions:

  • name: Function name (required)
  • description: Function description (required)
  • parameters: Parameter definition using JSON Schema format
    • type: Parameter type
    • properties: Parameter property definitions
    • required: List of required parameters

Use cases:

  • Call third-party APIs
  • Execute database queries
  • Trigger business processes
  • Integrate with internal systems

Remote MCP

Connect to remote Model Context Protocol (MCP) services to extend model capabilities.

Configuration example:

json
{
  "tools": [
    {
      "type": "remote_mcp",
      "remote_mcp": {
        "url": "https://your-mcp-server.com/api",
        "auth_token": "your_auth_token",
        "timeout": 30
      }
    }
  ]
}

Parameter descriptions:

  • url: MCP server address (required)
  • auth_token: Authentication token (optional)
  • timeout: Timeout in seconds, default 30 seconds

Use cases:

  • Connect to enterprise-level AI services
  • Use domain-specific models
  • Access protected data sources
  • Distributed AI system integration

Tool Response Format

When the model uses tools, the response format will include tool call information:

json
{
  "id": "resp-123456",
  "object": "response",
  "created_at": 1677652288,
  "status": "completed",
  "model": "gpt-5.2-pro",
  "output": [
    {
      "id": "fc_abc123",
      "type": "function_call",
      "status": "completed",
      "call_id": "call_abc123",
      "name": "get_weather",
      "arguments": "{\"city\": \"Beijing\"}"
    }
  ]
}

Function calls are returned as function_call items in output. After execution, send the result in a function_call_output input item, using the same call_id to associate it with the call.

Tool call workflow:

  1. Model receives user input
  2. Analyzes whether tools are needed
  3. If needed, returns tool call request
  4. Client executes tool call
  5. Returns tool results to model
  6. Model generates final response

Important Notes

  1. Image URL requirements:

    • Must be a publicly accessible URL
    • Or use Base64 encoded Data URI format
  2. Token billing:

    • Images consume tokens based on their aspect_ratio
    • High-aspect_ratio images are automatically resized to optimize costs
    • Tool calls also consume additional tokens
  3. Content order:

    • Order of elements in content array affects model understanding
    • Recommended to place text instructions first, then images
  4. Multimodal combinations:

    • Can mix multiple texts and images in one request
    • Supports multi-turn conversations with context coherence
  5. Tool usage limitations:

    • When using multiple tools simultaneously, the model intelligently selects the most appropriate tool
    • Function calling requires clear function definitions and parameter descriptions
    • Web search results may be limited by region and time
  6. API compatibility:

    • Fully compatible with OpenAI Responses API format
    • Seamlessly migrate existing OpenAI code
    • Supports all OpenAI tool extension features

Réponses

{
  "id": "resp-9876543210",
  "object": "response",
  "created_at": 1677652288,
  "status": "completed",
  "model": "gpt-5.2-pro",
  "output": [
    {
      "id": "msg_9876543210",
      "type": "message",
      "status": "completed",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "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.",
          "annotations": []
        }
      ]
    }
  ],
  "usage": {
    "input_tokens": 156,
    "input_tokens_details": {
      "cached_tokens": 0
    },
    "output_tokens": 45,
    "total_tokens": 201
  }
}

Vous avez repéré un problème dans cette documentation ? Écrivez à support@apisea.ai.