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¶
Prepare a personal access token or service account API key for Genesis. See Access credentials for credential selection and permissions.
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 |
|---|---|---|---|
|
string |
Yes |
Selected model ID from |
|
string or array of object |
Yes |
Text input or ordered text messages. |
|
string |
Required for a message array |
Message role; the example uses |
|
string or array of object |
Required for a message array |
Message text or input text blocks. |
|
string |
Required for a text block |
Use |
|
string |
Required for a text block |
Input text. |
|
boolean |
No |
Whether to store the Response. The example disables storage. With a personal access token and model-service storage support, set to |
|
integer |
No |
Output token limit; reasoning models can include reasoning tokens in this budget. |
|
string |
No |
Additional instructions for this generation. |
|
number |
No |
Sampling temperature, when supported by the selected model. |
|
number |
No |
Nucleus sampling parameter, when supported by the selected model. |
|
boolean |
No |
Set to |
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 |
|---|---|---|
|
string |
Response identifier; use it to retrieve or delete a stored response. |
|
string |
Object type |
|
string |
Generation status, such as |
|
string |
Model that processed the request. |
|
array of object |
Output items; text messages may follow reasoning items. |
|
string |
Output type, such as |
|
string |
Role of a message output item. |
|
array of object |
Content blocks in a message output item. |
|
string |
Generated text blocks use |
|
string |
Generated text. |
|
array of object |
Summary returned with a reasoning item, when present. |
|
string |
Summary block type, such as |
|
string |
Summary text. |
|
object |
Token usage for this request. |
|
integer |
Input tokens. |
|
integer |
Output 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 |
|---|---|---|
|
object |
Error details. |
|
string |
Error description; the example indicates a missing model ID. |
|
string |
Error type; may be omitted by a model service. |
|
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.