> This page location: Backend > AI Gateway > APIs > OpenAI Responses API
> Full Neon documentation index: https://neon.com/docs/llms.txt

> Summary: The OpenAI Responses endpoint exposes the OpenAI Responses API through Neon AI Gateway. Required for codex model variants, which do not work with the chat completions endpoint.

# OpenAI Responses API

Use the OpenAI Responses API with Neon AI Gateway

**Coming Soon: Private Preview**

This feature is in private preview: it's not ready for production use, and it may be briefly unavailable as we deploy updates. To get access, [sign up here](https://neon.com/blog/were-building-backends#access).

The OpenAI Responses endpoint exposes the [OpenAI Responses API](https://platform.openai.com/docs/api-reference/responses) through Neon AI Gateway. Use it with the OpenAI SDK's `responses.create()` method by changing only the `baseURL`.

**Base URL:** `https://<branch-host>/ai-gateway/openai/v1`

**Warning:** All codex model variants (`gpt-5-3-codex`, `gpt-5-2-codex`, `gpt-5-1-codex-max`, `gpt-5-1-codex-mini`) **require this endpoint**. They do not work with the [chat completions endpoint](https://neon.com/docs/ai-gateway/chat-completions).

## Supported models

This endpoint accepts OpenAI models only:

| Model ID             | Notes                  |
| -------------------- | ---------------------- |
| `gpt-5-4`            |                        |
| `gpt-5-4-mini`       |                        |
| `gpt-5-4-nano`       |                        |
| `gpt-5-3-codex`      | Requires this endpoint |
| `gpt-5-2-codex`      | Requires this endpoint |
| `gpt-5-2`            |                        |
| `gpt-5-1-codex-max`  | Requires this endpoint |
| `gpt-5-1-codex-mini` | Requires this endpoint |
| `gpt-5-1`            |                        |

Sending a non-OpenAI model ID returns `400 model is not available on this endpoint`.

## Basic request

**TypeScript (OpenAI SDK)**

```typescript
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env.NEON_AI_GATEWAY_TOKEN,
  baseURL: `${process.env.NEON_AI_GATEWAY_BASE_URL}/ai-gateway/openai/v1`,
});

const response = await client.responses.create({
  model: 'gpt-5-4',
  input: [{ role: 'user', content: 'What is Neon?' }],
});

console.log(response.output_text);
```

**Python (OpenAI SDK)**

```python
from openai import OpenAI
import os

client = OpenAI(
    api_key=os.environ['NEON_AI_GATEWAY_TOKEN'],
    base_url=f"{os.environ['NEON_AI_GATEWAY_BASE_URL']}/ai-gateway/openai/v1",
)

response = client.responses.create(
    model='gpt-5-4',
    input=[{'role': 'user', 'content': 'What is Neon?'}],
)

print(response.output_text)
```

**cURL**

```bash
curl -X POST "$NEON_AI_GATEWAY_BASE_URL/ai-gateway/openai/v1/responses" \
  -H "Authorization: Bearer $NEON_AI_GATEWAY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5-4",
    "input": [{"role": "user", "content": "What is Neon?"}]
  }'
```

## Streaming

**TypeScript (OpenAI SDK)**

```typescript
const stream = await client.responses.create({
  model: 'gpt-5-4',
  input: [{ role: 'user', content: 'Explain database branching.' }],
  stream: true,
});

for await (const event of stream) {
  if (event.type === 'response.output_text.delta') {
    process.stdout.write(event.delta);
  }
}
```

**Python (OpenAI SDK)**

```python
with client.responses.stream(
    model='gpt-5-4',
    input=[{'role': 'user', 'content': 'Explain database branching.'}],
) as stream:
    for event in stream:
        if event.type == 'response.output_text.delta':
            print(event.delta, end='', flush=True)
```

**cURL**

```bash
curl -X POST "$NEON_AI_GATEWAY_BASE_URL/ai-gateway/openai/v1/responses" \
  -H "Authorization: Bearer $NEON_AI_GATEWAY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5-4",
    "input": [{"role": "user", "content": "Explain database branching."}],
    "stream": true
  }'
```

## Error handling

| Status            | Message                                   | Cause                                  |
| ----------------- | ----------------------------------------- | -------------------------------------- |
| `400 Bad Request` | `unknown model`                           | Model ID not in the catalog            |
| `400 Bad Request` | `model is not available on this endpoint` | Non-OpenAI model sent to this endpoint |

For authentication, quota, and upstream errors, see [Troubleshooting](https://neon.com/docs/ai-gateway/troubleshooting).

## Next steps

- [Models](https://neon.com/docs/ai-gateway/models): full model catalog and which models require this endpoint
- [Chat completions](https://neon.com/docs/ai-gateway/chat-completions): use any model via the unified OpenAI-compatible endpoint
- [Authentication](https://neon.com/docs/ai-gateway/authentication): credential scopes and branch binding

---

## Related docs (APIs)

- [Chat completions](https://neon.com/docs/ai-gateway/chat-completions)
- [Anthropic Messages API](https://neon.com/docs/ai-gateway/anthropic-messages)
- [Gemini API](https://neon.com/docs/ai-gateway/gemini)
