---
title: "Responses API"
description: "Access 1折AI via the OpenAI Responses API, covering input, output, streaming events, and compatibility boundaries."
headingIds: {"Minimal Request":"section-1","Differences from Chat Completions":"section-2","Python SDK":"section-3","Streaming Reads":"section-4","Compatibility Scope":"section-5"}
---

<aside className="docs-publication" data-pagefind-ignore>

Documentation maintained by [1ZheAI](https://1zheai.com/en/editorial/#publisher). [Sources and corrections](https://1zheai.com/en/editorial/).

Found an error? [Contact support](mailto:support@1zheai.com) with the page address and a description. Do not send API keys or account credentials.

</aside>
Codex CLI uses the Responses protocol. When writing your own applications, you can also request GPT models that support this API via `POST https://1zheai.com/v1/responses`. Set the OpenAI SDK Base URL to `https://1zheai.com/v1`.

## Minimal Request

```bash
curl --fail-with-body --connect-timeout 10 --max-time 120 \
  https://1zheai.com/v1/responses \
  -H "Authorization: Bearer $ONEZHE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-6-astra",
    "input": "用三句话解释 API 网关。",
    "store": false
  }'
```

Before running, set `ONEZHE_API_KEY` and confirm the model is in [your available list ](/en/docs/api-models/). `store: false` is a storage option in the protocol; it does not mean that all service tiers have no logging or data retention. Do not infer privacy commitments from this.

## Differences from Chat Completions

| Content | Chat Completions | Responses |
| --- | --- | --- |
| Input | `messages` | `input`, which can be a string or structured input items |
| Text result | `choices[].message.content` | message content blocks in `output` |
| SDK text helper attribute | Extract choices yourself | `response.output_text` |
| Streaming text | `choices[].delta.content` | `response.output_text.delta` events |
| Completion check | `finish_reason` and stream end | Check response status and termination events |

`output_text` is a convenience attribute provided by the SDK; do not assume this field exists at the top level of the raw HTTP JSON. When calling HTTP directly, iterate over `output`, select `type: message`, then read the `text` of `type: output_text` in its `content`.

## Python SDK

After installing `python -m pip install openai`:

```python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["ONEZHE_API_KEY"],
    base_url="https://1zheai.com/v1",
    timeout=120.0,
    max_retries=0,
)
response = client.responses.create(
    model=os.environ.get("ONEZHE_MODEL", "gpt-6-astra"),
    input="用三句话解释 API 网关。",
    store=False,
)
print(response.output_text)
print("status:", response.status)
```

Here automatic retries are disabled to make it easier to locate a single request during initial integration. Before going live, set the policy according to [timeouts and retries ](/en/docs/retries/).

## Streaming Reads

Use after initializing `client` above:

```python
with client.responses.create(
    model=os.environ.get("ONEZHE_MODEL", "gpt-6-astra"),
    input="用三句话解释 API 网关。",
    store=False,
    stream=True,
) as stream:
    for event in stream:
        if event.type == "response.output_text.delta":
            print(event.delta, end="", flush=True)
        elif event.type == "response.completed":
            print("\n完成")
        elif event.type in {"response.failed", "response.incomplete", "error"}:
            raise RuntimeError(f"响应未完成：{event.type}")
```

If disconnected without receiving a completion event, the result should be marked as incomplete; do not judge success based only on the text already output.

## Compatibility Scope

This page covers creating responses and reading text. Do not infer from this that background tasks, historical response retrieval, `previous_response_id`, hosted tools, file storage, and other capabilities are all available. When session continuation is needed, first verify with explicit history input; when specific tools are needed, verify item by item per model and client.

For configuring ready-made tools, see [Codex CLI ](/en/docs/quickstart-codex/). For SDK usage, refer to [OpenAI Python SDK ](https://github.com/openai/openai-python).
