---
title: OpenAI Responses
url: https://runapi.ai/docs/api/openai/responses.md
canonical: https://runapi.ai/docs/api/openai/responses
locale: en
---

# OpenAI Responses

## Overview

Use RunAPI's OpenAI-compatible Responses operation with a compatible model and the protocol's request and response shapes.

### Quick start

1. Create an API key and set it as RUNAPI_API_KEY.
2. Choose a compatible model, then send the documented path parameters and JSON body.
3. Read the JSON response or server-sent events shown for this operation, and handle protocol errors.

## Endpoint

POST /v1/responses

Base URL: https://runapi.ai

Contract version: v1

Preferred authentication: Authorization: Bearer YOUR_API_TOKEN

## Authentication carriers

RunAPI accepts each carrier listed below. Generated samples use the protocol's preferred header.

- `Authorization: Bearer YOUR_API_TOKEN` (Preferred)
- `x-api-key: YOUR_API_TOKEN`
- `x-goog-api-key: YOUR_API_TOKEN`
- `?key=YOUR_API_TOKEN`

## Compatible models

Open a model page for current pricing, rate limits, and commercial-usage details.

- [claude-fable-5](/models/claude)
- [claude-sonnet-5](/models/claude)
- [claude-opus-5](/models/claude)
- [claude-opus-4-8](/models/claude)
- [claude-opus-4-7](/models/claude)
- [claude-opus-4-6](/models/claude)
- [claude-sonnet-4-6](/models/claude)
- [claude-opus-4-5-20251101](/models/claude)
- [claude-sonnet-4-5-20250929](/models/claude)
- [claude-haiku-4-5-20251001](/models/claude)
- [claude-opus-4-1-20250805](/models/claude)
- [gpt-5.5](/models/gpt)
- [gpt-5.5-pro](/models/gpt)
- [gpt-5.4](/models/gpt)
- [gpt-5.4-mini](/models/gpt)
- [gpt-5.4-nano](/models/gpt)
- [gpt-5.4-pro](/models/gpt)
- [gpt-5.3-codex](/models/gpt)
- [gpt-5.3-codex-spark](/models/gpt)
- [gpt-5.2](/models/gpt)
- [gpt-5.2-pro](/models/gpt)
- [gpt-5.6-luna](/models/gpt)
- [gpt-5.6-sol](/models/gpt)
- [gpt-5.6-terra](/models/gpt)
- [gemini-3.5-flash](/models/gemini)
- [gemini-3.1-pro-preview](/models/gemini)
- [gemini-3-flash-preview](/models/gemini)
- [gemini-2.5-pro](/models/gemini)
- [gemini-2.5-flash](/models/gemini)
- [deepseek-v4-pro](/models/deepseek)
- [deepseek-v4-flash](/models/deepseek)
- [glm-5.2](/models/glm)
- [glm-5.1](/models/glm)
- [glm-5-turbo](/models/glm)
- [glm-5](/models/glm)
- [glm-4.7](/models/glm)
- [glm-4.6](/models/glm)
- [glm-4.5](/models/glm)
- [glm-4.5-air](/models/glm)
- [kimi-k3](/models/kimi)
- [kimi-k2.7-code](/models/kimi)
- [kimi-k2.6](/models/kimi)
- [kimi-k2.5](/models/kimi)
- [MiniMax-M3](/models/minimax)
- [MiniMax-M2.7](/models/minimax)
- [MiniMax-M2.7-highspeed](/models/minimax)
- [MiniMax-M2.5](/models/minimax)
- [MiniMax-M2.5-highspeed](/models/minimax)
- [MiniMax-M2.1](/models/minimax)
- [MiniMax-M2](/models/minimax)
- [grok-4.20-0309-non-reasoning](/models/grok)
- [grok-4.5](/models/grok)
- [grok-4.3](/models/grok)

## Request contract

Only fields with both public protocol and RunAPI support evidence are listed. Additional JSON body fields are passed through.

### JSON body

Required: `model`

```json
{
  "input": {
    "description": "Text, message items, or tool results provided to the model.",
    "type": [
      "string",
      "array"
    ]
  },
  "instructions": {
    "description": "System or developer instructions for this response.",
    "type": [
      "string",
      "null"
    ]
  },
  "max_output_tokens": {
    "description": "Maximum number of output tokens, including visible and reasoning tokens.",
    "type": [
      "integer",
      "null"
    ]
  },
  "model": {
    "description": "RunAPI model identifier returned by the compatible model catalog.",
    "type": "string"
  },
  "stream": {
    "default": false,
    "description": "Return typed Responses events as server-sent events.",
    "type": [
      "boolean",
      "null"
    ]
  },
  "tools": {
    "description": "Tools the model may call.",
    "type": "array"
  }
}
```

### Request example

```json
{
  "input": "Say hello in one sentence.",
  "model": "gpt-5.4"
}
```

## Synchronous response

HTTP 200

### Schema

```json
{
  "additionalProperties": true,
  "properties": {
    "id": {
      "type": "string"
    },
    "model": {
      "type": "string"
    },
    "object": {
      "const": "response",
      "type": "string"
    },
    "output": {
      "type": "array"
    },
    "status": {
      "type": "string"
    },
    "usage": {
      "additionalProperties": true,
      "properties": {
        "input_tokens": {
          "type": "integer"
        },
        "output_tokens": {
          "type": "integer"
        },
        "total_tokens": {
          "type": "integer"
        }
      },
      "required": [
        "input_tokens",
        "output_tokens",
        "total_tokens"
      ],
      "type": "object"
    }
  },
  "required": [
    "id",
    "object",
    "status",
    "model",
    "output"
  ],
  "type": "object"
}
```

