porn-api 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
porn_api/__init__.py ADDED
@@ -0,0 +1,93 @@
1
+ """Spicy API (spicyapi.com) client: porn API for AI image, image-to-video and chat generation.
2
+
3
+ Standard library only. Image generation and chat are OpenAI-compatible, so the OpenAI SDK with
4
+ base_url="https://api.spicyapi.com/v1" also works; this client adds image edits by URL, video
5
+ tasks with polling, the account balance and the model list with prices.
6
+ """
7
+
8
+ import json
9
+ import os
10
+ import time
11
+ import urllib.error
12
+ import urllib.request
13
+
14
+ __version__ = "0.1.0"
15
+ __all__ = ["SpicyAPI", "SpicyAPIError"]
16
+
17
+
18
+ class SpicyAPIError(Exception):
19
+ """status: 401 bad key, 402 balance, 400 params, 422 prompt blocked (never charged), 429 capacity."""
20
+
21
+ def __init__(self, message, status, type_="api_error", body=None):
22
+ super().__init__(message)
23
+ self.status, self.type, self.body = status, type_, body
24
+
25
+
26
+ class SpicyAPI:
27
+ def __init__(self, api_key=None, base_url="https://api.spicyapi.com/v1", timeout=300, opener=None):
28
+ self.api_key = api_key or os.environ.get("SPICYAPI_KEY")
29
+ if not self.api_key:
30
+ raise ValueError("Spicy API key missing: pass api_key or set SPICYAPI_KEY (https://www.spicyapi.com/dashboard/api-keys)")
31
+ self.base_url, self.timeout = base_url.rstrip("/"), timeout
32
+ self._open = opener or urllib.request.urlopen
33
+
34
+ def request(self, method, path, body=None):
35
+ req = urllib.request.Request(
36
+ self.base_url + path,
37
+ data=None if body is None else json.dumps(body).encode(),
38
+ method=method,
39
+ headers={"Authorization": f"Bearer {self.api_key}", "Content-Type": "application/json", "User-Agent": f"porn-api-py/{__version__}"},
40
+ )
41
+ try:
42
+ with self._open(req, timeout=self.timeout) as res:
43
+ return json.loads(res.read() or b"{}")
44
+ except urllib.error.HTTPError as e:
45
+ raw = e.read()
46
+ try:
47
+ data = json.loads(raw)
48
+ except ValueError:
49
+ data = {"raw": raw.decode(errors="replace")}
50
+ err = data.get("error") if isinstance(data, dict) else None
51
+ err = err if isinstance(err, dict) else {}
52
+ raise SpicyAPIError(err.get("message") or f"HTTP {e.code}", e.code, err.get("type", "api_error"), data) from None
53
+
54
+ # Images
55
+ def generate_image(self, model, prompt, **params):
56
+ """Text to image. params: negative_prompt, size ("1024*1024"), n (1 to 4), seed. Returns {"data": [{"url"}], "cost_usd"}."""
57
+ return self.request("POST", "/images/generations", {"model": model, "prompt": prompt, **params})
58
+
59
+ def edit_image(self, model, prompt, image_urls, **params):
60
+ """Prompt-driven edit. image_urls must be images this account generated."""
61
+ return self.request("POST", "/images/edits", {"model": model, "prompt": prompt, "image_urls": list(image_urls), **params})
62
+
63
+ def list_images(self):
64
+ return self.request("GET", "/images")
65
+
66
+ # Video
67
+ def generate_video(self, model, prompt, **params):
68
+ """Starts a task. params: image_url, resolution ("720P"), duration (seconds), negative_prompt, audio, seed."""
69
+ return self.request("POST", "/videos/generations", {"model": model, "prompt": prompt, **params})
70
+
71
+ def get_video(self, task_id):
72
+ return self.request("GET", f"/videos/tasks/{task_id}")
73
+
74
+ def wait_for_video(self, task_id, interval=12, timeout=1200):
75
+ """Polls until the task succeeds (output.video_url) or fails (refunded)."""
76
+ deadline = time.monotonic() + timeout
77
+ while True:
78
+ task = self.get_video(task_id)
79
+ if task.get("status") in ("succeeded", "failed"):
80
+ return task
81
+ if time.monotonic() > deadline:
82
+ raise SpicyAPIError(f"Video task {task_id} still {task.get('status')} after {timeout}s", 408, "timeout", task)
83
+ time.sleep(interval)
84
+
85
+ # Chat (non-streaming; for streaming use the OpenAI SDK with this base_url), account, models
86
+ def chat(self, model, messages, **params):
87
+ return self.request("POST", "/chat/completions", {"model": model, "messages": messages, **params, "stream": False})
88
+
89
+ def account(self):
90
+ return self.request("GET", "/account")
91
+
92
+ def models(self):
93
+ return self.request("GET", "/models")
@@ -0,0 +1,77 @@
1
+ Metadata-Version: 2.4
2
+ Name: porn-api
3
+ Version: 0.1.0
4
+ Summary: Porn API client for AI image, image-to-video and chat generation. Official Spicy API (spicyapi.com) client, OpenAI-compatible, pay per generation. 18+.
5
+ Author-email: Spicy API <support@spicyapi.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://www.spicyapi.com/porn-ai-api
8
+ Project-URL: Documentation, https://www.spicyapi.com/docs
9
+ Project-URL: Pricing, https://www.spicyapi.com/pricing
10
+ Project-URL: Source, https://github.com/Wayfinity/porn-api
11
+ Keywords: porn api,nsfw api,adult api,ai porn,nsfw image generation,nsfw video generation,image to video,uncensored,openai compatible,spicyapi.com
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Topic :: Multimedia :: Graphics
16
+ Classifier: Topic :: Multimedia :: Video
17
+ Requires-Python: >=3.8
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Dynamic: license-file
21
+
22
+ # porn-api: Python client for AI porn image and video generation
23
+
24
+ Official Python client for [Spicy API](https://www.spicyapi.com) at **spicyapi.com**, a porn API in the generation sense: it creates original adult images, image-to-video clips and uncensored chat from a prompt. It is not a tube-site data API. One key, pay per generation, no subscription. 18+ only.
25
+
26
+ Standard library only, Python 3.8+. (Spicy API at spicyapi.com is a different company from the similarly named spicyapi.ai.)
27
+
28
+ ```bash
29
+ pip install porn-api
30
+ ```
31
+
32
+ ```python
33
+ from porn_api import SpicyAPI
34
+
35
+ spicy = SpicyAPI() # reads SPICYAPI_KEY
36
+
37
+ # Text to image: durable CDN URLs plus the exact cost
38
+ img = spicy.generate_image("spicy-image-1", "a woman on a beach at golden hour, photorealistic", size="1024*1024")
39
+ print(img["data"][0]["url"], img["cost_usd"])
40
+
41
+ # Image to video: start a task, then wait for it
42
+ task = spicy.generate_video("spicy-motion-2", "slow turn toward camera", image_url=img["data"][0]["url"], resolution="720P", duration=5)
43
+ done = spicy.wait_for_video(task["id"])
44
+ print(done["status"], done.get("output", {}).get("video_url"))
45
+
46
+ print(spicy.account()) # balance
47
+ print(spicy.models()) # models with prices and limits
48
+ ```
49
+
50
+ ## Keys and the sandbox
51
+
52
+ Sign up at [spicyapi.com/auth](https://www.spicyapi.com/auth) and copy the key from Dashboard, API Keys. Tick **Sandbox** when creating a key to get one that returns sample output and bills nothing.
53
+
54
+ ## Prices
55
+
56
+ Images from $0.06, video from $0.10 per second, chat from $0.575 per 1M tokens. What you are charged is exactly `cost_usd` in each response. Failed generations are refunded; blocked prompts are never charged. Full table: [spicyapi.com/pricing](https://www.spicyapi.com/pricing).
57
+
58
+ ## Already using the OpenAI SDK?
59
+
60
+ ```python
61
+ from openai import OpenAI
62
+ client = OpenAI(base_url="https://api.spicyapi.com/v1", api_key="sk-spicy-...")
63
+ ```
64
+
65
+ Image generation and chat are drop-in, streaming included. This package adds image edits by URL, video tasks with polling, the balance and the priced model list.
66
+
67
+ ## Errors
68
+
69
+ `SpicyAPIError` carries `status` and `type`: 401 bad key, 402 insufficient balance, 400 invalid parameters, 422 prompt blocked by moderation, 429 model at capacity.
70
+
71
+ ## Rules
72
+
73
+ Adults only, no real people without consent, no minors in any form, and no uploads: inputs to edits and video must be images your account generated. Read the [acceptable use policy](https://www.spicyapi.com/acceptable-use). Products built on the API must age-verify their users.
74
+
75
+ [Docs](https://www.spicyapi.com/docs) · [MCP server for AI agents](https://www.spicyapi.com/docs/mcp) · [Examples](https://github.com/Wayfinity/porn-api) · [JavaScript client](https://www.npmjs.com/package/spicyapi)
76
+
77
+ MIT licensed.
@@ -0,0 +1,6 @@
1
+ porn_api/__init__.py,sha256=Pb8WVRBU_8HjcYf494uwWll3QN5HQSDiFbDrJb4ADGk,4272
2
+ porn_api-0.1.0.dist-info/licenses/LICENSE,sha256=xDCduYb-y-WIjnmetac30QyWMvgS0f9Fn8_Jwq_XtUQ,1066
3
+ porn_api-0.1.0.dist-info/METADATA,sha256=XOUIAUzrXJk8DlUED4xckQ2K8Kz2gCRjzR8LIoEc454,3737
4
+ porn_api-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
5
+ porn_api-0.1.0.dist-info/top_level.txt,sha256=N4erlskDGb7OAybmMbiPsSFv0Xyvd6oIRy4UxvThbpo,9
6
+ porn_api-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Spicy API
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
1
+ porn_api