Quickstart

Let's get you up and running with state-of-the-art AI.


Introduction

The SmartLens API is based on REST. Our API has predictable resource-oriented URLs, accepts and returns JSON-encoded bodies, and uses standard HTTP response codes and authentication. The base URL of the API is https://api.smartlens.ai.

While you can always call our REST API directly, we've built client libraries to make it even easier to integrate SmartLens into your app. Our Python client library is now available, with many more coming soon.

Bash

$ pip install smartlens

Authentication

When calling the REST API directly, you need to specify your API key with each request using the "Authorization" request header.

cURL

-H "Authorization: MY-API-KEY"

When using one of our client libraries, you only need to specify your API key once -- upon initialization. Below is an example for the SmartLens Python library.

Python

import smartlens
smartlens.api_key = "MY_API_KEY"

Making requests

Every individual service has a unique endpoint and schema, and every API handles exactly one input per request. The SmartLens Image Tagging and Image Captioning APIs accept JPEGand PNG files as inputs, either as a file encoded in base64 or as a URL. SmartLens Document AI accepts PDF, JPEG, and PNG files as inputs, either as a file encoded in base64 or as a URL.

The SmartLens API only accepts HTTP POST requests. Our current endpoints are:

  • /v1/models/tag/predict - SmartLens Image Tagging
  • /v1/models/document-ai/predict - SmartLens Document AI
  • /v1/models/caption/predict - SmartLens Image Captioning
  • /v1/models/analyze-text/predict - SmartLens Text Analysis

Here's an example of how to use our SmartLens Image Tagging API. Simply attach your image to the API request using the image parameter. For API-specific quickstarts and detailed schema for every SmartLens service, please refer to the sidebar menu.

cURL

curl -X POST "https://api.smartlens.ai/v1/models/tag/predict" \
     -H "accept: application/json" \
     -H "Authorization: MY-API-KEY" \
     -H "Content-Type: application/json" \
     -d "{ \"image\": \"MY-IMAGE\"}"

Python

import smartlens
smartlens.api_key = "MY_API_KEY"

response = smartlens.runTags(
   image = "MY-IMAGE (can be JPEG or PNG, submitted as a web URL or as bytes encoded in base64)"
)

API playground

We've built an API playground to make it even easier to explore our APIs. Check it out at https://api.smartlens.ai, which is also the base URL for the SmartLens API.


That's it!

Please refer to the sidebar menu for API-specific quickstarts and detailed schema information. If you have any questions or feedback, please reach out to us at [email protected].