Skip to content

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/responses

Request parameters

ParameterTypeRequiredDescription
modelstringYesModel ID, e.g. gpt-4o-mini
inputstring | arrayYesInput content — plain text or a structured message array
instructionsstringNoSystem-level instructions (like a system prompt)
streambooleanNoWhether to stream, default false
temperaturenumberNoSampling temperature
max_output_tokensintegerNoMax tokens to generate
toolsarrayNoTool definitions
previous_response_idstringNoLink 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.