MathGPT API Documentation
Introduction
MathGPT provides an API for accessing our advanced mathematics problem-solving models. This documentation provides details on how to integrate and use the MathGPT API.
Workflow
- Create an API token with your access key and secret key. You can create a long-lived token or a short-lived token for client-side use.
- Use the API token to make requests to the MathGPT ask API.
Endpoints
Get API Token
You need to get an API token before you make any requests to the MathGPT ask API.
URL: https://api.mathgptpro.com/v1/api-tokens
Method: POST
Headers: None
Request Body:
Field | Type | Description |
---|---|---|
accessKey | string | Access key |
secretKey | string | Secret key |
tokenLifeTime (optional) | a number in [1, 1440], default 1 | Life time in minutes, 1 min to 1 day |
Response:
A JWT token (String)
Example (with tokenLifeTime):
Request Body:
{
"accessKey": "677619f2-5986-4dba-bc8d-12e3c01cd4081720675111914",
"secretKey": "mgp_f1ab2c82-b059-4e8a-9f3c-42f1a3f78f2a1720675111914",
"tokenLifeTime": 1440
}
Response:
eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI1IiwiY2FycmllckFjY2Vzc0tleSI6IjY3NzYxOWYyLTU5ODYtNGRiYS1iYzhkLTEyZTNjMDFjZDQwODE3MjA2NzUxMTE5MTQiLCJpYXQiOjE3MjA3NjE2MjAsImV4cCI6MTcyMDg0ODAyMH0.yl2wlwGENZy9npeH3bY3htT97KmJGrHPrZohqLdeqbo
Example (without tokenLifeTime):
Request Body:
{
"accessKey": "677619f2-5986-4dba-bc8d-12e3c01cd4081720675111914",
"secretKey": "mgp_f1ab2c82-b059-4e8a-9f3c-42f1a3f78f2a1720675111914"
}
Response:
eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI1IiwiY2FycmllckFjY2Vzc0tleSI6IjY3NzYxOWYyLTU5ODYtNGRiYS1iYzhkLTEyZTNjMDFjZDQwODE3MjA2NzUxMTE5MTQiLCJpYXQiOjE3MjA3NjE2NTYsImV4cCI6MTcyMDc2MTcxNn0.L5uaR0QLq6rlWy0cr_uk8aT2WCDvHOJSRdi0xk2SEpI
MathGPT Ask API
Generate solutions for text or image-based math problems with LaTeX. You can send text, image (only one image each time), or both text and image.
If your request includes an image, the generated result will be considered as the analysis of the image.
If your request includes both text and image, we will concat the text and image together to form a single problem.
We offer two models: PRO
and MAX
. MAX
model is more accurate with higher cost compared to PRO
model.
URL: https://api.mathgptpro.com/v1/ask
Method: POST
Headers:
Key | Value | Description |
---|---|---|
Authorization | Bearer YOUR_API_TOKEN | Which you get from Get API Token |
Request Body:
Field | Type | Description |
---|---|---|
text (optional) | string | Text description of the math problem. |
image (optional) | string | The URL of image of the math problem. |
model (optional) | string | Which model to use. Can be PRO or MAX , default MAX |
Response:
An streaming event flow containing the solution process.
Example (only image):
Headers:
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI1IiwiY2FycmllckFjY2Vzc0tleSI6IjY3NzYxOWYyLTU5ODYtNGRiYS1iYzhkLTEyZTNjMDFjZDQwODE3MjA2NzUxMTE5MTQiLCJpYXQiOjE3MjA3NjE2MjAsImV4cCI6MTcyMDg0ODAyMH0.yl2wlwGENZy9npeH3bY3htT97KmJGrHPrZohqLdeqbo
Request Body:
{
"image": "https://fmd-mathgpt-public.s3.us-east-2.amazonaws.com/resource-library/example/en/1/img1.png"
}
Response:
The response will be an event stream with parts of the solution. Each part is a string with quotes around it.
"To"
" find"
" the" // ... more parts not shown
Combined Final Solution:
To find the value of \( f(-2 - g(3)) \), we need to follow these steps:
1. Calculate \( g(3) \).
2. Substitute \( g(3) \) into the expression \(-2 - g(3)\).
3. Substitute the result into \( f(x) \).
First, we calculate \( g(3) \):
\[
g(x) = x^2 - 3
\]
\[
g(3) = 3^2 - 3 = 9 - 3 = 6
\]
Next, we substitute \( g(3) \) into \(-2 - g(3)\):
\[
-2 - g(3) = -2 - 6 = -8
\]
Finally, we substitute \(-8\) into \( f(x) \):
\[
f(x) = \frac{3}{4}x + 10
\]
\[
f(-8) = \frac{3}{4}(-8) + 10 = \frac{3 \cdot (-8)}{4} + 10 = \frac{-24}{4} + 10 = -6 + 10 = 4
\]
Therefore, the value of \( f(-2 - g(3)) \) is:
\[
\boxed{4}
\]
Example (only text):
Headers:
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI1IiwiY2FycmllckFjY2Vzc0tleSI6IjY3NzYxOWYyLTU5ODYtNGRiYS1iYzhkLTEyZTNjMDFjZDQwODE3MjA2NzUxMTE5MTQiLCJpYXQiOjE3MjA3NjE2MjAsImV4cCI6MTcyMDg0ODAyMH0.yl2wlwGENZy9npeH3bY3htT97KmJGrHPrZohqLdeqbo
Request Body:
{
"text": "1+1"
}
Response:
The response will be an event stream with parts of the solution. Each part is a string.
"Sure"
","
" here" // ... more parts not shown
Combined Final Solution:
Sure, here is the step-by-step solution for the given math question:
\[
1 + 1
\]
Step 1: Identify the numbers to be added.
\[
1 \quad \text{and} \quad 1
\]
Step 2: Perform the addition.
\[
1 + 1 = 2
\]
Therefore, the solution is:
\[
\boxed{2}
\]
Example (text and image):
Headers:
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI1IiwiY2FycmllckFjY2Vzc0tleSI6IjY3NzYxOWYyLTU5ODYtNGRiYS1iYzhkLTEyZTNjMDFjZDQwODE3MjA2NzUxMTE5MTQiLCJpYXQiOjE3MjA3NjE2MjAsImV4cCI6MTcyMDg0ODAyMH0.yl2wlwGENZy9npeH3bY3htT97KmJGrHPrZohqLdeqbo
Request Body:
{
"image": "https://fmd-mathgpt-public.s3.us-east-2.amazonaws.com/resource-library/example/en/1/img1.png",
"text": "How to solve it?",
"model": "PRO"
}
Response:
The response will be an event stream with parts of the solution. Each part is a string.
"First"
","
" we" // ... more parts not shown
Combined Final Solution:
First, we need to find $g(3)$:
\[g(3) = 3^2 - 3 = 9 - 3 = 6.\]
Next, we substitute $g(3)$ into the expression $-2 - g(3)$:
\[-2 - g(3) = -2 - 6 = -8.\]
Now, we substitute $-8$ into the expression $f(-2 - g(3))$:
\[f(-2 - g(3)) = f(-8) = \frac{3}{4}(-8) + 10 = -6 + 10 = 4.\]
Therefore, the value of $f(-2 - g(3))$ is $\boxed{4}$.
For more information, visit our website (opens in a new tab) or contact our support team.