Skip to content
English

Responses API

Access 1折AI via the OpenAI Responses API, covering input, output, streaming events, and compatibility boundaries.

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.

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 . 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.

ContentChat CompletionsResponses
Inputmessagesinput, which can be a string or structured input items
Text resultchoices[].message.contentmessage content blocks in output
SDK text helper attributeExtract choices yourselfresponse.output_text
Streaming textchoices[].delta.contentresponse.output_text.delta events
Completion checkfinish_reason and stream endCheck 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.

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 .

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.

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 . For SDK usage, refer to OpenAI Python SDK .