curl https://api.apimart.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"
}
]
}
]
}'
import requests
import os
url = "https://api.apimart.ai/v1/responses"
payload = {
"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"
}
]
}
]
}
headers = {
"Authorization": f"Bearer {os.environ.get('OPENAI_API_KEY')}",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const url = "https://api.apimart.ai/v1/responses";
const payload = {
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"
}
]
}
]
};
const headers = {
"Authorization": `Bearer ${process.env.OPENAI_API_KEY}`,
"Content-Type": "application/json"
};
fetch(url, {
method: "POST",
headers: headers,
body: JSON.stringify(payload)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
)
func main() {
url := "https://api.apimart.ai/v1/responses"
payload := map[string]interface{}{
"model": "gpt-5.2-pro",
"input": []map[string]interface{}{
{
"role": "user",
"content": []map[string]string{
{
"type": "input_text",
"text": "What is in this image?",
},
{
"type": "input_image",
"image_url": "https://openai-documentation.vercel.app/images/cat_and_otter.png",
},
},
},
},
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer "+os.Getenv("OPENAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
}
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
String url = "https://api.apimart.ai/v1/responses";
String apiKey = System.getenv("OPENAI_API_KEY");
String payload = """
{
"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"
}
]
}
]
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
<?php
$url = "https://api.apimart.ai/v1/responses";
$apiKey = getenv('OPENAI_API_KEY');
$payload = [
"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"
]
]
]
]
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . $apiKey,
"Content-Type: application/json"
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
require 'net/http'
require 'json'
require 'uri'
url = URI("https://api.apimart.ai/v1/responses")
api_key = ENV['OPENAI_API_KEY']
payload = {
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"
}
]
}
]
}
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer #{api_key}"
request["Content-Type"] = "application/json"
request.body = payload.to_json
response = http.request(request)
puts response.body
import Foundation
let url = URL(string: "https://api.apimart.ai/v1/responses")!
let apiKey = ProcessInfo.processInfo.environment["OPENAI_API_KEY"] ?? ""
let payload: [String: Any] = [
"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"
]
]
]
]
]
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer \(apiKey)", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let error = error {
print("Error: \(error)")
return
}
if let data = data, let responseString = String(data: data, encoding: .utf8) {
print(responseString)
}
}
task.resume()
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
var url = "https://api.apimart.ai/v1/responses";
var apiKey = Environment.GetEnvironmentVariable("OPENAI_API_KEY");
var payload = @"{
""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""
}
]
}
]
}";
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}");
var content = new StringContent(payload, Encoding.UTF8, "application/json");
var response = await client.PostAsync(url, content);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
#include <stdio.h>
#include <curl/curl.h>
#include <stdlib.h>
int main(void) {
CURL *curl;
CURLcode res;
const char *api_key = getenv("OPENAI_API_KEY");
curl_global_init(CURL_GLOBAL_DEFAULT);
curl = curl_easy_init();
if(curl) {
const char *url = "https://api.apimart.ai/v1/responses";
const char *payload = "{"
"\"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\"}]}]"
"}";
char auth_header[256];
snprintf(auth_header, sizeof(auth_header), "Authorization: Bearer %s", api_key);
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, auth_header);
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, payload);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
res = curl_easy_perform(curl);
if(res != CURLE_OK) {
fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(res));
}
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
}
curl_global_cleanup();
return 0;
}
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSURL *url = [NSURL URLWithString:@"https://api.apimart.ai/v1/responses"];
NSString *apiKey = [NSProcessInfo processInfo].environment[@"OPENAI_API_KEY"];
NSDictionary *payload = @{
@"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"
}
]
}
]
};
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:payload
options:0
error:&error];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:[NSString stringWithFormat:@"Bearer %@", apiKey]
forHTTPHeaderField:@"Authorization"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:jsonData];
NSURLSessionDataTask *task = [[NSURLSession sharedSession]
dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"Error: %@", error);
return;
}
NSString *result = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
NSLog(@"%@", result);
}];
[task resume];
[[NSRunLoop mainRunLoop] run];
}
return 0;
}
(* Requires cohttp and yojson libraries *)
open Lwt
open Cohttp
open Cohttp_lwt_unix
let url = "https://api.apimart.ai/v1/responses"
let api_key = Sys.getenv "OPENAI_API_KEY"
let payload = {|{
"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"
}
]
}
]
}|}
let () =
let headers = Header.init ()
|> fun h -> Header.add h "Authorization" ("Bearer " ^ api_key)
|> fun h -> Header.add h "Content-Type" "application/json"
in
let body = Cohttp_lwt.Body.of_string payload in
let response = Client.post ~headers ~body (Uri.of_string url) >>= fun (resp, body) ->
body |> Cohttp_lwt.Body.to_string >|= fun body_str ->
print_endline body_str
in
Lwt_main.run response
import 'dart:convert';
import 'dart:io';
import 'package:http/http.dart' as http;
void main() async {
final url = Uri.parse('https://api.apimart.ai/v1/responses');
final apiKey = Platform.environment['OPENAI_API_KEY'];
final payload = {
'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'
}
]
}
]
};
final response = await http.post(
url,
headers: {
'Authorization': 'Bearer $apiKey',
'Content-Type': 'application/json',
},
body: jsonEncode(payload),
);
print(response.body);
}
library(httr)
library(jsonlite)
url <- "https://api.apimart.ai/v1/responses"
api_key <- Sys.getenv("OPENAI_API_KEY")
payload <- list(
model = "gpt-5.2-pro",
input = list(
list(
role = "user",
content = list(
list(
type = "input_text",
text = "What is in this image?"
),
list(
type = "input_image",
image_url = "https://openai-documentation.vercel.app/images/cat_and_otter.png"
)
)
)
)
)
response <- POST(
url,
add_headers(
Authorization = paste("Bearer", api_key),
`Content-Type` = "application/json"
),
body = toJSON(payload, auto_unbox = TRUE),
encode = "raw"
)
cat(content(response, "text"))
{
"code": 200,
"data": {
"id": "resp-9876543210",
"object": "response",
"created": 1677652288,
"model": "gpt-5.2-pro",
"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
}
}
}
{
"error": {
"code": 400,
"message": "Invalid request parameters",
"type": "invalid_request_error"
}
}
{
"error": {
"code": 401,
"message": "Authentication failed, please check your API key",
"type": "authentication_error"
}
}
{
"error": {
"code": 402,
"message": "Insufficient account balance, please top up and try again",
"type": "payment_required"
}
}
{
"error": {
"code": 403,
"message": "Access forbidden, you do not have permission to access this resource",
"type": "permission_error"
}
}
{
"error": {
"code": 429,
"message": "Too many requests, please try again later",
"type": "rate_limit_error"
}
}
{
"error": {
"code": 500,
"message": "Internal server error, please try again later",
"type": "server_error"
}
}
{
"error": {
"code": 502,
"message": "Gateway error, server temporarily unavailable",
"type": "bad_gateway"
}
}
Serie de texto
API multimodal OpenAI Responses
- Totalmente compatible con el formato de la API OpenAI Responses
- Admite entrada multimodal con texto e imágenes
- Admite extensiones de herramientas: búsqueda web, búsqueda en archivos, llamadas a funciones, MCP remoto
POST
/
v1
/
responses
curl https://api.apimart.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"
}
]
}
]
}'
import requests
import os
url = "https://api.apimart.ai/v1/responses"
payload = {
"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"
}
]
}
]
}
headers = {
"Authorization": f"Bearer {os.environ.get('OPENAI_API_KEY')}",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const url = "https://api.apimart.ai/v1/responses";
const payload = {
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"
}
]
}
]
};
const headers = {
"Authorization": `Bearer ${process.env.OPENAI_API_KEY}`,
"Content-Type": "application/json"
};
fetch(url, {
method: "POST",
headers: headers,
body: JSON.stringify(payload)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
)
func main() {
url := "https://api.apimart.ai/v1/responses"
payload := map[string]interface{}{
"model": "gpt-5.2-pro",
"input": []map[string]interface{}{
{
"role": "user",
"content": []map[string]string{
{
"type": "input_text",
"text": "What is in this image?",
},
{
"type": "input_image",
"image_url": "https://openai-documentation.vercel.app/images/cat_and_otter.png",
},
},
},
},
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer "+os.Getenv("OPENAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
}
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
String url = "https://api.apimart.ai/v1/responses";
String apiKey = System.getenv("OPENAI_API_KEY");
String payload = """
{
"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"
}
]
}
]
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
<?php
$url = "https://api.apimart.ai/v1/responses";
$apiKey = getenv('OPENAI_API_KEY');
$payload = [
"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"
]
]
]
]
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . $apiKey,
"Content-Type: application/json"
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
require 'net/http'
require 'json'
require 'uri'
url = URI("https://api.apimart.ai/v1/responses")
api_key = ENV['OPENAI_API_KEY']
payload = {
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"
}
]
}
]
}
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer #{api_key}"
request["Content-Type"] = "application/json"
request.body = payload.to_json
response = http.request(request)
puts response.body
import Foundation
let url = URL(string: "https://api.apimart.ai/v1/responses")!
let apiKey = ProcessInfo.processInfo.environment["OPENAI_API_KEY"] ?? ""
let payload: [String: Any] = [
"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"
]
]
]
]
]
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer \(apiKey)", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let error = error {
print("Error: \(error)")
return
}
if let data = data, let responseString = String(data: data, encoding: .utf8) {
print(responseString)
}
}
task.resume()
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
var url = "https://api.apimart.ai/v1/responses";
var apiKey = Environment.GetEnvironmentVariable("OPENAI_API_KEY");
var payload = @"{
""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""
}
]
}
]
}";
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}");
var content = new StringContent(payload, Encoding.UTF8, "application/json");
var response = await client.PostAsync(url, content);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
#include <stdio.h>
#include <curl/curl.h>
#include <stdlib.h>
int main(void) {
CURL *curl;
CURLcode res;
const char *api_key = getenv("OPENAI_API_KEY");
curl_global_init(CURL_GLOBAL_DEFAULT);
curl = curl_easy_init();
if(curl) {
const char *url = "https://api.apimart.ai/v1/responses";
const char *payload = "{"
"\"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\"}]}]"
"}";
char auth_header[256];
snprintf(auth_header, sizeof(auth_header), "Authorization: Bearer %s", api_key);
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, auth_header);
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, payload);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
res = curl_easy_perform(curl);
if(res != CURLE_OK) {
fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(res));
}
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
}
curl_global_cleanup();
return 0;
}
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSURL *url = [NSURL URLWithString:@"https://api.apimart.ai/v1/responses"];
NSString *apiKey = [NSProcessInfo processInfo].environment[@"OPENAI_API_KEY"];
NSDictionary *payload = @{
@"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"
}
]
}
]
};
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:payload
options:0
error:&error];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:[NSString stringWithFormat:@"Bearer %@", apiKey]
forHTTPHeaderField:@"Authorization"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:jsonData];
NSURLSessionDataTask *task = [[NSURLSession sharedSession]
dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"Error: %@", error);
return;
}
NSString *result = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
NSLog(@"%@", result);
}];
[task resume];
[[NSRunLoop mainRunLoop] run];
}
return 0;
}
(* Requires cohttp and yojson libraries *)
open Lwt
open Cohttp
open Cohttp_lwt_unix
let url = "https://api.apimart.ai/v1/responses"
let api_key = Sys.getenv "OPENAI_API_KEY"
let payload = {|{
"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"
}
]
}
]
}|}
let () =
let headers = Header.init ()
|> fun h -> Header.add h "Authorization" ("Bearer " ^ api_key)
|> fun h -> Header.add h "Content-Type" "application/json"
in
let body = Cohttp_lwt.Body.of_string payload in
let response = Client.post ~headers ~body (Uri.of_string url) >>= fun (resp, body) ->
body |> Cohttp_lwt.Body.to_string >|= fun body_str ->
print_endline body_str
in
Lwt_main.run response
import 'dart:convert';
import 'dart:io';
import 'package:http/http.dart' as http;
void main() async {
final url = Uri.parse('https://api.apimart.ai/v1/responses');
final apiKey = Platform.environment['OPENAI_API_KEY'];
final payload = {
'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'
}
]
}
]
};
final response = await http.post(
url,
headers: {
'Authorization': 'Bearer $apiKey',
'Content-Type': 'application/json',
},
body: jsonEncode(payload),
);
print(response.body);
}
library(httr)
library(jsonlite)
url <- "https://api.apimart.ai/v1/responses"
api_key <- Sys.getenv("OPENAI_API_KEY")
payload <- list(
model = "gpt-5.2-pro",
input = list(
list(
role = "user",
content = list(
list(
type = "input_text",
text = "What is in this image?"
),
list(
type = "input_image",
image_url = "https://openai-documentation.vercel.app/images/cat_and_otter.png"
)
)
)
)
)
response <- POST(
url,
add_headers(
Authorization = paste("Bearer", api_key),
`Content-Type` = "application/json"
),
body = toJSON(payload, auto_unbox = TRUE),
encode = "raw"
)
cat(content(response, "text"))
{
"code": 200,
"data": {
"id": "resp-9876543210",
"object": "response",
"created": 1677652288,
"model": "gpt-5.2-pro",
"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
}
}
}
{
"error": {
"code": 400,
"message": "Invalid request parameters",
"type": "invalid_request_error"
}
}
{
"error": {
"code": 401,
"message": "Authentication failed, please check your API key",
"type": "authentication_error"
}
}
{
"error": {
"code": 402,
"message": "Insufficient account balance, please top up and try again",
"type": "payment_required"
}
}
{
"error": {
"code": 403,
"message": "Access forbidden, you do not have permission to access this resource",
"type": "permission_error"
}
}
{
"error": {
"code": 429,
"message": "Too many requests, please try again later",
"type": "rate_limit_error"
}
}
{
"error": {
"code": 500,
"message": "Internal server error, please try again later",
"type": "server_error"
}
}
{
"error": {
"code": 502,
"message": "Gateway error, server temporarily unavailable",
"type": "bad_gateway"
}
}
curl https://api.apimart.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"
}
]
}
]
}'
import requests
import os
url = "https://api.apimart.ai/v1/responses"
payload = {
"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"
}
]
}
]
}
headers = {
"Authorization": f"Bearer {os.environ.get('OPENAI_API_KEY')}",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const url = "https://api.apimart.ai/v1/responses";
const payload = {
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"
}
]
}
]
};
const headers = {
"Authorization": `Bearer ${process.env.OPENAI_API_KEY}`,
"Content-Type": "application/json"
};
fetch(url, {
method: "POST",
headers: headers,
body: JSON.stringify(payload)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
)
func main() {
url := "https://api.apimart.ai/v1/responses"
payload := map[string]interface{}{
"model": "gpt-5.2-pro",
"input": []map[string]interface{}{
{
"role": "user",
"content": []map[string]string{
{
"type": "input_text",
"text": "What is in this image?",
},
{
"type": "input_image",
"image_url": "https://openai-documentation.vercel.app/images/cat_and_otter.png",
},
},
},
},
}
jsonData, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer "+os.Getenv("OPENAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
}
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class Main {
public static void main(String[] args) throws Exception {
String url = "https://api.apimart.ai/v1/responses";
String apiKey = System.getenv("OPENAI_API_KEY");
String payload = """
{
"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"
}
]
}
]
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(payload))
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
<?php
$url = "https://api.apimart.ai/v1/responses";
$apiKey = getenv('OPENAI_API_KEY');
$payload = [
"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"
]
]
]
]
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . $apiKey,
"Content-Type: application/json"
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
require 'net/http'
require 'json'
require 'uri'
url = URI("https://api.apimart.ai/v1/responses")
api_key = ENV['OPENAI_API_KEY']
payload = {
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"
}
]
}
]
}
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer #{api_key}"
request["Content-Type"] = "application/json"
request.body = payload.to_json
response = http.request(request)
puts response.body
import Foundation
let url = URL(string: "https://api.apimart.ai/v1/responses")!
let apiKey = ProcessInfo.processInfo.environment["OPENAI_API_KEY"] ?? ""
let payload: [String: Any] = [
"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"
]
]
]
]
]
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer \(apiKey)", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let error = error {
print("Error: \(error)")
return
}
if let data = data, let responseString = String(data: data, encoding: .utf8) {
print(responseString)
}
}
task.resume()
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
var url = "https://api.apimart.ai/v1/responses";
var apiKey = Environment.GetEnvironmentVariable("OPENAI_API_KEY");
var payload = @"{
""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""
}
]
}
]
}";
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}");
var content = new StringContent(payload, Encoding.UTF8, "application/json");
var response = await client.PostAsync(url, content);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
#include <stdio.h>
#include <curl/curl.h>
#include <stdlib.h>
int main(void) {
CURL *curl;
CURLcode res;
const char *api_key = getenv("OPENAI_API_KEY");
curl_global_init(CURL_GLOBAL_DEFAULT);
curl = curl_easy_init();
if(curl) {
const char *url = "https://api.apimart.ai/v1/responses";
const char *payload = "{"
"\"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\"}]}]"
"}";
char auth_header[256];
snprintf(auth_header, sizeof(auth_header), "Authorization: Bearer %s", api_key);
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, auth_header);
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, payload);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
res = curl_easy_perform(curl);
if(res != CURLE_OK) {
fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(res));
}
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
}
curl_global_cleanup();
return 0;
}
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSURL *url = [NSURL URLWithString:@"https://api.apimart.ai/v1/responses"];
NSString *apiKey = [NSProcessInfo processInfo].environment[@"OPENAI_API_KEY"];
NSDictionary *payload = @{
@"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"
}
]
}
]
};
NSError *error;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:payload
options:0
error:&error];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:[NSString stringWithFormat:@"Bearer %@", apiKey]
forHTTPHeaderField:@"Authorization"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:jsonData];
NSURLSessionDataTask *task = [[NSURLSession sharedSession]
dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"Error: %@", error);
return;
}
NSString *result = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
NSLog(@"%@", result);
}];
[task resume];
[[NSRunLoop mainRunLoop] run];
}
return 0;
}
(* Requires cohttp and yojson libraries *)
open Lwt
open Cohttp
open Cohttp_lwt_unix
let url = "https://api.apimart.ai/v1/responses"
let api_key = Sys.getenv "OPENAI_API_KEY"
let payload = {|{
"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"
}
]
}
]
}|}
let () =
let headers = Header.init ()
|> fun h -> Header.add h "Authorization" ("Bearer " ^ api_key)
|> fun h -> Header.add h "Content-Type" "application/json"
in
let body = Cohttp_lwt.Body.of_string payload in
let response = Client.post ~headers ~body (Uri.of_string url) >>= fun (resp, body) ->
body |> Cohttp_lwt.Body.to_string >|= fun body_str ->
print_endline body_str
in
Lwt_main.run response
import 'dart:convert';
import 'dart:io';
import 'package:http/http.dart' as http;
void main() async {
final url = Uri.parse('https://api.apimart.ai/v1/responses');
final apiKey = Platform.environment['OPENAI_API_KEY'];
final payload = {
'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'
}
]
}
]
};
final response = await http.post(
url,
headers: {
'Authorization': 'Bearer $apiKey',
'Content-Type': 'application/json',
},
body: jsonEncode(payload),
);
print(response.body);
}
library(httr)
library(jsonlite)
url <- "https://api.apimart.ai/v1/responses"
api_key <- Sys.getenv("OPENAI_API_KEY")
payload <- list(
model = "gpt-5.2-pro",
input = list(
list(
role = "user",
content = list(
list(
type = "input_text",
text = "What is in this image?"
),
list(
type = "input_image",
image_url = "https://openai-documentation.vercel.app/images/cat_and_otter.png"
)
)
)
)
)
response <- POST(
url,
add_headers(
Authorization = paste("Bearer", api_key),
`Content-Type` = "application/json"
),
body = toJSON(payload, auto_unbox = TRUE),
encode = "raw"
)
cat(content(response, "text"))
{
"code": 200,
"data": {
"id": "resp-9876543210",
"object": "response",
"created": 1677652288,
"model": "gpt-5.2-pro",
"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
}
}
}
{
"error": {
"code": 400,
"message": "Invalid request parameters",
"type": "invalid_request_error"
}
}
{
"error": {
"code": 401,
"message": "Authentication failed, please check your API key",
"type": "authentication_error"
}
}
{
"error": {
"code": 402,
"message": "Insufficient account balance, please top up and try again",
"type": "payment_required"
}
}
{
"error": {
"code": 403,
"message": "Access forbidden, you do not have permission to access this resource",
"type": "permission_error"
}
}
{
"error": {
"code": 429,
"message": "Too many requests, please try again later",
"type": "rate_limit_error"
}
}
{
"error": {
"code": 500,
"message": "Internal server error, please try again later",
"type": "server_error"
}
}
{
"error": {
"code": 502,
"message": "Gateway error, server temporarily unavailable",
"type": "bad_gateway"
}
}
Autorizaciones
##Todas las APIs requieren autenticación mediante Bearer Token##Obtener API Key:Visite la página de gestión de API Keys para obtener su API KeyAñádala al encabezado de la solicitud:
Authorization: Bearer YOUR_API_KEY
Body
Nombre del modeloLos modelos admitidos incluyen:
gpt-5.2-progpt-5.2-codex- Más modelos próximamente…
Lista de contenidos de entradaArray de entradas; cada elemento contiene los campos
role y content.💡 Relleno rápido (área Try it):- Haga clic en ”+ Add an item” para agregar un elemento de entrada
- Entrada de
role:user(mensaje del usuario),assistant(respuesta de la IA) osystem(prompt del sistema) - En
contentañada bloques de contenido (pueden incluir texto e imágenes)
Mostrar Detalles de los campos
Mostrar Detalles de los campos
Tipo de rolOpciones:
user (mensaje del usuario), assistant (respuesta de la IA, para múltiples turnos), system (prompt del sistema, para definir el comportamiento de la IA)Array de contenidosAdmite varios tipos de bloques de contenido, puede incluir texto e imágenes.
Mostrar Tipos de bloques de contenido
Mostrar Tipos de bloques de contenido
Tipo de contenidoOpciones:
input_text: Entrada de textoinput_image: Entrada de imagen
Contenido de textoSe utiliza cuando
type es input_text; introduzca el contenido del textoURL de la imagenSe utiliza cuando
type es input_image; introduzca la URL de la imagen o la codificación base64Admite dos formatos:1. URL completa de la imagen- URL de imagen accesible públicamente (http:// o https://)
- Ejemplo:
https://example.com/image.jpg
- Debe usar el formato Data URI completo
- Formato:
data:image/{format};base64,{base64_data} - Formatos de imagen admitidos: jpeg, png, gif, webp
Controla la aleatoriedad de la salida, rango 0-2
- Los valores más bajos (por ejemplo, 0.2) hacen la salida más determinística
- Los valores más altos (por ejemplo, 1.8) hacen la salida más aleatoria
Número máximo de tokens a generarLos distintos modelos tienen límites máximos diferentes; consulte la documentación específica de cada modelo
Si se debe usar salida en streaming
true: Respuesta en streaming (formato SSE)false: Devuelve la respuesta completa de una sola vez
Parámetro de muestreo por núcleo (nucleus sampling), rango 0-1Controla la diversidad del texto generado; se recomienda usar este parámetro alternativamente con temperatureValor por defecto: 1.0
Lista de herramientas para extender las capacidades del modeloTipos de herramientas admitidos:
- Búsqueda web (
web_search): Búsqueda de información en tiempo real en internet - Búsqueda de archivos (
file_search): Buscar contenido en archivos cargados - Llamada a funciones (
function): Llamar a funciones personalizadas - MCP remoto (
remote_mcp): Conectarse a servicios remotos del Model Context Protocol
[{"type": "web_search"}]Respuesta
Identificador único de la respuesta
Tipo de objeto, fijado como
responseTimestamp de creación
Nombre del modelo realmente utilizado
Lista de respuestas generadas
Mostrar Propiedades
Mostrar Propiedades
Índice de la elección
Motivo de finalizaciónValores posibles:
stop- Finalización naturallength- Se alcanzó la longitud máximacontent_filter- Filtrado de contenido
Ejemplos de uso
Entrada solo de texto
{
"model": "gpt-5.2-pro",
"input": [
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "Hello, introduce artificial intelligence"
}
]
}
]
}
Uso de la herramienta de búsqueda web
{
"model": "gpt-5.2-pro",
"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.2-pro",
"tools": [{"type": "web_search"}],
"input": "What positive news is there today?"
}'
Comprensión de imágenes
{
"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"
}
]
}
]
}
Análisis de múltiples imágenes
{
"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"
}
]
}
]
}
Imagen codificada en Base64
{
"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..."
}
]
}
]
}
Uso de la herramienta de búsqueda de archivos
{
"model": "gpt-5.2-pro",
"tools": [{"type": "file_search"}],
"input": "Based on uploaded documents, summarize the company's quarterly performance"
}
Uso de llamada a funciones
{
"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?"
}
Uso de MCP remoto
{
"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"
}
Combinando múltiples herramientas
{
"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"
}
Especificaciones de los tipos de contenido
input_text
Tipo de entrada de texto Propiedades:type: Fijado como"input_text"text: Contenido del texto (cadena)
input_image
Tipo de entrada de imagen Propiedades:type: Fijado como"input_image"image_url: URL de la imagen o data URI codificado en Base64
- JPEG
- PNG
- GIF
- WebP
- Tamaño máximo de archivo: 20MB
- aspect_ratio recomendada: No más de 2048x2048 píxeles
Detalles del uso de herramientas
Búsqueda web
La herramienta de búsqueda web permite al modelo acceder a información en tiempo real desde internet. Ejemplo de configuración:{
"tools": [{"type": "web_search"}]
}
- Consultar las últimas noticias y eventos actuales
- Obtener datos en tiempo real (acciones, clima, tipos de cambio, etc.)
- Buscar la documentación técnica más reciente
- Verificar información factual
Búsqueda de archivos
La herramienta de búsqueda de archivos permite al modelo buscar información relevante en los documentos cargados. Ejemplo de configuración:{
"tools": [{"type": "file_search"}]
}
- Analizar documentos internos corporativos
- Buscar especificaciones técnicas y manuales
- Consultar contratos y documentos legales
- Sistemas de preguntas y respuestas sobre bases de conocimiento
Llamada a funciones
Defina funciones personalizadas para permitir al modelo llamar a APIs externas o ejecutar operaciones específicas. Ejemplo completo de configuración:{
"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"]
}
}
}
]
}
name: Nombre de la función (requerido)description: Descripción de la función (requerido)parameters: Definición de parámetros usando el formato JSON Schematype: Tipo del parámetroproperties: Definiciones de las propiedades del parámetrorequired: Lista de parámetros requeridos
- Llamar a APIs de terceros
- Ejecutar consultas a bases de datos
- Activar procesos de negocio
- Integración con sistemas internos
MCP remoto
Conéctese a servicios remotos del Model Context Protocol (MCP) para ampliar las capacidades del modelo. Ejemplo de configuración:{
"tools": [
{
"type": "remote_mcp",
"remote_mcp": {
"url": "https://your-mcp-server.com/api",
"auth_token": "your_auth_token",
"timeout": 30
}
}
]
}
url: Dirección del servidor MCP (requerido)auth_token: Token de autenticación (opcional)timeout: Tiempo de espera en segundos, por defecto 30 segundos
- Conectarse a servicios de IA de nivel empresarial
- Utilizar modelos específicos de un dominio
- Acceder a fuentes de datos protegidas
- Integración de sistemas de IA distribuidos
Formato de respuesta de las herramientas
Cuando el modelo utiliza herramientas, el formato de respuesta incluirá información sobre la llamada a la herramienta:{
"id": "resp-123456",
"object": "response",
"created": 1677652288,
"model": "gpt-5.2-pro",
"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"
}
]
}
- El modelo recibe la entrada del usuario
- Analiza si se necesitan herramientas
- Si es necesario, devuelve una solicitud de llamada a la herramienta
- El cliente ejecuta la llamada a la herramienta
- Devuelve los resultados de la herramienta al modelo
- El modelo genera la respuesta final
Notas importantes
-
Requisitos para la URL de la imagen:
- Debe ser una URL accesible públicamente
- O utilizar el formato Data URI codificado en Base64
-
Facturación de tokens:
- Las imágenes consumen tokens en función de su aspect_ratio
- Las imágenes con aspect_ratio alta se redimensionan automáticamente para optimizar costos
- Las llamadas a herramientas también consumen tokens adicionales
-
Orden del contenido:
- El orden de los elementos en el array de content afecta la comprensión del modelo
- Se recomienda colocar primero las instrucciones de texto y después las imágenes
-
Combinaciones multimodales:
- Puede mezclar varios textos e imágenes en una sola solicitud
- Admite conversaciones de múltiples turnos con coherencia contextual
-
Limitaciones del uso de herramientas:
- Al usar varias herramientas simultáneamente, el modelo selecciona inteligentemente la más adecuada
- La llamada a funciones requiere definiciones claras de las funciones y descripciones de los parámetros
- Los resultados de la búsqueda web pueden estar limitados por región y tiempo
-
Compatibilidad de API:
- Totalmente compatible con el formato de la API OpenAI Responses
- Migre sin problemas el código existente de OpenAI
- Admite todas las funciones de extensión de herramientas de OpenAI
⌘I