apideepseek 0.1.1__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.
Files changed (39) hide show
  1. apideepseek-0.1.1/LICENSE +21 -0
  2. apideepseek-0.1.1/MANIFEST.in +1 -0
  3. apideepseek-0.1.1/PKG-INFO +237 -0
  4. apideepseek-0.1.1/README.md +211 -0
  5. apideepseek-0.1.1/apideepseek/__init__.py +26 -0
  6. apideepseek-0.1.1/apideepseek/clients/__init__.py +3 -0
  7. apideepseek-0.1.1/apideepseek/clients/auth.py +248 -0
  8. apideepseek-0.1.1/apideepseek/clients/base.py +249 -0
  9. apideepseek-0.1.1/apideepseek/clients/chat.py +161 -0
  10. apideepseek-0.1.1/apideepseek/clients/client.py +223 -0
  11. apideepseek-0.1.1/apideepseek/clients/files.py +198 -0
  12. apideepseek-0.1.1/apideepseek/conversation.py +124 -0
  13. apideepseek-0.1.1/apideepseek/data/__init__.py +0 -0
  14. apideepseek-0.1.1/apideepseek/data/constants.py +18 -0
  15. apideepseek-0.1.1/apideepseek/data/device_ids.py +468 -0
  16. apideepseek-0.1.1/apideepseek/http/__init__.py +3 -0
  17. apideepseek-0.1.1/apideepseek/http/_config.py +2 -0
  18. apideepseek-0.1.1/apideepseek/http/_sse.py +117 -0
  19. apideepseek-0.1.1/apideepseek/log.py +66 -0
  20. apideepseek-0.1.1/apideepseek/pow/__init__.py +0 -0
  21. apideepseek-0.1.1/apideepseek/pow/_pow.cpp +327 -0
  22. apideepseek-0.1.1/apideepseek/pow/_pow.pyi +22 -0
  23. apideepseek-0.1.1/apideepseek/pow/pow.py +105 -0
  24. apideepseek-0.1.1/apideepseek/types/__init__.py +1 -0
  25. apideepseek-0.1.1/apideepseek/types/enums.py +12 -0
  26. apideepseek-0.1.1/apideepseek/types/exceptions/__init__.py +55 -0
  27. apideepseek-0.1.1/apideepseek/types/exceptions/_classes.py +196 -0
  28. apideepseek-0.1.1/apideepseek/types/exceptions/_recognition.py +104 -0
  29. apideepseek-0.1.1/apideepseek/types/models/__init__.py +0 -0
  30. apideepseek-0.1.1/apideepseek/types/models/_model_utils.py +80 -0
  31. apideepseek-0.1.1/apideepseek/types/models/classes.py +60 -0
  32. apideepseek-0.1.1/apideepseek.egg-info/PKG-INFO +237 -0
  33. apideepseek-0.1.1/apideepseek.egg-info/SOURCES.txt +38 -0
  34. apideepseek-0.1.1/apideepseek.egg-info/dependency_links.txt +1 -0
  35. apideepseek-0.1.1/apideepseek.egg-info/requires.txt +1 -0
  36. apideepseek-0.1.1/apideepseek.egg-info/top_level.txt +1 -0
  37. apideepseek-0.1.1/pyproject.toml +49 -0
  38. apideepseek-0.1.1/setup.cfg +4 -0
  39. apideepseek-0.1.1/setup.py +57 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 inmyuse
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.
@@ -0,0 +1 @@
1
+ recursive-include apideepseek *.cpp *.hpp *.h *.pyi
@@ -0,0 +1,237 @@
1
+ Metadata-Version: 2.4
2
+ Name: apideepseek
3
+ Version: 0.1.1
4
+ Summary: High-performance async Python client for the private DeepSeek API
5
+ Author: inmyuse
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/inmyuse/apideepseek
8
+ Project-URL: Documentation, https://github.com/inmyuse/apideepseek#documentation
9
+ Project-URL: Issues, https://github.com/inmyuse/apideepseek/issues
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.9
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Programming Language :: C++
18
+ Classifier: Operating System :: Microsoft :: Windows
19
+ Classifier: Operating System :: POSIX :: Linux
20
+ Classifier: Framework :: AsyncIO
21
+ Requires-Python: >=3.9
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: aiohttp>=3.9
25
+ Dynamic: license-file
26
+
27
+ # apideepseek
28
+
29
+ <p align="left">
30
+ <img src="docs/assets/icon.svg" width="90">
31
+ </p>
32
+
33
+ ![Python](https://img.shields.io/badge/python-3.9+-blue.svg)
34
+ ![Platform](https://img.shields.io/badge/platform-linux%20%7C%20windows-lightgrey)
35
+ ![Async](https://img.shields.io/badge/asyncio-fully%20async-blueviolet)
36
+ ![DeepSeek](https://img.shields.io/badge/API-DeepSeek-blue)
37
+
38
+ `apideepseek` is an async Python client for the private DeepSeek API. It supports token or email/password authentication, streaming responses, multi-turn conversations, image uploads, model modes, and account registration.
39
+
40
+ Russian documentation: [docs/ru/README.md](docs/ru/README.md)
41
+
42
+ ## Installation
43
+
44
+ ```bash
45
+ pip install apideepseek
46
+ ```
47
+
48
+ Building from source requires a C++17 compiler with AVX2 support and `pybind11` for the PoW extension. See [docs/en/pow.md](docs/en/pow.md).
49
+
50
+ ## Quick Start
51
+
52
+ ### Ask One Question
53
+
54
+ ```python
55
+ import asyncio
56
+ from apideepseek import DeepSeekClient
57
+
58
+ async def main():
59
+ async with DeepSeekClient(token="YOUR_TOKEN") as client:
60
+ result = await client.ask("Hello!")
61
+ print(result.text)
62
+
63
+ asyncio.run(main())
64
+ ```
65
+
66
+ You can also log in with email and password:
67
+
68
+ ```python
69
+ async with DeepSeekClient(email="myname@example.com", password="password123") as client:
70
+ result = await client.ask("Hello!")
71
+ print(result.text)
72
+ ```
73
+
74
+ ## Model Modes
75
+
76
+ Use `ModelType` when creating the client or for a single request.
77
+
78
+ | Mode | Use When | Code |
79
+ |------|----------|------|
80
+ | Fast/default | Normal text chat, fastest general mode | `ModelType.DEFAULT` |
81
+ | Expert | Harder reasoning or expert answers | `ModelType.EXPERT` |
82
+ | Vision/recognition | Questions about an image | `ModelType.VISION` |
83
+
84
+ ```python
85
+ import asyncio
86
+ from apideepseek import DeepSeekClient, ModelType
87
+
88
+ async def main():
89
+ async with DeepSeekClient(token="YOUR_TOKEN", model=ModelType.DEFAULT) as client:
90
+ fast = await client.ask("Short answer: what is asyncio?")
91
+ expert = await client.ask(
92
+ "Analyze the tradeoffs in detail",
93
+ model=ModelType.EXPERT,
94
+ )
95
+ print(fast.text)
96
+ print(expert.text)
97
+
98
+ asyncio.run(main())
99
+ ```
100
+
101
+ ## Attach an Image to a Prompt
102
+
103
+ The current upload helper supports PNG and JPEG images. It does not upload arbitrary PDF, DOCX, TXT, or ZIP files.
104
+
105
+ The simplest form is passing `Path` directly to `ask`; the client uploads the image and attaches it to the prompt:
106
+
107
+ ```python
108
+ import asyncio
109
+ from pathlib import Path
110
+ from apideepseek import DeepSeekClient, ModelType
111
+
112
+ async def main():
113
+ async with DeepSeekClient(token="YOUR_TOKEN") as client:
114
+ result = await client.ask(
115
+ "What is shown in this image?",
116
+ image=Path("photo.jpg"),
117
+ model=ModelType.VISION,
118
+ )
119
+ print(result.text)
120
+
121
+ asyncio.run(main())
122
+ ```
123
+
124
+ If you want to reuse the same image in several requests, upload it once:
125
+
126
+ ```python
127
+ img = await client.upload_image(Path("photo.jpg"))
128
+ result = await client.ask("Describe the image", image=img, model=ModelType.VISION)
129
+ ```
130
+
131
+ Raw bytes also work:
132
+
133
+ ```python
134
+ data = Path("photo.png").read_bytes()
135
+ result = await client.ask("Read the text in this image", image=data, model=ModelType.VISION)
136
+ ```
137
+
138
+ ## Create a New Conversation
139
+
140
+ Use `client.new_conversation()` for a multi-turn chat. The `Conversation` object remembers the last `message_id` and sends it as `parent_message_id` on the next turn.
141
+
142
+ ```python
143
+ import asyncio
144
+ from apideepseek import DeepSeekClient
145
+
146
+ async def main():
147
+ async with DeepSeekClient(token="YOUR_TOKEN") as client:
148
+ chat = client.new_conversation()
149
+ first = await chat.ask("My name is Alex. Remember it.")
150
+ second = await chat.ask("What is my name?")
151
+ print(first.text)
152
+ print(second.text)
153
+
154
+ asyncio.run(main())
155
+ ```
156
+
157
+ Create another independent thread by creating another `Conversation`:
158
+
159
+ ```python
160
+ chat_a = client.new_conversation()
161
+ chat_b = client.new_conversation()
162
+ ```
163
+
164
+ ## Streaming
165
+
166
+ By default `ask_stream()` yields only new text fragments. Use `cumulative=True` if you need the full text so far on every iteration.
167
+
168
+ ```python
169
+ async for chunk in client.ask_stream("Tell me about Python"):
170
+ print(chunk, end="", flush=True)
171
+ ```
172
+
173
+ Streaming also works inside a conversation:
174
+
175
+ ```python
176
+ chat = client.new_conversation()
177
+ async for chunk in chat.ask_stream("Explain async/await"):
178
+ print(chunk, end="", flush=True)
179
+ ```
180
+
181
+ ## Register a New Account
182
+
183
+ ```python
184
+ import asyncio
185
+ from apideepseek import DeepSeekClient
186
+
187
+ async def main():
188
+ await DeepSeekClient.send_reg_code("myname@example.com")
189
+ code = input("Code from email: ")
190
+ token = await DeepSeekClient.confirm_reg_code(
191
+ "myname@example.com",
192
+ "password123",
193
+ code,
194
+ )
195
+ print("Token:", token)
196
+
197
+ asyncio.run(main())
198
+ ```
199
+
200
+ ## Result Object
201
+
202
+ `ask()` and `Conversation.ask()` return `DeepSeekTurnResult`:
203
+
204
+ ```python
205
+ result = await client.ask("Hello")
206
+ print(result.text) # full assistant response
207
+ print(result.session_id) # DeepSeek chat session id
208
+ print(result.message_id) # assistant message id for threading
209
+ ```
210
+
211
+ ## Error Handling
212
+
213
+ ```python
214
+ from apideepseek import DeepSeekClient, AuthorizationError, DeepSeekError
215
+
216
+ try:
217
+ async with DeepSeekClient(token="invalid") as client:
218
+ await client.ask("Hello")
219
+ except AuthorizationError:
220
+ print("Token is invalid")
221
+ except DeepSeekError as e:
222
+ print(f"API error: {e}")
223
+ ```
224
+
225
+ ## Documentation
226
+
227
+ - [DeepSeekClient methods](docs/en/client.md)
228
+ - [Conversation](docs/en/conversation.md)
229
+ - [Data types](docs/en/types.md)
230
+ - [Exceptions](docs/en/exceptions.md)
231
+ - [Proof-of-Work](docs/en/pow.md)
232
+
233
+ ## Requirements
234
+
235
+ - Python 3.9+
236
+ - `aiohttp >= 3.9`
237
+ - C++17 compiler with AVX2 to build the PoW extension from source, or a prebuilt wheel
@@ -0,0 +1,211 @@
1
+ # apideepseek
2
+
3
+ <p align="left">
4
+ <img src="docs/assets/icon.svg" width="90">
5
+ </p>
6
+
7
+ ![Python](https://img.shields.io/badge/python-3.9+-blue.svg)
8
+ ![Platform](https://img.shields.io/badge/platform-linux%20%7C%20windows-lightgrey)
9
+ ![Async](https://img.shields.io/badge/asyncio-fully%20async-blueviolet)
10
+ ![DeepSeek](https://img.shields.io/badge/API-DeepSeek-blue)
11
+
12
+ `apideepseek` is an async Python client for the private DeepSeek API. It supports token or email/password authentication, streaming responses, multi-turn conversations, image uploads, model modes, and account registration.
13
+
14
+ Russian documentation: [docs/ru/README.md](docs/ru/README.md)
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ pip install apideepseek
20
+ ```
21
+
22
+ Building from source requires a C++17 compiler with AVX2 support and `pybind11` for the PoW extension. See [docs/en/pow.md](docs/en/pow.md).
23
+
24
+ ## Quick Start
25
+
26
+ ### Ask One Question
27
+
28
+ ```python
29
+ import asyncio
30
+ from apideepseek import DeepSeekClient
31
+
32
+ async def main():
33
+ async with DeepSeekClient(token="YOUR_TOKEN") as client:
34
+ result = await client.ask("Hello!")
35
+ print(result.text)
36
+
37
+ asyncio.run(main())
38
+ ```
39
+
40
+ You can also log in with email and password:
41
+
42
+ ```python
43
+ async with DeepSeekClient(email="myname@example.com", password="password123") as client:
44
+ result = await client.ask("Hello!")
45
+ print(result.text)
46
+ ```
47
+
48
+ ## Model Modes
49
+
50
+ Use `ModelType` when creating the client or for a single request.
51
+
52
+ | Mode | Use When | Code |
53
+ |------|----------|------|
54
+ | Fast/default | Normal text chat, fastest general mode | `ModelType.DEFAULT` |
55
+ | Expert | Harder reasoning or expert answers | `ModelType.EXPERT` |
56
+ | Vision/recognition | Questions about an image | `ModelType.VISION` |
57
+
58
+ ```python
59
+ import asyncio
60
+ from apideepseek import DeepSeekClient, ModelType
61
+
62
+ async def main():
63
+ async with DeepSeekClient(token="YOUR_TOKEN", model=ModelType.DEFAULT) as client:
64
+ fast = await client.ask("Short answer: what is asyncio?")
65
+ expert = await client.ask(
66
+ "Analyze the tradeoffs in detail",
67
+ model=ModelType.EXPERT,
68
+ )
69
+ print(fast.text)
70
+ print(expert.text)
71
+
72
+ asyncio.run(main())
73
+ ```
74
+
75
+ ## Attach an Image to a Prompt
76
+
77
+ The current upload helper supports PNG and JPEG images. It does not upload arbitrary PDF, DOCX, TXT, or ZIP files.
78
+
79
+ The simplest form is passing `Path` directly to `ask`; the client uploads the image and attaches it to the prompt:
80
+
81
+ ```python
82
+ import asyncio
83
+ from pathlib import Path
84
+ from apideepseek import DeepSeekClient, ModelType
85
+
86
+ async def main():
87
+ async with DeepSeekClient(token="YOUR_TOKEN") as client:
88
+ result = await client.ask(
89
+ "What is shown in this image?",
90
+ image=Path("photo.jpg"),
91
+ model=ModelType.VISION,
92
+ )
93
+ print(result.text)
94
+
95
+ asyncio.run(main())
96
+ ```
97
+
98
+ If you want to reuse the same image in several requests, upload it once:
99
+
100
+ ```python
101
+ img = await client.upload_image(Path("photo.jpg"))
102
+ result = await client.ask("Describe the image", image=img, model=ModelType.VISION)
103
+ ```
104
+
105
+ Raw bytes also work:
106
+
107
+ ```python
108
+ data = Path("photo.png").read_bytes()
109
+ result = await client.ask("Read the text in this image", image=data, model=ModelType.VISION)
110
+ ```
111
+
112
+ ## Create a New Conversation
113
+
114
+ Use `client.new_conversation()` for a multi-turn chat. The `Conversation` object remembers the last `message_id` and sends it as `parent_message_id` on the next turn.
115
+
116
+ ```python
117
+ import asyncio
118
+ from apideepseek import DeepSeekClient
119
+
120
+ async def main():
121
+ async with DeepSeekClient(token="YOUR_TOKEN") as client:
122
+ chat = client.new_conversation()
123
+ first = await chat.ask("My name is Alex. Remember it.")
124
+ second = await chat.ask("What is my name?")
125
+ print(first.text)
126
+ print(second.text)
127
+
128
+ asyncio.run(main())
129
+ ```
130
+
131
+ Create another independent thread by creating another `Conversation`:
132
+
133
+ ```python
134
+ chat_a = client.new_conversation()
135
+ chat_b = client.new_conversation()
136
+ ```
137
+
138
+ ## Streaming
139
+
140
+ By default `ask_stream()` yields only new text fragments. Use `cumulative=True` if you need the full text so far on every iteration.
141
+
142
+ ```python
143
+ async for chunk in client.ask_stream("Tell me about Python"):
144
+ print(chunk, end="", flush=True)
145
+ ```
146
+
147
+ Streaming also works inside a conversation:
148
+
149
+ ```python
150
+ chat = client.new_conversation()
151
+ async for chunk in chat.ask_stream("Explain async/await"):
152
+ print(chunk, end="", flush=True)
153
+ ```
154
+
155
+ ## Register a New Account
156
+
157
+ ```python
158
+ import asyncio
159
+ from apideepseek import DeepSeekClient
160
+
161
+ async def main():
162
+ await DeepSeekClient.send_reg_code("myname@example.com")
163
+ code = input("Code from email: ")
164
+ token = await DeepSeekClient.confirm_reg_code(
165
+ "myname@example.com",
166
+ "password123",
167
+ code,
168
+ )
169
+ print("Token:", token)
170
+
171
+ asyncio.run(main())
172
+ ```
173
+
174
+ ## Result Object
175
+
176
+ `ask()` and `Conversation.ask()` return `DeepSeekTurnResult`:
177
+
178
+ ```python
179
+ result = await client.ask("Hello")
180
+ print(result.text) # full assistant response
181
+ print(result.session_id) # DeepSeek chat session id
182
+ print(result.message_id) # assistant message id for threading
183
+ ```
184
+
185
+ ## Error Handling
186
+
187
+ ```python
188
+ from apideepseek import DeepSeekClient, AuthorizationError, DeepSeekError
189
+
190
+ try:
191
+ async with DeepSeekClient(token="invalid") as client:
192
+ await client.ask("Hello")
193
+ except AuthorizationError:
194
+ print("Token is invalid")
195
+ except DeepSeekError as e:
196
+ print(f"API error: {e}")
197
+ ```
198
+
199
+ ## Documentation
200
+
201
+ - [DeepSeekClient methods](docs/en/client.md)
202
+ - [Conversation](docs/en/conversation.md)
203
+ - [Data types](docs/en/types.md)
204
+ - [Exceptions](docs/en/exceptions.md)
205
+ - [Proof-of-Work](docs/en/pow.md)
206
+
207
+ ## Requirements
208
+
209
+ - Python 3.9+
210
+ - `aiohttp >= 3.9`
211
+ - C++17 compiler with AVX2 to build the PoW extension from source, or a prebuilt wheel
@@ -0,0 +1,26 @@
1
+ from apideepseek.clients import DeepSeekClient
2
+ from apideepseek.conversation import Conversation
3
+ from apideepseek.types.enums import ModelType
4
+ from apideepseek.types.models.classes import DeepSeekTurnResult, UploadedImage
5
+ from apideepseek.types.exceptions import (
6
+ AioDeepSeekError,
7
+ DeepSeekError,
8
+ DeepSeekAPIError,
9
+ AuthorizationError,
10
+ InvalidToken,
11
+ VisionUnavailableError,
12
+ )
13
+
14
+ __all__ = [
15
+ "DeepSeekClient",
16
+ "Conversation",
17
+ "ModelType",
18
+ "DeepSeekTurnResult",
19
+ "UploadedImage",
20
+ "AioDeepSeekError",
21
+ "DeepSeekError",
22
+ "DeepSeekAPIError",
23
+ "AuthorizationError",
24
+ "InvalidToken",
25
+ "VisionUnavailableError",
26
+ ]
@@ -0,0 +1,3 @@
1
+ from apideepseek.clients.client import DeepSeekClient
2
+
3
+ __all__ = ["DeepSeekClient"]