API Documentation

Programmatic access to our AI solver for developers. Integrate powerful homework solving capabilities into your applications.

Subscribers only • Unlimited requests • RESTful API

Authentication

How to Get Your API Token

  1. Subscribe to our Pro plan at Pricing
  2. Navigate to your Dashboard
  3. Click "Create New Token" in the API Tokens section
  4. Give your token a descriptive name
  5. Copy the token immediately (it will only be shown once!)

Using Your Token

Include your API token in the Authorization header of all requests:

Authorization: Bearer YOUR_API_TOKEN

Security Warning: Never expose your API token in client-side code or public repositories. Store it securely and only use it in server-side applications.

Base URL

https://aipictureanswer.com/api/v1

All API requests should use Content-Type: application/json

API Endpoints

POST /api/v1/solve

Solve a homework problem using EITHER a text question OR an image (not both).

Important: You must provide exactly one of these fields. Sending both question and image together will result in a validation error.

Request Body (Option 1: Text Question)

{
  "question": "Solve: 2x + 5 = 15"
}

Request Body (Option 2: Image Only)

{
  "image": "data:image/jpeg;base64,/9j/4AAQSkZJRg..."
}

Note: Images must be base64 encoded with the data URI prefix (e.g., data:image/jpeg;base64,...)

Response (200 OK)

{
  "success": true,
  "data": {
    "answer": "Step 1: Subtract 5 from both sides...",
    "conversation_id": 12345
  },
  "usage": {
    "requests_today": 15,
    "is_unlimited": true
  }
}

Error Responses

401 Unauthorized - Invalid or missing API token
403 Forbidden - Credits required
422 Validation Error - Missing question or image
422 Validation Error - Both question and image provided (only one allowed)
500 Server Error - Something went wrong
GET /api/v1/usage

Get your API usage statistics and account information.

Response (200 OK)

{
  "success": true,
  "data": {
    "total_requests": 150,
    "credit_balance": 892,
    "free_requests_today": 2,
    "free_requests_limit": 3,
    "active_tokens": 2
  }
}

Code Examples

cURL

curl -X POST https://aipictureanswer.com/api/v1/solve \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "question": "Solve: 2x + 5 = 15"
  }'

JavaScript (Node.js)

const fetch = require('node-fetch');

const apiToken = 'YOUR_API_TOKEN';

async function solveProblem(question) {
  const response = await fetch('https://aipictureanswer.com/api/v1/solve', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${apiToken}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({ question })
  });

  const data = await response.json();
  return data;
}

// Usage
solveProblem('Solve: 2x + 5 = 15')
  .then(result => console.log(result.data.answer))
  .catch(error => console.error(error));

Python

import requests
import base64

api_token = "YOUR_API_TOKEN"
base_url = "https://aipictureanswer.com/api/v1"

def solve_problem(question=None, image_path=None):
    """
    Solve a problem using EITHER question OR image (not both)
    """
    headers = {
        "Authorization": f"Bearer {api_token}",
        "Content-Type": "application/json"
    }
    
    payload = {}
    
    # Add either question OR image (not both)
    if question and image_path:
        raise ValueError("Cannot provide both question and image. Choose one.")
    elif question:
        payload["question"] = question
    elif image_path:
        with open(image_path, "rb") as image_file:
            encoded = base64.b64encode(image_file.read()).decode()
            payload["image"] = f"data:image/jpeg;base64,{encoded}"
    else:
        raise ValueError("Must provide either question or image_path")
    
    response = requests.post(
        f"{base_url}/solve",
        headers=headers,
        json=payload
    )
    
    return response.json()

# Usage examples:
# Text question only:
result = solve_problem(question="Solve: 2x + 5 = 15")
# OR image only:
# result = solve_problem(image_path="problem.jpg")
print(result["data"]["answer"])

PHP

<?php
$apiToken = 'YOUR_API_TOKEN';
$baseUrl = 'https://aipictureanswer.com/api/v1';

function solveProblem($question = null, $imagePath = null) {
    global $apiToken, $baseUrl;
    
    // Ensure exactly one parameter is provided
    if (($question && $imagePath) || (!$question && !$imagePath)) {
        throw new Exception('Must provide EITHER question OR image, not both or neither');
    }
    
    $payload = [];
    
    // Add either question OR image
    if ($question) {
        $payload['question'] = $question;
    } else {
        $imageData = base64_encode(file_get_contents($imagePath));
        $payload['image'] = 'data:image/jpeg;base64,' . $imageData;
    }
    
    $ch = curl_init($baseUrl . '/solve');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'Authorization: Bearer ' . $apiToken,
        'Content-Type: application/json'
    ]);
    
    $response = curl_exec($ch);
    curl_close($ch);
    
    return json_decode($response, true);
}

// Usage examples:
// Text question only:
$result = solveProblem('Solve: 2x + 5 = 15');
// OR image only:
// $result = solveProblem(null, 'problem.jpg');
echo $result['data']['answer'];
?>

Rate Limits & Best Practices

Unlimited Requests

Pro subscribers have unlimited API requests with no rate limiting.

Secure Token Storage

Store your API tokens securely using environment variables or secrets management.

HTTPS Only

All API requests must use HTTPS for security.

Error Handling

Always implement proper error handling for failed requests.

Don't Expose Tokens

Never expose your API tokens in client-side code, public repositories, or browser JavaScript.

Need Help?

If you have questions about the API or need assistance with integration, we're here to help!