OpenAI Multimodal Responses API
Fully compatible with OpenAI Responses API format
Tutta la documentazione/v1/responses- Supports multimodal input with text and images
- Supports tool extensions: web search, file search, function calling, remote MCP
Esempi di richieste
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:
Authorization: Bearer YOUR_API_KEYBody
modelstringrequireddefault: gpt-5.2-proModel name
Supported models include:
gpt-5.2-progpt-5.2-codexqwen3.8-max- More models coming soon...
inputarrayrequiredInput content list
Input array, each item contains role and content fields.
💡 Quick fill (Try it area):
- Click "+ Add an item" to add an input item
roleinput:user(user message),assistant(AI response), orsystem(system prompt)contentadd content blocks (can include text and images)
Field details
rolestringrequireddefault: userRole type
Options: user (user message), assistant (AI response, for multi-turn), system (system prompt, to set AI behavior)
contentarrayrequiredContent array
Supports multiple types of content blocks, can include text and images.
Content block types
typestringrequiredContent type
Options:
input_text: Text inputinput_image: Image input
textstringText content
Used when type is input_text, fill in the text content
prompt_cache_breakpointobjectMark 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_urlstringImage 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_optionsobjectOpenAI 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: 30m30m: a minimum lifetime of 30 minutes, the default. 12h: a minimum lifetime of 12 hours.
modestringdefault: implicitimplicit: 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.
temperaturenumberControls 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_tokensintegerMaximum number of tokens to generate
Different models have different maximum limits, please refer to specific model documentation
streambooleanWhether to use streaming output
true: Stream response (SSE format)false: Return complete response at once
Default: false
top_pnumberNucleus sampling parameter, range 0-1
Controls diversity of generated text, recommended to use with temperature alternatively
Default: 1.0
toolsarrayTools 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.
idstringUnique identifier for the response
objectstringObject type, fixed as response
created_atintegerCreation timestamp
modelstringActual model name used
statusstringResponse status, such as completed, incomplete, or failed.
outputarrayAn 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
typestringOutput item type, such as message, reasoning, or function_call.
contentarrayContent blocks of a message item. Text blocks contain type: "output_text" and text. Parse other output items according to their own type.
usageobjectToken usage statistics
Properties
input_tokensintegerTotal input tokens, including ordinary input, cache reads, and cache writes.
input_tokens_detailsobjectInput 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_tokensintegerTokens read from the cache, already included in input_tokens.
cache_write_tokensintegerTotal 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_detailsobjectCache-write tokens split by TTL. The two counts do not overlap.
Properties
ttl_30m_tokensintegerTokens written with a 30-minute TTL.
ttl_12h_tokensintegerTokens written with a 12-hour TTL.
output_tokensintegerTotal output tokens.
total_tokensintegerTotal 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.
{
"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:
input_tokens - input_tokens_details.cached_tokens - input_tokens_details.cache_write_tokenscache_write_tokens = ttl_30m_tokens + ttl_12h_tokens
total_tokens = input_tokens + output_tokensCache 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
{
"model": "gpt-5.2-pro",
"input": [
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "Hello, introduce artificial intelligence"
}
]
}
]
}Using Web Search Tool
{
"model": "gpt-5.2-pro",
"tools": [{"type": "web_search"}],
"input": "What positive news is there today?"
}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
{
"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
{
"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
{
"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
{
"model": "gpt-5.2-pro",
"tools": [{"type": "file_search"}],
"input": "Based on uploaded documents, summarize the company's quarterly performance"
}Using Function Calling
{
"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
{
"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
{
"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
Web Search
The web search tool allows the model to access real-time internet information.
Configuration example:
{
"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
File Search
The file search tool allows the model to search for relevant information in uploaded documents.
Configuration example:
{
"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:
{
"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 formattype: Parameter typeproperties: Parameter property definitionsrequired: 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:
{
"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:
{
"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:
- Model receives user input
- Analyzes whether tools are needed
- If needed, returns tool call request
- Client executes tool call
- Returns tool results to model
- Model generates final response
Important Notes
Image URL requirements:
- Must be a publicly accessible URL
- Or use Base64 encoded Data URI format
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
Content order:
- Order of elements in content array affects model understanding
- Recommended to place text instructions first, then images
Multimodal combinations:
- Can mix multiple texts and images in one request
- Supports multi-turn conversations with context coherence
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
API compatibility:
- Fully compatible with OpenAI Responses API format
- Seamlessly migrate existing OpenAI code
- Supports all OpenAI tool extension features
Risposte
{
"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
}
}Modelli che usano questo endpoint
qwen3.8-max
gpt-4.1
gpt-4.1-2025-04-14
gpt-4.1-mini
gpt-4.1-mini-2025-04-14
GPT-4o
gpt-4ogpt-4o-2024-11-20
GPT-4o Mini
gpt-4o-minigpt-5
gpt-5-2025-08-07
gpt-5-mini
gpt-5-mini-2025-08-07
Hai trovato un problema in questa documentazione? Scrivi a support@apisea.ai.