Skip to main content

okslop

OKSLOP — Python SDK

The official Python client for OKSLOP — free, AI-generated stock photos for any project.

OKSLOP gives you instant access to a library of AI-generated images — search by keyword, filter by style, or generate exactly what you need from a text prompt. Use them in blogs, apps, docs, landing pages, social content, or anywhere you need a visual. No attribution required, no licensing fees, no hassle.

Browse photos and AI creators at okslop.com. Get your free API key to start building.

Homepage okslop.com
Plugin Page okslop.com/apps/python-sdk
Documentation okslop.com/developers
PyPI pypi.org/project/okslop
TypeScript SDK npmjs.com/package/okslop

Installation

pip install okslop

Quick Start

from okslop import OKSLOP

# Initialize (works without API key, optional for higher limits)
client = OKSLOP()

# Or with API key
client = OKSLOP(api_key="your-api-key")

# Search for photos
result = client.photos.search(query="cozy coffee shop morning light", per_page=10)
for photo in result.results:
    print(f"{photo.id}: {photo.alt_description}")

# Get a specific photo
photo = client.photos.get("abc123")
print(photo.urls.full)

# Download to file
client.photos.download_file("abc123", "photo.webp")

# Get random photos
photos = client.photos.random(count=5)

# Generate a new image (requires API key)
result = client.embed(
    prompt="minimalist desk setup with plants",
    contributor="modern-minimal"
)

API Reference

OKSLOP(api_key=None, base_url=None)

Initialize the client.

  • api_key (optional): Your API key for higher rate limits
  • base_url (optional): Override API base URL (default: https://api.okslop.com/api/v1)

Photos

client.photos.search(query, page=None, per_page=None, orientation=None, sort=None, contributor=None)

Search for photos by semantic query.

Returns: SearchResult with .results list of Photo

client.photos.get(id)

Get a single photo by ID.

Returns: Photo

client.photos.list(page=None, per_page=None, sort=None)

List photos.

Returns: PaginatedPhotos

client.photos.random(count=None, query=None, orientation=None)

Get random photos.

Returns: List[Photo]

client.photos.download(id)

Get download URL for a photo.

Returns: dict with url

client.photos.download_file(id, path, size="full")

Download a photo to disk.

  • size: "thumb" (400px), "small" (800px), "full" (2000px), or "raw"

Returns: Path

Categories

client.categories.list()

List all categories.

Returns: List[Category]

client.categories.get(slug)

Get a category by slug.

Returns: Category

client.categories.photos(slug, page=None, per_page=None)

Get photos in a category.

Returns: PaginatedPhotos

Collections

client.collections.list(page=None, per_page=None)

List collections.

Returns: List[Collection]

client.collections.get(slug)

Get a collection by slug.

Returns: Collection

client.collections.photos(slug, page=None, per_page=None)

Get photos in a collection.

Returns: PaginatedPhotos

Embed (Image Generation)

client.embed(prompt, contributor, orientation=None, seed=None, instant=None)

Generate a new image from a prompt. Requires API key.

Returns: EmbedResult

client.embed_batch(requests)

Generate multiple images. Requires API key.

Returns: List[EmbedResult]

Photo Object

photo.id               # Unique ID
photo.description      # Description
photo.alt_description  # Alt text
photo.width            # Width in pixels
photo.height           # Height in pixels
photo.color            # Dominant color hex
photo.urls.thumb       # 400px URL
photo.urls.small       # 800px URL
photo.urls.regular     # 1080px URL
photo.urls.full        # 2000px URL
photo.urls.raw         # Original resolution
photo.user.name        # Contributor name
photo.user.username    # Contributor username
photo.downloads        # Download count
photo.views            # View count
photo.likes            # Like count

Async Support

from okslop import AsyncOKSLOP

async def main():
    async with AsyncOKSLOP() as client:
        result = await client.photos.search(query="mountains")
        for photo in result.results:
            print(photo.id)

import asyncio
asyncio.run(main())

CLI

For CLI usage, use the npx CLI (requires Node.js):

npx okslop search "coffee shop" --limit 5
npx okslop download abc123 --output photo.webp

Development

Models are generated from packages/sdk-spec/okslop-spec.json (extracted from TypeScript SDK).

# Generate models from spec
pnpm generate

# Or directly
python3 scripts/generate.py

This generates:

  • src/okslop/models.py — Pydantic models
  • src/okslop/_methods.py — Method specs

Building

pnpm build   # generate + build wheel

Publishing to PyPI

./scripts/publish.sh         # publish to PyPI
./scripts/publish.sh --test  # publish to TestPyPI first

Requires TWINE_API_TOKEN env var or ~/.pypirc credentials.

License

MIT

Metadata

Release files for okslop 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for okslop 0.0.3
File Size Uploaded Provenance Actions
okslop-0.0.3.tar.gz 7.5 kB Without provenance Details for okslop-0.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for okslop 0.0.3
File Interpreter ABI Platform Actions
okslop-0.0.3-py3-none-any.whl Python 3 none any Details for okslop-0.0.3-py3-none-any.whl

Total release size: 16.6 kB

Release files / okslop-0.0.3.tar.gz

Download URL okslop-0.0.3.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2e862f9f635cf294f0dc3feb4e061006d738f1802ed8c1342e3ad4bdafe191ef
BLAKE2b-256 checksum
How to use checksums
27a332d35c482e6f07eed2732f22dfe99f8d843e578242e8751bf69fabea3b3d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.7

Release files / okslop-0.0.3-py3-none-any.whl

Download URL okslop-0.0.3-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
04bf45cfb1d9a0eaadf0126080a9f22d570f3ff8a407bffb67e8ea5ad6e97082
BLAKE2b-256 checksum
How to use checksums
c4141e56835576a2805116a4af196dce304dac261482303eb955fbf47940a8da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.7

Security for okslop 0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page