AIXHUBDocs
API integration

OpenAI Responses API

Send non-streaming and streaming Responses requests through AIXHUB with Bearer authentication, explicit completion checks, and bounded retry handling.

AIXHUB exposes an OpenAI-compatible Responses route. Use the Base URL https://api.aixhub.org/v1 or send HTTP POST directly to https://api.aixhub.org/v1/responses. Authenticate with Authorization: Bearer <AIXHUB API key> and use an exact compatible model ID such as panel-model-id.

POSThttps://api.aixhub.org/v1/responses

Create a dedicated key through API authentication, copy the model ID from Model routes, and keep the real key out of source files, command history, screenshots, and logs.

Request fields

The minimal request uses these public Responses fields:

FieldTypeRequiredUse in this guide
modelstringYesExact AIXHUB model ID, panel-model-id
inputstring or input-item arrayYesA bounded instruction; examples use a string
instructionsstringNoHigher-level response instructions when the application needs them
streambooleanNoSet to true to receive Server-Sent Events

Do not send a Chat Completions messages body to this endpoint. Add optional tools, conversation state, structured text settings, or token limits only after the minimal request works and the selected route supports them.

Set temporary environment variables

In Bash, read the key without echoing it or storing the real value in shell history:

read -r -s -p "AIXHUB API key: " AIXHUB_KEY
printf '\n'
export AIXHUB_API_KEY="$AIXHUB_KEY"
unset AIXHUB_KEY
export AIXHUB_MODEL="panel-model-id"

In Windows PowerShell, use a SecureString for input and expose the plain value only to the current process environment:

$secureKey = Read-Host "AIXHUB API key" -AsSecureString
$plainKey = [System.Net.NetworkCredential]::new("", $secureKey).Password
$env:AIXHUB_API_KEY = $plainKey
$env:AIXHUB_MODEL = "panel-model-id"
Remove-Variable plainKey, secureKey

Close the terminal after testing to clear its process environment. Never print AIXHUB_API_KEY while diagnosing a request.

Minimal Bash request

curl --fail-with-body --silent --show-error \
  --request POST \
  --url "https://api.aixhub.org/v1/responses" \
  --header "Authorization: Bearer $AIXHUB_API_KEY" \
  --header "Content-Type: application/json" \
  --data @- <<JSON
{
  "model": "$AIXHUB_MODEL",
  "input": "Reply with OK only."
}
JSON

Minimal PowerShell request

$body = @{
  model = $env:AIXHUB_MODEL
  input = "Reply with OK only."
} | ConvertTo-Json

$request = @{
  Method = "Post"
  Uri = "https://api.aixhub.org/v1/responses"
  Headers = @{ Authorization = "Bearer $($env:AIXHUB_API_KEY)" }
  ContentType = "application/json"
  Body = $body
}

$response = Invoke-RestMethod @request
$response | ConvertTo-Json -Depth 20

$text = @(
  $response.output |
    Where-Object { $_.type -eq "message" } |
    ForEach-Object { $_.content } |
    Where-Object { $_.type -eq "output_text" } |
    Select-Object -ExpandProperty text
) -join ""
$text

The request body and Authorization header are the same on both shells. Preserve the HTTP status, response body, and only the response headers actually returned by the server. Redact credentials and user input before sharing diagnostics.

Response example

The following is a complete representative non-streaming Responses object using public OpenAI field shapes. IDs, timestamps, token counts, defaults, and optional fields can differ in an actual response; it does not assert any AIXHUB-specific response field.

{
  "id": "resp_example",
  "object": "response",
  "created_at": 1780000000,
  "status": "completed",
  "background": false,
  "error": null,
  "incomplete_details": null,
  "instructions": null,
  "max_output_tokens": null,
  "model": "panel-model-id",
  "output": [
    {
      "id": "msg_example",
      "type": "message",
      "status": "completed",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "annotations": [],
          "text": "OK"
        }
      ]
    }
  ],
  "parallel_tool_calls": true,
  "previous_response_id": null,
  "reasoning": {
    "effort": null,
    "summary": null
  },
  "store": true,
  "temperature": 1.0,
  "text": {
    "format": {
      "type": "text"
    }
  },
  "tool_choice": "auto",
  "tools": [],
  "top_p": 1.0,
  "truncation": "disabled",
  "usage": {
    "input_tokens": 12,
    "input_tokens_details": {
      "cached_tokens": 0
    },
    "output_tokens": 2,
    "output_tokens_details": {
      "reasoning_tokens": 0
    },
    "total_tokens": 14
  },
  "user": null,
  "metadata": {}
}

Treat status: "completed" as the successful response condition. For failed, inspect error; for incomplete, inspect incomplete_details and do not treat partial output as complete.

The output array can contain different item types. Do not assume that output[0].content[0] is always text. Iterate output items, find assistant message content with type: "output_text", and concatenate those text values in order. An official SDK may provide an output_text convenience accessor, while raw HTTP clients must inspect the complete object. Use usage only when it is present.