### Example

```json
{
  "id": "resp_example",
  "model": "gpt-5.4",
  "object": "response",
  "output": [
    {
      "content": [
        {
          "annotations": [],
          "text": "Hello! How can I help today?",
          "type": "output_text"
        }
      ],
      "id": "msg_example",
      "role": "assistant",
      "status": "completed",
      "type": "message"
    }
  ],
  "status": "completed",
  "usage": {
    "input_tokens": 12,
    "output_tokens": 8,
    "total_tokens": 20
  }
}
```

## SSE event: output_text_delta

Media type: `text/event-stream`

### Schema

```json
{
  "additionalProperties": true,
  "properties": {
    "content_index": {
      "type": "integer"
    },
    "delta": {
      "type": "string"
    },
    "item_id": {
      "type": "string"
    },
    "output_index": {
      "type": "integer"
    },
    "type": {
      "const": "response.output_text.delta",
      "type": "string"
    }
  },
  "required": [
    "type",
    "item_id",
    "output_index",
    "content_index",
    "delta"
  ],
  "type": "object"
}
```

### Example

```json
{
  "content_index": 0,
  "delta": "Hello",
  "item_id": "msg_example",
  "output_index": 0,
  "type": "response.output_text.delta"
}
```

## SSE event: completed

Media type: `text/event-stream`

### Schema

```json
{
  "additionalProperties": true,
  "properties": {
    "response": {
      "additionalProperties": true,
      "properties": {
        "id": {
          "type": "string"
        },
        "model": {
          "type": "string"
        },
        "object": {
          "const": "response",
          "type": "string"
        },
        "output": {
          "type": "array"
        },
        "status": {
          "type": "string"
        },
        "usage": {
          "additionalProperties": true,
          "properties": {
            "input_tokens": {
              "type": "integer"
            },
            "output_tokens": {
              "type": "integer"
            },
            "total_tokens": {
              "type": "integer"
            }
          },
          "required": [
            "input_tokens",
            "output_tokens",
            "total_tokens"
          ],
          "type": "object"
        }
      },
      "required": [
        "id",
        "object",
        "status",
        "model",
        "output",
        "usage"
      ],
      "type": "object"
    },
    "type": {
      "const": "response.completed",
      "type": "string"
    }
  },
  "required": [
    "type",
    "response"
  ],
  "type": "object"
}
```

### Example

```json
{
  "response": {
    "id": "resp_example",
    "model": "gpt-5.4",
    "object": "response",
    "output": [
      {
        "content": [
          {
            "annotations": [],
            "text": "Hello! How can I help today?",
            "type": "output_text"
          }
        ],
        "id": "msg_example",
        "role": "assistant",
        "status": "completed",
        "type": "message"
      }
    ],
    "status": "completed",
    "usage": {
      "input_tokens": 12,
      "output_tokens": 8,
      "total_tokens": 20
    }
  },
  "type": "response.completed"
}
```

## Protocol error: invalid_request

HTTP 400

### Schema

```json
{
  "additionalProperties": true,
  "properties": {
    "error": {
      "additionalProperties": true,
      "properties": {
        "code": {
          "type": [
            "string",
            "null"
          ]
        },
        "message": {
          "type": "string"
        },
        "param": {
          "type": [
            "string",
            "null"
          ]
        },
        "type": {
          "type": "string"
        }
      },
      "required": [
        "message",
        "type"
      ],
      "type": "object"
    }
  },
  "required": [
    "error"
  ],
  "type": "object"
}
```

### Example

```json
{
  "error": {
    "code": null,
    "message": "input must be a string or an array",
    "param": "input",
    "type": "invalid_request_error"
  }
}
```

## Usage

### Schema

```json
{
  "additionalProperties": true,
  "properties": {
    "input_tokens": {
      "type": "integer"
    },
    "output_tokens": {
      "type": "integer"
    },
    "total_tokens": {
      "type": "integer"
    }
  },
  "required": [
    "input_tokens",
    "output_tokens",
    "total_tokens"
  ],
  "type": "object"
}
```

### Example

```json
{
  "input_tokens": 12,
  "output_tokens": 8,
  "total_tokens": 20
}
```

## Generated Code Samples

Each cURL, JavaScript, and Python sample sends the validated request from this contract without requiring a protocol-specific SDK.

### curl

```curl
curl -X POST https://runapi.ai/v1/responses \
  -H Authorization:\ Bearer\ YOUR_API_TOKEN \
  -H Content-Type:\ application/json \
  -d \{\"model\":\"gpt-5.4\",\"input\":\"Say\ hello\ in\ one\ sentence.\"\}
```

### javascript

```javascript
const response = await fetch("https://runapi.ai/v1/responses", {
  method: "POST",
  headers: {
  "Authorization": "Bearer YOUR_API_TOKEN",
  "Content-Type": "application/json"
},
  body: JSON.stringify({
  "model": "gpt-5.4",
  "input": "Say hello in one sentence."
})
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const data = await response.json();
console.log(data);
```

### python

#### Install

```bash
pip install requests
```

```python
import requests

response = requests.post(
    "https://runapi.ai/v1/responses",
    headers={"Authorization": "Bearer YOUR_API_TOKEN", "Content-Type": "application/json"},
    json={"model": "gpt-5.4", "input": "Say hello in one sentence."}
)
response.raise_for_status()
print(response.json())
```

## Related Guides

- [Authentication](/docs/guides/authentication)
- [Quickstart](/docs/guides/llm-api/quickstart)
