Language
Inference Space Docs

Responses API (OpenAI-Compatible)

OpenAI Responses passthrough at POST /v1/responses, plus optional stateful session subroutes for retrieval, cancellation, and input items.

Inference Space provides the OpenAI Responses-compatible endpoint POST /v1/responses. It is a passthrough endpoint for the OpenAI Responses protocol and the standard request entry point for Codex CLI. Existing OpenAI Responses clients can connect by switching the Base, Key, and provider.

The API is identical for private deployments; only replace the Base domain → Enterprise Private Deployment.

Overview

  • Endpoint: POST https://ai.inf.space/v1/responses (OpenAI Responses API passthrough)
  • Base: https://ai.inf.space/v1 (the browser console shares the ai.inf.space host; use the /v1 path for API requests)
  • Authentication: Authorization: Bearer <gk_...>; API Keys start with gk_ and are created in the console
  • Default behavior: Pure passthrough—the request body is forwarded directly upstream and the request path is unchanged

Available model IDs and prices are determined by the console. See Model List and Authentication.

Provider Is Required

/v1/responses and /v1/chat/completions share the same origin and strict routing behavior: every request must explicitly declare the upstream provider, with no implicit fallback. The three declaration methods are listed below in descending priority:

  1. URL query parameter ?provider=X
  2. Request header X-Provider: X (Codex CLI commonly uses this in the sandbox because it cannot append a query string to base_url)
  3. Request body field body.provider

Missing or unknown providers return 400 invalid_request_error. For routable providers, see the Chat Completions section (anthropic, openai, dashscope, deepseek, gemini, kimi, and openrouter).

Passthrough Request

curl "https://ai.inf.space/v1/responses?provider=openai" \
  -H "Authorization: Bearer $TOS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5-x",
    "input": "Introduce yourself in three sentences."
  }'
import os, requests

resp = requests.post(
    "https://ai.inf.space/v1/responses",
    params={"provider": "openai"},
    headers={
        "Authorization": f"Bearer {os.environ['TOS_API_KEY']}",
        "Content-Type": "application/json",
    },
    json={
        "model": "gpt-5-x",
        "input": "Introduce yourself in three sentences.",
    },
)
print(resp.json())
const resp = await fetch(
  "https://ai.inf.space/v1/responses?provider=openai",
  {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.TOS_API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      model: "gpt-5-x",
      input: "Introduce yourself in three sentences.",
    }),
  },
);
console.log(await resp.json());

By default, when stateful mode is disabled, /v1/responses is a pure passthrough: the gateway handles only authentication, routing, parameter trimming, and metering, while preserving the OpenAI Responses request and response bodies. Refer to the OpenAI Responses API specification for the exact request and response fields.

Optional Stateful Session Subroutes

When stateful mode is enabled (RESPONSES_STATEFUL_ENABLED=true), the gateway exposes additional stateful session subroutes based on response.id:

MethodPathDescription
GET/v1/responses/{id}Retrieve a response
DELETE/v1/responses/{id}Delete a response
GET/v1/responses/{id}/input_itemsList the response's input items
POST/v1/responses/{id}/cancelCancel an in-progress response
# Retrieve
curl "https://ai.inf.space/v1/responses/resp_xxx" \
  -H "Authorization: Bearer $TOS_API_KEY"

# List input items
curl "https://ai.inf.space/v1/responses/resp_xxx/input_items" \
  -H "Authorization: Bearer $TOS_API_KEY"

# Cancel
curl -X POST "https://ai.inf.space/v1/responses/resp_xxx/cancel" \
  -H "Authorization: Bearer $TOS_API_KEY"

# Delete
curl -X DELETE "https://ai.inf.space/v1/responses/resp_xxx" \
  -H "Authorization: Bearer $TOS_API_KEY"

Stateful subroutes require API Key authentication. Unauthenticated requests return 401 with the data-plane's flat error structure:

{
  "error": "missing_api_key",
  "message": "API key required (Authorization: Bearer gk_...)"
}

Subroutes are mounted only when RESPONSES_STATEFUL_ENABLED=true. When disabled, /v1/responses is available only as a passthrough POST endpoint and its subpaths are unavailable. The deployment operator decides whether to enable stateful mode; for the public cloud, follow the console and observed behavior.

Billing

Usage is metered and billed from the input and output tokens in usage, in units of 1M tokens. Actual prices, available models, and discounts are determined by console and organization pricing; organization-specific prices and contract discounts take precedence.

On this page