Response object IDs are opaque. A request ID belongs to HTTP response headers, not this JSON example.

Streaming

Set stream to true and process the response as Server-Sent Events. The endpoint and Bearer authentication do not change.

Bash SSE request

curl --no-buffer --fail-with-body --silent --show-error \
  --request POST \
  --url "https://api.aixhub.org/v1/responses" \
  --header "Authorization: Bearer $AIXHUB_API_KEY" \
  --header "Content-Type: application/json" \
  --header "Accept: text/event-stream" \
  --data @- <<JSON
{
  "model": "$AIXHUB_MODEL",
  "input": "Reply with OK only.",
  "stream": true
}
JSON

PowerShell SSE request

Use curl.exe inside PowerShell so events are printed as they arrive:

$streamBody = @{
  model = $env:AIXHUB_MODEL
  input = "Reply with OK only."
  stream = $true
} | ConvertTo-Json -Compress

$streamBody | curl.exe --no-buffer --fail-with-body --silent --show-error --request POST --url "https://api.aixhub.org/v1/responses" --header "Authorization: Bearer $($env:AIXHUB_API_KEY)" --header "Content-Type: application/json" --header "Accept: text/event-stream" --data-binary "@-"

Handle these public Responses event types:

EventMeaningClient action
response.createdA response object was createdStore the response ID from the event payload when present
response.in_progressGeneration is in progressKeep reading; this is not a terminal success
response.output_text.deltaA text fragment arrivedAppend delta in event order
response.completedTerminal successFinalize accumulated text and inspect the completed response
response.failedTerminal failureDiscard or mark partial output and inspect error
response.incompleteTerminal incomplete resultMark output incomplete and inspect incomplete_details
errorTerminal stream errorStop reading, preserve the redacted error payload, and do not accept partial output

HTTP 200 and one or more delta events do not prove success. Wait for exactly one terminal outcome: response.completed, response.failed, response.incomplete, or error. Only response.completed is success. A connection close without a terminal event is ambiguous and must not be reported as completed.

Only store a request ID header when the HTTP response actually includes one, such as x-request-id. Preserve the exact header name and value returned; do not synthesize an ID. Likewise, read usage from a terminal response object only when that field is present.

Errors and retries

Capture the HTTP status, redacted error body, and response headers before deciding whether to retry:

ResultTypical action
400Fix the request body or unsupported field; do not retry unchanged
401Fix the Bearer key; do not retry unchanged
403Resolve access, policy, subscription, or balance conditions; do not retry until the cause changes
404Correct the endpoint or duplicated /v1; do not retry unchanged
429Reduce rate or concurrency; consider a bounded retry
500, 502, 503, 504Treat as potentially transient, but retry only within an explicit duplicate-risk policy
response.failed or response.incomplete after HTTP 200Treat the stream as failed or incomplete; do not convert partial text into success
error after HTTP 200Treat the stream as failed, preserve the redacted payload, and stop reading

Use a conservative retry boundary:

  1. Limit automatic retries to a small total attempt budget, such as three attempts including the original request.
  2. If the response actually contains Retry-After, honor that returned value. If it is absent, use capped exponential backoff with jitter; do not invent a server-directed delay.
  3. Do not automatically retry 400, 401, 403, or 404 with the same request.
  4. A Responses creation request can perform non-idempotent, billable generation. After a timeout, disconnect, ambiguous 5xx, or partially received stream, a blind replay can create duplicate output and cost.
  5. Retry an ambiguous request only when the application explicitly accepts duplicates or has its own correlation and deduplication policy. Otherwise surface the uncertain result for review.

Never log the Bearer token. If a request ID header is actually returned, include that redacted diagnostic identifier when contacting support. Continue with the error code reference for AIXHUB-facing status handling.

Verification

After extracting the assistant output_text from the non-streaming response or after receiving response.completed from the stream, the expected text is:

OK

Verify all of the following:

  1. The HTTP request completed without an error status.
  2. The response object or terminal event reports status: "completed".
  3. The concatenated assistant output_text is OK.
  4. AIXHUB Usage contains a request at the same time with panel-model-id and a successful status. Compare an API mode only when Usage actually displays it.
  5. Preserve a returned request ID header only when it exists; its absence is not a reason to create one.

Clear temporary credentials when testing is complete:

unset AIXHUB_API_KEY AIXHUB_MODEL
Remove-Item Env:AIXHUB_API_KEY, Env:AIXHUB_MODEL -ErrorAction SilentlyContinue
Remove-Variable request, body, response, text, streamBody, secureKey -ErrorAction SilentlyContinue
The Responses request completes, assistant output is OK, and AIXHUB Usage records the matching time, model, and successful status.

For application code, continue with the OpenAI SDK guide. For a maintained Responses client, use Codex CLI.

Official sources

The official links define the public OpenAI Responses contract. The AIXHUB Base URL, Bearer authentication, model route, and Usage checks come from this documentation site's integration contract.

Last verified: 2026-07-14

On this page