# Pexafy API — full documentation > Single-file dump of the Pexafy developer docs (https://docs.pexafy.com), generated from the > pages themselves by scripts/build_llms_full.py — do not edit by hand. > Pexafy is a free-to-use AI semantic stock-image search engine + API. > Base URL: https://api.pexafy.com/api/v1 — auth via the x-api-key header. > Product-level summary, live source list and catalogue figures are generated from > the catalogue itself at https://pexafy.com/llms.txt — prefer it over any figure > quoted here. ====================================================================== # Overview ====================================================================== https://docs.pexafy.com/
Pexafy is a **semantic image search engine** for **free, royalty-free stock photos**, with a REST API on top. One key searches **nine** free-photo libraries at once — Unsplash, Pexels, Pixabay, Kaboompics, Burst, StockSnap, Picjumbo, Skitterphoto and NegativeSpace — and every photo it returns is free to use, with **no attribution required**. Search by **text**, by **image**, or by **both at once**. The search is semantic: you describe the scene you have in mind — the light, the mood, the moment — instead of guessing which keywords the photographer typed when they uploaded the shot. - [Try Search on Pexafy.com](https://pexafy.com): Run a real semantic search right now — no account, no key needed. - [Get Free API Key](https://pexafy.com/dashboard/api-keys/create/): Create your key in the dashboard. The free plan needs no credit card. - [API Quickstart](https://docs.pexafy.com/quickstart): Your first search request, in under five minutes. - [Why Pexafy](https://docs.pexafy.com/why-pexafy): Semantic search vs keyword stock search — the three modes explained. ## What a semantic search looks like Nobody tags a photo with that sentence. Pexafy ranks on the **meaning** of the scene, which is why full descriptive sentences work better here than bare keywords. [**Run this search yourself →**](https://pexafy.com/?q=The+quiet+after+a+summer+thunderstorm%2C+everything+dripping+and+still) ## Your first API call Pass your key in the `x-api-key` header: ```bash curl "https://api.pexafy.com/api/v1/search/photos?q=the+quiet+after+a+summer+thunderstorm%2C+everything+dripping+and+still" \ -H "x-api-key: YOUR_API_KEY" ``` Get your API key at [pexafy.com/dashboard/api-keys/create](https://pexafy.com/dashboard/api-keys/create/) — it works on your first call, and the free plan needs no credit card. The [Quickstart](https://docs.pexafy.com/quickstart) walks through the whole flow. ## Where to go next - [Use Pexafy from an AI assistant](https://docs.pexafy.com/mcp): A remote MCP server with OAuth — no API key to paste. - [Libraries & integrations](https://docs.pexafy.com/sdks): Python, LangChain, the Vercel AI SDK, agent frameworks and no-code tools — the same key everywhere. - [API Reference](https://docs.pexafy.com/api-reference/search/search-photos-by-text): Search, photos, facets, collections and usage — every endpoint, with examples. - [Pagination](https://docs.pexafy.com/pagination): Page through large result sets by page number or with a cursor. - [Errors & rate limits](https://docs.pexafy.com/errors): Error codes, quota headers and what to do when you hit a limit. ====================================================================== # Why Pexafy ====================================================================== https://docs.pexafy.com/why-pexafy
Pexafy is a **semantic image search engine** for **free, royalty-free stock photos**. Every image is **free to use — no attribution required**, pulled from one curated library that aggregates **nine** leading free-photo providers: Unsplash, Pexels, Pixabay, Kaboompics, Burst, StockSnap, Picjumbo, Skitterphoto and NegativeSpace. **One Pexafy request = one semantic search across all nine sources.** With the providers' own APIs the same search takes 3 to 5 calls, plus the merge logic and the JSON normalisation — code you write, maintain and pay for. One key, one schema, one rate limit instead of one of each per provider. What sets Pexafy apart is *how* you search. A traditional stock library matches the **keywords** people typed when they uploaded a photo. Pexafy matches the **meaning, mood and story** of the scene you describe — so you find the right image even when nobody tagged it with your exact words. This page walks through the **three ways to search Pexafy**, and why each one finds better photos than keyword-based stock search. ## What "semantic search" means Semantic search understands *what you mean*, not just *what you typed*. Describe a scene in a full sentence — the light, the emotion, the moment — and Pexafy ranks photos by how closely they capture that idea. No tag-guessing, no boolean operators, no scrolling through pages of near-misses. The richer your description, the better the match. ## Three ways to search - **1 · Text search**: Describe a scene in plain language and get photos that match its meaning. - **2 · Image search**: Upload a photo and find visually similar images — semantic reverse image search. - **3 · Image + text**: Start from a picture, then steer the results with words. ## 1. Text search — search images by description The fastest way in: type what you picture, in plain English. Because the search is semantic, **full descriptive sentences beat bare keywords**. Here is a real Pexafy search for a query no keyword index would handle well: [**Try it yourself →**](https://pexafy.com/?q=The%20quiet%20after%20a%20summer%20thunderstorm%2C%20everything%20dripping%20and%20still) Every result is a real, high-resolution, royalty-free photo you can use straight away — no attribution required. ## 2. Image search — turn a watermarked thumbnail into free photos This is where semantic **reverse image search** earns its keep. Say you found the perfect shot on a paid stock site — but it's a low-resolution, **watermarked** preview you'd have to license. Drop that thumbnail into Pexafy and it finds **free, royalty-free photos of the same scene** — same subject, mood and composition — that you can actually use. Here's a watermarked stock thumbnail of a group of friends: Drop it into the search bar (click the **camera** icon) and Pexafy returns **free** photos of the same moment — no watermark, no licence to buy: [**Try it yourself →**](https://pexafy.com/) ## 3. Image + text — start from a picture, steer it with words The most powerful mode combines both: give Pexafy a **reference image and a few words**, and it balances *what the picture looks like* with *what you describe*. Take the same group photo and add a direction like **"with hands in the air"** — and the results shift toward that moment while keeping the original look and feel: [**Try it yourself →**](https://pexafy.com/) ## Free plan and limits The **free plan** includes **5,000 API requests a month** at up to **20 requests a minute** (1,200 an hour), with **1 API key**. It needs no credit card and does not expire. The monthly quota resets on the 1st of each month at 00:00 UTC. Every limit, plan by plan: [Plans & limits](https://docs.pexafy.com/plans) · [pexafy.com/pricing](https://pexafy.com/pricing/). ## Start building - [Get an API key](https://docs.pexafy.com/quickstart): Run your first semantic search in minutes. - [Use Pexafy in Claude](https://docs.pexafy.com/mcp): Search free stock photos right inside your AI assistant. ====================================================================== # Quickstart ====================================================================== https://docs.pexafy.com/quickstart Three steps: get a key, run a few lines of code, read the photos that come back. It's free to start, with no credit card. ## 1. Get your key 1. **Open the key page** Go to [pexafy.com/dashboard/api-keys/create](https://pexafy.com/dashboard/api-keys/create/). No account yet? Sign in with Google or GitHub, or create a free account with your email. No credit card. 2. **Create the key** Leave the key type on **Pexafy API** and click **Create API Key**. The name and the expiration are optional. 3. **Copy your key** The next page shows your key: click **Copy key**. Below it, Pexafy AI Assist asks what you are building and gives you code that runs as is, with your key already in it. Lost the key? It stays in [API Keys](https://pexafy.com/dashboard/api-keys/): click **Display** next to it. > **The key works on your first call.** > > The free plan includes **5,000 requests a month**, up to **1,200 an hour** — see [Plans & limits](https://docs.pexafy.com/plans). > **Warning:** > Keep your key private, like a password: never put it on a web page or in a public repository. ## 2. Make your first request Pick your language, copy the code, and replace `YOUR_API_KEY` with your key. Tip: on the page that shows your key, Pexafy AI Assist writes this code for you, with your key already in it. Python: ```python import requests API_KEY = "YOUR_API_KEY" response = requests.get( "https://api.pexafy.com/api/v1/search/photos", params={"q": "a red fox walking through the snow"}, headers={"x-api-key": API_KEY}, ) response.raise_for_status() for photo in response.json()["data"]: print(photo["urls"]["regular"]) ``` JavaScript: ```javascript const API_KEY = "YOUR_API_KEY"; const url = new URL("https://api.pexafy.com/api/v1/search/photos"); url.searchParams.set("q", "a red fox walking through the snow"); const response = await fetch(url, { headers: { "x-api-key": API_KEY }, }); if (!response.ok) throw new Error("HTTP " + response.status); const { data } = await response.json(); for (const photo of data) console.log(photo.urls.regular); ``` cURL: ```bash curl -G "https://api.pexafy.com/api/v1/search/photos" --data-urlencode "q=a red fox walking through the snow" -H "x-api-key: YOUR_API_KEY" ``` PHP: ```php "a red fox walking through the snow"]); $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, ["x-api-key: $apiKey"]); $body = json_decode(curl_exec($ch), true); foreach ($body["data"] as $photo) { echo $photo["urls"]["regular"], PHP_EOL; } ``` **How to run it**, from a terminal: | Language | Save the code as | Install once | Run, in the same folder | | --- | --- | --- | --- | | Python 3 | `search.py` | `pip install requests` | `python search.py` | | JavaScript (Node.js 18 or later) | `search.mjs` | nothing | `node search.mjs` | | cURL | nothing to save | nothing | paste the line and press Enter | | PHP 7.4 or later | `search.php` | nothing | `php search.php` | - On macOS and Linux, type `python3` and `pip3` instead of `python` and `pip`. - On Windows, type `curl.exe` instead of `curl`. - Keep the `.mjs` ending for JavaScript, and run it with Node.js, on your computer or your server. Never in a web page, where anyone could read your key. - PHP uses its curl extension. If PHP says `curl_init` is undefined, install it (on Ubuntu: `sudo apt install php-curl`). Python, JavaScript and PHP print a link to each photo found: open one in your browser. cURL prints the whole answer, as JSON. > Pexafy searches by **meaning**: describe the scene in a sentence. > `a red fox walking through deep snow at dawn` matches better than `fox snow`. ## 3. Read the response The answer is JSON. Here is a trimmed example: each photo has more fields than shown. ```json { "success": true, "data": [ { "photo_id": "019e1a0d-1a4f-7d62-856f-e6775b49785d", "urls": { "thumb": "https://images.pexels.com/photos/20853949/pexels-photo-20853949.jpeg?w=200", "regular": "https://images.pexels.com/photos/20853949/pexels-photo-20853949.jpeg?w=1280", "full": "https://images.pexels.com/photos/20853949/pexels-photo-20853949.jpeg?w=2400" }, "width": 8234, "height": 5489, "alt_description": "Red fox walking through a snowy field with bushes and trees behind it", "photographer_full_name": "Dip Kheto", "source": "Pexels", "license_type": "free", "attribution": { "plain": "Photo by Dip Kheto on Pexels (https://pexafy.com/legal/licenses/#pexels)" } } ], "meta": { "request_id": "ad7140d9-2cc2-4134-8bae-6b90ba3dede2", "took_ms": 86.42 }, "pagination": { "next_cursor": "eyJycyI6IjBlYWNjM2Q5...", "per_page": 20, "has_more": true }, "error": null } ``` - `data` is the list of photos, best match first. - `urls` gives each photo in several sizes: `thumb` is small, `regular` suits a web page, `full` is the largest. - `attribution.plain` is a ready-made credit line. `attribution.html` is the same, with links. - `pagination.next_cursor` gets you the next page: see [Pagination](https://docs.pexafy.com/pagination). - `error` is `null` when all went well. Otherwise it says what went wrong: see [Errors](https://docs.pexafy.com/errors). Every field and every search option, such as color, orientation or source, is in the [API reference](https://docs.pexafy.com/api-reference/search/search-photos-by-text). ## Using an AI assistant instead? - [Use Pexafy in your AI assistant](https://docs.pexafy.com/mcp): ChatGPT, Claude, Cursor, VS Code and more. Most of them need no key: you sign in once. ## Libraries and integrations - [Libraries & integrations](https://docs.pexafy.com/sdks): A Python library, LangChain, the Vercel AI SDK, agent frameworks and no-code tools such as n8n, Make and Zapier. The same key works everywhere. ## Get help as you build Pexafy AI Assist The bubble in the bottom-right corner of every page. It answers from these docs — so it knows the parameters, the plan limits and the error codes — and it replies in your language. Ask it for a whole integration, not just a parameter: *"write me a Python function that searches and downloads the first result"*, and it writes it against the current API. > Answers are generated, so verify anything going to production. When it does not know, it > says so rather than guessing — and that tells us a page is missing. ## Next steps - [Page through results](https://docs.pexafy.com/pagination) by page number or with a cursor - Browse **Search**, **Photos**, **Facets**, **Collections** and **Usage** for every endpoint - [Dashboard](https://pexafy.com/dashboard) for your usage, [Plans & limits](https://docs.pexafy.com/plans) and [pricing](https://pexafy.com/pricing) for the plans ====================================================================== # Libraries & integrations ====================================================================== https://docs.pexafy.com/sdks A Pexafy search is one web request, so it works from any language or tool. The libraries and guides below save you the setup. **The same key works everywhere**: [create one](https://pexafy.com/dashboard/api-keys/create/) if you don't have it yet. | You want to… | Go to | | --- | --- | | Search photos from a Python script or app | [Python](#python) | | Search photos from JavaScript or Node.js | [JavaScript](#javascript) | | Give photo search to a LangChain or LangGraph agent | [LangChain](#langchain) | | Give photo search to a Vercel AI SDK agent | [Vercel AI SDK](#vercel-ai-sdk) | | Use another agent framework | [Agent frameworks](#agent-frameworks) | | Automate without code, in n8n, Make or Zapier | [No-code](#no-code) | | Ask for photos in ChatGPT, Claude, Cursor or VS Code | [AI assistants](https://docs.pexafy.com/mcp) | ## Python Install the library (Python 3.9 or later): ```bash pip install pexafy ``` Save this as `search.py`, put your key in place of `YOUR_API_KEY`, and run `python search.py`: ```python from pexafy import Client client = Client("YOUR_API_KEY") for photo in client.search("a quiet street in the rain", per_page=5): print(photo.urls.regular) ``` It prints a link to each photo found. On macOS and Linux, type `pip3` and `python3` instead of `pip` and `python`. Rather keep the key out of your code? Write `Client()` and set the `PEXAFY_API_KEY` environment variable instead. The library also searches by image, pages through results for you, and comes with an async client and a `pexafy` command. Everything is in its [README on GitHub](https://github.com/Pexafy/pexafy-python) · [PyPI](https://pypi.org/project/pexafy/). ## JavaScript No package needed: with Node.js 18 or later, `fetch` is built in. Save this as `search.mjs`, put your key in place of `YOUR_API_KEY`, and run `node search.mjs`: ```javascript const API_KEY = "YOUR_API_KEY"; const url = new URL("https://api.pexafy.com/api/v1/search/photos"); url.searchParams.set("q", "a quiet street in the rain"); const response = await fetch(url, { headers: { "x-api-key": API_KEY }, }); if (!response.ok) throw new Error("HTTP " + response.status); const { data } = await response.json(); for (const photo of data) console.log(photo.urls.regular); ``` Run it on your computer or your server, never in a web page, where anyone could read your key. Building an AI agent in JavaScript or TypeScript? Use [LangChain.js](#langchain), the [Vercel AI SDK](#vercel-ai-sdk) or one of the [agent frameworks](#agent-frameworks). ## LangChain `langchain-pexafy` gives LangChain and LangGraph agents three tools: search photos, find similar photos and get one photo, each with its licence and credit line. Python: ```bash pip install -U langchain-pexafy ``` JavaScript: ```bash npm install langchain-pexafy @langchain/core ``` Set the `PEXAFY_API_KEY` environment variable, then hand the tools to your agent: Python: ```python from langchain_pexafy import PexafyToolkit tools = PexafyToolkit().get_tools() ``` JavaScript: ```ts import { PexafyToolkit } from "langchain-pexafy"; const tools = new PexafyToolkit().getTools(); ``` A complete agent, in Python and TypeScript: [LangChain & LangGraph](https://docs.pexafy.com/langchain). ## Vercel AI SDK `pexafy-ai-sdk` gives AI SDK agents three tools to find free-to-use photos, each with its licence and credit line. ```bash npm install pexafy-ai-sdk ai zod ``` Set the `PEXAFY_API_KEY` environment variable, then hand the tools to your model: ```ts import { pexafyTools } from "pexafy-ai-sdk"; const tools = pexafyTools(); ``` A complete example: [Vercel AI SDK](https://docs.pexafy.com/ai-sdk). ## Agent frameworks Most agent frameworks can use an MCP server, the standard way to plug tools into an AI agent. Point yours at `https://mcp.pexafy.com/mcp` and send your key as `Authorization: Bearer YOUR_KEY`: the agent gets Pexafy's search tools. Any Pexafy key works. One page per framework, with code you can copy: - [OpenAI Agents SDK](https://docs.pexafy.com/openai-agents): Python and TypeScript - [Claude Agent SDK](https://docs.pexafy.com/claude-agent-sdk): Python and TypeScript - [Google ADK](https://docs.pexafy.com/google-adk): Python and TypeScript - [Mastra](https://docs.pexafy.com/mastra): TypeScript - [CrewAI](https://docs.pexafy.com/crewai): Python - [LlamaIndex](https://docs.pexafy.com/llamaindex): Python - [Pydantic AI](https://docs.pexafy.com/pydantic-ai): Python - [Strands Agents](https://docs.pexafy.com/strands): Python - [Agno](https://docs.pexafy.com/agno): Python - [Microsoft Agent Framework](https://docs.pexafy.com/microsoft-agent-framework): Python Your framework isn't listed? If it can connect to a remote MCP server (Streamable HTTP), the same address and header work. What the tools do: [What your assistant can do](https://docs.pexafy.com/mcp#what-your-assistant-can-do). ## No-code There is no Pexafy app to install in n8n, Make or Zapier: one web request does the job. Add an HTTP step to your workflow with these settings: ``` Method: GET URL: https://api.pexafy.com/api/v1/search/photos Query: q = a cosy café on a rainy evening Header: x-api-key = YOUR_API_KEY ``` | Tool | Step to add | | --- | --- | | **n8n** | An **HTTP Request** node. Turn on **Send Query Parameters** for `q`, and **Send Headers** for `x-api-key`. | | **Make** | The **HTTP** app, **Make a request** module. Add `x-api-key` under **Headers**, `q` under **Query String**, and set **Parse response** to **Yes**. | | **Zapier** | **Webhooks by Zapier**, with the **GET** event. Add `q` under **Query String Params**, and `x-api-key` under **Headers**. | The answer is the same as in the [Quickstart](https://docs.pexafy.com/quickstart): the photos are in `data`, and the link to each one is in `urls.regular`. - [Prefer to ask in a chat?](https://docs.pexafy.com/mcp): ChatGPT, Claude, Cursor or VS Code can search Pexafy for you, with no code and, for most of them, no key. ====================================================================== # Plans & limits ====================================================================== https://docs.pexafy.com/plans The **free plan** includes **5,000 API requests a month** at up to **20 requests a minute** (1,200 an hour), with **1 API key**. It needs no credit card and does not expire. The monthly quota resets on the 1st of each month at 00:00 UTC. | Plan | Price | API requests / month | Rate limit | API keys | | --- | --- | --- | --- | --- | | Free | Free, no credit card | 5,000 | 20/minute (1,200/hour) | 1 | | Starter | $5/month or $48/year | 25,000 | 30/minute (1,800/hour) | 3 | | Pro | $19/month or $192/year | 250,000 | 60/minute (3,600/hour) | 5 | | Team | $59/month or $588/year | 1,000,000 | 200/minute (12,000/hour) | 25 | | Business | $99/month or $996/year | 2,000,000 | 300/minute (18,000/hour) | Unlimited | | Enterprise | $249/month or $2,496/year | 5,000,000 | 500/minute (30,000/hour) | Unlimited | Prices are in US dollars. Features that differ by plan (search filters, enriched fields, support) are compared on https://pexafy.com/pricing/ - **Monthly quota** — counted per account, across all its API keys, and reset on the 1st of each month at 00:00 UTC. Past it, the API answers `429` with `error.code` `QUOTA_EXCEEDED` and no `Retry-After` header: waiting a few seconds does not help, the next month or a bigger plan does. - **Rate limit** — requests per minute. Past it, the API answers `429` with `error.code` `RATE_LIMITED` and a `Retry-After` header, in seconds. - **Headers** — every response carries `X-Quota-Limit`, `X-Quota-Remaining`, `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset`, so a client can slow down before it hits a wall. See [Errors & rate limits](https://docs.pexafy.com/errors). - **Pages** — each page of results counts as one request, whether it is asked for with `page` or with `cursor`. - **Free calls** — reading your usage (`/usage`), the facets (`/facets/…`) and your collections does not count against the monthly quota. Generated from the live plan catalogue on 3 November 2026. ====================================================================== # Pagination ====================================================================== https://docs.pexafy.com/pagination Search results are returned **one page at a time**. You can move through them in either of two ways — use whichever your code already does: - **By number** — add `page=2`, `page=3`… to the same request, as with most photo APIs. - **With a cursor** — pass back the `next_cursor` token the previous page gave you. Both return the same photos in the same order. **Each page counts as one request** against your [quota](https://docs.pexafy.com/plans), whichever way you ask for it. ## The `pagination` object Every list response includes a `pagination` object next to your `data`: ```json { "success": true, "data": [ /* photos for this page */ ], "pagination": { "per_page": 20, "has_more": true, "next_cursor": "eyJycyI6Ij... (opaque token)", "total_results": null } } ``` | Field | Meaning | | --- | --- | | `per_page` | How many photos are on each page. You choose this with `per_page` (1–100, default 20). | | `has_more` | `true` if there is at least one more page after this one. | | `next_cursor` | The token to pass as `cursor` to get the next page. It is `null` when `has_more` is `false`. | | `total_results` | How many results can be paged through. Filled in when you page with `page`; `null` otherwise. | When the request carries `page`, two more fields come back: | Field | Meaning | | --- | --- | | `page` | The page you received (1 is the first). | | `next_page` | The number to send as `page` for the next page, or `null` on the last one. | ## Paging by number Send the same request with `page=1`, `page=2`, … and stop when `next_page` is `null` (or `has_more` is `false`). `page` starts at **1**. Page 1: ```bash curl "https://api.pexafy.com/api/v1/search/photos?q=a+child+discovering+snow+for+the+first+time&per_page=20&page=1" \ -H "x-api-key: YOUR_API_KEY" ``` Page 2: ```bash curl "https://api.pexafy.com/api/v1/search/photos?q=a+child+discovering+snow+for+the+first+time&per_page=20&page=2" \ -H "x-api-key: YOUR_API_KEY" ``` ```python import requests BASE = "https://api.pexafy.com/api/v1/search/photos" headers = {"x-api-key": "YOUR_API_KEY"} params = {"q": "a child discovering snow for the first time", "per_page": 20, "page": 1} photos = [] while params["page"]: r = requests.get(BASE, headers=headers, params=params).json() photos.extend(r["data"]) params["page"] = r["pagination"]["next_page"] # None after the last page print(f"Collected {len(photos)} photos") ``` ## Paging with a cursor 1. Make your search as usual. 2. Read `pagination.next_cursor` from the response. 3. Repeat the **same** request, adding `cursor=`. 4. Stop when `has_more` is `false` (at that point `next_cursor` is `null`). First page: ```bash curl "https://api.pexafy.com/api/v1/search/photos?q=a+child+discovering+snow+for+the+first+time&per_page=20" \ -H "x-api-key: YOUR_API_KEY" ``` Next page: ```bash curl "https://api.pexafy.com/api/v1/search/photos?q=a+child+discovering+snow+for+the+first+time&per_page=20&cursor=PASTE_next_cursor_HERE" \ -H "x-api-key: YOUR_API_KEY" ``` Here is the same loop in Python: ```python import requests BASE = "https://api.pexafy.com/api/v1/search/photos" headers = {"x-api-key": "YOUR_API_KEY"} params = {"q": "a child discovering snow for the first time", "per_page": 20} photos = [] while True: r = requests.get(BASE, headers=headers, params=params).json() photos.extend(r["data"]) page = r["pagination"] if not page["has_more"]: break params["cursor"] = page["next_cursor"] # follow the cursor print(f"Collected {len(photos)} photos") ``` > **Keep your query the same between pages.** The cursor already remembers your search > text and filters, so you only need to add `cursor`. Set `per_page` on the first > request; following pages keep that same page size. If you send both `cursor` and `page`, > the cursor wins. > **Warning:** > **Cursors are short-lived** — they stay valid for about **5 minutes**. If a cursor > expires (or you change the query), simply start again from the first page without a > `cursor`. Page numbers do not expire. ## How deep you can go A text search can be paged through up to its **100 best results** — five pages of 20, or one page of 100. A search with filters only (no `q`) goes deeper. Past the last result, `data` is an empty list and `has_more` is `false`. For more photos on a subject, vary the wording of `q` rather than going further down the same list: the best matches are at the top. > `limit` is not the page size: it caps the **total** number of results across all pages. > Use `per_page` for the number of photos per page. An unknown parameter is ignored and named > in `meta.warnings` — see [Errors & rate limits](https://docs.pexafy.com/errors#warnings). ## Which endpoints paginate? Three search endpoints support pagination: - **Search photos by text** — `GET /api/v1/search/photos` (`page` or `cursor`) - **Search photos by picture** — `POST /api/v1/search/photos` (an upload, or a `photo_id`; `cursor`) - **Find similar photos** — `GET /api/v1/photos/{photo_id}/similar` (`cursor`) They all work the same way with a cursor: read `pagination.next_cursor` and pass it back as `cursor` to get the next page, stopping when `has_more` is `false`. (On some plans the number of similar photos is capped to a single page — in that case `has_more` is `false` from the start.) > For **image search**, you only upload the image on the **first** request. To get the next > page, send the request again with just `cursor=` — no need to re-upload the > image. The cursor already remembers your image and filters. > > Searching with `photo_id` instead of an upload pages the same way. The per-plan cap on > similar photos applies to it too, so on a capped plan you get one page and `has_more` is > `false`. The other endpoints return a single response and do not take a `cursor`: facets, collections and usage return their full list directly. ====================================================================== # Idempotency ====================================================================== https://docs.pexafy.com/idempotency A network error does not tell you whether the server acted. Retrying a `POST` blindly risks doing the work twice — a second collection created, a second photo added. Send an **`Idempotency-Key`** and the retry is free: Pexafy replays the first response instead of running the request again. This applies to **`POST` requests only**. `GET` and `DELETE` are already safe to repeat, so they ignore the header. ## Using it Generate a unique key per logical operation — a UUID is the usual choice — and send it with the request: ```bash curl -X POST "https://api.pexafy.com/api/v1/collections" \ -H "x-api-key: $PEXAFY_API_KEY" \ -H "Idempotency-Key: 7d1f0c2e-3b64-4f8a-9c11-2ad5e6f80b93" \ -H "Content-Type: application/json" \ -d '{"name": "Autumn campaign"}' ``` Retry the exact same call and you get the same body and the same status code back, plus a header telling you it was a replay rather than a fresh action: ```http X-Idempotent-Replay: true ``` ## Rules | Rule | Detail | | --- | --- | | Scope | `POST` only. Other methods ignore the header. | | Key format | Up to 128 characters, letters, digits, `-` and `_`. Anything else is rejected with `400 INVALID_IDEMPOTENCY_KEY`. | | Retention | **24 hours.** After that the key is forgotten and the same request would act again. | | What is stored | Successful responses only (`2xx`). A failed request is not remembered, so you can retry it and actually get through. | | Reuse | A key identifies one operation. Reusing it for a *different* request returns the **first** response, not the new one — so never reuse a key across operations. | > Keys are stored per key value, not per endpoint. Generate a fresh one for each > operation you want to be able to retry. ## When to bother Use it whenever a failed call would be expensive to repeat — creating a collection, adding photos in bulk from a job that may be retried by your queue. For plain searches it adds nothing: `GET /search/photos` is already safe to repeat as often as you like. ====================================================================== # Errors & status codes ====================================================================== https://docs.pexafy.com/errors Every error uses the **same envelope** as successful responses — only `success` is `false` and the `error` object is populated: ```json { "success": false, "data": null, "meta": { "request_id": "b3f1c2e4-...", "took_ms": 2.9 }, "error": { "code": "MISSING_PARAMS", "message": "At least one criterion required: q, color_name, color_hex, orientation, source, license_type, photographer or after_date.", "request_id": "b3f1c2e4-..." } } ``` Always branch on `error.code` (stable, machine-readable) rather than parsing `error.message` (human-readable, may change). Quote `meta.request_id` when contacting support. ## HTTP status codes | Status | Meaning | | --- | --- | | `200` / `201` | Success. | | `400` | Bad request — a parameter is missing or invalid. | | `401` | Authentication failed — missing or invalid key. Send it in the `x-api-key` header or as `Authorization: Bearer `, never in the URL. | | `403` | Forbidden — your plan or account is not allowed to perform this action. | | `404` | The resource (photo, collection, photographer) or route does not exist. | | `409` | Conflict — the action clashes with the current state (e.g. duplicate). | | `422` | Validation error — a parameter failed validation (type, range, required). | | `429` | Too many requests — you hit the rate limit or the monthly quota; `error.code` says which. | | `500` | Internal error — something went wrong on our side. | | `504` | The search backend timed out — retry shortly. | ## Error codes | `error.code` | Status | When it happens | | --- | --- | --- | | `MISSING_PARAMS` | 400 | A search was sent with no query and no filter. | | `INVALID_PARAMS` | 400 | Conflicting parameters (e.g. `color_name` **and** `color_hex` together). | | `INVALID_ID` | 400 | `photo_id` is not a valid UUID. | | `VALIDATION_ERROR` | 422 | A parameter failed validation (out of range, wrong type, required). The `error.fields` array lists each offending parameter. | | `MISSING_IMAGE` | 422 | Image search was called without an `image` file. | | `INVALID_IMAGE` | 422 | The uploaded file is not a supported image (JPEG, PNG, WebP, AVIF) or is too large. | | `UNAUTHORIZED` | 401 | The `x-api-key` header is missing or invalid. | | `FORBIDDEN` | 403 | Your account/plan cannot perform this action. | | `PLAN_RESTRICTION` | 403 | The requested field or feature is not in your plan. | | `COLLECTIONS_LIMIT_REACHED` | 403 | You reached the maximum number of collections for your plan. | | `PHOTO_NOT_FOUND` | 404 | No photo matches the given `photo_id`. | | `NOT_FOUND` | 404 | The collection, photographer or route does not exist. For a route, `error.message` names the one you probably meant (e.g. `/api/v1/search/photos` for `/v1/search`). | | `PHOTO_ALREADY_IN_COLLECTION` | 409 | The photo is already in that collection. | | `RATE_LIMITED` | 429 | You exceeded the request rate limit. | | `QUOTA_EXCEEDED` | 429 | You used your plan's monthly requests. Resets on the 1st of the month at 00:00 UTC. | | `SEARCH_TIMEOUT` | 504 | The search backend did not respond in time — retry. | | `INTERNAL_ERROR` | 500 | Unexpected server error — retry, then contact support with the `request_id`. | > `VALIDATION_ERROR` responses include an extra `error.fields` array — one entry per invalid > parameter with its `field`, `message` and `type` — so you can show precise form errors. ## Warnings A parameter the endpoint does not know is **ignored, not refused** — the request still succeeds. So that it does not go unnoticed, the response then carries a `meta.warnings` list and an `X-Pexafy-Warning` header naming what was ignored and what to send instead: ```json { "success": true, "data": [ /* photos */ ], "meta": { "request_id": "b3f1c2e4-...", "took_ms": 41.7, "warnings": [ { "code": "UNKNOWN_PARAMETER", "parameter": "page_size", "message": "`page_size` is not a parameter of this endpoint and was ignored. Use `per_page` (1–100, default 20) for the page size." } ] } } ``` | `warnings[].code` | When it happens | | --- | --- | | `UNKNOWN_PARAMETER` | The parameter is not read by this endpoint (a typo, or a name from another API). | | `LIMIT_IS_TOTAL` | `limit` was sent without `per_page`: `limit` caps the total across pages, `per_page` sets the page size. | | `INVALID_PAGE` | `page` is not a whole number from 1; the first page was returned. | | `PAGE_IGNORED` | Both `page` and `cursor` were sent; the cursor was used. | | `QUERY_IGNORED` | Both `q` and `query` were sent; `q` was used. | | `QUERY_TOO_LONG` | `query` is longer than 500 characters and was not used. | `meta.warnings` is absent when there is nothing to report, so its presence alone tells you to look at your parameters. ## Rate limits and quotas Two limits apply to every API key, both set by your plan — see [Plans & limits](https://docs.pexafy.com/plans) for the figures: - a **rate limit**, in requests per minute. Past it you get `429` `RATE_LIMITED` with a `Retry-After` header (seconds): wait that long and retry. - a **monthly quota**, counted per account across all its keys. Past it you get `429` `QUOTA_EXCEEDED` and **no** `Retry-After`: retrying does not help until the quota resets on the 1st of the month (00:00 UTC), or until you move to a bigger plan. Every response tells you where you stand: | Header | Meaning | | --- | --- | | `X-Plan` | Your plan. | | `X-Quota-Limit` | Requests included per month. | | `X-Quota-Remaining` | Requests left this month. | | `X-RateLimit-Limit` | Requests allowed per minute. | | `X-RateLimit-Remaining` | Requests left in the current minute. | | `X-RateLimit-Reset` | Unix timestamp (seconds) by which the per-minute window has reset. | Each page of results counts as one request, whether you ask for it with `page` or with `cursor` (see [Pagination](https://docs.pexafy.com/pagination)). Reading your usage (`/usage`), the facets (`/facets/…`) and your collections does not count against the monthly quota. ====================================================================== # Connect your assistant ====================================================================== https://docs.pexafy.com/mcp Pexafy lets your AI assistant find real photos that are free to use: ask in your own words, *"a cosy café on a rainy evening, for my blog post"*, and the photos appear right in the conversation. It plugs in through **MCP**, the standard way assistants plug in tools, so you add Pexafy once and it is there whenever you need a photo. - [Add to ChatGPT](https://chatgpt.com/plugins/plugin_asdk_app_6a837089eb1c8191b29a0d126a54f770?search=pexafy): One click from ChatGPT's app directory. A free Pexafy account is enough. - [Another assistant](#connect-your-assistant): Claude, Cursor, VS Code, Claude Code and more: follow the steps for yours below. ## Do you need a key? Usually not. There are two ways to connect an assistant: - **Sign in (recommended)**: Nothing to copy. You add Pexafy to your assistant, a Pexafy window opens, you sign in and click **Authorize**. The connection makes its own key, shown in **API Keys** as *Connected assistant*. - **With a key**: For tools that cannot open a sign-in window: scripts, agent frameworks, CI. You paste a key in the tool's settings, sent as `Authorization: Bearer YOUR_KEY`. | Your assistant | How it connects | | --- | --- | | **ChatGPT** | [One click](https://chatgpt.com/plugins/plugin_asdk_app_6a837089eb1c8191b29a0d126a54f770?search=pexafy), then sign in. | | **Claude.ai, Claude Desktop** | Add a connector, then sign in. | | **LibreChat** | Add the server, then sign in. | | **Devin** | One command, then sign in. A key works too. | | **Claude Code** | One command. Search right away, sign in from the terminal when you want. A key works too. | | **Codex, OpenCode** | One command. Search right away, sign in from the terminal when you want. | | **Cursor, VS Code, Cline, Zed** | Add the server. Search right away, sign in from the chat when you want. A key works too. | | **Gemini CLI, GitHub Copilot CLI, Factory Droid** | One command. Search right away, sign in from the chat when you want. | | **Agent frameworks, scripts, CI** | A key: see [agent frameworks](https://docs.pexafy.com/sdks#agent-frameworks). | *Search right away* means without an account, with a small daily allowance to try Pexafy. To use your own Pexafy plan, ask your assistant *"connect my Pexafy account"*: the Pexafy sign-in page opens in your browser. > **Which key?** Any Pexafy key works, with the MCP server and with the API. To create one labelled > for assistants, open [Create a key](https://pexafy.com/dashboard/api-keys/create/), choose the > **MCP Agent** key type, then click **Create API Key**. ## Connect your assistant Every assistant uses the same address. You don't open it in a browser: you paste it into your assistant. ``` https://mcp.pexafy.com/mcp ``` ### Chat apps #### ChatGPT **The easy way: one click.** - [Add Pexafy to ChatGPT](https://chatgpt.com/plugins/plugin_asdk_app_6a837089eb1c8191b29a0d126a54f770?search=pexafy): Opens Pexafy in ChatGPT's app directory. 1. Click the card above: Pexafy opens in ChatGPT's app directory. Install it. 2. When ChatGPT asks, sign in with your Pexafy account and click **Authorize**. A free account is enough. 3. In a new chat, type **@Pexafy**, pick Pexafy in the list that appears, then say what you need. > Picking Pexafy from the **@** list is what tells ChatGPT to use it: typing the word alone is > not enough. You can also start your message with *"Pexafy, find photos of…"*. **The advanced way: developer mode.** Only if you want to add the server by hand. 1. Open **Settings → Security and login** and turn on **Developer mode**. 2. Go to **Plugins** and click **+** to create a developer-mode app. 3. Name it `Pexafy` and paste `https://mcp.pexafy.com/mcp`. 4. Choose **OAuth** as the authentication method, then sign in with Pexafy. Developer mode is available to Plus, Pro, Business, Enterprise and Education accounts on the web. #### Claude Claude.ai and Claude Desktop sign in with your Pexafy account: there is no key to paste. 1. Open **Customize → Connectors**. 2. Click **+**, then **Add custom connector**. 3. Paste `https://mcp.pexafy.com/mcp` and click **Add**. 4. Sign in with Pexafy in the window Claude opens, and approve access. Works on every Claude plan: Free, Pro, Max, Team and Enterprise. A free Claude account can hold one custom connector. Step by step, with tips: [Connect Pexafy in Claude](https://docs.pexafy.com/claude). #### LibreChat LibreChat detects that Pexafy uses sign-in: each user signs in with their own Pexafy account, there is no key to paste. 1. Open **MCP Settings** and click **+**. 2. Name the server `Pexafy` and paste `https://mcp.pexafy.com/mcp`. 3. Leave **Streamable HTTPS** and **None (Auto-detect)** as they are, tick **I trust this application**, then click **Create**. 4. Click **Connect**, then **Continue with OAuth**, and sign in with Pexafy. If you run LibreChat yourself, you can add Pexafy for every user in `librechat.yaml` instead, then restart it. Each user still signs in with Pexafy once, from **Connect**. ```yaml mcpServers: pexafy: type: streamable-http url: https://mcp.pexafy.com/mcp ``` ### Code editors and coding agents #### Claude Code In a terminal, from any project, run: ```bash claude mcp add --transport http pexafy https://mcp.pexafy.com/mcp ``` Ask for photos in plain language: it works right away, without an account. To use your Pexafy account, sign in from the terminal. The Pexafy sign-in page opens in your browser, with no key to copy: ```bash claude mcp login pexafy ``` Prefer a project file? Add the same entry to `.mcp.json`. An entry with a `url` but no `type` is rejected. ```json { "mcpServers": { "pexafy": { "type": "http", "url": "https://mcp.pexafy.com/mcp" } } } ``` **With a key instead (optional).** For a machine where you can't sign in in a browser: ```bash claude mcp add --transport http pexafy https://mcp.pexafy.com/mcp --header "Authorization: Bearer YOUR_KEY" ``` You can also install the [Claude Code plugin](#claude-code-plugin), which adds the server and two skills at once. #### Cursor **In one click:** [Add to Cursor](https://cursor.com/install-mcp?name=pexafy&config=eyJ1cmwiOiJodHRwczovL21jcC5wZXhhZnkuY29tL21jcCJ9). Or by hand: create `.cursor/mcp.json` in your project (or `~/.cursor/mcp.json` for every project): ```json { "mcpServers": { "pexafy": { "url": "https://mcp.pexafy.com/mcp" } } } ``` Reopen Cursor and check Pexafy under **Customize** in the sidebar. Ask for photos in plain language: it works right away, without an account. To use your Pexafy account, ask the agent *"connect my Pexafy account"*: the Pexafy sign-in page opens in your browser. With a key: add `"headers": { "Authorization": "Bearer YOUR_KEY" }` next to `"url"`. #### VS Code For GitHub Copilot in VS Code. **In one click:** [Install in VS Code](https://vscode.dev/redirect?url=vscode%3Amcp%2Fby-name%2Fcom.pexafy%2Fpexafy-mcp). Or by hand: run **MCP: Add Server** from the Command Palette, or create `.vscode/mcp.json` yourself: ```json { "servers": { "pexafy": { "type": "http", "url": "https://mcp.pexafy.com/mcp" } } } ``` Open Chat in **Agent** mode and pick Pexafy in the tools list. Ask for photos in plain language: it works right away, without an account. To use your Pexafy account, ask *"connect my Pexafy account"*: the Pexafy sign-in page opens in your browser. With a key: add `"headers": { "Authorization": "Bearer YOUR_KEY" }` next to `"url"`. #### Codex In a terminal, from any project, run: ```bash codex mcp add pexafy --url https://mcp.pexafy.com/mcp ``` Codex opens the Pexafy sign-in page as soon as you add the server: sign in, or close it and carry on without an account. To sign in later: ```bash codex mcp login pexafy ``` #### Cline In a terminal, from any project, run: ```bash cline mcp install pexafy --transport http https://mcp.pexafy.com/mcp ``` Ask for photos in plain language: it works right away, without an account. To use your Pexafy account, ask *"connect my Pexafy account"*: the Pexafy sign-in page opens in your browser. With a key, add it to the command instead: ```bash cline mcp install pexafy --transport http https://mcp.pexafy.com/mcp --header "Authorization: Bearer YOUR_KEY" ``` Check it with `cline config mcp`. #### Devin In a terminal, from any project, run: ```bash devin mcp add -s user pexafy https://mcp.pexafy.com/mcp ``` Devin opens the Pexafy sign-in page: approve access, then ask for a photo in plain language. With a key instead: ```bash devin mcp add -s user pexafy https://mcp.pexafy.com/mcp -H "Authorization: Bearer YOUR_KEY" ``` Check it with `devin mcp list`. #### Zed Zed connects to remote MCP servers natively, without an extension. 1. Open **Settings → AI → MCP Servers**. 2. Click **Add Server**, choose **Add Remote Server** and paste `https://mcp.pexafy.com/mcp`. 3. Ask for photos in plain language in the Agent Panel: it works right away, without an account. 4. To use your Pexafy account, ask *"connect my Pexafy account"*: Zed opens the Pexafy sign-in page (Zed 1.11.3 or later). The same entry in `settings.json`: ```json { "context_servers": { "pexafy": { "url": "https://mcp.pexafy.com/mcp" } } } ``` With a key: add `"headers": { "Authorization": "Bearer YOUR_KEY" }` next to `"url"`. #### More agents One command adds Pexafy to each of these, from its command line: Gemini CLI: ```bash gemini mcp add -s user --transport http pexafy https://mcp.pexafy.com/mcp ``` GitHub Copilot CLI: ```bash copilot mcp add --transport http pexafy https://mcp.pexafy.com/mcp ``` OpenCode: ```bash opencode mcp add pexafy --url https://mcp.pexafy.com/mcp ``` Factory Droid: ```bash droid mcp add pexafy https://mcp.pexafy.com/mcp --type http ``` Ask for photos in plain language: it works right away, without an account. To use your Pexafy account, ask *"connect my Pexafy account"*. In OpenCode, you can also sign in from the terminal with `opencode mcp auth pexafy`. **Another tool?** Any MCP client that supports remote servers (Streamable HTTP) works: give it `https://mcp.pexafy.com/mcp`. It signs in if it can; otherwise, send a key as `Authorization: Bearer YOUR_KEY`. ## What your assistant can do Pexafy gives your assistant five tools. You never call them yourself: ask in plain words and the assistant picks the right one. All of them are read-only: they find and fetch photos, and never change anything in your account. | Tool | What it does | Ask, for example | | --- | --- | --- | | `search_photos` | Finds photos from a description. It can keep only landscape, portrait or square photos. | *"Find photos of two people sharing a bench in comfortable silence, landscape only."* | | `search_photos_by_image` | Finds photos that look like an image: a link, a file, base64 data or a photo it already found. Words can adjust the result. | *"More like the second one, but at night."* | | `get_photo_file_by_photo_id` | Gives one photo as an image file, with the credit line to display. | *"Give me the first photo as a file for my slide."* | | `get_grid_selected_photos` | Reads the photos you liked in the results grid, in the order you chose. | *"Use the photos I liked for my article."* | | `connect_account` | Links your Pexafy account from the conversation. | *"Connect my Pexafy account."* | In ChatGPT, Claude, VS Code and Cursor, the results appear as a **grid** in the conversation: open a photo, heart the ones you like, press **≈** for more like it. Your picks go back to the assistant, in your order. In a terminal, the results arrive as links with their credit lines. > Describe the scene, not keywords: *"the last sunlight of the day on a dusty windowsill"* works > better than *"sunlight window"*. If your assistant reaches for another image tool, name it: > *"Search Pexafy for…"*, or tell it once: *"Use Pexafy whenever I ask for a photo."* ## Why not the built-in image search? Most assistants can already search images on the web. They return whatever ranks: screenshots, logos, watermarked previews, often images you have **no right to reuse**, behind links that break. - **Every result is usable.** Professional, high-resolution photos from free-photo libraries, **free to use, with no attribution required**. A ready-made credit line comes with each photo if you'd still like to credit the photographer. - **Built for photography.** Pexafy understands scenes, light and mood: *"the quiet after a summer thunderstorm"* returns photos that fit the idea, not just the words. - **Stable results.** Each photo comes with real image links, its photographer and its source page, not a web page that may disappear. ## Skills for coding agents A skill is a short guide that teaches a coding agent when a request calls for real photos, which Pexafy tool fits it, and how to hand each photo over with its licence and credit line. It works alongside the server; it does not replace it. It is optional. ```bash npx skills add Pexafy/pexafy-mcp --skill find-stock-photos ``` This needs [Node.js](https://nodejs.org). It installs the `find-stock-photos` skill for the coding agents on your computer: Claude Code, Cursor, Codex, GitHub Copilot, Cline and others. In Cline, this does the same: ```bash cline skill install Pexafy/pexafy-mcp --skill find-stock-photos ``` ### Claude Code plugin The Pexafy plugin for Claude Code adds the Pexafy server and two skills: `find-photos`, and `illustrate-content`, which picks one photo per section of an article, a page or a deck. Type these two commands inside Claude Code: ``` /plugin marketplace add Pexafy/pexafy-plugins /plugin install pexafy@pexafy ``` With the plugin, you don't need `claude mcp add`. To sign in, run `/mcp` in Claude Code, pick Pexafy and follow the steps in your browser. ## Limits and the Free plan - Searches made by your assistant count against your Pexafy plan, like API calls. What each plan includes: [Plans & limits](https://docs.pexafy.com/plans). - **The Free plan includes one key in total, and a connected assistant uses it too.** Every assistant you connect by signing in shares that key. If you already created a key, the sign-in window offers to revoke it (see [Troubleshooting](#troubleshooting)). - Without an account, the tools that allow it come with a small daily allowance, to try Pexafy. - When you reach a limit, your assistant tells you in the conversation. Need more? Compare the plans on [pexafy.com/pricing](https://pexafy.com/pricing/). ## Troubleshooting #### It asks me to free a key The Free plan includes one key in total. If you already have one, the sign-in window says **Free up a key to connect…** and lists your key with a **Revoke** button. - **Revoke it**, and the assistant connects. Anything that used that key, such as your code, stops working. - Or click **Cancel** and keep your key. Paste it into a tool that takes a key (Claude Code, Cursor, VS Code, Cline, Devin, Zed), or keep using it in your code. Paid plans include more keys: see [Plans & limits](https://docs.pexafy.com/plans). #### Which key do I use? Most assistants need none: they sign in, and the connection makes its own key. For a tool that asks for a key, any Pexafy key works, with the MCP server and with the API. In the dashboard, the **MCP Agent** key type creates one labelled for assistants. Send it as `Authorization: Bearer YOUR_KEY`. #### Nothing happens after I authorize Try again in a normal browser window, not a private one, and allow pop-ups for the page. Signing in to [pexafy.com](https://pexafy.com) first, in the same browser, also helps. Still stuck? Remove Pexafy from your assistant, add it again, and sign in. #### My assistant does not use Pexafy Check that Pexafy is turned on in your assistant's tools or connectors. Then name it: *"Search Pexafy for photos of…"*. In ChatGPT, type **@Pexafy** and pick it from the list. You can also tell your assistant once: *"Use Pexafy whenever I ask for a photo."* #### I see links, not a grid of photos The grid appears where the assistant can display it: ChatGPT, Claude, VS Code and Cursor. Elsewhere, such as in a terminal, the results arrive as links with their credit lines. #### How do I disconnect? Remove Pexafy from your assistant's settings. Or revoke the *Connected assistant* key in [API Keys](https://pexafy.com/dashboard/api-keys/): this disconnects every assistant you connected by signing in. #### Is the server up? [mcp.pexafy.com/health](https://mcp.pexafy.com/health) answers without signing in. The status of every Pexafy service is on [status.pexafy.com](https://status.pexafy.com). ## Go further - [Building your own app?](https://docs.pexafy.com/quickstart): Call the REST API with a key: copy-paste code in Python, JavaScript, PHP and cURL. - [Libraries & integrations](https://docs.pexafy.com/sdks): Python, LangChain, the Vercel AI SDK, agent frameworks and no-code tools. > No Pexafy account yet? [Create a free one](https://pexafy.com/auth/register/): it takes a minute > and no credit card is required. ====================================================================== # Connect Pexafy in Claude ====================================================================== https://docs.pexafy.com/claude Pexafy plugs into Claude as a connector, so you can find photos without leaving the conversation. Just describe what you need, *"a child discovering snow for the first time"*, and Claude returns real photos that are free to use. Every Claude app connects the same way: you **sign in with your Pexafy account** once. There is no key to copy. Using ChatGPT? [Add Pexafy to ChatGPT in one click](https://chatgpt.com/plugins/plugin_asdk_app_6a837089eb1c8191b29a0d126a54f770?search=pexafy). Cursor, VS Code or another assistant? See [Use Pexafy in your AI assistant](https://docs.pexafy.com/mcp). The connector lives at a single address: ``` https://mcp.pexafy.com/mcp ``` Pick the guide that matches the Claude app you use. #### Claude.ai & Claude Desktop These apps connect by **signing in**: you log in with your Pexafy account and approve access. There is **no key to copy or paste**. 1. **Open connector settings** In Claude, go to **Customize → Connectors**, click **+**, then choose **Add custom connector**. 2. **Add the Pexafy address** Give it a name (for example `Pexafy`) and paste the server address: ``` https://mcp.pexafy.com/mcp ``` Click **Add**. 3. **Sign in with Pexafy** Claude opens a Pexafy sign-in window. Log in with your Pexafy account and approve the requested access. Claude handles the rest automatically. > No account yet? [Create a free Pexafy account](https://pexafy.com/auth/register/) first, > then come back and connect. 4. **Start searching** Pexafy now appears in Claude's tool list. Ask for a photo in plain language and Claude will use Pexafy to find it, and show the photos inline. Works on every Claude plan: Free, Pro, Max, Team and Enterprise. A free Claude account can hold one custom connector. On a Team or Enterprise plan, an owner may need to add Pexafy first, under **Organization settings → Connectors**. #### Claude Code Claude Code also connects by **signing in**. A key is optional. 1. **Add the server** In a terminal, from any project, run: ```bash claude mcp add --transport http pexafy https://mcp.pexafy.com/mcp ``` You can ask for photos right away, without an account, with a small daily allowance. 2. **Sign in with Pexafy** Run: ```bash claude mcp login pexafy ``` The Pexafy sign-in page opens in your browser: sign in and approve access. No key to copy. You can also ask Claude *"connect my Pexafy account"*. 3. **Check and search** Run `claude mcp list` to confirm Pexafy is connected, then ask Claude for a photo in plain language. Prefer a project file? Add this to `.mcp.json` at your project root. An entry with a `url` but no `type` is rejected. ```json { "mcpServers": { "pexafy": { "type": "http", "url": "https://mcp.pexafy.com/mcp" } } } ``` #### Use a key instead (optional) For a machine where you can't sign in in a browser, such as a CI runner. Any Pexafy key works: [create one](https://pexafy.com/dashboard/api-keys/create/), or reuse the key you already have. Then run: ```bash claude mcp add --transport http pexafy https://mcp.pexafy.com/mcp \ --header "Authorization: Bearer YOUR_KEY" ``` In `.mcp.json`, add `"headers": { "Authorization": "Bearer YOUR_KEY" }` next to `"url"`. > **Warning:** > Send the key in the **`Authorization: Bearer`** header, as shown. Keep it out of shared > configs and public repositories. #### Other MCP clients ChatGPT, Cursor, VS Code, Codex, Zed and more have their own steps on [Use Pexafy in your AI assistant](https://docs.pexafy.com/mcp#connect-your-assistant). The address is a standard remote MCP server over Streamable HTTP, so any [MCP-compatible](https://modelcontextprotocol.io) client works. Point it at: ``` https://mcp.pexafy.com/mcp ``` Authenticate either way: - **Sign in (OAuth)**: the server supports OAuth discovery and dynamic client registration, so clients that support it connect with no key at all. - **A key**: send any Pexafy key as `Authorization: Bearer YOUR_KEY`. ## The Claude Code plugin (optional) The Pexafy plugin adds the Pexafy server and two skills to Claude Code: `find-photos`, and `illustrate-content`, which picks one photo per section of an article, a page or a deck. Type these two commands inside Claude Code: ``` /plugin marketplace add Pexafy/pexafy-plugins /plugin install pexafy@pexafy ``` With the plugin, you don't need `claude mcp add`. To sign in, run `/mcp` in Claude Code, pick Pexafy and follow the steps in your browser. Prefer a skill for every coding agent on your computer? See [Skills for coding agents](https://docs.pexafy.com/mcp#skills-for-coding-agents). ## What you can ask for Once connected, just talk to Claude naturally. A few examples: - *"Find me a few photos of two people sharing a bench in comfortable silence."* - *"I need a hero image: the last sunlight of the day hitting a dusty windowsill, landscape orientation."* - *"Here's a photo I like: find more like this one."* Pexafy searches by **meaning**: the more you describe the scene, light and mood, the better the match. Full sentences beat bare keywords. What each Pexafy tool does: [What your assistant can do](https://docs.pexafy.com/mcp#what-your-assistant-can-do). > **Make Pexafy your default image search.** When several image tools are available, Claude may > reach for its built-in web image search instead of Pexafy. Just tell it once, for example > *"Use Pexafy as the default tool whenever I ask for a photo or image"*, and it will route > image requests to Pexafy for the rest of the conversation. You can also name it explicitly any > time: *"Search Pexafy for…"*. ## Using the photos Results are **free to use — no attribution required**. If you'd still like to credit the photographer (or a photo's license asks for it), every result ships with ready-to-display **attribution** (`attribution.html` and `attribution.plain`). See the [API Reference](https://docs.pexafy.com/api-reference/search/search-photos-by-text) for the full list of fields each result carries. ## FAQ #### Do I need an API key? No. Claude.ai, Claude Desktop and Claude Code all **sign in** with your Pexafy account: the connection makes its own key, listed in **API Keys** as *Connected assistant*. In Claude Code, a key is optional, for a machine where you can't sign in in a browser. Either way, searches run against your own Pexafy account. #### Is it free? Pexafy has a free plan, and the connector uses the same quota as the rest of the API: there is no extra charge for searching through Claude. Usage counts against your plan's limits. See [Plans & limits](https://docs.pexafy.com/plans) for what each plan includes. #### The sign-in window asks me to free up a key. What's wrong? Nothing is broken. The **Free plan includes one key in total**, and a connected assistant uses it too. If you already have a key, the sign-in window says **Free up a key to connect…** and lists it with a **Revoke** button. Revoke it and Claude connects; anything that used that key, such as your code, stops working. Or click **Cancel** and keep your key: in Claude Code, you can use it as shown in *Use a key instead*. Paid plans include more keys. #### Can I use my existing API key? Yes, in Claude Code. **Any Pexafy key works**, with the MCP server and with the API, whether you created it for your code or for an assistant. In the dashboard, the **MCP Agent** key type creates one labelled for assistants. Pass it in the `Authorization: Bearer` header (see *Use a key instead* in the Claude Code tab). Claude.ai and Claude Desktop always sign in instead: they have no field for a key. #### Which assistants are supported? Any client that speaks the Model Context Protocol. This page covers **Claude.ai**, **Claude Desktop** and **Claude Code**. ChatGPT, Cursor, VS Code, Codex, Zed and others are on [Use Pexafy in your AI assistant](https://docs.pexafy.com/mcp). #### Will Claude show the photos, or just links? Compatible clients (Claude.ai and Claude Desktop) display the photos **inline**, as a grid in the conversation, so you can see results without opening links. In Claude Code, the results arrive as links with their credit lines. The structured data (photo IDs, URLs and attribution) is always included too. #### Do I have to credit the photographer? Follow the license of each photo. Free-licensed photos don't strictly require it, but attribution is appreciated; other licenses may require credit. Every result ships with ready-made `attribution.html` and `attribution.plain` strings so you can display credit correctly. #### How many photos does each search return? By default a search returns a page of results, and the assistant typically shows a handful inline. You can always ask for more ("show me a few more") or narrow the request with a more specific description or a filter like orientation or color. #### Is my data safe? The connector only relays your searches to the Pexafy API over HTTPS and returns the results. Your queries run under your own account and quota. You can disconnect at any time by removing the connector in your Claude settings, or by revoking its key in your Pexafy dashboard. - [All AI assistants](https://docs.pexafy.com/mcp): ChatGPT in one click, Cursor, VS Code, Codex and more, the tools and troubleshooting. - [Build your own integration](https://docs.pexafy.com/quickstart): The same search powers the REST API: start with the Quickstart. ====================================================================== # Vercel AI SDK ====================================================================== https://docs.pexafy.com/ai-sdk `pexafy-ai-sdk` gives [AI SDK](https://ai-sdk.dev) agents three tools to find real, free-to-use photos (Unsplash, Pexels, Pixabay and more). Each photo comes back with its URL, alt text, licence and credit line. ## Install ```bash npm install pexafy-ai-sdk ai zod ``` Set `PEXAFY_API_KEY`. Create a free key at [pexafy.com/dashboard/api-keys/create](https://pexafy.com/dashboard/api-keys/create/) (no card). ## Use ```bash npm install @ai-sdk/anthropic # for this example; any AI SDK provider works export ANTHROPIC_API_KEY="sk-ant-..." ``` ```ts import { anthropic } from "@ai-sdk/anthropic"; import { generateText, stepCountIs } from "ai"; import { pexafyTools } from "pexafy-ai-sdk"; const { text } = await generateText({ model: anthropic("claude-haiku-4-5"), tools: pexafyTools(), stopWhen: stepCountIs(5), prompt: "Find a header photo for a post about remote work, with its credit line.", }); console.log(text); ``` ## Tools | Function | Arguments the model fills | |---|---| | `searchPhotos()` | `query`, optional `orientation` (`landscape`, `portrait`, `square`), `count` | | `findSimilarPhotos()` | `photo_id`, optional `count` | | `getPhoto()` | `photo_id` | `pexafyTools()` returns all three. Options on each: `apiKey`, `maxResults` (default 6, max 20), `timeoutMs` (default 30000), `maxRetries` (default 2). ## Output Each photo is one record: ```json { "rank": 1, "photo_id": "019e1ea7-2e82-7a34-a451-4c6c7c8250f4", "alt_text": "Red bicycle parked against white wall with front wheel facing left and back wheel right", "url": "https://images.unsplash.com/photo-1520538254843-27a40bae5e3a?w=1280", "thumbnail_url": "https://images.unsplash.com/photo-1520538254843-27a40bae5e3a?w=400", "width": 4896, "height": 3264, "orientation": "landscape", "dominant_color": "#CAB8B4", "photographer": "Mitchel Lensink", "source": "Unsplash", "source_page_url": "https://unsplash.com/photos/red-bicycle-near-white-wall-Hx_dY7Xeszo", "license": "free", "credit": "Photo by Mitchel Lensink on Unsplash (https://pexafy.com/legal/licenses/#unsplash)" } ``` On the free plan, show the `credit` line next to each photo you publish. ## Errors A spent quota, an unknown `photo_id` or an invalid key reaches the model as a tool error. A per-minute rate limit, a server error or a network failure is retried automatically. See [Errors & rate limits](https://docs.pexafy.com/errors). [Source on GitHub](https://github.com/Pexafy/pexafy-ai-sdk) · [npm](https://www.npmjs.com/package/pexafy-ai-sdk) · MIT ====================================================================== # LangChain & LangGraph ====================================================================== https://docs.pexafy.com/langchain `langchain-pexafy` (Python and JavaScript) gives [LangChain](https://docs.langchain.com) and LangGraph agents three tools to find real, free-to-use photos (Unsplash, Pexels, Pixabay and more). Each photo comes back with its URL, alt text, licence and credit line. ## Install Python: ```bash pip install -U langchain-pexafy ``` TypeScript: ```bash npm install langchain-pexafy @langchain/core ``` ```bash export PEXAFY_API_KEY="pexafy_..." ``` Create a free key at [pexafy.com/dashboard/api-keys/create](https://pexafy.com/dashboard/api-keys/create/) (no card). ## Use The examples also need LangChain's agent and a chat model (any provider works): Python: ```bash pip install -U langchain langchain-anthropic ``` TypeScript: ```bash npm install langchain @langchain/anthropic ``` Python: ```python from langchain.agents import create_agent from langchain_pexafy import PexafyToolkit agent = create_agent("anthropic:claude-haiku-4-5", tools=PexafyToolkit().get_tools()) result = agent.invoke({"messages": [ {"role": "user", "content": "Find a header photo for a post about remote work, with its credit line."} ]}) print(result["messages"][-1].content) ``` TypeScript: ```ts import { createAgent } from "langchain"; import { PexafyToolkit } from "langchain-pexafy"; const agent = createAgent({ model: "anthropic:claude-haiku-4-5", tools: new PexafyToolkit().getTools(), }); const result = await agent.invoke({ messages: [{ role: "user", content: "Find a header photo for a post about remote work, with its credit line." }], }); console.log(result.messages.at(-1)?.content); ``` Set `ANTHROPIC_API_KEY` for this example. `create_agent` / `createAgent` runs on LangGraph; the tools also work with `ToolNode` and any model's `bind_tools()` / `bindTools()`. ## Tools | Class | Tool name | Arguments | |---|---|---| | `PexafySearchPhotos` | `pexafy_search_photos` | `query`, optional `orientation`, `count` | | `PexafyFindSimilarPhotos` | `pexafy_find_similar_photos` | `photo_id`, optional `count` | | `PexafyGetPhoto` | `pexafy_get_photo` | `photo_id` | `PexafyToolkit().get_tools()` (Python) or `new PexafyToolkit().getTools()` (TypeScript) returns all three. Options on each: `api_key` / `apiKey`, `max_results` / `maxResults` (default 6, max 20). ## Output The tool message is a JSON list with one record per photo: `photo_id`, `alt_text`, `url`, `thumbnail_url`, `width`, `height`, `orientation`, `dominant_color`, `photographer`, `source`, `source_page_url`, `license`, `credit`. `ToolMessage.artifact` holds the full API records. On the free plan, show the `credit` line next to each photo you publish. ## Errors A spent quota, an unknown `photo_id` or a server error reaches the model as a tool error. A per-minute rate limit is retried automatically. An invalid key raises `pexafy.AuthenticationError` in Python; in TypeScript, LangGraph's `ToolNode` passes it to the model as a tool error. See [Errors & rate limits](https://docs.pexafy.com/errors). [Source on GitHub](https://github.com/Pexafy/langchain-pexafy) · [PyPI](https://pypi.org/project/langchain-pexafy/) · [npm](https://www.npmjs.com/package/langchain-pexafy) · MIT ====================================================================== # OpenAI Agents SDK ====================================================================== https://docs.pexafy.com/openai-agents OpenAI Agents SDK agents use Pexafy through its MCP server, `https://mcp.pexafy.com/mcp`, with your API key in the `Authorization` header. The agent searches free-to-use photos (Unsplash, Pexels, Pixabay and more) and gets each one back with its licence and credit line. ## Install Python: ```bash pip install openai-agents ``` TypeScript: ```bash npm install @openai/agents zod ``` ```bash export PEXAFY_API_KEY="pexafy_..." # free key: pexafy.com/dashboard/api-keys/create export OPENAI_API_KEY="sk-..." ``` Create a key at [pexafy.com/dashboard/api-keys/create](https://pexafy.com/dashboard/api-keys/create/). Any Pexafy key works. ## Use Python: ```python import asyncio import os from agents import Agent, Runner from agents.mcp import MCPServerStreamableHttp, create_static_tool_filter async def main(): async with MCPServerStreamableHttp( name="pexafy", params={ "url": "https://mcp.pexafy.com/mcp", "headers": {"Authorization": f"Bearer {os.environ['PEXAFY_API_KEY']}"}, }, tool_filter=create_static_tool_filter( allowed_tool_names=["search_photos", "search_photos_by_image"] ), ) as pexafy: agent = Agent( name="Illustrator", instructions="Find free stock photos and give each photo's credit line.", mcp_servers=[pexafy], ) result = await Runner.run(agent, "Find a header photo for a post about remote work.") print(result.final_output) asyncio.run(main()) ``` TypeScript: ```ts import { Agent, MCPServerStreamableHttp, createMCPToolStaticFilter, run } from "@openai/agents"; const pexafy = new MCPServerStreamableHttp({ name: "pexafy", url: "https://mcp.pexafy.com/mcp", requestInit: { headers: { Authorization: `Bearer ${process.env.PEXAFY_API_KEY}` } }, toolFilter: createMCPToolStaticFilter({ allowed: ["search_photos", "search_photos_by_image"] }), }); await pexafy.connect(); try { const agent = new Agent({ name: "Illustrator", instructions: "Find free stock photos and give each photo's credit line.", mcpServers: [pexafy], }); const result = await run(agent, "Find a header photo for a post about remote work."); console.log(result.finalOutput); } finally { await pexafy.close(); } ``` The tool filter keeps the two search tools. The other tools are for chat clients, where a person views a photo grid or links an account. ## Hosted MCP With a hosted MCP tool, OpenAI's servers call Pexafy for you and your code opens no MCP connection: Python: ```python import os from agents import Agent, HostedMCPTool, Runner agent = Agent( name="Illustrator", instructions="Find free stock photos and give each photo's credit line.", tools=[ HostedMCPTool( tool_config={ "type": "mcp", "server_label": "pexafy", "server_url": "https://mcp.pexafy.com/mcp", "headers": {"Authorization": f"Bearer {os.environ['PEXAFY_API_KEY']}"}, "allowed_tools": ["search_photos", "search_photos_by_image"], "require_approval": "never", } ) ], ) result = Runner.run_sync(agent, "Find a header photo for a post about remote work.") print(result.final_output) ``` TypeScript: ```ts import { Agent, hostedMcpTool, run } from "@openai/agents"; const agent = new Agent({ name: "Illustrator", instructions: "Find free stock photos and give each photo's credit line.", tools: [ hostedMcpTool({ serverLabel: "pexafy", serverUrl: "https://mcp.pexafy.com/mcp", headers: { Authorization: `Bearer ${process.env.PEXAFY_API_KEY}` }, allowedTools: ["search_photos", "search_photos_by_image"], requireApproval: "never", }), ], }); const result = await run(agent, "Find a header photo for a post about remote work."); console.log(result.finalOutput); ``` On the free plan, show the credit line next to each photo you publish. See [what the MCP server can do](https://docs.pexafy.com/mcp#what-your-assistant-can-do) for the full tool list. ====================================================================== # Claude Agent SDK ====================================================================== https://docs.pexafy.com/claude-agent-sdk Claude Agent SDK agents use Pexafy through its MCP server, `https://mcp.pexafy.com/mcp`, with your API key in the `Authorization` header. The agent searches free-to-use photos (Unsplash, Pexels, Pixabay and more) and gets each one back with its licence and credit line. ## Install Python: ```bash pip install claude-agent-sdk ``` TypeScript: ```bash npm install @anthropic-ai/claude-agent-sdk ``` ```bash export PEXAFY_API_KEY="pexafy_..." # free key: pexafy.com/dashboard/api-keys/create export ANTHROPIC_API_KEY="sk-ant-..." ``` Create a key at [pexafy.com/dashboard/api-keys/create](https://pexafy.com/dashboard/api-keys/create/). Any Pexafy key works. ## Use Python: ```python import asyncio import os from claude_agent_sdk import ClaudeAgentOptions, ResultMessage, query options = ClaudeAgentOptions( mcp_servers={ "pexafy": { "type": "http", "url": "https://mcp.pexafy.com/mcp", "headers": {"Authorization": f"Bearer {os.environ['PEXAFY_API_KEY']}"}, } }, allowed_tools=["mcp__pexafy__search_photos", "mcp__pexafy__search_photos_by_image"], ) async def main(): async for message in query( prompt="Find a header photo for a post about remote work, with its credit line.", options=options, ): if isinstance(message, ResultMessage): print(message.result) asyncio.run(main()) ``` TypeScript: ```ts import { query } from "@anthropic-ai/claude-agent-sdk"; for await (const message of query({ prompt: "Find a header photo for a post about remote work, with its credit line.", options: { mcpServers: { pexafy: { type: "http", url: "https://mcp.pexafy.com/mcp", headers: { Authorization: `Bearer ${process.env.PEXAFY_API_KEY}` }, }, }, allowedTools: ["mcp__pexafy__search_photos", "mcp__pexafy__search_photos_by_image"], }, })) { if (message.type === "result" && message.subtype === "success") console.log(message.result); } ``` The `allowed_tools` (Python) and `allowedTools` (TypeScript) options let the agent call the two search tools without asking for permission. MCP tools are named `mcp____`. On the free plan, show the credit line next to each photo you publish. See [what the MCP server can do](https://docs.pexafy.com/mcp#what-your-assistant-can-do) for the full tool list. ====================================================================== # Google ADK ====================================================================== https://docs.pexafy.com/google-adk ADK agents use Pexafy through its MCP server, `https://mcp.pexafy.com/mcp`, with your API key in the `Authorization` header. The agent searches free-to-use photos (Unsplash, Pexels, Pixabay and more) and gets each one back with its licence and credit line. ## Install Python: ```bash pip install "google-adk[mcp]" ``` TypeScript: ```bash npm install @google/adk @modelcontextprotocol/sdk npm install -D @google/adk-devtools ``` ```bash export PEXAFY_API_KEY="pexafy_..." # free key: pexafy.com/dashboard/api-keys/create export GOOGLE_API_KEY="..." # Gemini API key ``` Create a key at [pexafy.com/dashboard/api-keys/create](https://pexafy.com/dashboard/api-keys/create/). Any Pexafy key works. The MCP tools need the `mcp` extra in Python and `@modelcontextprotocol/sdk` in TypeScript. ## Use pexafy_agent/agent.py: ```python import os from google.adk.agents import Agent from google.adk.tools.mcp_tool import McpToolset from google.adk.tools.mcp_tool.mcp_session_manager import StreamableHTTPConnectionParams root_agent = Agent( model="gemini-flash-latest", name="pexafy_agent", instruction="Find free stock photos for the user and give each photo's credit line.", tools=[ McpToolset( connection_params=StreamableHTTPConnectionParams( url="https://mcp.pexafy.com/mcp", headers={"Authorization": f"Bearer {os.environ['PEXAFY_API_KEY']}"}, ), tool_filter=["search_photos", "search_photos_by_image"], ) ], ) ``` pexafy_agent.ts: ```ts import { LlmAgent, MCPToolset } from "@google/adk"; export const rootAgent = new LlmAgent({ model: "gemini-flash-latest", name: "pexafy_agent", instruction: "Find free stock photos for the user and give each photo's credit line.", tools: [ new MCPToolset( { type: "StreamableHTTPConnectionParams", url: "https://mcp.pexafy.com/mcp", transportOptions: { requestInit: { headers: { Authorization: `Bearer ${process.env.PEXAFY_API_KEY}` } }, }, }, ["search_photos", "search_photos_by_image"], ), ], }); ``` Run it: `adk run pexafy_agent` in Python (the folder also needs an `__init__.py` containing `from . import agent`), `npx adk run pexafy_agent.ts` in TypeScript. The tool filter keeps the two search tools. The other tools are for chat clients, where a person views a photo grid or links an account. On the free plan, show the credit line next to each photo you publish. See [what the MCP server can do](https://docs.pexafy.com/mcp#what-your-assistant-can-do) for the full tool list. ====================================================================== # CrewAI ====================================================================== https://docs.pexafy.com/crewai CrewAI agents use Pexafy through its MCP server, `https://mcp.pexafy.com/mcp`, with your API key in the `Authorization` header. The agent searches free-to-use photos (Unsplash, Pexels, Pixabay and more) and gets each one back with its licence and credit line. ## Install ```bash pip install crewai export PEXAFY_API_KEY="pexafy_..." # free key: pexafy.com/dashboard/api-keys/create export OPENAI_API_KEY="sk-..." # CrewAI's default model provider ``` Create a key at [pexafy.com/dashboard/api-keys/create](https://pexafy.com/dashboard/api-keys/create/). Any Pexafy key works. ## Use ```python import os from crewai import Agent, Crew, Task from crewai.mcp import MCPServerHTTP, create_static_tool_filter illustrator = Agent( role="Illustrator", goal="Find free stock photos and give each photo's credit line", backstory="You pick real photos that match what a text is about.", mcps=[ MCPServerHTTP( url="https://mcp.pexafy.com/mcp", headers={"Authorization": f"Bearer {os.environ['PEXAFY_API_KEY']}"}, tool_filter=create_static_tool_filter( allowed_tool_names=["search_photos", "search_photos_by_image"] ), ) ], ) task = Task( description="Find a header photo for a post about remote work.", expected_output="The photo URL and its credit line.", agent=illustrator, ) print(Crew(agents=[illustrator], tasks=[task]).kickoff()) ``` The tool filter keeps the two search tools. The other tools are for chat clients, where a person views a photo grid or links an account. On the free plan, show the credit line next to each photo you publish. See [what the MCP server can do](https://docs.pexafy.com/mcp#what-your-assistant-can-do) for the full tool list. ====================================================================== # LlamaIndex ====================================================================== https://docs.pexafy.com/llamaindex LlamaIndex agents use Pexafy through its MCP server, `https://mcp.pexafy.com/mcp`, with your API key in the `Authorization` header. The agent searches free-to-use photos (Unsplash, Pexels, Pixabay and more) and gets each one back with its licence and credit line. ## Install ```bash pip install llama-index-core llama-index-tools-mcp llama-index-llms-openai export PEXAFY_API_KEY="pexafy_..." # free key: pexafy.com/dashboard/api-keys/create export OPENAI_API_KEY="sk-..." ``` Create a key at [pexafy.com/dashboard/api-keys/create](https://pexafy.com/dashboard/api-keys/create/). Any Pexafy key works. ## Use ```python import asyncio import os from llama_index.core.agent.workflow import FunctionAgent from llama_index.llms.openai import OpenAI from llama_index.tools.mcp import BasicMCPClient, McpToolSpec async def main(): client = BasicMCPClient( "https://mcp.pexafy.com/mcp", headers={"Authorization": f"Bearer {os.environ['PEXAFY_API_KEY']}"}, ) tools = await McpToolSpec( client, allowed_tools=["search_photos", "search_photos_by_image"] ).to_tool_list_async() agent = FunctionAgent( tools=tools, llm=OpenAI(model="gpt-5.4-mini"), system_prompt="Find free stock photos and give each photo's credit line.", ) print(await agent.run("Find a header photo for a post about remote work.")) asyncio.run(main()) ``` The `allowed_tools` list keeps the two search tools. The other tools are for chat clients, where a person views a photo grid or links an account. On the free plan, show the credit line next to each photo you publish. See [what the MCP server can do](https://docs.pexafy.com/mcp#what-your-assistant-can-do) for the full tool list. ====================================================================== # Pydantic AI ====================================================================== https://docs.pexafy.com/pydantic-ai Pydantic AI agents use Pexafy through its MCP server, `https://mcp.pexafy.com/mcp`, with your API key in the `Authorization` header. The agent searches free-to-use photos (Unsplash, Pexels, Pixabay and more) and gets each one back with its licence and credit line. ## Install ```bash pip install "pydantic-ai-slim[mcp,anthropic]" export PEXAFY_API_KEY="pexafy_..." # free key: pexafy.com/dashboard/api-keys/create export ANTHROPIC_API_KEY="sk-ant-..." # for this example; any Pydantic AI model works ``` Create a key at [pexafy.com/dashboard/api-keys/create](https://pexafy.com/dashboard/api-keys/create/). Any Pexafy key works. ## Use ```python import os from pydantic_ai import Agent from pydantic_ai.mcp import MCPToolset, StreamableHttpTransport pexafy = MCPToolset( StreamableHttpTransport( "https://mcp.pexafy.com/mcp", headers={"Authorization": f"Bearer {os.environ['PEXAFY_API_KEY']}"}, ) ).filtered(lambda ctx, tool: tool.name in {"search_photos", "search_photos_by_image"}) agent = Agent( "anthropic:claude-haiku-4-5", instructions="Find free stock photos and give each photo's credit line.", toolsets=[pexafy], ) result = agent.run_sync("Find a header photo for a post about remote work.") print(result.output) ``` The `filtered` call keeps the two search tools. The other tools are for chat clients, where a person views a photo grid or links an account. On the free plan, show the credit line next to each photo you publish. See [what the MCP server can do](https://docs.pexafy.com/mcp#what-your-assistant-can-do) for the full tool list. ====================================================================== # Mastra ====================================================================== https://docs.pexafy.com/mastra Mastra agents use Pexafy through its MCP server, `https://mcp.pexafy.com/mcp`, with your API key in the `Authorization` header. The agent searches free-to-use photos (Unsplash, Pexels, Pixabay and more) and gets each one back with its licence and credit line. ## Install Mastra needs Node.js 22.13 or later. ```bash npm install @mastra/core @mastra/mcp export PEXAFY_API_KEY="pexafy_..." # free key: pexafy.com/dashboard/api-keys/create export ANTHROPIC_API_KEY="sk-ant-..." # for this example; any Mastra model works ``` Create a key at [pexafy.com/dashboard/api-keys/create](https://pexafy.com/dashboard/api-keys/create/). Any Pexafy key works. ## Use ```ts import { Agent } from "@mastra/core/agent"; import { MCPClient } from "@mastra/mcp"; const mcp = new MCPClient({ servers: { pexafy: { url: new URL("https://mcp.pexafy.com/mcp"), requestInit: { headers: { Authorization: `Bearer ${process.env.PEXAFY_API_KEY}` } }, }, }, }); const { pexafy } = await mcp.listToolsets(); const agent = new Agent({ id: "photo-agent", name: "Photo agent", instructions: "Find free stock photos and give each photo's credit line.", model: "anthropic/claude-haiku-4-5", tools: { search_photos: pexafy.search_photos, search_photos_by_image: pexafy.search_photos_by_image }, }); const result = await agent.generate("Find a header photo for a post about remote work."); console.log(result.text); await mcp.disconnect(); ``` The agent gets the two search tools. The other tools are for chat clients, where a person views a photo grid or links an account. On the free plan, show the credit line next to each photo you publish. See [what the MCP server can do](https://docs.pexafy.com/mcp#what-your-assistant-can-do) for the full tool list. ====================================================================== # Strands Agents ====================================================================== https://docs.pexafy.com/strands Strands agents use Pexafy through its MCP server, `https://mcp.pexafy.com/mcp`, with your API key in the `Authorization` header. The agent searches free-to-use photos (Unsplash, Pexels, Pixabay and more) and gets each one back with its licence and credit line. ## Install ```bash pip install "strands-agents[anthropic]" export PEXAFY_API_KEY="pexafy_..." # free key: pexafy.com/dashboard/api-keys/create export ANTHROPIC_API_KEY="sk-ant-..." # for this example; any Strands model provider works ``` Create a key at [pexafy.com/dashboard/api-keys/create](https://pexafy.com/dashboard/api-keys/create/). Any Pexafy key works. ## Use ```python import os from strands import Agent from strands.models.anthropic import AnthropicModel from strands.tools.mcp import MCPClient pexafy = MCPClient( url="https://mcp.pexafy.com/mcp", headers={"Authorization": f"Bearer {os.environ['PEXAFY_API_KEY']}"}, tool_filters={"allowed": ["search_photos", "search_photos_by_image"]}, ) agent = Agent( model=AnthropicModel(model_id="claude-haiku-4-5", max_tokens=2000), system_prompt="Find free stock photos and give each photo's credit line.", tools=[pexafy], ) agent("Find a header photo for a post about remote work.") ``` `tool_filters` keeps the two search tools. The other tools are for chat clients, where a person views a photo grid or links an account. On the free plan, show the credit line next to each photo you publish. See [what the MCP server can do](https://docs.pexafy.com/mcp#what-your-assistant-can-do) for the full tool list. ====================================================================== # Agno ====================================================================== https://docs.pexafy.com/agno Agno agents use Pexafy through its MCP server, `https://mcp.pexafy.com/mcp`, with your API key in the `Authorization` header. The agent searches free-to-use photos (Unsplash, Pexels, Pixabay and more) and gets each one back with its URL, licence and credit line. ## Install ```bash pip install "agno[mcp]" anthropic export PEXAFY_API_KEY="pexafy_..." # free key: pexafy.com/dashboard/api-keys/create export ANTHROPIC_API_KEY="sk-ant-..." # for this example; any Agno model works ``` Create a key at [pexafy.com/dashboard/api-keys/create](https://pexafy.com/dashboard/api-keys/create/). Any Pexafy key works. ## Use ```python import asyncio import os from agno.agent import Agent from agno.models.anthropic import Claude from agno.tools.mcp import MCPTools async def main(): async with MCPTools( url="https://mcp.pexafy.com/mcp", transport="streamable-http", headers={"Authorization": f"Bearer {os.environ['PEXAFY_API_KEY']}"}, include_tools=["search_photos", "search_photos_by_image"], ) as pexafy: agent = Agent( model=Claude(id="claude-haiku-4-5"), instructions="Find free stock photos and give each photo's URL and credit line.", tools=[pexafy], ) result = await agent.arun("Find a header photo for a post about remote work.") print(result.content) asyncio.run(main()) ``` `include_tools` keeps the two search tools. The other tools are for chat clients, where a person views a photo grid or links an account. On the free plan, show the credit line next to each photo you publish. See [what the MCP server can do](https://docs.pexafy.com/mcp#what-your-assistant-can-do) for the full tool list. ====================================================================== # Microsoft Agent Framework ====================================================================== https://docs.pexafy.com/microsoft-agent-framework Microsoft Agent Framework agents use Pexafy through its MCP server, `https://mcp.pexafy.com/mcp`, with your API key in the `Authorization` header. The agent searches free-to-use photos (Unsplash, Pexels, Pixabay and more) and gets each one back with its URL, licence and credit line. ## Install ```bash pip install agent-framework export PEXAFY_API_KEY="pexafy_..." # free key: pexafy.com/dashboard/api-keys/create export OPENAI_API_KEY="sk-..." # for this example; Azure OpenAI and other providers work too ``` Create a key at [pexafy.com/dashboard/api-keys/create](https://pexafy.com/dashboard/api-keys/create/). Any Pexafy key works. ## Use ```python import asyncio import os from agent_framework import Agent, MCPStreamableHTTPTool from agent_framework.openai import OpenAIChatClient async def main(): async with MCPStreamableHTTPTool( name="pexafy", url="https://mcp.pexafy.com/mcp", static_headers={"Authorization": f"Bearer {os.environ['PEXAFY_API_KEY']}"}, allowed_tools=["search_photos", "search_photos_by_image"], ) as pexafy: agent = Agent( client=OpenAIChatClient(model="gpt-5.4-mini"), instructions="Find free stock photos and give each photo's URL and credit line.", tools=pexafy, ) result = await agent.run("Find a header photo for a post about remote work.") print(result.text) asyncio.run(main()) ``` `allowed_tools` keeps the two search tools. The other tools are for chat clients, where a person views a photo grid or links an account. On the free plan, show the credit line next to each photo you publish. See [what the MCP server can do](https://docs.pexafy.com/mcp#what-your-assistant-can-do) for the full tool list. ====================================================================== # API Reference ====================================================================== ## Search photos by text `GET /api/v1/search/photos` — https://docs.pexafy.com/api-reference/search/search-photos-by-text Search the photo library with **natural language**, not keywords. Pexafy understands the *meaning, mood and story* of a scene, so full descriptive sentences return far better matches than a couple of tags. For example: - `an old man sitting at a café table he has visited every morning for thirty years` - `two people sharing a bench in comfortable silence` - `the last sunlight of the day hitting a dusty windowsill` - `a child discovering snow for the first time` Short queries like `mountain sunset` still work, but the more you describe the scene, light and emotion you have in mind, the closer the results. You can combine your text query with filters (color, orientation, source, license, photographer, date) to narrow the results. **At least one criterion is required**: either a text query (`q`) or one of the filters. ### What you get back A list of photos in `data`. The most useful fields on each photo are: | Field | Description | | --- | --- | | `photo_id` | Unique Pexafy identifier — use it with the **Photos** and **Collections** endpoints. | | `urls` | Ready-to-use image links in five sizes: `thumb`, `small`, `regular`, `large`, `full`. | | `description` / `alt_description` | A short caption and accessibility-friendly text. | | `color_name`, `color_hex`, `orientation` | Visual attributes of the photo. | | `source`, `license_type` | Where the photo comes from and how it may be used. | | `photographer_username`, `attribution` | Credit information. `attribution.html` and `attribution.plain` are ready to display. | | `relevance_score` | How closely the photo matches your query, from `0` to `1` (higher is better). | Results are returned page by page — see the [Pagination](https://docs.pexafy.com/pagination) guide to fetch the next page. Parameters: - `q` [query]: Your search query in plain language — full descriptive sentences work best (e.g. `two people sharing a bench in comfortable silence`), though short queries like `mountain sunset` are fine too. Up to 500 characters. Optional if you provide at least one filter instead. - `color_name` [query]: Keep only photos whose dominant color matches this name (e.g. `blue`, `red`, `teal`). Call `GET /api/v1/facets/colors` (see the **Facets** section) to get the list of available color names. Cannot be combined with `color_hex`. - `color_hex` [query]: Keep only photos close to this hex color (e.g. `#1E90FF`). Cannot be combined with `color_name`. Use `color_tolerance` to widen or tighten the match. - `color_tolerance` [query]: How far a photo's colour may sit from the one you asked for, from `0` (strict) to `255` (very loose). Defaults to `20`. Applies to **both** `color_hex` and `color_name`: for a hex it is the radius around that exact shade, for a name it widens or narrows the colour family. - `orientation` [query]: Keep only photos with these shapes: `landscape`, `portrait` and/or `square`. Repeat the parameter to pass several. See `GET /api/v1/facets/orientations`. - `source` [query]: Keep only photos from these providers (e.g. `Pexels`, `Unsplash`, `Pixabay`). Repeat the parameter to pass several. Call `GET /api/v1/facets/sources` to list every available source. - `license_type` [query]: Keep only photos with these license types (e.g. `free`). Call `GET /api/v1/facets/licenses` to list the available license types. - `per_page` [query]: Number of photos per page, from 1 to 100. Defaults to 20. - `limit` [query]: Maximum TOTAL number of results to return across all pages — NOT the page size (use `per_page` for that). e.g. limit=4 with per_page=2 returns two pages of 2 results, then stops. Omit for no cap. - `score_threshold` [query]: Minimum relevance a photo must reach to appear, from `0` to `1`. Raise it (e.g. `0.3`) to keep only strong matches and drop loosely related photos; leave it unset to get the widest set of results. - `cursor` [query]: Token used to fetch the next page. Take the `pagination.next_cursor` value from a previous response and pass it back here. See the [Pagination](https://docs.pexafy.com/pagination) guide. - `fields` [query]: Comma-separated list to return only the fields you need (e.g. `photo_id,urls,attribution`), which makes responses smaller. Omit to get every field your plan allows. Valid values: `photo_id`, `source_photo_id`, `image_url`, `urls`, `source_image_url`, `width`, `height`, `orientation`, `blur_hash`, `color_name`, `color_hex`, `source`, `license_type`, `photographer_username`, `photographer_full_name`, `photographer_url`, `source_description`, `description`, `alt_description`, `relevance_score`, `uploaded_on`, `attribution`. There is no `photographer` field — the credit is carried by `photographer_username`, `photographer_full_name` and `photographer_url`. An unknown name returns `400 INVALID_FIELDS` listing the values your plan accepts. - `after_date` [query]: Only return photos published on or after this date, formatted `YYYY-MM-DD`. - `sort_by` [query]: Order of the results: `relevance` (default — best match first) or `newest` (most recently added first). - `photographer` [query]: Only return photos from this photographer's username. Use `GET /api/v1/facets/photographers/suggest` to find usernames. ## Search photos by image `POST /api/v1/search/photos` — https://docs.pexafy.com/api-reference/search/search-photos-by-image Give the search a picture and get visually similar photos in return — same subject, composition, colors or style. Ideal for finding alternatives to a photo you already have. The picture can come from either side: **upload a file** (`image`), or name a photo you already found here with **`photo_id`** — never both. With a `photo_id` nothing is uploaded and nothing is analysed again, so it answers faster; the photo itself is left out of its own results. On its own, `photo_id` returns exactly what **Find similar photos** returns for that photo. You can also pass a text query (`q`) together with the picture to steer the results: the search then balances *what the picture looks like* with *what your words describe*. Use `text_alpha` to control that balance. That is how you keep what someone asked for while showing more of the photo they picked: `photo_id` for the photo, `q` for the intent. **Accepted formats:** JPEG, PNG, WebP or AVIF, up to 10 MB. The same filters as text search are available, and the response has the exact same shape — see **Search photos by text** for the list of fields you get back. Parameters: - `photo_id` [query]: A photo already in the catalogue, used as the reference instead of an upload. Mutually exclusive with `image`. Nothing is uploaded and nothing is analysed again, and the photo itself never appears among its own results. On its own it returns exactly what `GET /api/v1/photos/{photo_id}/similar` returns; combined with `q`, it returns that same search steered by your words. Per-plan caps on similar photos apply to it as well. - `q` [query]: Optional words, in plain language, to steer the visual match (e.g. `the same scene but at golden hour` or `warmer and more cheerful`). When set, results match both the picture and your text. - `text_alpha` [query]: Balance between your text and the image when both are provided, from `0` to `10`. `0` ignores the text (pure visual search), `1.7` (the default) is balanced, and higher values give your words more weight. Has no effect without `q`. - `color_name` [query]: Keep only photos whose dominant color matches this name (e.g. `blue`, `red`, `teal`). Call `GET /api/v1/facets/colors` (see the **Facets** section) to get the list of available color names. Cannot be combined with `color_hex`. - `color_hex` [query]: Keep only photos close to this hex color (e.g. `#1E90FF`). Cannot be combined with `color_name`. Use `color_tolerance` to widen or tighten the match. - `color_tolerance` [query]: How far a photo's colour may sit from the one you asked for, from `0` (strict) to `255` (very loose). Defaults to `20`. Applies to **both** `color_hex` and `color_name`: for a hex it is the radius around that exact shade, for a name it widens or narrows the colour family. - `orientation` [query]: Keep only photos with these shapes: `landscape`, `portrait` and/or `square`. Repeat the parameter to pass several. See `GET /api/v1/facets/orientations`. - `source` [query]: Keep only photos from these providers (e.g. `Pexels`, `Unsplash`, `Pixabay`). Repeat the parameter to pass several. Call `GET /api/v1/facets/sources` to list every available source. - `license_type` [query]: Keep only photos with these license types (e.g. `free`). Call `GET /api/v1/facets/licenses` to list the available license types. - `per_page` [query]: Number of photos per page, from 1 to 100. Defaults to 20. - `limit` [query]: Maximum TOTAL number of results to return across all pages — NOT the page size (use `per_page` for that). Omit for no cap. - `score_threshold` [query]: Minimum relevance a photo must reach to appear, from `0` to `1`. Raise it (e.g. `0.3`) to keep only strong matches and drop loosely related photos; leave it unset to get the widest set of results. - `after_date` [query]: Only return photos published on or after this date, formatted `YYYY-MM-DD`. - `sort_by` [query]: Order of the results: `relevance` (default — best match first) or `newest` (most recently added first). - `photographer` [query]: Only return photos from this photographer's username. Use `GET /api/v1/facets/photographers/suggest` to find usernames. - `cursor` [query]: Token to fetch the next page. Take `pagination.next_cursor` from a previous response and pass it back here — no need to re-upload the image. See the Pagination guide. Request body (multipart/form-data): - `image` [body, required]: Image file (JPEG, PNG, WebP, or AVIF) ## Get a photo `GET /api/v1/photos/{photo_id}` — https://docs.pexafy.com/api-reference/photos/get-a-photo Retrieve the full details of a single photo by its Pexafy `photo_id` (the identifier returned by every search result). You get everything search returns, plus extra metadata when available: exact `width` and `height`, the original `source_image_url`, the photographer's `full_name` and profile `url`, and the upload date (`uploaded_on`). The `urls` object gives you the image in five ready-to-use sizes. Parameters: - `photo_id` [path]: The photo's unique Pexafy identifier (a UUID), as returned by search. - `fields` [query]: Comma-separated list to return only the fields you need (e.g. `photo_id,urls,attribution`). Omit to get everything. Valid values: `photo_id`, `source_photo_id`, `image_url`, `urls`, `source_image_url`, `width`, `height`, `orientation`, `blur_hash`, `color_name`, `color_hex`, `source`, `license_type`, `photographer_username`, `photographer_full_name`, `photographer_url`, `source_description`, `description`, `alt_description`, `relevance_score`, `uploaded_on`, `attribution`. There is no `photographer` field — the credit is carried by `photographer_username`, `photographer_full_name` and `photographer_url`. An unknown name returns `400 INVALID_FIELDS` listing the values your plan accepts. ## Find similar photos `GET /api/v1/photos/{photo_id}/similar` — https://docs.pexafy.com/api-reference/photos/find-similar-photos Return photos that look similar to a given one — a quick way to offer alternatives or build a visually consistent set. The reference photo itself is never included in the results. Each result has the same fields as a search result. Parameters: - `photo_id` [path]: The reference photo's unique Pexafy identifier (a UUID). - `per_page` [query]: Number of similar photos to return, from 1 to 100. Defaults to 20. - `limit` [query]: Maximum TOTAL number of similar photos across all pages — NOT the page size (use `per_page` for that). Omit for no cap. - `cursor` [query]: Token to fetch the next page. Take `pagination.next_cursor` from a previous response and pass it back here. See the Pagination guide. ## List colors `GET /api/v1/facets/colors` — https://docs.pexafy.com/api-reference/facets/list-colors List the dominant colors you can filter photos by. Each entry has a `name` (pass it as `color_name` when searching) and its `hex` code — handy for building a color picker. > **Facets** are simply the lists of values that the search filters accept. Read them once to populate your filter UI, then feed the chosen value back into **Search photos**. ## List sources `GET /api/v1/facets/sources` — https://docs.pexafy.com/api-reference/facets/list-sources List the photo providers available in the library (for example Unsplash, Pexels, Pixabay). Use a `name` as the `source` filter when searching. Each entry also includes a `license_url` pointing to that provider's licensing terms. ## List orientations `GET /api/v1/facets/orientations` — https://docs.pexafy.com/api-reference/facets/list-orientations List the available photo shapes — `landscape`, `portrait` and `square`. Use a `name` as the `orientation` filter when searching. ## List license types `GET /api/v1/facets/licenses` — https://docs.pexafy.com/api-reference/facets/list-license-types List the license types available in the library. Use a `name` as the `license_type` filter when searching to keep only photos you are allowed to use in a given way. ## Search photographers `GET /api/v1/facets/photographers/suggest` — https://docs.pexafy.com/api-reference/facets/search-photographers Autocomplete photographer names as the user types. Pass a partial name or username in `q` and get back the best-matching photographers, the most prolific first. Use a returned `username` as the `photographer` filter when searching. Parameters: - `q` [query]: What the user has typed so far — a partial name or username (1–100 characters). - `limit` [query]: Maximum number of suggestions to return, from 1 to 50. Defaults to 10. ## Get a photographer's profiles `GET /api/v1/facets/photographers/{username}` — https://docs.pexafy.com/api-reference/facets/get-a-photographers-profiles Return every profile for a photographer across providers. The same `username` can exist on several sources (Unsplash, Pexels, Pixabay) and may even be different people, so this returns a **list** — one entry per source, each with its own `full_name`, profile `url` and per-source `photos_count`. Parameters: - `username` [path]: The photographer's exact username, as returned by the suggest endpoint or found on a photo. ## List collections `GET /api/v1/collections` — https://docs.pexafy.com/api-reference/collections/list-collections List all the collections (saved photo albums) that belong to your account, newest first. Each entry includes its `name`, `description`, `photos_count` and `cover_photo_id`. > A **collection** is a named group of photos you save to your account, like an album or a moodboard. ## Create a collection `POST /api/v1/collections` — https://docs.pexafy.com/api-reference/collections/create-a-collection Create a new collection (a saved album of photos). Your plan may limit how many collections you can have; if you reach the limit you'll get a `403` asking you to upgrade. Request body (application/json): - `name` [body, required]: Name - `description` [body]: Description - `is_public` [body]: Is Public ## Get a collection `GET /api/v1/collections/{collection_id}` — https://docs.pexafy.com/api-reference/collections/get-a-collection Retrieve a single collection together with the photos it contains, the most recently added first. Parameters: - `collection_id` [path]: The collection's numeric identifier. ## Delete a collection `DELETE /api/v1/collections/{collection_id}` — https://docs.pexafy.com/api-reference/collections/delete-a-collection Permanently delete a collection and remove every photo saved in it. This cannot be undone (the original photos in the library are not affected). Parameters: - `collection_id` [path]: The collection's numeric identifier. ## Add a photo to a collection `POST /api/v1/collections/{collection_id}/photos` — https://docs.pexafy.com/api-reference/collections/add-a-photo-to-a-collection Save a photo into a collection. The photo automatically becomes the collection's cover if it is the first one added. Adding the same photo twice returns a `409`. Parameters: - `collection_id` [path]: The numeric identifier of the collection to add the photo to. Request body (application/json): - `photo_id` [body, required]: Photo Id - `photo_thumbnail_url` [body]: Photo Thumbnail Url - `photo_source` [body]: Photo Source - `photo_photographer` [body]: Photo Photographer ## Remove a photo from a collection `DELETE /api/v1/collections/{collection_id}/photos/{photo_id}` — https://docs.pexafy.com/api-reference/collections/remove-a-photo-from-a-collection Remove a photo from a collection. If it was the cover, the most recently added remaining photo becomes the new cover. Parameters: - `collection_id` [path]: The numeric identifier of the collection to remove the photo from. - `photo_id` [path]: The Pexafy `photo_id` of the photo to remove from the collection. ## Current month usage `GET /api/v1/usage` — https://docs.pexafy.com/api-reference/usage/current-month-usage See how many API requests you have made during the current billing month and how many you have left under your plan. Counters update in real time. The response contains the `period` (e.g. `2026-06`) and a `requests` object with `used`, `limit` and `remaining`. ## Daily usage history `GET /api/v1/usage/daily` — https://docs.pexafy.com/api-reference/usage/daily-usage-history Get your request count for each day over a recent window (up to the last 90 days), oldest day first. Useful for drawing a usage chart. Days older than 90 days are not kept. Parameters: - `days` [query]: How many days back to include, from 1 to 90. Defaults to 30. ## Monthly usage history `GET /api/v1/usage/monthly` — https://docs.pexafy.com/api-reference/usage/monthly-usage-history Get your total request count for each month (up to the last 24), the most recent month first. Useful for tracking long-term usage and billing history. Parameters: - `months` [query]: How many months to include, from 1 to 24. Defaults to 12. ## Usage by API key `GET /api/v1/usage/by-key` — https://docs.pexafy.com/api-reference/usage/usage-by-api-key Break your usage down by individual API key — see this month's and today's request count for each active key. Handy for spotting which key (or which app) drives the most traffic.