Create a Response

Submit input to generate a Response and read generated text from its output items.

POST https://token.moi.matrixorigin.cn/v1/responses

Before you begin

  1. Prepare a personal access token or service account API key for Genesis. See Access credentials for credential selection and permissions.

  2. Use List callable models to select a model that supports Responses.

Request body

Replace $GENESIS_ACCESS_TOKEN and $MODEL_ID with your credential and the selected model ID.

curl -X POST \
  "https://token.moi.matrixorigin.cn/v1/responses" \
  -H "Authorization: Bearer $GENESIS_ACCESS_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{
  "model": "'"$MODEL_ID"'",
  "input": "Reply with OK.",
  "store": false,
  "max_output_tokens": 256
}'

The fields below cover text generation. Tools, multimodal input, and state references require corresponding model capabilities and request configuration.

Parameter

Type

Required

Description

model

string

Yes

Selected model ID from data[].id in the model list.

input

string or array of object

Yes

Text input or ordered text messages.

input[].role

string

Required for a message array

Message role; the example uses user.

input[].content

string or array of object

Required for a message array

Message text or input text blocks.

input[].content[].type

string

Required for a text block

Use input_text for an input text block.

input[].content[].text

string

Required for a text block

Input text.

store

boolean

No

Whether to store the Response. The example disables storage. With a personal access token and model-service storage support, set to true to retrieve or delete it later.

max_output_tokens

integer

No

Output token limit; reasoning models can include reasoning tokens in this budget.

instructions

string

No

Additional instructions for this generation.

temperature

number

No

Sampling temperature, when supported by the selected model.

top_p

number

No

Nucleus sampling parameter, when supported by the selected model.

stream

boolean

No

Set to true for Responses SSE events; streaming cannot be enabled together with storage.

Successful response

A successful request returns the generated output and its status. Check the status to determine whether the output is complete.

{
  "id": "resp-example",
  "object": "response",
  "status": "completed",
  "model": "MODEL_ID",
  "output": [
    {
      "type": "message",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "OK"
        }
      ]
    }
  ],
  "usage": {
    "input_tokens": 12,
    "output_tokens": 1,
    "total_tokens": 13
  }
}

Field

Type

Description

id

string

Response identifier; use it to retrieve or delete a stored response.

object

string

Object type response.

status

string

Generation status, such as completed; check it to determine whether output is complete.

model

string

Model that processed the request.

output

array of object

Output items; text messages may follow reasoning items.

output[].type

string

Output type, such as message or reasoning.

output[].role

string

Role of a message output item.

output[].content

array of object

Content blocks in a message output item.

output[].content[].type

string

Generated text blocks use output_text.

output[].content[].text

string

Generated text.

output[].summary

array of object

Summary returned with a reasoning item, when present.

output[].summary[].type

string

Summary block type, such as summary_text.

output[].summary[].text

string

Summary text.

usage

object

Token usage for this request.

usage.input_tokens

integer

Input tokens.

usage.output_tokens

integer

Output tokens.

usage.total_tokens

integer

Total tokens.

Error response

A missing model ID returns HTTP 400. Supply the model ID before sending the request again.

{
  "error": {
    "message": "missing required parameter: model",
    "type": "invalid_request",
    "code": "invalid_request"
  }
}

Field

Type

Description

error

object

Error details.

error.message

string

Error description; the example indicates a missing model ID.

error.type

string

Error type; may be omitted by a model service.

error.code

string or null

Error code; may be omitted by a model service.

Next steps

For a response created with a personal access token and storage enabled, use its id to Retrieve a Response. Delete the Response when no longer needed. Full-content retrieval and retention depend on the selected model service.

Last updated on