Responses API
Responses is OpenAI's next-generation generation endpoint. Building on chat completions, it offers a simpler input form, built-in tools, and stateful interactions. YouQi AI is compatible with this format.
Create a response
POST /v1/responsesRequest parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model ID, e.g. gpt-4o-mini |
input | string | array | Yes | Input content — plain text or a structured message array |
instructions | string | No | System-level instructions (like a system prompt) |
stream | boolean | No | Whether to stream, default false |
temperature | number | No | Sampling temperature |
max_output_tokens | integer | No | Max tokens to generate |
tools | array | No | Tool definitions |
previous_response_id | string | No | Link the previous response ID for stateful multi-turn interactions |
Request example
bash
curl https://ai.youqi.tech/v1/responses \
-H "Authorization: Bearer sk-YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o-mini",
"instructions": "You are a helpful assistant.",
"input": "Introduce Hangzhou in one sentence."
}'With the OpenAI Python SDK:
python
from openai import OpenAI
client = OpenAI(
base_url="https://ai.youqi.tech/v1",
api_key="sk-YOUR_API_KEY",
)
resp = client.responses.create(
model="gpt-4o-mini",
input="Hello",
)
print(resp.output_text)Response example
json
{
"id": "resp_abc123",
"object": "response",
"created_at": 1715367049,
"model": "gpt-4o-mini",
"status": "completed",
"output": [
{
"type": "message",
"role": "assistant",
"content": [
{ "type": "output_text", "text": "Hangzhou is a city famed for West Lake, blending deep history with a vibrant digital economy." }
]
}
],
"usage": {
"input_tokens": 20,
"output_tokens": 22,
"total_tokens": 42
}
}Stateful multi-turn interactions
Link the previous response with previous_response_id to continue a conversation without resending the history:
bash
curl https://ai.youqi.tech/v1/responses \
-H "Authorization: Bearer sk-YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o-mini",
"previous_response_id": "resp_abc123",
"input": "What are its famous attractions?"
}'Note
Support for stateful interactions and tool orchestration depends on the selected model. If a model does not support a field, the gateway passes through upstream behavior or returns a corresponding error. For maximum compatibility, you can also use the Chat endpoint.