Homework Correction API
CleverSee-Homework Correction API
Call the correctHomework interface to submit a single-page homework image and retrieve question locations, answer information, and correction results.
API description
Interface name: correctHomework
Capability: Corrects a single-page homework image and returns the processing status and available per-question results. These results can include the question's location, answer area, user's answer, standard answer, and correction details. The returned fields depend on the image content and question type.
Item | Description |
Request method | POST |
Service URL |
|
Request format |
|
Authentication | Request header |
This service is priced at CNY 18 per million input tokens and CNY 52 per million output tokens. There is no additional per-call fee. For details, see Vertical Search Billing.
To use this service, you must apply for access. Contact your business manager for assistance.
You can also apply for access through the official Q&A channel: Q&A Consultation
API definition
Request parameters
Parameter | Type | Required | Default | Description | Example |
imageUrl | string | Either | None | The public network HTTP/HTTPS URL of a single-page homework image. The image must be directly downloadable. | See request example |
imageBase64 | string | Either | None | The standard Base64-encoded string of a single image. Retain any necessary trailing | Full image Base64 |
dewarp | boolean | No | true | Specifies whether to dewarp the image. If set to | false |
Response parameters
Results
Field | Type | Returned when | Description |
requestId | string | Always | A unique identifier for the request. Include this ID when you contact technical support for troubleshooting. |
data | object | Always | The correction results. |
data.status | string | Always | The status of the full-page correction. A successful response always has this field set to success. The inability to determine the results for some answer points does not affect the overall success status. |
data.question_results |
| May be omitted, | An array of objects containing the results for each question. An empty array |
data.upstreamRequestId | string | May be omitted or | The request ID returned by the upstream correction service. |
data.dewarp_url | string | May be omitted | The URL of the dewarped image. All coordinates in the result are relative to this image. If |
data.angle | integer | May be omitted | The clockwise rotation angle of the original image. Valid values are |
data.usage | object | May be omitted or | The token usage for this correction. If no large model is called (for example, a page of arithmetic problems is processed by a dedicated engine), this object may not be returned or all its values may be 0. |
data.usage.prompt_tokens | number | Returned if | Number of input tokens. |
data.usage.completion_tokens | number | Returned if | Number of output tokens. |
data.usage.total_tokens | number | Returned if | Total number of tokens. |
Question and answer results
The "Returned when" rules in the following table apply only if the corresponding array element exists.
Field | Type | Returned when | Description |
data.question_results[].finish | boolean | Always | Indicates whether processing for this question is complete. If |
data.question_results[].question_id | string | Always | A unique 32-character hexadecimal string (without hyphens) that identifies the question. It is generated by the server and used for troubleshooting and reconciliation. |
data.question_results[].question_content | string | May be omitted | The content of the question, taken from the final stage of the correction pipeline. It can contain LaTeX, line breaks, and whitespaces. This field may be returned only when |
data.question_results[].question_type | string | May be omitted | The type of the question, for example, "Oral arithmetic problem". |
data.question_results[].question_points |
| Always | The coordinates of the question's bounding box, as a 2D array. The outer array represents question blocks, and each block contains four {x, y} points, starting from the top-left corner and proceeding clockwise. |
data.question_results[].question_points[][].x | number | Returned as part of a coordinate point object | The x-coordinate (in pixels). |
data.question_results[].question_points[][].y | number | Returned as part of a coordinate point object | The y-coordinate (in pixels). |
data.question_results[].solution | string | May be omitted | The correct answer and explanation text for the question. It can contain LaTeX. This field is omitted for some question types. |
data.question_results[].answer_results |
| May be omitted | An array of results for each answer point. If this field is omitted or empty, it means no answer area was detected for the question. |
data.question_results[].answer_results[].check_result | string | Always | The correction verdict. Valid values: "true" (correct), "false" (incorrect), or "unknown" (cannot be determined). |
data.question_results[].answer_results[].check_point | object | May be omitted | The coordinate {x, y} for placing the correction mark (check or cross). Use this point to render the correction mark. |
data.question_results[].answer_results[].check_point.x | number | Returned as part of a coordinate point object | The x-coordinate (in pixels). |
data.question_results[].answer_results[].check_point.y | number | Returned as part of a coordinate point object | The y-coordinate (in pixels). |
data.question_results[].answer_results[].answer_points |
| May be omitted | The coordinates of the answer area's bounding box. It consists of four {x, y} points, starting from the top-left corner and proceeding clockwise. This field is omitted for placeholder entries where the correction pipeline did not produce a result. |
data.question_results[].answer_results[].answer_points[].x | number | Returned as part of a coordinate point object | The x-coordinate (in pixels). |
data.question_results[].answer_results[].answer_points[].y | number | Returned as part of a coordinate point object | The y-coordinate (in pixels). |
data.question_results[].answer_results[].user_answer | string | May be omitted | The student's answer text as recognized from the answer area. This is an empty string |
data.question_results[].answer_results[].standard_answer | string | May be omitted | The standard answer for this answer point. It can contain LaTeX. This field is omitted if no standard answer is available. |
Examples
The example image URL is a placeholder. Replace it with the URL of an actual, downloadable, single-page homework image. The response example is for illustrating the data structure only.
Request parameters
{
"imageUrl": "https://example.com/images/homework.png"
}To submit a local image by using Base64 encoding, run the following commands. Replace homework.png with the path to your image file and set the API_KEY environment variable in advance.
python3 - homework.png <<'PY' > homework-request.json &&
import base64, json, sys
from pathlib import Path
image = Path(sys.argv[1]).read_bytes()
print(json.dumps({"imageBase64": base64.b64encode(image).decode("ascii")}))
PY
curl -sS 'https://cloud-iqs.aliyuncs.com/homework/correct' \
-H "X-API-Key: $API_KEY" \
-H 'Content-Type: application/json' \
--data @homework-request.jsonResponse parameters
{
"requestId": "example-request-id",
"data": {
"status": "success",
"upstreamRequestId": "3f1c9a52-1e2b-4c77-9a30-8f2e1d4b0a11",
"dewarp_url": "https://cdn.example.com/dewarp/0aa71449.jpg?Expires=1789999999&Signature=...",
"question_results": [
{
"question_id": "bf880a1500573dc39d7ad16900e6008b",
"finish": true,
"question_points": [
[{"x":65,"y":303}, {"x":464,"y":304}, {"x":464,"y":440}, {"x":64,"y":440}],
[{"x":540,"y":120}, {"x":940,"y":121}, {"x":940,"y":200}, {"x":539,"y":200}]
],
"answer_results": [
{
"answer_points": [{"x":381,"y":334}, {"x":412,"y":334}, {"x":412,"y":366}, {"x":381,"y":366}],
"user_answer": "0",
"standard_answer": "0",
"check_result": "true",
"check_point": {"x":425,"y":350}
},
{
"answer_points": [{"x":172,"y":391}, {"x":259,"y":391}, {"x":259,"y":426}, {"x":172,"y":426}],
"user_answer": "x=\\frac{b}{k}",
"standard_answer": "x=-\\frac{b}{k}",
"check_result": "false",
"check_point": {"x":272,"y":409}
}
],
"solution": "Answer: $x=-\\frac{b}{k}$.\nExplanation: When the graph of a linear function intersects the x-axis, the y-coordinate is 0. Set $y=0$ to get $kx+b=0$. Transposing the term and dividing both sides by $k$ yields the result."
},
{
"question_id": "9f1cad5bc12b34a69eec437060235b35",
"finish": true,
"question_points": [
[{"x":66,"y":740}, {"x":465,"y":741}, {"x":465,"y":870}, {"x":65,"y":870}]
],
"answer_results": [
{"user_answer":"", "check_result":"unknown"}
]
}
]
}
}This example shows an excerpt of the correction results for two questions.
API call
Use an API key that has been authorized for this interface and pass it in the X-API-Key request header. The following example reads the credential from the API_KEY environment variable. For security, do not hardcode your actual credentials in front-end web pages or public code.
curl -X POST 'https://cloud-iqs.aliyuncs.com/homework/correct' \
--header "X-API-Key: $API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"imageUrl": "https://example.com/images/homework.png"
}'Error codes
When an error occurs, check the HTTP status code and response body. A JSON response for a parameter validation failure includes requestId, errorCode, and errorMessage. For other errors, the returned fields may vary. The response body format may differ for formatting errors, and the response body for a 415 error may be empty.
Example of a parameter error:
{
"requestId": "example-request-id",
"errorCode": "InvalidParameter",
"errorMessage": "Image too large"
}HTTP status | Error code | Description | Solution |
400 | InvalidParameter | The image source is missing, a parameter is invalid, or the image exceeds size limits. | Check the image source, parameter mutual exclusion rules, and the Base64 string length. |
403 | Retrieval.InvalidAPIKey | The API key is invalid. | Check the |
403 | See response | Insufficient permissions or quota. | Verify the service activation status, calling permissions, and available quota. |
413 | RequestTooLarge | The entire HTTP request body exceeds the size limit. | Reduce the request body size or use the |
415 | See response | The request format is not supported. | Use |
429 | ThrottlingService (common) | The request rate is too high. | Reduce the call frequency and implement a backoff and retry strategy. |
502 | See response | Failed to process the image or retrieve results. | Verify that the image URL is accessible and inspect its content. If the issue persists, contact technical support. |
503 | See response | The service is temporarily unavailable. | Try again later. If the issue persists, contact technical support. |
504 | RequestTimeout | The processing timed out. | Retry the request. If the issue persists, provide the request ID when contacting technical support. |