Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docsa.stemfard.com/llms.txt

Use this file to discover all available pages before exploring further.

Stemfard can return step-by-step solutions in multiple formats so you can render them however your application requires. Whether you are building a web UI that needs HTML markup, a document system that requires LaTeX typesetting, or an accessibility feature that feeds output to a text-to-speech engine, you control the format through the steps_output_formats request parameter.

Requesting output formats

Set steps_output_formats to an array of one or more format strings in your request body. The steps array in the response will then include content rendered in each format you specified.
You can request multiple formats in a single call by passing more than one value in the array — for example, "steps_output_formats": ["html", "latex"]. The API returns all requested formats together, so you only need one round-trip regardless of how many formats your application uses.

The three formats

The html format wraps mathematical expressions and step text in standard HTML markup. Use this when you are rendering solutions directly into a web page without a dedicated math typesetting library.Request:
cURL
curl --request POST \
  --url https://api.stemfard.com/api/v1/mathematics/linear-algebra/matrix-operations/matrix-arithmetic/add \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "a": [[1, 2], [3, 4]],
    "b": [[5, 6], [7, 8]],
    "api_level": "standard",
    "steps_output_formats": ["html"]
  }'
Example step output:
html step output
{
  "step": 1,
  "description": "Add corresponding elements of matrices A and B",
  "expression": "<p>sum[i][j] = A[i][j] + B[i][j]</p><p>sum = <strong>[[6, 8], [10, 12]]</strong></p>"
}

Combining multiple formats

You can include any combination of html, latex, and speech in a single request. Each step in the response will contain the expression rendered in every format you requested.
cURL (all three formats)
curl --request POST \
  --url https://api.stemfard.com/api/v1/mathematics/linear-algebra/matrix-operations/matrix-arithmetic/add \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "a": [[1, 2], [3, 4]],
    "b": [[5, 6], [7, 8]],
    "api_level": "standard",
    "steps_output_formats": ["html", "latex", "speech"]
  }'
multi-format step output
{
  "step": 1,
  "description": "Add corresponding elements of matrices A and B",
  "expression_html": "<p>sum[i][j] = A[i][j] + B[i][j]</p><p>sum = <strong>[[6, 8], [10, 12]]</strong></p>",
  "expression_latex": "\\begin{pmatrix}1&2\\\\3&4\\end{pmatrix} + \\begin{pmatrix}5&6\\\\7&8\\end{pmatrix} = \\begin{pmatrix}6&8\\\\10&12\\end{pmatrix}",
  "expression_speech": "Add each element of matrix A to the corresponding element of matrix B. The result is 6, 8 in the first row and 10, 12 in the second row."
}

Including background theory

Set steps_bg: true in your request to include background theory notes alongside each step. These notes explain the mathematical rule or concept being applied, which is useful for learners who need more context than the step expression alone provides.
cURL (with background theory)
curl --request POST \
  --url https://api.stemfard.com/api/v1/mathematics/linear-algebra/matrix-operations/matrix-arithmetic/matmul \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "a": [[1, 2], [3, 4]],
    "b": [[5, 6], [7, 8]],
    "api_level": "standard",
    "steps_output_formats": ["latex"],
    "steps_bg": true
  }'
When steps_bg is enabled, each step object includes an additional background field:
step with background theory
{
  "step": 1,
  "description": "Multiply row 1 of A by column 1 of B",
  "expression": "(1 \\cdot 5) + (2 \\cdot 7) = 19",
  "background": "Matrix multiplication computes the dot product of each row in A with each column in B. The element at position (i, j) in the result equals the sum of products of row i from A and column j from B."
}
steps_bg requires api_level to be "standard" or "detailed", since lite responses do not include a steps array.

Parameter reference

Type: string[]Default: [""] (no formatted output)An array of format identifiers controlling how step expressions are rendered. Accepted values are "html", "latex", and "speech". Pass an empty array or omit the parameter to receive steps without a specific output format applied.
Type: booleanDefault: trueWhen true, each step object includes a background field containing an explanation of the mathematical concept or rule used in that step. Requires api_level: "standard" or api_level: "detailed".