PromptSearch API Beta

Search over 9 million images generated by StableDiffusion AI

Please login with Discord to view your credentials

This is the same API that powers the main site. There are some rate limits however but I'm planning on increasing it as the servers become more reliable to handle higher volume of requests. Please contact me if you need your rate limit to be increased. The following rate limit headers are return along each response.

OpenAPI UI

Explore the API spec with OpenAPI UI. With this tool you can even make the API requests without writing any code.

NodeJs

npm install node-fetch form-data
const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
const fs = require('fs');
var FormData = require('form-data');

Search by text

fetch("https://api.pagebrain.ai/promptsearch/v1/search?q=tesla", {
    "headers": {"x-pagebrain-api-key": "XXX","x-pagebrain-client-id": "XXX"},
    "method": "POST",
  }).then(r => r.json()).then(j => console.log(j))
The response would look something like
{
    "q": "tesla",
    "page": 1,
    "results": [
      {
        "url": "https://media.discordapp.net/attachments/.../...png",
        "prompt": "surrealist portrait painting of elon musk, futuristic",
        "score": 0.3323565721511841
      },
      ...
    ]
  }
  

Search by URL

const url = "https://images.unsplash.com/photo-1604164448130-d1df213c64eb?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1935&q=80"
fetch("https://api.pagebrain.ai/promptsearch/v1/search?q="+encodeURIComponent(url), {
    "headers": {"x-pagebrain-api-key": "XXX","x-pagebrain-client-id": "XXX"},
    "method": "POST",
  }).then(r => r.json()).then(j => console.log(j))

Search by uploading image

const formData = new FormData();
formData.append('image', fs.createReadStream('image.jpg'));

fetch("https://api.pagebrain.ai/promptsearch/v1/search", {
    "method": "POST",
    "headers": {"x-pagebrain-api-key": "XXX","x-pagebrain-client-id": "XXX"},
    "body": formData
}).then(r => r.json()).then(j => console.log(j));

FAQ

Data source? Tech stack?

This project is based on Romain Beaumont's clip-retrieval and initial data was scraped from StableDiffusion Beta Discord channel which is still available on Github. I've made some optimizations for scalability and build a nice k8s pipeline for continous scraping and indexing. The current search index was built using CLIP ViT-B/32 embbeddings and AutoFAISS on A100 on GCP. The actual inference time was fairly less but alot of time was wasted waiting for docker images to download and wrangling nvidia drivers!

Why another search engine? How is it different from x?

1. I'm generally fascinated about search engines, so this was fun for me! I'm hoping you find this cool too. 2. When I started working on this I wasn't aware of any alternatives, now there's dozes of good and better ones. The pace of things around this is crazy! 3. Why not?

Why is this hosted here?

This domain has become designated graveyard for my side project. Paid too much money for the ".ai" domain.

Just drop a line to say hi or feel free to fling tomatoes in my direction if you must. On Discord