APIFree
APIFree
Text Generation

POST /v1/responses

OpenAI Responses-style text generation endpoint.

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

NameTypeRequiredDescription
AuthorizationstringYesBearer token in the format Bearer YOUR_API_KEY.
Content-TypestringYesMust be application/json.

Request body parameters

NameTypeRequiredDescription
modelstringYesModel ID to use for generation.
inputstring / arrayYesInput content for the model.
instructionsstringNoHigh-level instruction applied to the request.
streambooleanNoWhether to return SSE streaming events.
temperaturenumberNoSampling temperature.
top_pnumberNoNucleus sampling parameter.
max_output_tokensintegerNoMaximum output token count.
toolsarrayNoTool definitions available during generation.
tool_choicestring / objectNoTool calling strategy.
metadataobjectNoOptional 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:

FieldTypeDescription
idstringUnique response ID.
objectstringObject type, such as response.
created_atintegerUnix timestamp for creation time.
statusstringCurrent response status.
modelstringModel used for generation.
outputarrayGenerated content output.
usageobjectToken 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