Skip to content
API reference

Create a response

Reference for POST /v1/responses, which generates a response in the OpenAI Responses format without stored state.

This page is the reference for the Responses-compatible endpoint. It is intended for developers who use clients that send requests in the OpenAI Responses format, such as Codex.

Endpoint

POST https://api.engy.ai/v1/responses

Authentication

Send your API key in the Authorization header as a bearer token. For details, see Inference API overview.

Parameters

Body parameters

ParameterTypeRequiredDescription
modelStringYesThe model ID. A leading vendor/ segment is ignored.
inputString or arrayYesThe conversation. A string is treated as one user message. For an array, see Input items.
instructionsStringNoThe system prompt.
max_output_tokensIntegerNoThe maximum number of output tokens.
streamBooleanNoIf true, the response is streamed as server-sent events.
temperatureNumberNoThe sampling temperature.
top_pNumberNoThe nucleus sampling threshold.
toolsArrayNoThe tools that the model can call. Only tools with type set to function are supported.
tool_choiceString or objectNoauto, required, none, or a named function.
parallel_tool_callsBooleanNoWhether the model can return several tool calls in one response.
providerObjectNoWorker requirements. For details, see The provider object.

The endpoint is stateless. The store and previous_response_id parameters have no effect, so send the full conversation in input with each request. The reasoning, text, and prompt_cache_key parameters are also ignored.

Input items

Item typeDescription
messageA message with role (user, assistant, system, or developer) and text content. The developer role is treated as system.
function_callA tool call that the model made, with call_id, name, and arguments.
function_call_outputThe result of a tool call, with call_id and output.

Images, reasoning items, and item references are ignored.

Response

Response fields

FieldTypeDescription
idStringThe response ID.
objectStringAlways response.
created_atIntegerThe creation time, as a Unix timestamp in seconds.
statusStringcompleted, or incomplete if the output reached max_output_tokens.
modelStringThe model ID, as sent in the request.
errorNullAlways null for a successful response.
incomplete_detailsObject or null{"reason": "max_output_tokens"} if status is incomplete.
outputArrayA message item with output_text content, followed by one function_call item for each tool call.
usage.input_tokensIntegerThe number of input tokens.
usage.input_tokens_details.cached_tokensIntegerThe number of input tokens billed at the cached rate.
usage.output_tokensIntegerThe number of output tokens.
usage.output_tokens_details.reasoning_tokensIntegerThe number of reasoning tokens.
usage.total_tokensIntegerThe sum of input and output tokens.

The response does not contain reasoning items. Streaming responses end with a response.completed event, or with response.failed if an error occurs.

Errors

StatusCause
400The request is invalid, or the prompt plus max_output_tokens exceeds the context window.
401The API key is missing or invalid.
402The available balance does not cover the request.
404The model does not exist or is unavailable.
429Capacity is exhausted, or a concurrency limit is reached.
503No worker meets the provider requirements.
504The model server timed out.

Example

curl https://api.engy.ai/v1/responses \
  -H "Authorization: Bearer $ENGY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "glm-5.2",
    "instructions": "You are a concise assistant.",
    "input": "What is the capital of France?"
  }'

Response:

{
  "id": "resp_7a3c5e9b1d2f4a6c8e0b2d4f",
  "object": "response",
  "created_at": 1792281600,
  "status": "completed",
  "model": "glm-5.2",
  "error": null,
  "incomplete_details": null,
  "output": [
    {
      "type": "message",
      "id": "msg_2e4a6c8b0d1f3a5c7e9b1d3f",
      "status": "completed",
      "role": "assistant",
      "content": [
        {"type": "output_text", "annotations": [], "text": "The capital of France is Paris."}
      ]
    }
  ],
  "usage": {
    "input_tokens": 22,
    "input_tokens_details": {"cached_tokens": 0},
    "output_tokens": 19,
    "output_tokens_details": {"reasoning_tokens": 11},
    "total_tokens": 41
  }
}