nemati 0.1.2__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.
- nemati-0.1.2/.gitignore +123 -0
- nemati-0.1.2/CHANGELOG.md +27 -0
- nemati-0.1.2/LICENSE +21 -0
- nemati-0.1.2/PKG-INFO +276 -0
- nemati-0.1.2/README.md +237 -0
- nemati-0.1.2/pyproject.toml +92 -0
- nemati-0.1.2/src/nemati/__init__.py +40 -0
- nemati-0.1.2/src/nemati/_async/__init__.py +7 -0
- nemati-0.1.2/src/nemati/_async/_client.py +207 -0
- nemati-0.1.2/src/nemati/_client.py +95 -0
- nemati-0.1.2/src/nemati/_config.py +49 -0
- nemati-0.1.2/src/nemati/_exceptions.py +117 -0
- nemati-0.1.2/src/nemati/_http.py +160 -0
- nemati-0.1.2/src/nemati/_version.py +3 -0
- nemati-0.1.2/src/nemati/models/__init__.py +45 -0
- nemati-0.1.2/src/nemati/models/account.py +179 -0
- nemati-0.1.2/src/nemati/models/audio.py +87 -0
- nemati-0.1.2/src/nemati/models/chat.py +119 -0
- nemati-0.1.2/src/nemati/models/documents.py +74 -0
- nemati-0.1.2/src/nemati/models/image.py +84 -0
- nemati-0.1.2/src/nemati/models/market.py +116 -0
- nemati-0.1.2/src/nemati/models/trends.py +135 -0
- nemati-0.1.2/src/nemati/models/writer.py +114 -0
- nemati-0.1.2/src/nemati/resources/__init__.py +23 -0
- nemati-0.1.2/src/nemati/resources/account.py +117 -0
- nemati-0.1.2/src/nemati/resources/audio.py +166 -0
- nemati-0.1.2/src/nemati/resources/chat.py +200 -0
- nemati-0.1.2/src/nemati/resources/documents.py +267 -0
- nemati-0.1.2/src/nemati/resources/image.py +207 -0
- nemati-0.1.2/src/nemati/resources/market.py +253 -0
- nemati-0.1.2/src/nemati/resources/trends.py +302 -0
- nemati-0.1.2/src/nemati/resources/writer.py +86 -0
- nemati-0.1.2/tests/conftest.py +23 -0
- nemati-0.1.2/tests/test_client.py +56 -0
nemati-0.1.2/.gitignore
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
*.egg-info/
|
|
24
|
+
.installed.cfg
|
|
25
|
+
*.egg
|
|
26
|
+
|
|
27
|
+
# PyInstaller
|
|
28
|
+
*.manifest
|
|
29
|
+
*.spec
|
|
30
|
+
|
|
31
|
+
# Installer logs
|
|
32
|
+
pip-log.txt
|
|
33
|
+
pip-delete-this-directory.txt
|
|
34
|
+
|
|
35
|
+
# Unit test / coverage reports
|
|
36
|
+
htmlcov/
|
|
37
|
+
.tox/
|
|
38
|
+
.nox/
|
|
39
|
+
.coverage
|
|
40
|
+
.coverage.*
|
|
41
|
+
.cache
|
|
42
|
+
nosetests.xml
|
|
43
|
+
coverage.xml
|
|
44
|
+
*.cover
|
|
45
|
+
*.py,cover
|
|
46
|
+
.hypothesis/
|
|
47
|
+
.pytest_cache/
|
|
48
|
+
|
|
49
|
+
# Translations
|
|
50
|
+
*.mo
|
|
51
|
+
*.pot
|
|
52
|
+
|
|
53
|
+
# Django stuff:
|
|
54
|
+
*.log
|
|
55
|
+
local_settings.py
|
|
56
|
+
|
|
57
|
+
# Flask stuff:
|
|
58
|
+
instance/
|
|
59
|
+
.webassets-cache
|
|
60
|
+
|
|
61
|
+
# Scrapy stuff:
|
|
62
|
+
.scrapy
|
|
63
|
+
|
|
64
|
+
# Sphinx documentation
|
|
65
|
+
docs/_build/
|
|
66
|
+
|
|
67
|
+
# PyBuilder
|
|
68
|
+
target/
|
|
69
|
+
|
|
70
|
+
# Jupyter Notebook
|
|
71
|
+
.ipynb_checkpoints
|
|
72
|
+
|
|
73
|
+
# IPython
|
|
74
|
+
profile_default/
|
|
75
|
+
ipython_config.py
|
|
76
|
+
|
|
77
|
+
# pyenv
|
|
78
|
+
.python-version
|
|
79
|
+
|
|
80
|
+
# celery beat schedule file
|
|
81
|
+
celerybeat-schedule
|
|
82
|
+
|
|
83
|
+
# SageMath parsed files
|
|
84
|
+
*.sage.py
|
|
85
|
+
|
|
86
|
+
# Environments
|
|
87
|
+
.env
|
|
88
|
+
.venv
|
|
89
|
+
env/
|
|
90
|
+
venv/
|
|
91
|
+
ENV/
|
|
92
|
+
env.bak/
|
|
93
|
+
venv.bak/
|
|
94
|
+
|
|
95
|
+
# Spyder project settings
|
|
96
|
+
.spyderproject
|
|
97
|
+
.spyproject
|
|
98
|
+
|
|
99
|
+
# Rope project settings
|
|
100
|
+
.ropeproject
|
|
101
|
+
|
|
102
|
+
# mkdocs documentation
|
|
103
|
+
/site
|
|
104
|
+
|
|
105
|
+
# mypy
|
|
106
|
+
.mypy_cache/
|
|
107
|
+
.dmypy.json
|
|
108
|
+
dmypy.json
|
|
109
|
+
|
|
110
|
+
# Pyre type checker
|
|
111
|
+
.pyre/
|
|
112
|
+
|
|
113
|
+
# IDE
|
|
114
|
+
.idea/
|
|
115
|
+
.vscode/
|
|
116
|
+
*.swp
|
|
117
|
+
*.swo
|
|
118
|
+
*~
|
|
119
|
+
|
|
120
|
+
# OS
|
|
121
|
+
.DS_Store
|
|
122
|
+
Thumbs.db
|
|
123
|
+
toturail
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [0.1.0] - 2026-01-28
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- Initial release
|
|
14
|
+
- Chat completions with streaming support
|
|
15
|
+
- AI Writer with templates
|
|
16
|
+
- Image generation (text-to-image, image-to-image, upscale)
|
|
17
|
+
- Audio (text-to-speech, speech-to-text)
|
|
18
|
+
- Trend Discovery across multiple platforms
|
|
19
|
+
- Market Intelligence for stocks and crypto
|
|
20
|
+
- Document processing (upload, convert, chat)
|
|
21
|
+
- Account management (credits, usage, limits)
|
|
22
|
+
- Async client support
|
|
23
|
+
- Comprehensive error handling
|
|
24
|
+
- Full type hints
|
|
25
|
+
|
|
26
|
+
[Unreleased]: https://github.com/nemati-ai/nemati-ai/compare/v0.1.0...HEAD
|
|
27
|
+
[0.1.0]: https://github.com/nemati-ai/nemati-ai/releases/tag/v0.1.0
|
nemati-0.1.2/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 NEMATI AI LLC
|
|
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.
|
nemati-0.1.2/PKG-INFO
ADDED
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: nemati
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: Official Python SDK for Nemati AI - AI Content Creation, Image Generation, Trend Discovery & More
|
|
5
|
+
Project-URL: Homepage, https://nemati.ai
|
|
6
|
+
Project-URL: Documentation, https://docs.nemati.ai/sdk/python
|
|
7
|
+
Project-URL: Repository, https://github.com/nemati-ai/nemati
|
|
8
|
+
Project-URL: Changelog, https://github.com/nemati-ai/nemati/blob/main/CHANGELOG.md
|
|
9
|
+
Project-URL: Issues, https://github.com/nemati-ai/nemati/issues
|
|
10
|
+
Author-email: NEMATI AI <support@nemati.ai>
|
|
11
|
+
License-Expression: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: ai,chatgpt,content-creation,image-generation,nemati,openai,sdk,text-to-speech,trend-discovery
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
25
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
26
|
+
Requires-Python: >=3.8
|
|
27
|
+
Requires-Dist: httpx>=0.25.0
|
|
28
|
+
Requires-Dist: pydantic>=2.0.0
|
|
29
|
+
Requires-Dist: typing-extensions>=4.0.0
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: black>=23.0.0; extra == 'dev'
|
|
32
|
+
Requires-Dist: mypy>=1.0.0; extra == 'dev'
|
|
33
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
|
|
34
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
|
|
35
|
+
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
36
|
+
Requires-Dist: respx>=0.20.0; extra == 'dev'
|
|
37
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
38
|
+
Description-Content-Type: text/markdown
|
|
39
|
+
|
|
40
|
+
# Nemati AI Python SDK
|
|
41
|
+
|
|
42
|
+
[](https://badge.fury.io/py/nemati-ai)
|
|
43
|
+
[](https://pypi.org/project/nemati-ai/)
|
|
44
|
+
[](https://opensource.org/licenses/MIT)
|
|
45
|
+
|
|
46
|
+
Official Python SDK for [Nemati AI](https://nemati.ai) - Your all-in-one AI platform for content creation, image generation, trend discovery, and more.
|
|
47
|
+
|
|
48
|
+
## Installation
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pip install nemati-ai
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Quick Start
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
from nemati import NematiAI
|
|
58
|
+
|
|
59
|
+
# Initialize client
|
|
60
|
+
client = NematiAI(api_key="your-api-key")
|
|
61
|
+
|
|
62
|
+
# Chat completion
|
|
63
|
+
response = client.chat.create(
|
|
64
|
+
messages=[
|
|
65
|
+
{"role": "user", "content": "What is machine learning?"}
|
|
66
|
+
]
|
|
67
|
+
)
|
|
68
|
+
print(response.content)
|
|
69
|
+
|
|
70
|
+
# AI Writer
|
|
71
|
+
content = client.writer.generate(
|
|
72
|
+
prompt="Write a blog post about AI trends in 2026",
|
|
73
|
+
content_type="blog_post"
|
|
74
|
+
)
|
|
75
|
+
print(content.text)
|
|
76
|
+
|
|
77
|
+
# Image Generation
|
|
78
|
+
image = client.image.generate(
|
|
79
|
+
prompt="A futuristic city at sunset",
|
|
80
|
+
size="1024x1024"
|
|
81
|
+
)
|
|
82
|
+
image.save("city.png")
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Features
|
|
86
|
+
|
|
87
|
+
- 🤖 **Chat Completions** - Conversational AI with multiple models
|
|
88
|
+
- ✍️ **AI Writer** - Generate blogs, articles, social posts, and more
|
|
89
|
+
- 🎨 **Image Generation** - Text-to-image, image-to-image, upscaling
|
|
90
|
+
- 🔊 **Audio** - Text-to-speech and speech-to-text
|
|
91
|
+
- 📈 **Trend Discovery** - Track trends across YouTube, TikTok, Reddit, and more
|
|
92
|
+
- 📊 **Market Intelligence** - Stock and crypto data with AI analysis
|
|
93
|
+
- 📄 **Document Processing** - Upload, convert, and chat with documents
|
|
94
|
+
- ⚡ **Async Support** - Full async/await support for high-performance apps
|
|
95
|
+
|
|
96
|
+
## Authentication
|
|
97
|
+
|
|
98
|
+
Get your API key from [nemati.ai/dashboard/api-keys](https://nemati.ai/dashboard/api-keys).
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
# Option 1: Pass directly
|
|
102
|
+
client = NematiAI(api_key="nai_live_xxxxxxxxxxxx")
|
|
103
|
+
|
|
104
|
+
# Option 2: Environment variable
|
|
105
|
+
# Set NEMATI_API_KEY in your environment
|
|
106
|
+
client = NematiAI()
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Usage Examples
|
|
110
|
+
|
|
111
|
+
### Chat Completions
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
# Simple chat
|
|
115
|
+
response = client.chat.create(
|
|
116
|
+
messages=[
|
|
117
|
+
{"role": "system", "content": "You are a helpful assistant."},
|
|
118
|
+
{"role": "user", "content": "Explain quantum computing"}
|
|
119
|
+
],
|
|
120
|
+
model="gpt-4",
|
|
121
|
+
max_tokens=1000
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
print(response.content)
|
|
125
|
+
print(f"Tokens used: {response.usage.total_tokens}")
|
|
126
|
+
|
|
127
|
+
# Streaming
|
|
128
|
+
for chunk in client.chat.create(
|
|
129
|
+
messages=[{"role": "user", "content": "Write a poem about AI"}],
|
|
130
|
+
stream=True
|
|
131
|
+
):
|
|
132
|
+
print(chunk.content, end="", flush=True)
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### AI Writer
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
# Generate content
|
|
139
|
+
content = client.writer.generate(
|
|
140
|
+
prompt="Write a product description for an AI assistant app",
|
|
141
|
+
content_type="product_description",
|
|
142
|
+
tone="professional",
|
|
143
|
+
max_tokens=500
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
# Use templates
|
|
147
|
+
templates = client.writer.templates.list()
|
|
148
|
+
content = client.writer.templates.generate(
|
|
149
|
+
template_id="social-media-post",
|
|
150
|
+
variables={
|
|
151
|
+
"topic": "AI trends",
|
|
152
|
+
"platform": "LinkedIn"
|
|
153
|
+
}
|
|
154
|
+
)
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Image Generation
|
|
158
|
+
|
|
159
|
+
```python
|
|
160
|
+
# Text to image
|
|
161
|
+
image = client.image.generate(
|
|
162
|
+
prompt="A serene mountain landscape at dawn",
|
|
163
|
+
size="1024x1024",
|
|
164
|
+
quality="hd"
|
|
165
|
+
)
|
|
166
|
+
image.save("landscape.png")
|
|
167
|
+
|
|
168
|
+
# Image to image
|
|
169
|
+
edited = client.image.edit(
|
|
170
|
+
image=open("photo.jpg", "rb"),
|
|
171
|
+
prompt="Make it look like a watercolor painting"
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
# Upscale
|
|
175
|
+
upscaled = client.image.upscale(
|
|
176
|
+
image=open("small.jpg", "rb"),
|
|
177
|
+
scale=4
|
|
178
|
+
)
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Trend Discovery
|
|
182
|
+
|
|
183
|
+
```python
|
|
184
|
+
# Search trends
|
|
185
|
+
trends = client.trends.search(
|
|
186
|
+
query="artificial intelligence",
|
|
187
|
+
platforms=["youtube", "tiktok", "reddit"],
|
|
188
|
+
timeframe="7d"
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
for trend in trends.items:
|
|
192
|
+
print(f"{trend.platform}: {trend.title}")
|
|
193
|
+
print(f" Engagement: {trend.engagement}")
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Async Support
|
|
197
|
+
|
|
198
|
+
```python
|
|
199
|
+
import asyncio
|
|
200
|
+
from nemati import AsyncNematiAI
|
|
201
|
+
|
|
202
|
+
async def main():
|
|
203
|
+
client = AsyncNematiAI(api_key="your-api-key")
|
|
204
|
+
|
|
205
|
+
response = await client.chat.create(
|
|
206
|
+
messages=[{"role": "user", "content": "Hello!"}]
|
|
207
|
+
)
|
|
208
|
+
print(response.content)
|
|
209
|
+
|
|
210
|
+
await client.close()
|
|
211
|
+
|
|
212
|
+
asyncio.run(main())
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Error Handling
|
|
216
|
+
|
|
217
|
+
```python
|
|
218
|
+
from nemati.exceptions import (
|
|
219
|
+
AuthenticationError,
|
|
220
|
+
RateLimitError,
|
|
221
|
+
InsufficientCreditsError,
|
|
222
|
+
ValidationError,
|
|
223
|
+
APIError
|
|
224
|
+
)
|
|
225
|
+
|
|
226
|
+
try:
|
|
227
|
+
response = client.chat.create(messages=[...])
|
|
228
|
+
except AuthenticationError:
|
|
229
|
+
print("Invalid API key")
|
|
230
|
+
except RateLimitError as e:
|
|
231
|
+
print(f"Rate limited. Retry after {e.retry_after} seconds")
|
|
232
|
+
except InsufficientCreditsError as e:
|
|
233
|
+
print(f"Need {e.required} credits, have {e.available}")
|
|
234
|
+
except ValidationError as e:
|
|
235
|
+
print(f"Invalid request: {e.errors}")
|
|
236
|
+
except APIError as e:
|
|
237
|
+
print(f"API error {e.status_code}: {e.message}")
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### Account & Usage
|
|
241
|
+
|
|
242
|
+
```python
|
|
243
|
+
# Check credits
|
|
244
|
+
credits = client.account.credits()
|
|
245
|
+
print(f"Remaining: {credits.remaining}")
|
|
246
|
+
|
|
247
|
+
# Get usage stats
|
|
248
|
+
usage = client.account.usage(
|
|
249
|
+
start_date="2026-01-01",
|
|
250
|
+
end_date="2026-01-31"
|
|
251
|
+
)
|
|
252
|
+
print(f"Total requests: {usage.total_requests}")
|
|
253
|
+
|
|
254
|
+
# Get plan limits
|
|
255
|
+
limits = client.account.limits()
|
|
256
|
+
print(f"Chat messages/day: {limits.chat.max_messages_per_day}")
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
## Documentation
|
|
260
|
+
|
|
261
|
+
Full documentation is available at [docs.nemati.ai/sdk/python](https://docs.nemati.ai/sdk/python)
|
|
262
|
+
|
|
263
|
+
## Requirements
|
|
264
|
+
|
|
265
|
+
- Python 3.8+
|
|
266
|
+
- API key from [nemati.ai](https://nemati.ai)
|
|
267
|
+
|
|
268
|
+
## License
|
|
269
|
+
|
|
270
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
271
|
+
|
|
272
|
+
## Support
|
|
273
|
+
|
|
274
|
+
- 📧 Email: support@nemati.ai
|
|
275
|
+
- 💬 Discord: [discord.gg/nemati](https://discord.gg/nemati/KrFTV64NvS)
|
|
276
|
+
- 🐛 Issues: [GitHub Issues](https://github.com/nematiai/nemati-ai/issues)
|
nemati-0.1.2/README.md
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
# Nemati AI Python SDK
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/py/nemati-ai)
|
|
4
|
+
[](https://pypi.org/project/nemati-ai/)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
Official Python SDK for [Nemati AI](https://nemati.ai) - Your all-in-one AI platform for content creation, image generation, trend discovery, and more.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install nemati-ai
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
from nemati import NematiAI
|
|
19
|
+
|
|
20
|
+
# Initialize client
|
|
21
|
+
client = NematiAI(api_key="your-api-key")
|
|
22
|
+
|
|
23
|
+
# Chat completion
|
|
24
|
+
response = client.chat.create(
|
|
25
|
+
messages=[
|
|
26
|
+
{"role": "user", "content": "What is machine learning?"}
|
|
27
|
+
]
|
|
28
|
+
)
|
|
29
|
+
print(response.content)
|
|
30
|
+
|
|
31
|
+
# AI Writer
|
|
32
|
+
content = client.writer.generate(
|
|
33
|
+
prompt="Write a blog post about AI trends in 2026",
|
|
34
|
+
content_type="blog_post"
|
|
35
|
+
)
|
|
36
|
+
print(content.text)
|
|
37
|
+
|
|
38
|
+
# Image Generation
|
|
39
|
+
image = client.image.generate(
|
|
40
|
+
prompt="A futuristic city at sunset",
|
|
41
|
+
size="1024x1024"
|
|
42
|
+
)
|
|
43
|
+
image.save("city.png")
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Features
|
|
47
|
+
|
|
48
|
+
- 🤖 **Chat Completions** - Conversational AI with multiple models
|
|
49
|
+
- ✍️ **AI Writer** - Generate blogs, articles, social posts, and more
|
|
50
|
+
- 🎨 **Image Generation** - Text-to-image, image-to-image, upscaling
|
|
51
|
+
- 🔊 **Audio** - Text-to-speech and speech-to-text
|
|
52
|
+
- 📈 **Trend Discovery** - Track trends across YouTube, TikTok, Reddit, and more
|
|
53
|
+
- 📊 **Market Intelligence** - Stock and crypto data with AI analysis
|
|
54
|
+
- 📄 **Document Processing** - Upload, convert, and chat with documents
|
|
55
|
+
- ⚡ **Async Support** - Full async/await support for high-performance apps
|
|
56
|
+
|
|
57
|
+
## Authentication
|
|
58
|
+
|
|
59
|
+
Get your API key from [nemati.ai/dashboard/api-keys](https://nemati.ai/dashboard/api-keys).
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
# Option 1: Pass directly
|
|
63
|
+
client = NematiAI(api_key="nai_live_xxxxxxxxxxxx")
|
|
64
|
+
|
|
65
|
+
# Option 2: Environment variable
|
|
66
|
+
# Set NEMATI_API_KEY in your environment
|
|
67
|
+
client = NematiAI()
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Usage Examples
|
|
71
|
+
|
|
72
|
+
### Chat Completions
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
# Simple chat
|
|
76
|
+
response = client.chat.create(
|
|
77
|
+
messages=[
|
|
78
|
+
{"role": "system", "content": "You are a helpful assistant."},
|
|
79
|
+
{"role": "user", "content": "Explain quantum computing"}
|
|
80
|
+
],
|
|
81
|
+
model="gpt-4",
|
|
82
|
+
max_tokens=1000
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
print(response.content)
|
|
86
|
+
print(f"Tokens used: {response.usage.total_tokens}")
|
|
87
|
+
|
|
88
|
+
# Streaming
|
|
89
|
+
for chunk in client.chat.create(
|
|
90
|
+
messages=[{"role": "user", "content": "Write a poem about AI"}],
|
|
91
|
+
stream=True
|
|
92
|
+
):
|
|
93
|
+
print(chunk.content, end="", flush=True)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### AI Writer
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
# Generate content
|
|
100
|
+
content = client.writer.generate(
|
|
101
|
+
prompt="Write a product description for an AI assistant app",
|
|
102
|
+
content_type="product_description",
|
|
103
|
+
tone="professional",
|
|
104
|
+
max_tokens=500
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
# Use templates
|
|
108
|
+
templates = client.writer.templates.list()
|
|
109
|
+
content = client.writer.templates.generate(
|
|
110
|
+
template_id="social-media-post",
|
|
111
|
+
variables={
|
|
112
|
+
"topic": "AI trends",
|
|
113
|
+
"platform": "LinkedIn"
|
|
114
|
+
}
|
|
115
|
+
)
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Image Generation
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
# Text to image
|
|
122
|
+
image = client.image.generate(
|
|
123
|
+
prompt="A serene mountain landscape at dawn",
|
|
124
|
+
size="1024x1024",
|
|
125
|
+
quality="hd"
|
|
126
|
+
)
|
|
127
|
+
image.save("landscape.png")
|
|
128
|
+
|
|
129
|
+
# Image to image
|
|
130
|
+
edited = client.image.edit(
|
|
131
|
+
image=open("photo.jpg", "rb"),
|
|
132
|
+
prompt="Make it look like a watercolor painting"
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
# Upscale
|
|
136
|
+
upscaled = client.image.upscale(
|
|
137
|
+
image=open("small.jpg", "rb"),
|
|
138
|
+
scale=4
|
|
139
|
+
)
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Trend Discovery
|
|
143
|
+
|
|
144
|
+
```python
|
|
145
|
+
# Search trends
|
|
146
|
+
trends = client.trends.search(
|
|
147
|
+
query="artificial intelligence",
|
|
148
|
+
platforms=["youtube", "tiktok", "reddit"],
|
|
149
|
+
timeframe="7d"
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
for trend in trends.items:
|
|
153
|
+
print(f"{trend.platform}: {trend.title}")
|
|
154
|
+
print(f" Engagement: {trend.engagement}")
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Async Support
|
|
158
|
+
|
|
159
|
+
```python
|
|
160
|
+
import asyncio
|
|
161
|
+
from nemati import AsyncNematiAI
|
|
162
|
+
|
|
163
|
+
async def main():
|
|
164
|
+
client = AsyncNematiAI(api_key="your-api-key")
|
|
165
|
+
|
|
166
|
+
response = await client.chat.create(
|
|
167
|
+
messages=[{"role": "user", "content": "Hello!"}]
|
|
168
|
+
)
|
|
169
|
+
print(response.content)
|
|
170
|
+
|
|
171
|
+
await client.close()
|
|
172
|
+
|
|
173
|
+
asyncio.run(main())
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Error Handling
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
from nemati.exceptions import (
|
|
180
|
+
AuthenticationError,
|
|
181
|
+
RateLimitError,
|
|
182
|
+
InsufficientCreditsError,
|
|
183
|
+
ValidationError,
|
|
184
|
+
APIError
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
try:
|
|
188
|
+
response = client.chat.create(messages=[...])
|
|
189
|
+
except AuthenticationError:
|
|
190
|
+
print("Invalid API key")
|
|
191
|
+
except RateLimitError as e:
|
|
192
|
+
print(f"Rate limited. Retry after {e.retry_after} seconds")
|
|
193
|
+
except InsufficientCreditsError as e:
|
|
194
|
+
print(f"Need {e.required} credits, have {e.available}")
|
|
195
|
+
except ValidationError as e:
|
|
196
|
+
print(f"Invalid request: {e.errors}")
|
|
197
|
+
except APIError as e:
|
|
198
|
+
print(f"API error {e.status_code}: {e.message}")
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Account & Usage
|
|
202
|
+
|
|
203
|
+
```python
|
|
204
|
+
# Check credits
|
|
205
|
+
credits = client.account.credits()
|
|
206
|
+
print(f"Remaining: {credits.remaining}")
|
|
207
|
+
|
|
208
|
+
# Get usage stats
|
|
209
|
+
usage = client.account.usage(
|
|
210
|
+
start_date="2026-01-01",
|
|
211
|
+
end_date="2026-01-31"
|
|
212
|
+
)
|
|
213
|
+
print(f"Total requests: {usage.total_requests}")
|
|
214
|
+
|
|
215
|
+
# Get plan limits
|
|
216
|
+
limits = client.account.limits()
|
|
217
|
+
print(f"Chat messages/day: {limits.chat.max_messages_per_day}")
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## Documentation
|
|
221
|
+
|
|
222
|
+
Full documentation is available at [docs.nemati.ai/sdk/python](https://docs.nemati.ai/sdk/python)
|
|
223
|
+
|
|
224
|
+
## Requirements
|
|
225
|
+
|
|
226
|
+
- Python 3.8+
|
|
227
|
+
- API key from [nemati.ai](https://nemati.ai)
|
|
228
|
+
|
|
229
|
+
## License
|
|
230
|
+
|
|
231
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
232
|
+
|
|
233
|
+
## Support
|
|
234
|
+
|
|
235
|
+
- 📧 Email: support@nemati.ai
|
|
236
|
+
- 💬 Discord: [discord.gg/nemati](https://discord.gg/nemati/KrFTV64NvS)
|
|
237
|
+
- 🐛 Issues: [GitHub Issues](https://github.com/nematiai/nemati-ai/issues)
|