Official Python SDK for OKSLOP - AI stock photos
Project description
OKSLOP Python SDK
Official Python SDK for the OKSLOP API. Search, download, and generate AI stock photos.
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
photos = client.search("cozy coffee shop morning light", limit=10)
for photo in photos:
print(f"{photo.id}: {photo.alt}")
# Get a specific photo
photo = client.get_photo("abc123")
print(photo.urls.full)
# Download to file
client.download("abc123", "photo.webp")
# Generate a new image (requires API key)
photo = client.generate(
prompt="minimalist desk setup with plants",
contributor="modern-minimal" # optional style
)
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://okslop.com/api/v1)
client.search(query, limit=24, page=1)
Search for photos by semantic query.
Returns: List[Photo]
client.get_photo(photo_id)
Get a single photo by ID.
Returns: Photo
client.download(photo_id, path, size="full")
Download a photo to disk.
size:"thumb"(400px),"preview"(800px),"full"(2000px), or"original"
client.generate(prompt, contributor=None)
Generate a new image from a prompt. Requires API key.
Returns: Photo
client.random(count=1)
Get random photos.
Returns: List[Photo]
Photo Object
photo.id # Unique ID
photo.alt # Alt text / description
photo.width # Width in pixels
photo.height # Height in pixels
photo.urls.thumb # 400px URL
photo.urls.preview # 800px URL
photo.urls.full # 2000px URL
photo.urls.original # Original resolution
photo.contributor.name # Artist name
photo.contributor.slug # Artist slug
Async Support
from okslop import AsyncOKSLOP
async def main():
client = AsyncOKSLOP()
photos = await client.search("mountains")
print(photos)
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.1.tar.gz.
File metadata
- Download URL: okslop-0.0.1.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4c3c1abefa9133709f587b368f6010c030858746e7756fda273e1b1c85f261a
|
|
| MD5 |
c09a43c13e886ed51967540fc7a02e8a
|
|
| BLAKE2b-256 |
74a7b10cf139d988033aa8e976a7c8097e1e019de8c82395756ebfb2823bb7ac
|
File details
Details for the file okslop-0.0.1-py3-none-any.whl.
File metadata
- Download URL: okslop-0.0.1-py3-none-any.whl
- Upload date:
- Size: 8.4 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 |
352c261e5f970d96f2a05f6d1d312e2171d292d9474db7d099461e2def536c0a
|
|
| MD5 |
6d6192164db3aa7294a262b4b4dce6b2
|
|
| BLAKE2b-256 |
2c8b90beaa95af60525faaa659a5ba77f27c12d839730ad7a6fe0d65e3342983
|