Native OpenAI Format (Responses)
curl --request POST \
--url https://api.gravitex.ai/v1/responses \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"input": [
{}
],
"instructions": "<string>",
"max_output_tokens": 123,
"stream": true,
"temperature": 123,
"top_p": 123,
"reasoning": {},
"tools": [
{}
],
"tool_choice": {},
"parallel_tool_calls": true,
"max_tool_calls": 123,
"previous_response_id": "<string>",
"truncation": "<string>",
"metadata": {},
"user": "<string>"
}
'Chat & text
Native OpenAI Format (Responses)
POST
/
v1
/
responses
Native OpenAI Format (Responses)
curl --request POST \
--url https://api.gravitex.ai/v1/responses \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"input": [
{}
],
"instructions": "<string>",
"max_output_tokens": 123,
"stream": true,
"temperature": 123,
"top_p": 123,
"reasoning": {},
"tools": [
{}
],
"tool_choice": {},
"parallel_tool_calls": true,
"max_tool_calls": 123,
"previous_response_id": "<string>",
"truncation": "<string>",
"metadata": {},
"user": "<string>"
}
'Documentation Index
Fetch the complete documentation index at: https://docs.gravitex.ai/llms.txt
Use this file to discover all available pages before exploring further.
Introduction
The Responses API is OpenAIâs next-generation conversation interface, designed for the GPT-5 series and advanced features. Compared to the traditional Chat Completions API, the Responses API offers more granular reasoning control, built-in tool support, and multimodal input capabilities.Use Cases
- Reasoning-intensive tasks: Use GPT-5.5, GPT-5.4, GPT-5.4 Pro and other models with deep reasoning capability
- Web search requirements: Built-in Web Search Preview tool
- Advanced tool calling: Supports Function Call and Custom Tool Call
- Multi-turn conversation continuation: Conversation history management via
previous_response_id
Authentication
Bearer Token, e.g.,
Bearer sk-xxxxxxxxxxRequest Parameters
Model identifier, supported models include:
- GPT-5 series:
gpt-5.5,gpt-5.4,gpt-5.4-pro,gpt-5.4-mini,gpt-5.4-nano, etc. - GPT-4 series:
gpt-4o,gpt-4.1,gpt-4o-mini, etc.
Input message list, supports multiple formats:
- Simplified format:
[{"role": "user", "content": "text"}](similar to Chat Completions) - Standard format:
[{"type": "input_text", "text": "text"}] - Multimodal: Supports
input_image,input_filetypes
System instructions, equivalent to system message in Chat Completions
Maximum output token count, controls response length
Whether to enable streaming output, returns SSE format chunk data
Randomness control, 0-2, higher values make responses more random
Nucleus sampling parameter, 0-1, controls generation diversity
Reasoning configuration for controlling reasoning model behavior:
effort: Reasoning effort, options:"none","low","medium","high"summary: Reasoning summary, options:"auto","none","detailed"
Tool list, supports three types:
- Built-in Web Search:
{"type": "web_search_preview", "search_context_size": "medium"} - Built-in File Search:
{"type": "file_search"} - Custom Functions: Standard OpenAI Function Call format
Tool selection strategy:
"auto": Model automatically decides whether to call tools"none": Disable tool calling{"type": "function", "function": {"name": "function_name"}}: Force call specific function
Whether to allow parallel multiple tool calls
Maximum tool call limit
Previous response ID for conversation continuation
Truncation strategy:
"auto" or "disabled"Request metadata for tracking and debugging
User identifier
Basic Examples
- Simple Conversation (Non-streaming)
- Simple Conversation (Streaming)
- Python SDK
curl -X POST "https://api.gravitex.ai/v1/responses" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-d '{
"model": "gpt-5.2",
"max_output_tokens": 2048,
"input": [
{"role": "system", "content": "You are a helpful assistant"},
{"role": "user", "content": "Explain artificial intelligence briefly"}
]
}'
curl -N -X POST "https://api.gravitex.ai/v1/responses" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-d '{
"model": "gpt-5.2",
"stream": true,
"max_output_tokens": 2048,
"input": [
{"role": "user", "content": "Explain artificial intelligence briefly"}
]
}'
from openai import OpenAI
client = OpenAI(
api_key="sk-xxxxxxxxxx",
base_url="https://api.gravitex.ai/v1"
)
# Using Responses API
response = client.responses.create(
model="gpt-5.2",
max_output_tokens=2048,
input=[
{"role": "user", "content": "Explain artificial intelligence briefly"}
]
)
print(response.output[0].content[0].text)
Response Format
Non-streaming Response
{
"id": "resp_xxx",
"object": "response",
"created_at": 1768271369,
"model": "gpt-5.2",
"status": "completed",
"output": [
{
"id": "msg_xxx",
"type": "message",
"status": "completed",
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "Artificial Intelligence (AI) is a branch of computer science...",
"annotations": []
}
]
}
],
"usage": {
"input_tokens": 25,
"output_tokens": 150,
"total_tokens": 175,
"input_tokens_details": {
"cached_tokens": 0
},
"output_tokens_details": {
"reasoning_tokens": 50
}
}
}
Streaming Response (SSE Events)
Streaming responses use Server-Sent Events format with the following event types:| Event Type | Description |
|---|---|
response.created | Response created |
response.in_progress | Response in progress |
response.output_item.added | Output item added (tool call started) |
response.output_text.delta | Text delta |
response.output_text.done | Text completed |
response.output_item.done | Output item completed |
response.completed | Response completed |
event: response.created
data: {"type":"response.created","response":{"id":"resp_xxx","status":"in_progress"}}
event: response.output_text.delta
data: {"type":"response.output_text.delta","delta":"Artificial","sequence_number":1}
event: response.output_text.delta
data: {"type":"response.output_text.delta","delta":" Intelligence","sequence_number":2}
event: response.completed
data: {"type":"response.completed","response":{"id":"resp_xxx","status":"completed","usage":{...}}}
Advanced Features
1. Web Search
Enable built-in Web Search tool for real-time internet information retrieval.- Basic Example
- Advanced Configuration
curl -X POST "https://api.gravitex.ai/v1/responses" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-d '{
"model": "gpt-5.2",
"stream": true,
"max_output_tokens": 2048,
"input": [
{"role": "user", "content": "What are today'\''s news headlines?"}
],
"tools": [
{
"type": "web_search_preview",
"search_context_size": "medium"
}
]
}'
curl -X POST "https://api.gravitex.ai/v1/responses" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-d '{
"model": "gpt-5.2",
"stream": true,
"input": [
{"role": "user", "content": "What'\''s the weather in New York today?"}
],
"tools": [
{
"type": "web_search_preview",
"search_context_size": "high",
"user_location": {
"type": "approximate",
"country": "US",
"region": "NY",
"city": "New York",
"timezone": "America/New_York"
}
}
]
}'
-
search_context_size: Search context size"low": Low context, faster but fewer results"medium": Medium context (default)"high": High context, more search results but slower
-
user_location(optional): User location informationcountry: Country code (e.g., âUSâ, âCNâ)region: State/Provincecity: Citytimezone: Timezone
2. Reasoning Control
Control reasoning depth and output format for reasoning models.- Auto Reasoning Summary
- Detailed Reasoning
curl -X POST "https://api.gravitex.ai/v1/responses" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-d '{
"model": "gpt-5.5",
"stream": true,
"reasoning": {
"summary": "auto"
},
"max_output_tokens": 8192,
"input": [
{"role": "user", "content": "What is the formula for Tower of Hanoi?"}
]
}'
curl -X POST "https://api.gravitex.ai/v1/responses" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-d '{
"model": "gpt-5.5",
"stream": true,
"reasoning": {
"effort": "high",
"summary": "detailed"
},
"max_output_tokens": 16384,
"input": [
{"role": "user", "content": "Prove Fermat'\''s Last Theorem"}
]
}'
-
effort: Reasoning effort level"none": No reasoning"low": Light reasoning"medium": Medium reasoning (default)"high": Deep reasoning
-
summary: Reasoning summary"none": No reasoning summary"auto": Automatically decide whether to output summary"detailed": Output detailed reasoning process
3. Custom Function Calling
Supports standard OpenAI Function Calling format.curl -X POST "https://api.gravitex.ai/v1/responses" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-d '{
"model": "gpt-5.2",
"stream": true,
"input": [
{"role": "user", "content": "What'\''s the weather in Shanghai?"}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get weather information for a city",
"parameters": {
"type": "object",
"properties": {
"city": {
"type": "string",
"description": "City name"
}
},
"required": ["city"]
}
}
}
],
"tool_choice": "auto"
}'
{
"output": [
{
"id": "call_xxx",
"type": "function_call",
"status": "completed",
"name": "get_weather",
"call_id": "call_xxx",
"arguments": "{\"city\":\"Shanghai\"}"
}
]
}
4. Multimodal Input
Supports text, image, file and other input types.- Image Input
- File Input
curl -X POST "https://api.gravitex.ai/v1/responses" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-d '{
"model": "gpt-5.2",
"input": [
{
"type": "input_text",
"text": "What'\''s in this image?"
},
{
"type": "input_image",
"image_url": "https://example.com/image.jpg",
"detail": "high"
}
]
}'
curl -X POST "https://api.gravitex.ai/v1/responses" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-d '{
"model": "gpt-5.2",
"input": [
{
"type": "input_text",
"text": "Please analyze the content of this PDF document"
},
{
"type": "input_file",
"file_url": "https://example.com/document.pdf"
}
]
}'
5. Conversation Continuation
Useprevious_response_id to continue previous conversations.
# First conversation
curl -X POST "https://api.gravitex.ai/v1/responses" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-d '{
"model": "gpt-5.2",
"input": [
{"role": "user", "content": "What is quantum computing?"}
]
}'
# Response contains id: "resp_abc123"
# Second conversation (continuation)
curl -X POST "https://api.gravitex.ai/v1/responses" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-d '{
"model": "gpt-5.2",
"previous_response_id": "resp_abc123",
"input": [
{"role": "user", "content": "What are its application scenarios?"}
]
}'
Important Notes
- Model Compatibility: Not all models support all Responses API features
- Web Search: Only GPT-4o, GPT-4.1, GPT-5 and o-series models support it
- Reasoning: Only o-series and some GPT-5 models support
reasoningparameter - Content Obfuscation: Streaming response deltas may contain
obfuscationfield (content protection), full plaintext available inresponse.output_text.doneevent
- If you need standard Chat Completions format, use
/v1/chat/completionsendpoint withopenai/model prefix - The system will automatically convert formats for better client compatibility
Comparison: Responses API vs Chat Completions API
| Feature | Responses API | Chat Completions API |
|---|---|---|
| Reasoning Model Support | â Full support | â ď¸ Limited support |
| Built-in Web Search | â Native support | â Not supported |
| Reasoning Control | â Fine-grained control | â Not supported |
| Conversation Continuation | â
previous_response_id | â Via messages |
| Streaming Output | â SSE format | â SSE format |
| Client Compatibility | â ď¸ Needs adaptation | â Standard format |
| Use Cases | Reasoning, search, advanced features | General conversation |
Related Resources
Chat Completions API
Standard conversation interface documentation
Model List
View all supported models
FAQ
Responses API FAQs
âI