Official Python SDK for OKSLOP - AI stock photos
Project description
okslop
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 limitsbase_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 modelssrc/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.
Links
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file okslop-0.0.3.tar.gz.
File metadata
- Download URL: okslop-0.0.3.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e862f9f635cf294f0dc3feb4e061006d738f1802ed8c1342e3ad4bdafe191ef
|
|
| MD5 |
bcaa3498e4ef7c641dcf876bbfc8d413
|
|
| BLAKE2b-256 |
27a332d35c482e6f07eed2732f22dfe99f8d843e578242e8751bf69fabea3b3d
|
File details
Details for the file okslop-0.0.3-py3-none-any.whl.
File metadata
- Download URL: okslop-0.0.3-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04bf45cfb1d9a0eaadf0126080a9f22d570f3ff8a407bffb67e8ea5ad6e97082
|
|
| MD5 |
8de990bde746f72c8f5680aaca1e1ae7
|
|
| BLAKE2b-256 |
c4141e56835576a2805116a4af196dce304dac261482303eb955fbf47940a8da
|