Generate text with an OpenAI Responses-compatible request and response format.
Description
This endpoint is designed for OpenAI Responses-style integrations. It supports standard JSON responses as well as streaming, and is a good fit for new text generation applications that want a modern OpenAI-compatible interaction model.
Headers
| Name | Type | Required | Description |
|---|---|---|---|
Authorization | string | Yes | Bearer token in the format Bearer YOUR_API_KEY. |
Content-Type | string | Yes | Must be application/json. |
Request body parameters
| Name | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model ID to use for generation. |
input | string / array | Yes | Input content for the model. |
instructions | string | No | High-level instruction applied to the request. |
stream | boolean | No | Whether to return SSE streaming events. |
temperature | number | No | Sampling temperature. |
top_p | number | No | Nucleus sampling parameter. |
max_output_tokens | integer | No | Maximum output token count. |
tools | array | No | Tool definitions available during generation. |
tool_choice | string / object | No | Tool calling strategy. |
metadata | object | No | Optional metadata for your own tracking. |
Supported models
| Model |
|---|
gpt-5.4 |
gpt-5.4-mini |
gpt-5.4-nano |
gpt-5.2 |
gpt-5 |
gpt-5-mini |
gpt-5-nano |
gpt-4.1 |
gpt-4.1-mini |
gpt-4o |
gpt-4o-mini |
Example request
curl https://api.apifree.ai/v1/responses \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4.1-mini",
"input": "Write three taglines for a multimodal AI API platform.",
"stream": false
}'Response schema
A successful response typically includes:
| Field | Type | Description |
|---|---|---|
id | string | Unique response ID. |
object | string | Object type, such as response. |
created_at | integer | Unix timestamp for creation time. |
status | string | Current response status. |
model | string | Model used for generation. |
output | array | Generated content output. |
usage | object | Token usage information. |
Example response:
{
"id": "resp_123",
"object": "response",
"created_at": 1750000000,
"status": "completed",
"model": "gpt-4.1-mini",
"output": [
{
"type": "message",
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "One API for every model."
}
]
}
],
"usage": {
"input_tokens": 12,
"output_tokens": 18,
"total_tokens": 30
}
}
Streaming
If stream is true, the endpoint returns OpenAI-style SSE events. Consume the stream until the terminal completion event is received.
Errors
Errors are returned as JSON error objects. Typical cases include:
- Missing or invalid
model - Invalid JSON request body
- Authentication failure
- Upstream request failure