Smart question solving API

Updated at:

CleverSee API

Call the solveQuestion API to submit an image of a problem and receive its solution.

Overview

API Name: solveQuestion

Capability: The API can identify multiple questions within a single image. In such cases, result_type is set to multiple.

Item

Description

Request method

POST

Endpoint

https://cloud-iqs.aliyuncs.com/question/solve

Request format

application/json

Authentication

X-API-Key request header

This service is billed based on the number of prompt tokens and completion tokens. The rates are CNY 18 per million prompt tokens and CNY 52 per million completion tokens, with no additional per-call fees. For detailed rules, see Vertical Search Billing.

Note

This service requires activation. Please contact your business manager for assistance.

You can also request activation through our official support channel: Q&A and Support

API reference

Request parameters

Parameter

Type

Required

Default

Description

Example

format

string

Yes

None

The format of the image. Valid values are jpg, jpeg, or png. The value is case-insensitive.

png

imageUrl

string

Conditional

None

A publicly accessible HTTPS image URL. You must provide either this parameter or imageBase64.

See request example

imageBase64

string

Conditional

None

The standard Base64-encoded string of an image. Include trailing padding but do not include whitespace or a data: prefix. The original image size cannot exceed 10 MiB (10,485,760 bytes).

Full image Base64 string

The format parameter is required. You must provide either imageUrl or imageBase64. The specified format must match the actual file type. The image width and height cannot exceed 8,000 pixels, and the total number of pixels cannot exceed 2.6 million.

Response parameters

Parameter

Type

Returned

Description

requestId

string

Always

The unique identifier for the request. Provide this ID when troubleshooting.

data

object

Always

The solution results.

data.result_type

string

Always

single for a single question or multiple for multiple questions.

data.finished

boolean

Always

Always returns true in this response.

data.items

array<object>

Always

A list of the complete results for all identified questions. If the API fails to solve a question in a multi-question request, the content field for that item contains the reason for the failure.

data.items[].question_id

string

Always

The identifier for the question, derived from its title. If no title is available, the system generates sequential identifiers like "Question 1", "Question 2", and so on.

data.items[].content

string

Always

The complete solution in Markdown format, including the reasoning process and the final answer.

data.items[].status

string

Always

The status of the individual question. Valid values are processing or complete.

data.items[].image_url

string

Always

The URL of the image for the current question. This URL may be time-limited. If no image resource is associated and there is no request URL to fall back to, this field is an empty string.

data.items[].thinking

object

Optional or null

The reasoning process. This field is returned only when result_type is single. The API does not return this field for multi-question responses.

data.items[].thinking.content

string

If thinking is not null

The current reasoning content.

data.items[].thinking.status

string

If thinking is not null

The status. Valid values are processing or complete.

data.upstreamRequestId

string

Always

The request identifier echoed by the question-solving service.

data.usage

object

Optional or null

The token usage for this request.

data.usage.prompt_tokens

int64

Optional

The number of prompt tokens.

data.usage.completion_tokens

int64

Optional

The number of completion tokens.

data.usage.total_tokens

int64

Optional

The total number of tokens, which is the sum of prompt_tokens and completion_tokens.

Examples

The image URL in the example is a placeholder. Replace it with a publicly downloadable HTTPS image URL.

Request parameters

{
  "format": "png",
  "imageUrl": "https://example.com/images/equation.png"
}

When using a Base64-encoded image, replace imageUrl with imageBase64, provide the complete encoded string, and keep the format parameter.

Response parameters

{
  "requestId": "550e8400-e29b-41d4-a716-446655440000",
  "data": {
    "result_type": "multiple",
    "finished": true,
    "items": [
      {
        "question_id": "Question 1",
        "content": "Question 1: Identify the problem.\nThe final result is 2.",
        "status": "complete",
        "image_url": "https://cdn.example.com/solve/q-1.jpg"
      },
      {
        "question_id": "Question 2",
        "content": "Question 2: Define variable x.\nSolving for x yields x=3.",
        "status": "complete",
        "image_url": "https://cdn.example.com/solve/q-2.jpg"
      }
    ],
    "usage": {
      "prompt_tokens": 273,
      "completion_tokens": 356,
      "total_tokens": 629
    },
    "upstreamRequestId": "550e8400-e29b-41d4-a716-446655440000"
  }
}

This example does not include the thinking and usage objects. This does not imply that their content is empty or that the token usage is zero.

API calls

Use an API Key authorized for this API and pass it in the X-API-Key request header. The following example reads the credential from an environment variable named API_KEY. Do not hardcode your real credential in client-side code or public repositories.

curl -X POST 'https://cloud-iqs.aliyuncs.com/question/solve' \
  --header "X-API-Key: $API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
    "format": "png",
    "imageUrl": "https://example.com/images/equation.png"
  }'

Error codes

When an error occurs, first check the HTTP status code and the response body format before parsing the error message. A JSON response for a parameter validation failure includes requestId, errorCode, and errorMessage. For other types of errors, the response fields may vary. A response for a format error can differ from the standard structure; for example, a 415 error may have an empty response body.

Example of a parameter error:

{
  "requestId": "example-request-id",
  "errorCode": "InvalidParameter",
  "errorMessage": "Image too large"
}

Http status

Error code

Description

Solution

400

InvalidParameter

A required field is missing, a parameter is invalid, or the image exceeds the specified limits.

Check the format, HTTPS image source, parameter exclusivity rules, Base64 encoding, and original image size.

403

Retrieval.InvalidAPIKey

The API Key is invalid.

Check the X-API-Key request header and the credential.

403

See response

Insufficient permissions or quota.

Verify the API 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 an HTTPS image URL.

415

See response

The request format is not supported.

Set the Content-Type to application/json.

429

ThrottlingService (common)

The request rate is too high.

Reduce the call frequency and implement a backoff and retry strategy.

502

QuestionSolveFailed, UpstreamStreamInterrupted, UpstreamProtocolError, OutputLimitExceeded, etc.

Failed to solve the question, an interruption occurred in the result stream, the response format is invalid, or the output exceeded the limit.

Verify that the image is downloadable and check its content. If the issue persists, contact technical support.

503

ServiceUnavailable

The service is temporarily unavailable.

Try again later. If the issue persists, contact technical support.

504

RequestTimeout

The request timed out.

Try again later. If the issue persists, contact technical support with the request ID.

Related documents