jibayai 0.1.0__tar.gz

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.
jibayai-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 JibayAI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
jibayai-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,246 @@
1
+ Metadata-Version: 2.4
2
+ Name: jibayai
3
+ Version: 0.1.0
4
+ Summary: Official-style Python SDK for the JibayAI API
5
+ Author: JibayAI
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://jibay.ir/
8
+ Project-URL: Documentation, https://platform.jibay.ir/docs/
9
+ Keywords: jibayai,jibay,ai,chat,image,music,video,sdk
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Requires-Python: >=3.9
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: requests<3,>=2.31
23
+ Provides-Extra: dev
24
+ Requires-Dist: build>=1.2; extra == "dev"
25
+ Requires-Dist: twine>=5; extra == "dev"
26
+ Requires-Dist: pytest>=8; extra == "dev"
27
+ Dynamic: license-file
28
+
29
+ # JibayAI Python SDK
30
+
31
+ A small, validated Python client for the JibayAI chat, image, music and video APIs.
32
+
33
+ ## Installation
34
+
35
+ ```bash
36
+ pip install jibayai
37
+ ```
38
+
39
+ ## Quick start
40
+
41
+ ```python
42
+ from jibayai import JibayAI
43
+
44
+ client = JibayAI(api_key="YOUR_API_KEY")
45
+
46
+ result = client.chat(
47
+ "Hello, how are you?",
48
+ model="jibay-5",
49
+ )
50
+ print(result)
51
+ ```
52
+
53
+ You may keep the key outside source code:
54
+
55
+ ```bash
56
+ export JIBAYAI_API_KEY="YOUR_API_KEY"
57
+ ```
58
+
59
+ ```python
60
+ from jibayai import JibayAI
61
+
62
+ client = JibayAI()
63
+ print(client.chat("سلام"))
64
+ ```
65
+
66
+ ## Direct functions
67
+
68
+ For small scripts, the four operations are also available directly on the package:
69
+
70
+ ```python
71
+ import jibayai
72
+
73
+ result = jibayai.chat(
74
+ "Hello",
75
+ api_key="YOUR_API_KEY",
76
+ model="jibay-5",
77
+ )
78
+
79
+ image_result = jibayai.image("A futuristic city", api_key="YOUR_API_KEY")
80
+ music_result = jibayai.music("Calm jazz", api_key="YOUR_API_KEY")
81
+ video_result = jibayai.video("Autumn forest", api_key="YOUR_API_KEY")
82
+ ```
83
+
84
+ For repeated calls, prefer one `JibayAI` client so its HTTP connection is reused.
85
+
86
+ ## Chat
87
+
88
+ ```python
89
+ result = client.chat(
90
+ text="Latest AI news",
91
+ model="jibay-5",
92
+ system="Answer clearly and briefly.",
93
+ chats=[
94
+ {"role": "user", "text": "My name is Ali"},
95
+ {"role": "assistant", "text": "Nice to meet you"},
96
+ ],
97
+ search_web=True,
98
+ signal=False,
99
+ saved_memories={"language": "fa"},
100
+ mode_official=False,
101
+ )
102
+ ```
103
+
104
+ The documented chat request uses JSON. To support the previous form-encoded integration:
105
+
106
+ ```python
107
+ client = JibayAI(api_key="YOUR_API_KEY", chat_encoding="form")
108
+ # Or only for one request:
109
+ result = client.chat("Hello", encoding="form")
110
+ ```
111
+
112
+ ## Image
113
+
114
+ The API requires a numeric `device`. The SDK generates one automatically when omitted.
115
+
116
+ ```python
117
+ result = client.image("A futuristic city at night")
118
+ # Or:
119
+ result = client.image("A futuristic city at night", device=12345)
120
+ print(result)
121
+ ```
122
+
123
+ ## Music
124
+
125
+ ```python
126
+ result = client.music("Calm Persian jazz")
127
+ print(result)
128
+ ```
129
+
130
+ ## Video
131
+
132
+ ```python
133
+ result = client.video("An autumn forest with cinematic camera movement")
134
+ print(result)
135
+ ```
136
+
137
+ ## Download generated media
138
+
139
+ Generated media links are temporary, so save the result promptly:
140
+
141
+ ```python
142
+ saved_path = client.download(
143
+ "https://example.com/temporary-file.mp4",
144
+ "outputs/video.mp4",
145
+ )
146
+ print(saved_path)
147
+ ```
148
+
149
+ ## Validation
150
+
151
+ The SDK validates API key, text, booleans, chat history, device ID, timeout, retry count, URLs and model identifier syntax before sending a request.
152
+
153
+ By default, new model names are allowed when their syntax is valid. Enable strict model validation when you need an allow-list:
154
+
155
+ ```python
156
+ client = JibayAI(
157
+ api_key="YOUR_API_KEY",
158
+ strict_models=True,
159
+ supported_models=["jibay-4", "jibay-4.1", "jibay-5"],
160
+ )
161
+ ```
162
+
163
+ ## Error handling
164
+
165
+ ```python
166
+ from jibayai import (
167
+ JibayAI,
168
+ JibayError,
169
+ ValidationError,
170
+ AuthenticationError,
171
+ RateLimitError,
172
+ TimeoutError,
173
+ NetworkError,
174
+ ServerError,
175
+ )
176
+
177
+ client = JibayAI(api_key="YOUR_API_KEY")
178
+
179
+ try:
180
+ result = client.chat("Hello", model="jibay-5")
181
+ except ValidationError as exc:
182
+ print("Bad parameter:", exc.parameter, exc)
183
+ except AuthenticationError:
184
+ print("Check the API key")
185
+ except RateLimitError as exc:
186
+ print("Rate limited; retry after:", exc.retry_after)
187
+ except TimeoutError:
188
+ print("Request timed out")
189
+ except NetworkError:
190
+ print("Network connection failed")
191
+ except ServerError as exc:
192
+ print("JibayAI server error:", exc.status_code)
193
+ except JibayError as exc:
194
+ print("Other SDK error:", exc)
195
+ ```
196
+
197
+ ## Built-in help
198
+
199
+ ```python
200
+ print(client.help())
201
+ print(client.help("chat"))
202
+ print(client.help("errors"))
203
+ ```
204
+
205
+ ## Command line
206
+
207
+ ```bash
208
+ export JIBAYAI_API_KEY="YOUR_API_KEY"
209
+
210
+ jibayai chat "Hello" --model jibay-5
211
+ jibayai image "A futuristic city"
212
+ jibayai music "Calm jazz"
213
+ jibayai video "Autumn forest"
214
+ jibayai help errors
215
+ ```
216
+
217
+ Use `jibayai --help` and `jibayai <command> --help` for all parameters.
218
+
219
+ ## Local development and test
220
+
221
+ ```bash
222
+ python -m pip install -e .
223
+ python -m unittest discover -s tests -v
224
+ ```
225
+
226
+ ## Build
227
+
228
+ ```bash
229
+ python -m pip install --upgrade build twine
230
+ python -m build
231
+ python -m twine check dist/*
232
+ ```
233
+
234
+ ## Publish to TestPyPI
235
+
236
+ ```bash
237
+ python -m twine upload --repository testpypi dist/*
238
+ ```
239
+
240
+ ## Publish to PyPI
241
+
242
+ ```bash
243
+ python -m twine upload dist/*
244
+ ```
245
+
246
+ When Twine asks for credentials, use `__token__` as the username and your complete `pypi-...` token as the password.
@@ -0,0 +1,218 @@
1
+ # JibayAI Python SDK
2
+
3
+ A small, validated Python client for the JibayAI chat, image, music and video APIs.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install jibayai
9
+ ```
10
+
11
+ ## Quick start
12
+
13
+ ```python
14
+ from jibayai import JibayAI
15
+
16
+ client = JibayAI(api_key="YOUR_API_KEY")
17
+
18
+ result = client.chat(
19
+ "Hello, how are you?",
20
+ model="jibay-5",
21
+ )
22
+ print(result)
23
+ ```
24
+
25
+ You may keep the key outside source code:
26
+
27
+ ```bash
28
+ export JIBAYAI_API_KEY="YOUR_API_KEY"
29
+ ```
30
+
31
+ ```python
32
+ from jibayai import JibayAI
33
+
34
+ client = JibayAI()
35
+ print(client.chat("سلام"))
36
+ ```
37
+
38
+ ## Direct functions
39
+
40
+ For small scripts, the four operations are also available directly on the package:
41
+
42
+ ```python
43
+ import jibayai
44
+
45
+ result = jibayai.chat(
46
+ "Hello",
47
+ api_key="YOUR_API_KEY",
48
+ model="jibay-5",
49
+ )
50
+
51
+ image_result = jibayai.image("A futuristic city", api_key="YOUR_API_KEY")
52
+ music_result = jibayai.music("Calm jazz", api_key="YOUR_API_KEY")
53
+ video_result = jibayai.video("Autumn forest", api_key="YOUR_API_KEY")
54
+ ```
55
+
56
+ For repeated calls, prefer one `JibayAI` client so its HTTP connection is reused.
57
+
58
+ ## Chat
59
+
60
+ ```python
61
+ result = client.chat(
62
+ text="Latest AI news",
63
+ model="jibay-5",
64
+ system="Answer clearly and briefly.",
65
+ chats=[
66
+ {"role": "user", "text": "My name is Ali"},
67
+ {"role": "assistant", "text": "Nice to meet you"},
68
+ ],
69
+ search_web=True,
70
+ signal=False,
71
+ saved_memories={"language": "fa"},
72
+ mode_official=False,
73
+ )
74
+ ```
75
+
76
+ The documented chat request uses JSON. To support the previous form-encoded integration:
77
+
78
+ ```python
79
+ client = JibayAI(api_key="YOUR_API_KEY", chat_encoding="form")
80
+ # Or only for one request:
81
+ result = client.chat("Hello", encoding="form")
82
+ ```
83
+
84
+ ## Image
85
+
86
+ The API requires a numeric `device`. The SDK generates one automatically when omitted.
87
+
88
+ ```python
89
+ result = client.image("A futuristic city at night")
90
+ # Or:
91
+ result = client.image("A futuristic city at night", device=12345)
92
+ print(result)
93
+ ```
94
+
95
+ ## Music
96
+
97
+ ```python
98
+ result = client.music("Calm Persian jazz")
99
+ print(result)
100
+ ```
101
+
102
+ ## Video
103
+
104
+ ```python
105
+ result = client.video("An autumn forest with cinematic camera movement")
106
+ print(result)
107
+ ```
108
+
109
+ ## Download generated media
110
+
111
+ Generated media links are temporary, so save the result promptly:
112
+
113
+ ```python
114
+ saved_path = client.download(
115
+ "https://example.com/temporary-file.mp4",
116
+ "outputs/video.mp4",
117
+ )
118
+ print(saved_path)
119
+ ```
120
+
121
+ ## Validation
122
+
123
+ The SDK validates API key, text, booleans, chat history, device ID, timeout, retry count, URLs and model identifier syntax before sending a request.
124
+
125
+ By default, new model names are allowed when their syntax is valid. Enable strict model validation when you need an allow-list:
126
+
127
+ ```python
128
+ client = JibayAI(
129
+ api_key="YOUR_API_KEY",
130
+ strict_models=True,
131
+ supported_models=["jibay-4", "jibay-4.1", "jibay-5"],
132
+ )
133
+ ```
134
+
135
+ ## Error handling
136
+
137
+ ```python
138
+ from jibayai import (
139
+ JibayAI,
140
+ JibayError,
141
+ ValidationError,
142
+ AuthenticationError,
143
+ RateLimitError,
144
+ TimeoutError,
145
+ NetworkError,
146
+ ServerError,
147
+ )
148
+
149
+ client = JibayAI(api_key="YOUR_API_KEY")
150
+
151
+ try:
152
+ result = client.chat("Hello", model="jibay-5")
153
+ except ValidationError as exc:
154
+ print("Bad parameter:", exc.parameter, exc)
155
+ except AuthenticationError:
156
+ print("Check the API key")
157
+ except RateLimitError as exc:
158
+ print("Rate limited; retry after:", exc.retry_after)
159
+ except TimeoutError:
160
+ print("Request timed out")
161
+ except NetworkError:
162
+ print("Network connection failed")
163
+ except ServerError as exc:
164
+ print("JibayAI server error:", exc.status_code)
165
+ except JibayError as exc:
166
+ print("Other SDK error:", exc)
167
+ ```
168
+
169
+ ## Built-in help
170
+
171
+ ```python
172
+ print(client.help())
173
+ print(client.help("chat"))
174
+ print(client.help("errors"))
175
+ ```
176
+
177
+ ## Command line
178
+
179
+ ```bash
180
+ export JIBAYAI_API_KEY="YOUR_API_KEY"
181
+
182
+ jibayai chat "Hello" --model jibay-5
183
+ jibayai image "A futuristic city"
184
+ jibayai music "Calm jazz"
185
+ jibayai video "Autumn forest"
186
+ jibayai help errors
187
+ ```
188
+
189
+ Use `jibayai --help` and `jibayai <command> --help` for all parameters.
190
+
191
+ ## Local development and test
192
+
193
+ ```bash
194
+ python -m pip install -e .
195
+ python -m unittest discover -s tests -v
196
+ ```
197
+
198
+ ## Build
199
+
200
+ ```bash
201
+ python -m pip install --upgrade build twine
202
+ python -m build
203
+ python -m twine check dist/*
204
+ ```
205
+
206
+ ## Publish to TestPyPI
207
+
208
+ ```bash
209
+ python -m twine upload --repository testpypi dist/*
210
+ ```
211
+
212
+ ## Publish to PyPI
213
+
214
+ ```bash
215
+ python -m twine upload dist/*
216
+ ```
217
+
218
+ When Twine asks for credentials, use `__token__` as the username and your complete `pypi-...` token as the password.
@@ -0,0 +1,51 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77.0.3"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "jibayai"
7
+ version = "0.1.0"
8
+ description = "Official-style Python SDK for the JibayAI API"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ authors = [
14
+ { name = "JibayAI" }
15
+ ]
16
+ keywords = ["jibayai", "jibay", "ai", "chat", "image", "music", "video", "sdk"]
17
+ classifiers = [
18
+ "Development Status :: 3 - Alpha",
19
+ "Intended Audience :: Developers",
20
+ "Operating System :: OS Independent",
21
+ "Programming Language :: Python :: 3",
22
+ "Programming Language :: Python :: 3.9",
23
+ "Programming Language :: Python :: 3.10",
24
+ "Programming Language :: Python :: 3.11",
25
+ "Programming Language :: Python :: 3.12",
26
+ "Programming Language :: Python :: 3.13"
27
+ ]
28
+ dependencies = [
29
+ "requests>=2.31,<3"
30
+ ]
31
+
32
+ [project.optional-dependencies]
33
+ dev = [
34
+ "build>=1.2",
35
+ "twine>=5",
36
+ "pytest>=8"
37
+ ]
38
+
39
+ [project.urls]
40
+ Homepage = "https://jibay.ir/"
41
+ Documentation = "https://platform.jibay.ir/docs/"
42
+
43
+ [project.scripts]
44
+ jibayai = "jibayai.__main__:main"
45
+
46
+ [tool.setuptools.packages.find]
47
+ where = ["src"]
48
+
49
+ [tool.pytest.ini_options]
50
+ testpaths = ["tests"]
51
+ addopts = "-q"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,49 @@
1
+ """JibayAI Python SDK public interface."""
2
+
3
+ from .client import JibayAI
4
+ from .convenience import chat, image, music, video
5
+ from .errors import (
6
+ APIError,
7
+ AuthenticationError,
8
+ BadRequestError,
9
+ ConfigurationError,
10
+ ConflictError,
11
+ InvalidResponseError,
12
+ JibayError,
13
+ NetworkError,
14
+ NotFoundError,
15
+ PermissionDeniedError,
16
+ RateLimitError,
17
+ ServerError,
18
+ TimeoutError,
19
+ ValidationError,
20
+ )
21
+ from .helptext import sdk_help
22
+ from .version import __version__
23
+
24
+ Client = JibayAI
25
+
26
+ __all__ = [
27
+ "JibayAI",
28
+ "Client",
29
+ "chat",
30
+ "image",
31
+ "music",
32
+ "video",
33
+ "sdk_help",
34
+ "__version__",
35
+ "JibayError",
36
+ "ConfigurationError",
37
+ "ValidationError",
38
+ "NetworkError",
39
+ "TimeoutError",
40
+ "InvalidResponseError",
41
+ "APIError",
42
+ "BadRequestError",
43
+ "AuthenticationError",
44
+ "PermissionDeniedError",
45
+ "NotFoundError",
46
+ "ConflictError",
47
+ "RateLimitError",
48
+ "ServerError",
49
+ ]
@@ -0,0 +1,112 @@
1
+ """Command-line interface installed as ``jibayai``."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import json
7
+ import os
8
+ import sys
9
+ from typing import Any, List, Optional
10
+
11
+ from .client import JibayAI
12
+ from .errors import JibayError
13
+ from .helptext import sdk_help
14
+ from .version import __version__
15
+
16
+
17
+ def _add_common(parser: argparse.ArgumentParser) -> None:
18
+ parser.add_argument("--api-key", help="API key; otherwise JIBAYAI_API_KEY is used")
19
+ parser.add_argument("--base-url", default="https://jibay.ir", help="API base URL")
20
+ parser.add_argument("--timeout", type=float, default=60.0, help="timeout in seconds")
21
+ parser.add_argument("--retries", type=int, default=2, help="automatic retry count, 0-10")
22
+
23
+
24
+ def _print_result(result: Any) -> None:
25
+ if isinstance(result, (dict, list)):
26
+ print(json.dumps(result, ensure_ascii=False, indent=2))
27
+ elif result is None:
28
+ print("null")
29
+ else:
30
+ print(result)
31
+
32
+
33
+ def build_parser() -> argparse.ArgumentParser:
34
+ parser = argparse.ArgumentParser(
35
+ prog="jibayai",
36
+ description="JibayAI command-line client for chat, image, music and video.",
37
+ )
38
+ parser.add_argument("--version", action="version", version=f"%(prog)s {__version__}")
39
+ sub = parser.add_subparsers(dest="command", required=True)
40
+
41
+ chat = sub.add_parser("chat", help="send a chat message")
42
+ _add_common(chat)
43
+ chat.add_argument("text", help="message text")
44
+ chat.add_argument("--model", default="jibay-4.1")
45
+ chat.add_argument("--system")
46
+ chat.add_argument("--chats", help="JSON array of prior messages")
47
+ chat.add_argument("--saved-memories", help="JSON or plain text")
48
+ chat.add_argument("--search-web", action="store_true")
49
+ chat.add_argument("--signal", action="store_true")
50
+ chat.add_argument("--mode-official", action="store_true")
51
+ chat.add_argument("--encoding", choices=("json", "form"), default="json")
52
+
53
+ image = sub.add_parser("image", help="generate an image")
54
+ _add_common(image)
55
+ image.add_argument("text", help="image prompt")
56
+ image.add_argument("--device", type=int)
57
+
58
+ music = sub.add_parser("music", help="generate music")
59
+ _add_common(music)
60
+ music.add_argument("text", help="music style or prompt")
61
+
62
+ video = sub.add_parser("video", help="generate a video")
63
+ _add_common(video)
64
+ video.add_argument("text", help="video prompt")
65
+
66
+ help_parser = sub.add_parser("help", help="show detailed SDK help")
67
+ help_parser.add_argument("topic", nargs="?", default="overview")
68
+ return parser
69
+
70
+
71
+ def main(argv: Optional[List[str]] = None) -> int:
72
+ parser = build_parser()
73
+ args = parser.parse_args(argv)
74
+ if args.command == "help":
75
+ print(sdk_help(args.topic))
76
+ return 0
77
+
78
+ try:
79
+ with JibayAI(
80
+ api_key=args.api_key or os.getenv("JIBAYAI_API_KEY"),
81
+ base_url=args.base_url,
82
+ timeout=args.timeout,
83
+ retries=args.retries,
84
+ chat_encoding=getattr(args, "encoding", "json"),
85
+ ) as client:
86
+ if args.command == "chat":
87
+ result = client.chat(
88
+ args.text,
89
+ model=args.model,
90
+ system=args.system,
91
+ chats=args.chats,
92
+ saved_memories=args.saved_memories,
93
+ search_web=args.search_web,
94
+ signal=args.signal,
95
+ mode_official=args.mode_official,
96
+ encoding=args.encoding,
97
+ )
98
+ elif args.command == "image":
99
+ result = client.image(args.text, device=args.device)
100
+ elif args.command == "music":
101
+ result = client.music(args.text)
102
+ else:
103
+ result = client.video(args.text)
104
+ _print_result(result)
105
+ return 0
106
+ except JibayError as exc:
107
+ print(f"error: {exc}", file=sys.stderr)
108
+ return 1
109
+
110
+
111
+ if __name__ == "__main__":
112
+ raise SystemExit(main())