Responses
curl --request POST \
--url https://api.gregapi.com/v1/responses \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-4.1",
"input": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Summarize the attachment."
}
]
}
],
"response_format": {
"type": "json_schema"
}
}
'import requests
url = "https://api.gregapi.com/v1/responses"
payload = {
"model": "gpt-4.1",
"input": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Summarize the attachment."
}
]
}
],
"response_format": { "type": "json_schema" }
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'gpt-4.1',
input: [{role: 'user', content: [{type: 'text', text: 'Summarize the attachment.'}]}],
response_format: {type: 'json_schema'}
})
};
fetch('https://api.gregapi.com/v1/responses', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gregapi.com/v1/responses",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'gpt-4.1',
'input' => [
[
'role' => 'user',
'content' => [
[
'type' => 'text',
'text' => 'Summarize the attachment.'
]
]
]
],
'response_format' => [
'type' => 'json_schema'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.gregapi.com/v1/responses"
payload := strings.NewReader("{\n \"model\": \"gpt-4.1\",\n \"input\": [\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": \"Summarize the attachment.\"\n }\n ]\n }\n ],\n \"response_format\": {\n \"type\": \"json_schema\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.gregapi.com/v1/responses")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"gpt-4.1\",\n \"input\": [\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": \"Summarize the attachment.\"\n }\n ]\n }\n ],\n \"response_format\": {\n \"type\": \"json_schema\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gregapi.com/v1/responses")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"gpt-4.1\",\n \"input\": [\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": \"Summarize the attachment.\"\n }\n ]\n }\n ],\n \"response_format\": {\n \"type\": \"json_schema\"\n }\n}"
response = http.request(request)
puts response.read_bodyLarge Language Models (LLM)
Responses
A unified multimodal response interface supporting JSON mode, tool sequences, and mixed text-plus-image input.
POST
/
v1
/
responses
Responses
curl --request POST \
--url https://api.gregapi.com/v1/responses \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-4.1",
"input": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Summarize the attachment."
}
]
}
],
"response_format": {
"type": "json_schema"
}
}
'import requests
url = "https://api.gregapi.com/v1/responses"
payload = {
"model": "gpt-4.1",
"input": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Summarize the attachment."
}
]
}
],
"response_format": { "type": "json_schema" }
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'gpt-4.1',
input: [{role: 'user', content: [{type: 'text', text: 'Summarize the attachment.'}]}],
response_format: {type: 'json_schema'}
})
};
fetch('https://api.gregapi.com/v1/responses', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gregapi.com/v1/responses",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'gpt-4.1',
'input' => [
[
'role' => 'user',
'content' => [
[
'type' => 'text',
'text' => 'Summarize the attachment.'
]
]
]
],
'response_format' => [
'type' => 'json_schema'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.gregapi.com/v1/responses"
payload := strings.NewReader("{\n \"model\": \"gpt-4.1\",\n \"input\": [\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": \"Summarize the attachment.\"\n }\n ]\n }\n ],\n \"response_format\": {\n \"type\": \"json_schema\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.gregapi.com/v1/responses")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"gpt-4.1\",\n \"input\": [\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": \"Summarize the attachment.\"\n }\n ]\n }\n ],\n \"response_format\": {\n \"type\": \"json_schema\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gregapi.com/v1/responses")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"gpt-4.1\",\n \"input\": [\n {\n \"role\": \"user\",\n \"content\": [\n {\n \"type\": \"text\",\n \"text\": \"Summarize the attachment.\"\n }\n ]\n }\n ],\n \"response_format\": {\n \"type\": \"json_schema\"\n }\n}"
response = http.request(request)
puts response.read_bodyPOST /v1/responses is OpenAI’s next-generation unified interface. It can mix text, images, and other input types in a single request and return results in a structured format.
Request example
curl -X POST "https://api.gregapi.com/v1/responses" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4.1",
"input": [
{
"role": "user",
"content": [
{"type": "text", "text": "Summarize the key points of the attachment"}
]
}
],
"response_format": {"type": "json_schema"}
}'
Streaming and compatibility
- Streaming output: set
stream: trueto receive server-sent events (SSE) increments. When you need to stay compatible with the Chat Completions streaming format, you can convert on the SSE client side (GregAPI has built-in backward-compatibility handling). - Tool events: tool calls appear in the stream as
response.output_item.added; the stream closes with aggregatedusagetoken statistics.
Tips and notes
- The
inputfield can be a string or a composite array; an array is recommended so you can mix text, images, file references, and more. - Conversation history can be continued by adding multiple
role/contentsegments toinput. response_formatsupportsjson_schema,text, and other options. Combined with GregAPI’s flow-control strategy, it enables structured automation.- For tool calls, declare optional functions in
tools; results appear in thetool_callsfield ofoutput. - Billing note: when tools such as Web Search Preview, Code Interpreter, or File Search are enabled, GregAPI attaches extra billing metadata in
usagefor reconciliation.
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Response
200
Successful structured response