100xprompt 0.1.175__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 (44) hide show
  1. 100xprompt-0.1.175/.gitignore +6 -0
  2. 100xprompt-0.1.175/LICENSE +3 -0
  3. 100xprompt-0.1.175/PKG-INFO +232 -0
  4. 100xprompt-0.1.175/README.md +203 -0
  5. 100xprompt-0.1.175/examples/async_client.py +29 -0
  6. 100xprompt-0.1.175/examples/create_session.py +20 -0
  7. 100xprompt-0.1.175/examples/prompt.py +33 -0
  8. 100xprompt-0.1.175/examples/stream_events.py +45 -0
  9. 100xprompt-0.1.175/pyproject.toml +96 -0
  10. 100xprompt-0.1.175/script/generate.py +1118 -0
  11. 100xprompt-0.1.175/src/hundredxprompt/__init__.py +96 -0
  12. 100xprompt-0.1.175/src/hundredxprompt/_base_model.py +205 -0
  13. 100xprompt-0.1.175/src/hundredxprompt/_client.py +543 -0
  14. 100xprompt-0.1.175/src/hundredxprompt/_errors.py +274 -0
  15. 100xprompt-0.1.175/src/hundredxprompt/_events.py +130 -0
  16. 100xprompt-0.1.175/src/hundredxprompt/_generated/__init__.py +3 -0
  17. 100xprompt-0.1.175/src/hundredxprompt/_generated/async_resources.py +3578 -0
  18. 100xprompt-0.1.175/src/hundredxprompt/_generated/models.py +4950 -0
  19. 100xprompt-0.1.175/src/hundredxprompt/_generated/namespaces.py +199 -0
  20. 100xprompt-0.1.175/src/hundredxprompt/_generated/operations.py +140 -0
  21. 100xprompt-0.1.175/src/hundredxprompt/_generated/resources.py +3578 -0
  22. 100xprompt-0.1.175/src/hundredxprompt/_hooks.py +23 -0
  23. 100xprompt-0.1.175/src/hundredxprompt/_resource.py +30 -0
  24. 100xprompt-0.1.175/src/hundredxprompt/_server.py +303 -0
  25. 100xprompt-0.1.175/src/hundredxprompt/_session.py +229 -0
  26. 100xprompt-0.1.175/src/hundredxprompt/_streaming.py +359 -0
  27. 100xprompt-0.1.175/src/hundredxprompt/_types.py +47 -0
  28. 100xprompt-0.1.175/src/hundredxprompt/_version.py +5 -0
  29. 100xprompt-0.1.175/src/hundredxprompt/py.typed +0 -0
  30. 100xprompt-0.1.175/src/hundredxprompt/types.py +15 -0
  31. 100xprompt-0.1.175/tests/__init__.py +0 -0
  32. 100xprompt-0.1.175/tests/fixtures/fake_cli.py +70 -0
  33. 100xprompt-0.1.175/tests/helpers.py +66 -0
  34. 100xprompt-0.1.175/tests/integration/__init__.py +0 -0
  35. 100xprompt-0.1.175/tests/integration/conftest.py +91 -0
  36. 100xprompt-0.1.175/tests/integration/fake_openai.py +200 -0
  37. 100xprompt-0.1.175/tests/integration/test_engine.py +240 -0
  38. 100xprompt-0.1.175/tests/unit/__init__.py +0 -0
  39. 100xprompt-0.1.175/tests/unit/test_client.py +291 -0
  40. 100xprompt-0.1.175/tests/unit/test_generate.py +105 -0
  41. 100xprompt-0.1.175/tests/unit/test_models.py +208 -0
  42. 100xprompt-0.1.175/tests/unit/test_operations.py +57 -0
  43. 100xprompt-0.1.175/tests/unit/test_server.py +143 -0
  44. 100xprompt-0.1.175/tests/unit/test_streaming.py +206 -0
@@ -0,0 +1,6 @@
1
+ .venv/
2
+ dist/
3
+ __pycache__/
4
+ .mypy_cache/
5
+ .pytest_cache/
6
+ .ruff_cache/
@@ -0,0 +1,3 @@
1
+ Copyright (c) 2025 100xprompt
2
+
3
+ All rights reserved. No one should copy, modify, distribute, or do anything with this code.
@@ -0,0 +1,232 @@
1
+ Metadata-Version: 2.5
2
+ Name: 100xprompt
3
+ Version: 0.1.175
4
+ Summary: Python SDK for 100XPrompt: a fully-typed sync and async client for the 100xprompt engine, plus a launcher for `100xprompt serve`.
5
+ Project-URL: Homepage, https://100xprompt.com
6
+ Project-URL: Repository, https://github.com/nipurn123/100xprompt
7
+ Project-URL: Issues, https://github.com/nipurn123/100xprompt/issues
8
+ Author: 100XPrompt
9
+ License-File: LICENSE
10
+ Keywords: 100xprompt,agent,ai,client,coding-agent,llm,mcp,sdk
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: Other/Proprietary License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.9
24
+ Requires-Dist: httpx-sse<1,>=0.4
25
+ Requires-Dist: httpx<1,>=0.27
26
+ Requires-Dist: pydantic<3,>=2.8
27
+ Requires-Dist: typing-extensions>=4.7
28
+ Description-Content-Type: text/markdown
29
+
30
+ # 100xprompt (Python SDK)
31
+
32
+ Python SDK for [100XPrompt](https://100xprompt.com), the AI coding agent.
33
+
34
+ A fully-typed client for the 100XPrompt agent server, sync and async, plus a launcher that starts `100xprompt serve` for you. Use it to drive sessions, stream events, manage models, providers and MCP servers, and build your own tools, bots and CI jobs on top of 100XPrompt.
35
+
36
+ > **The SDK is a client.** It talks to a running `100xprompt` engine; it does not bundle the agent runtime or any model access. You need the CLI installed and a model configured for it to do anything.
37
+
38
+ ## Prerequisites
39
+
40
+ Install the 100XPrompt CLI so `100xprompt` is on your `PATH`, then sign in:
41
+
42
+ ```bash
43
+ curl -fsSL https://100xprompt.com/install | bash
44
+ ```
45
+
46
+ ```bash
47
+ 100xprompt auth login
48
+ ```
49
+
50
+ ## Install
51
+
52
+ ```bash
53
+ pip install 100xprompt
54
+ ```
55
+
56
+ The distribution is `100xprompt`; the import is `hundredxprompt` (a Python module name cannot start with a digit). Python 3.9 or newer.
57
+
58
+ ## Quick start
59
+
60
+ ```python
61
+ from hundredxprompt import Client
62
+ from hundredxprompt.types import TextPart, TextPartInput
63
+
64
+ with Client.start() as client:
65
+ session = client.session.create(title="demo")
66
+ reply = client.session.prompt(
67
+ session.id,
68
+ parts=[TextPartInput(text="Write unit tests for src/index.ts")],
69
+ )
70
+ print("".join(p.text for p in reply.parts if isinstance(p, TextPart)))
71
+ ```
72
+
73
+ `Client.start()` runs `100xprompt serve` on `127.0.0.1` and returns a client for it; leaving the `with` block (or `client.close()`) stops the server. The server takes port 4096 when it is free and any free port otherwise; pass `port=` to pin one, `cli=` to run another CLI (a path, or a command such as `["bun", "run", "src/main.ts"]`), `config=` to layer config over the user's own, and `cwd=` for the project it starts in.
74
+
75
+ The server requires a token on every request, on loopback too. `start()` picks a random one (or takes `token=`), hands it to the server, and the client sends it.
76
+
77
+ ## Stream events
78
+
79
+ `client.event.subscribe()` yields typed events and stays subscribed: when the connection drops it reconnects with `Last-Event-ID`, so the server replays what was missed (or sends `ServerReset` when it cannot). Heartbeats are skipped.
80
+
81
+ ```python
82
+ from hundredxprompt import Client
83
+ from hundredxprompt.types import EventMessagePartUpdated, EventServerConnected, EventSessionIdle, TextPart, TextPartInput
84
+
85
+ with Client.start() as client:
86
+ session = client.session.create()
87
+ with client.event.subscribe() as events:
88
+ for event in events:
89
+ if isinstance(event, EventServerConnected):
90
+ client.session.prompt_async(session.id, parts=[TextPartInput(text="Hello!")])
91
+ elif isinstance(event, EventMessagePartUpdated) and isinstance(event.properties.part, TextPart):
92
+ print(event.properties.part.text)
93
+ elif isinstance(event, EventSessionIdle) and event.properties.session_id == session.id:
94
+ break
95
+ ```
96
+
97
+ An event type this SDK version does not know yet (a newer server's) arrives as `UnknownEvent`, so a long-lived subscription never fails on one. Tune reconnects with `retry_delay`, `max_retry_delay`, `max_retry_attempts`, `max_retry_duration`, `liveness_timeout` and `on_error`.
98
+
99
+ ## Async
100
+
101
+ `AsyncClient` has the same methods, awaited:
102
+
103
+ ```python
104
+ import asyncio
105
+
106
+ from hundredxprompt import AsyncClient
107
+ from hundredxprompt.types import TextPartInput
108
+
109
+
110
+ async def main() -> None:
111
+ async with await AsyncClient.start() as client:
112
+ session = await client.session.create()
113
+ reply = await client.session.prompt(session.id, parts=[TextPartInput(text="Hi")])
114
+ print(reply.info.tokens)
115
+ async with client.event.subscribe() as events:
116
+ async for event in events:
117
+ print(event.type)
118
+ break
119
+
120
+
121
+ asyncio.run(main())
122
+ ```
123
+
124
+ ## Server and client separately
125
+
126
+ ```python
127
+ from hundredxprompt import Server
128
+
129
+ with Server.start(port=4096) as server:
130
+ client = server.client() # closing it leaves the server running
131
+ print(client.global_.health().version)
132
+ ```
133
+
134
+ ## Connect to an existing server
135
+
136
+ If a `100xprompt serve` is already running, locally or remotely, point a client at it. `serve` prints the token it requires; set `HUNDREDXPROMPT_SERVER_TOKEN` before starting it to choose the token yourself.
137
+
138
+ ```python
139
+ import os
140
+
141
+ from hundredxprompt import Client
142
+
143
+ client = Client("https://your-host.example.com", token=os.environ["HUNDREDXPROMPT_SERVER_TOKEN"])
144
+ ```
145
+
146
+ Pass `directory=` to scope every call to a project folder (a call's own `directory=` wins).
147
+
148
+ > Authentication, rate limiting and access control are enforced by the **server**, not the SDK. Secure your hosted instance accordingly.
149
+
150
+ ## Structured output
151
+
152
+ ```python
153
+ from pydantic import BaseModel
154
+
155
+ from hundredxprompt.types import TextPartInput
156
+
157
+
158
+ class City(BaseModel):
159
+ name: str
160
+ population: int
161
+
162
+
163
+ result = client.session.prompt_structured(
164
+ session.id, output_type=City, parts=[TextPartInput(text="The biggest city in France?")]
165
+ )
166
+ print(result.structured.population) # a validated City
167
+ ```
168
+
169
+ Pass `schema=` (a JSON Schema dict) instead of `output_type=` to get the value as plain JSON. When the model never delivers a valid value, it raises `StructuredOutputFailedError`.
170
+
171
+ ## Every operation
172
+
173
+ Every operation of the API is a method named after its `operationId`: `session.prompt` is `client.session.prompt(...)`, `global.health` is `client.global_.health()` (a trailing `_` where the name is a Python keyword), and `session.revert.preview` is `client.session.revert_preview(...)`. Path parameters are positional; query parameters and body fields are keyword arguments in snake case (`message_id=`, sent as `messageID`). Every method also takes `extra_headers`, `extra_query`, `extra_body` and `timeout`.
174
+
175
+ `hundredxprompt.OPERATIONS` lists every operation with the method that calls it.
176
+
177
+ ## Types
178
+
179
+ Every request and response model, and every event, is generated from the server's OpenAPI spec and lives in `hundredxprompt.types`:
180
+
181
+ ```python
182
+ from hundredxprompt.types import AssistantMessage, Event, Part, Session, TextPartInput
183
+ ```
184
+
185
+ Models are pydantic v2 models with snake-case attributes; `model.to_dict()` gives the server's JSON. Unions such as `Part`, `Message` and `Event` are discriminated by `type` (or `role`), so `isinstance` tells them apart. A value from a newer server that a model does not know is kept as sent, with a warning on the `hundredxprompt` logger, rather than failing the call.
186
+
187
+ ## Errors
188
+
189
+ | Exception | When |
190
+ | --- | --- |
191
+ | `LicenseError` | 403: the engine refuses work because this machine's account is not licensed. `message` says why and what to do, in words for a person. A subclass of `PermissionDeniedError`. |
192
+ | `BadRequestError`, `AuthenticationError`, `PermissionDeniedError`, `NotFoundError`, `ConflictError`, `InternalServerError` | 400, 401, 403, 404, 409, 5xx; any other status is `APIStatusError`. All carry `status_code` and the server's `body`. |
193
+ | `NoReplyError` | `session.prompt` ended without an assistant message: aborted (`.aborted`) or failed before the model answered (`.error`). |
194
+ | `APIConnectionError`, `APITimeoutError` | The server could not be reached, or did not answer in time. |
195
+ | `EventStreamRejectedError` | The event stream was refused (401/403/404); it does not reconnect. |
196
+ | `ServerStartError`, `CLINotFoundError` | `start()` could not run `100xprompt serve`; `output` holds what it printed. |
197
+
198
+ All of them derive from `HundredXPromptError`. `is_license_error(value)` is the same guard as the JS SDK's `isLicenseError`: it recognises the licence refusal on any of these errors, or on an error object as the server writes it.
199
+
200
+ ```python
201
+ from hundredxprompt import LicenseError
202
+
203
+ try:
204
+ client.session.prompt(session.id, parts=[TextPartInput(text="hi")])
205
+ except LicenseError as refused:
206
+ print(refused.message) # for example "Sign in to use 100xprompt ..."
207
+ ```
208
+
209
+ Reads (sessions, messages, the event stream), `abort`, deleting your own sessions and signing in still work while the licence refuses work.
210
+
211
+ ## Examples
212
+
213
+ [`examples/`](examples/): `create_session.py`, `prompt.py`, `stream_events.py`, `async_client.py`.
214
+
215
+ ## Development
216
+
217
+ The typed layer (`src/hundredxprompt/_generated/`, `_version.py`) is generated from `packages/sdk/openapi.json`, the spec the JS SDK is generated from, by `script/generate.py`. The repo's `script/generate.ts` runs it after regenerating the spec, and `script/build.ts` runs it before every build, so each CLI release regenerates the SDK at the CLI's version.
218
+
219
+ ```bash
220
+ uv sync
221
+ uv run python script/generate.py # regenerate; --check exits 1 when stale
222
+ uv run ruff check . && uv run ruff format --check . && uv run mypy
223
+ uv run pytest tests/unit # no CLI needed
224
+ uv run pytest tests/integration # a real `100xprompt serve` with a scripted model
225
+ bun script/build.ts # regenerate, then build the wheel and sdist into dist/
226
+ ```
227
+
228
+ The integration tests use the `100xprompt` on your `PATH` (or `HUNDREDXPROMPT_TEST_CLI`), isolated from your own data, with a local fake model provider. The licence test runs the CLI from this checkout's source with bun (a release build ignores the settings it needs), and is skipped without it.
229
+
230
+ ## License
231
+
232
+ Proprietary. See [LICENSE](./LICENSE).
@@ -0,0 +1,203 @@
1
+ # 100xprompt (Python SDK)
2
+
3
+ Python SDK for [100XPrompt](https://100xprompt.com), the AI coding agent.
4
+
5
+ A fully-typed client for the 100XPrompt agent server, sync and async, plus a launcher that starts `100xprompt serve` for you. Use it to drive sessions, stream events, manage models, providers and MCP servers, and build your own tools, bots and CI jobs on top of 100XPrompt.
6
+
7
+ > **The SDK is a client.** It talks to a running `100xprompt` engine; it does not bundle the agent runtime or any model access. You need the CLI installed and a model configured for it to do anything.
8
+
9
+ ## Prerequisites
10
+
11
+ Install the 100XPrompt CLI so `100xprompt` is on your `PATH`, then sign in:
12
+
13
+ ```bash
14
+ curl -fsSL https://100xprompt.com/install | bash
15
+ ```
16
+
17
+ ```bash
18
+ 100xprompt auth login
19
+ ```
20
+
21
+ ## Install
22
+
23
+ ```bash
24
+ pip install 100xprompt
25
+ ```
26
+
27
+ The distribution is `100xprompt`; the import is `hundredxprompt` (a Python module name cannot start with a digit). Python 3.9 or newer.
28
+
29
+ ## Quick start
30
+
31
+ ```python
32
+ from hundredxprompt import Client
33
+ from hundredxprompt.types import TextPart, TextPartInput
34
+
35
+ with Client.start() as client:
36
+ session = client.session.create(title="demo")
37
+ reply = client.session.prompt(
38
+ session.id,
39
+ parts=[TextPartInput(text="Write unit tests for src/index.ts")],
40
+ )
41
+ print("".join(p.text for p in reply.parts if isinstance(p, TextPart)))
42
+ ```
43
+
44
+ `Client.start()` runs `100xprompt serve` on `127.0.0.1` and returns a client for it; leaving the `with` block (or `client.close()`) stops the server. The server takes port 4096 when it is free and any free port otherwise; pass `port=` to pin one, `cli=` to run another CLI (a path, or a command such as `["bun", "run", "src/main.ts"]`), `config=` to layer config over the user's own, and `cwd=` for the project it starts in.
45
+
46
+ The server requires a token on every request, on loopback too. `start()` picks a random one (or takes `token=`), hands it to the server, and the client sends it.
47
+
48
+ ## Stream events
49
+
50
+ `client.event.subscribe()` yields typed events and stays subscribed: when the connection drops it reconnects with `Last-Event-ID`, so the server replays what was missed (or sends `ServerReset` when it cannot). Heartbeats are skipped.
51
+
52
+ ```python
53
+ from hundredxprompt import Client
54
+ from hundredxprompt.types import EventMessagePartUpdated, EventServerConnected, EventSessionIdle, TextPart, TextPartInput
55
+
56
+ with Client.start() as client:
57
+ session = client.session.create()
58
+ with client.event.subscribe() as events:
59
+ for event in events:
60
+ if isinstance(event, EventServerConnected):
61
+ client.session.prompt_async(session.id, parts=[TextPartInput(text="Hello!")])
62
+ elif isinstance(event, EventMessagePartUpdated) and isinstance(event.properties.part, TextPart):
63
+ print(event.properties.part.text)
64
+ elif isinstance(event, EventSessionIdle) and event.properties.session_id == session.id:
65
+ break
66
+ ```
67
+
68
+ An event type this SDK version does not know yet (a newer server's) arrives as `UnknownEvent`, so a long-lived subscription never fails on one. Tune reconnects with `retry_delay`, `max_retry_delay`, `max_retry_attempts`, `max_retry_duration`, `liveness_timeout` and `on_error`.
69
+
70
+ ## Async
71
+
72
+ `AsyncClient` has the same methods, awaited:
73
+
74
+ ```python
75
+ import asyncio
76
+
77
+ from hundredxprompt import AsyncClient
78
+ from hundredxprompt.types import TextPartInput
79
+
80
+
81
+ async def main() -> None:
82
+ async with await AsyncClient.start() as client:
83
+ session = await client.session.create()
84
+ reply = await client.session.prompt(session.id, parts=[TextPartInput(text="Hi")])
85
+ print(reply.info.tokens)
86
+ async with client.event.subscribe() as events:
87
+ async for event in events:
88
+ print(event.type)
89
+ break
90
+
91
+
92
+ asyncio.run(main())
93
+ ```
94
+
95
+ ## Server and client separately
96
+
97
+ ```python
98
+ from hundredxprompt import Server
99
+
100
+ with Server.start(port=4096) as server:
101
+ client = server.client() # closing it leaves the server running
102
+ print(client.global_.health().version)
103
+ ```
104
+
105
+ ## Connect to an existing server
106
+
107
+ If a `100xprompt serve` is already running, locally or remotely, point a client at it. `serve` prints the token it requires; set `HUNDREDXPROMPT_SERVER_TOKEN` before starting it to choose the token yourself.
108
+
109
+ ```python
110
+ import os
111
+
112
+ from hundredxprompt import Client
113
+
114
+ client = Client("https://your-host.example.com", token=os.environ["HUNDREDXPROMPT_SERVER_TOKEN"])
115
+ ```
116
+
117
+ Pass `directory=` to scope every call to a project folder (a call's own `directory=` wins).
118
+
119
+ > Authentication, rate limiting and access control are enforced by the **server**, not the SDK. Secure your hosted instance accordingly.
120
+
121
+ ## Structured output
122
+
123
+ ```python
124
+ from pydantic import BaseModel
125
+
126
+ from hundredxprompt.types import TextPartInput
127
+
128
+
129
+ class City(BaseModel):
130
+ name: str
131
+ population: int
132
+
133
+
134
+ result = client.session.prompt_structured(
135
+ session.id, output_type=City, parts=[TextPartInput(text="The biggest city in France?")]
136
+ )
137
+ print(result.structured.population) # a validated City
138
+ ```
139
+
140
+ Pass `schema=` (a JSON Schema dict) instead of `output_type=` to get the value as plain JSON. When the model never delivers a valid value, it raises `StructuredOutputFailedError`.
141
+
142
+ ## Every operation
143
+
144
+ Every operation of the API is a method named after its `operationId`: `session.prompt` is `client.session.prompt(...)`, `global.health` is `client.global_.health()` (a trailing `_` where the name is a Python keyword), and `session.revert.preview` is `client.session.revert_preview(...)`. Path parameters are positional; query parameters and body fields are keyword arguments in snake case (`message_id=`, sent as `messageID`). Every method also takes `extra_headers`, `extra_query`, `extra_body` and `timeout`.
145
+
146
+ `hundredxprompt.OPERATIONS` lists every operation with the method that calls it.
147
+
148
+ ## Types
149
+
150
+ Every request and response model, and every event, is generated from the server's OpenAPI spec and lives in `hundredxprompt.types`:
151
+
152
+ ```python
153
+ from hundredxprompt.types import AssistantMessage, Event, Part, Session, TextPartInput
154
+ ```
155
+
156
+ Models are pydantic v2 models with snake-case attributes; `model.to_dict()` gives the server's JSON. Unions such as `Part`, `Message` and `Event` are discriminated by `type` (or `role`), so `isinstance` tells them apart. A value from a newer server that a model does not know is kept as sent, with a warning on the `hundredxprompt` logger, rather than failing the call.
157
+
158
+ ## Errors
159
+
160
+ | Exception | When |
161
+ | --- | --- |
162
+ | `LicenseError` | 403: the engine refuses work because this machine's account is not licensed. `message` says why and what to do, in words for a person. A subclass of `PermissionDeniedError`. |
163
+ | `BadRequestError`, `AuthenticationError`, `PermissionDeniedError`, `NotFoundError`, `ConflictError`, `InternalServerError` | 400, 401, 403, 404, 409, 5xx; any other status is `APIStatusError`. All carry `status_code` and the server's `body`. |
164
+ | `NoReplyError` | `session.prompt` ended without an assistant message: aborted (`.aborted`) or failed before the model answered (`.error`). |
165
+ | `APIConnectionError`, `APITimeoutError` | The server could not be reached, or did not answer in time. |
166
+ | `EventStreamRejectedError` | The event stream was refused (401/403/404); it does not reconnect. |
167
+ | `ServerStartError`, `CLINotFoundError` | `start()` could not run `100xprompt serve`; `output` holds what it printed. |
168
+
169
+ All of them derive from `HundredXPromptError`. `is_license_error(value)` is the same guard as the JS SDK's `isLicenseError`: it recognises the licence refusal on any of these errors, or on an error object as the server writes it.
170
+
171
+ ```python
172
+ from hundredxprompt import LicenseError
173
+
174
+ try:
175
+ client.session.prompt(session.id, parts=[TextPartInput(text="hi")])
176
+ except LicenseError as refused:
177
+ print(refused.message) # for example "Sign in to use 100xprompt ..."
178
+ ```
179
+
180
+ Reads (sessions, messages, the event stream), `abort`, deleting your own sessions and signing in still work while the licence refuses work.
181
+
182
+ ## Examples
183
+
184
+ [`examples/`](examples/): `create_session.py`, `prompt.py`, `stream_events.py`, `async_client.py`.
185
+
186
+ ## Development
187
+
188
+ The typed layer (`src/hundredxprompt/_generated/`, `_version.py`) is generated from `packages/sdk/openapi.json`, the spec the JS SDK is generated from, by `script/generate.py`. The repo's `script/generate.ts` runs it after regenerating the spec, and `script/build.ts` runs it before every build, so each CLI release regenerates the SDK at the CLI's version.
189
+
190
+ ```bash
191
+ uv sync
192
+ uv run python script/generate.py # regenerate; --check exits 1 when stale
193
+ uv run ruff check . && uv run ruff format --check . && uv run mypy
194
+ uv run pytest tests/unit # no CLI needed
195
+ uv run pytest tests/integration # a real `100xprompt serve` with a scripted model
196
+ bun script/build.ts # regenerate, then build the wheel and sdist into dist/
197
+ ```
198
+
199
+ The integration tests use the `100xprompt` on your `PATH` (or `HUNDREDXPROMPT_TEST_CLI`), isolated from your own data, with a local fake model provider. The licence test runs the CLI from this checkout's source with bun (a release build ignores the settings it needs), and is skipped without it.
200
+
201
+ ## License
202
+
203
+ Proprietary. See [LICENSE](./LICENSE).
@@ -0,0 +1,29 @@
1
+ """The async client: prompt two sessions at once.
2
+
3
+ python examples/async_client.py
4
+ """
5
+
6
+ import asyncio
7
+
8
+ from hundredxprompt import AsyncClient
9
+ from hundredxprompt.types import TextPart, TextPartInput
10
+
11
+
12
+ async def ask(client: AsyncClient, question: str) -> str:
13
+ session = await client.session.create(title=question[:40])
14
+ reply = await client.session.prompt(session.id, parts=[TextPartInput(text=question)])
15
+ return "".join(part.text for part in reply.parts if isinstance(part, TextPart))
16
+
17
+
18
+ async def main() -> None:
19
+ async with await AsyncClient.start() as client:
20
+ answers = await asyncio.gather(
21
+ ask(client, "Name one prime number. Answer with the number only."),
22
+ ask(client, "Name one primary colour. Answer with the colour only."),
23
+ )
24
+ for answer in answers:
25
+ print(answer)
26
+
27
+
28
+ if __name__ == "__main__":
29
+ asyncio.run(main())
@@ -0,0 +1,20 @@
1
+ """Start a 100xprompt engine, create a session, and list the sessions it has.
2
+
3
+ python examples/create_session.py
4
+ """
5
+
6
+ from hundredxprompt import Client
7
+
8
+
9
+ def main() -> None:
10
+ with Client.start() as client:
11
+ health = client.global_.health()
12
+ print(f"100xprompt {health.version} at {client.base_url}")
13
+ session = client.session.create(title="Created from Python")
14
+ print(f"created {session.id}: {session.title}")
15
+ for listed in client.session.list(limit=5):
16
+ print(f" {listed.id} {listed.title}")
17
+
18
+
19
+ if __name__ == "__main__":
20
+ main()
@@ -0,0 +1,33 @@
1
+ """Send a prompt and print the reply.
2
+
3
+ python examples/prompt.py "What does this project do?"
4
+ """
5
+
6
+ import sys
7
+
8
+ from hundredxprompt import Client, LicenseError, NoReplyError
9
+ from hundredxprompt.types import TextPart, TextPartInput
10
+
11
+
12
+ def main() -> int:
13
+ question = " ".join(sys.argv[1:]) or "Say hello in one short sentence."
14
+ with Client.start() as client:
15
+ session = client.session.create(title="Prompt from Python")
16
+ try:
17
+ reply = client.session.prompt(session.id, parts=[TextPartInput(text=question)])
18
+ except LicenseError as refused:
19
+ print(refused.message, file=sys.stderr)
20
+ return 1
21
+ except NoReplyError as no_reply:
22
+ print(f"no reply: {no_reply}", file=sys.stderr)
23
+ return 1
24
+ if reply.info.error is not None:
25
+ print(f"the turn failed: {reply.info.error.name}", file=sys.stderr)
26
+ print("".join(part.text for part in reply.parts if isinstance(part, TextPart)))
27
+ tokens = reply.info.tokens
28
+ print(f"\n[{reply.info.provider_id}/{reply.info.model_id}: {tokens.input} in, {tokens.output} out]")
29
+ return 0
30
+
31
+
32
+ if __name__ == "__main__":
33
+ sys.exit(main())
@@ -0,0 +1,45 @@
1
+ """Prompt without waiting, and follow the turn on the event stream as it happens.
2
+
3
+ python examples/stream_events.py "Explain this repository in three bullets."
4
+ """
5
+
6
+ import sys
7
+
8
+ from hundredxprompt import Client, UnknownEvent
9
+ from hundredxprompt.types import (
10
+ EventMessagePartUpdated,
11
+ EventServerConnected,
12
+ EventSessionError,
13
+ EventSessionIdle,
14
+ TextPart,
15
+ TextPartInput,
16
+ ToolPart,
17
+ )
18
+
19
+
20
+ def main() -> None:
21
+ question = " ".join(sys.argv[1:]) or "Say hello in one short sentence."
22
+ with Client.start() as client:
23
+ session = client.session.create(title="Streamed from Python")
24
+ with client.event.subscribe() as events:
25
+ for event in events:
26
+ if isinstance(event, EventServerConnected):
27
+ # Subscribed: nothing the turn does can be missed now.
28
+ client.session.prompt_async(session.id, parts=[TextPartInput(text=question)])
29
+ elif isinstance(event, EventMessagePartUpdated):
30
+ part = event.properties.part
31
+ if isinstance(part, TextPart) and event.properties.delta:
32
+ print(event.properties.delta, end="", flush=True)
33
+ elif isinstance(part, ToolPart):
34
+ print(f"\n[{part.tool}: {part.state.status}]", flush=True)
35
+ elif isinstance(event, EventSessionError):
36
+ print(f"\nerror: {event.properties.error}")
37
+ elif isinstance(event, EventSessionIdle) and event.properties.session_id == session.id:
38
+ print()
39
+ break
40
+ elif isinstance(event, UnknownEvent):
41
+ pass # a newer server's event type
42
+
43
+
44
+ if __name__ == "__main__":
45
+ main()
@@ -0,0 +1,96 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.26"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ # The import name is `hundredxprompt`: a Python module name cannot start with a digit.
7
+ name = "100xprompt"
8
+ dynamic = ["version"]
9
+ description = "Python SDK for 100XPrompt: a fully-typed sync and async client for the 100xprompt engine, plus a launcher for `100xprompt serve`."
10
+ readme = "README.md"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.9"
13
+ authors = [{ name = "100XPrompt" }]
14
+ keywords = ["100xprompt", "ai", "agent", "coding-agent", "llm", "sdk", "client", "mcp"]
15
+ classifiers = [
16
+ "Development Status :: 4 - Beta",
17
+ "Intended Audience :: Developers",
18
+ "License :: Other/Proprietary License",
19
+ "Operating System :: OS Independent",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3 :: Only",
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
+ "Typing :: Typed",
28
+ ]
29
+ dependencies = [
30
+ "httpx>=0.27,<1",
31
+ "httpx-sse>=0.4,<1",
32
+ "pydantic>=2.8,<3",
33
+ "typing-extensions>=4.7",
34
+ ]
35
+
36
+ [project.urls]
37
+ Homepage = "https://100xprompt.com"
38
+ Repository = "https://github.com/nipurn123/100xprompt"
39
+ Issues = "https://github.com/nipurn123/100xprompt/issues"
40
+
41
+ [dependency-groups]
42
+ dev = [
43
+ "mypy>=1.13",
44
+ "pytest>=8",
45
+ "pytest-asyncio>=0.24",
46
+ "ruff==0.14.8",
47
+ ]
48
+
49
+ [tool.hatch.version]
50
+ path = "src/hundredxprompt/_version.py"
51
+
52
+ [tool.hatch.build.targets.wheel]
53
+ packages = ["src/hundredxprompt"]
54
+
55
+ [tool.hatch.build.targets.sdist]
56
+ include = ["src/hundredxprompt", "tests", "examples", "script/generate.py", "README.md", "LICENSE"]
57
+
58
+ [tool.ruff]
59
+ line-length = 120
60
+ target-version = "py39"
61
+
62
+ [tool.ruff.lint]
63
+ select = ["E", "F", "I", "B", "UP", "W"]
64
+ ignore = [
65
+ "E501", # the formatter owns line length; long docstrings and URLs stay whole
66
+ "UP006", # List/Dict: pydantic evaluates annotations at runtime, and 3.9 has no list[...] there
67
+ "UP007", # Optional/Union: the same, for X | Y
68
+ "UP035", # typing.List etc. are what 3.9 can evaluate
69
+ "UP045", # Optional[X], for the same reason
70
+ ]
71
+
72
+ [tool.ruff.lint.isort]
73
+ known-first-party = ["hundredxprompt"]
74
+
75
+ [tool.mypy]
76
+ # mypy no longer checks as 3.9; the package still runs on 3.9 (tests run there too).
77
+ python_version = "3.10"
78
+ strict = true
79
+ plugins = ["pydantic.mypy"]
80
+ files = ["src", "tests", "examples"]
81
+
82
+ [[tool.mypy.overrides]]
83
+ # A generated method returns what its call is cast to, which the transport types as Any.
84
+ module = ["hundredxprompt._generated.*"]
85
+ disable_error_code = ["no-any-return"]
86
+
87
+ [[tool.mypy.overrides]]
88
+ module = ["tests.*"]
89
+ disallow_untyped_defs = false
90
+ disallow_incomplete_defs = false
91
+
92
+ [tool.pytest.ini_options]
93
+ testpaths = ["tests"]
94
+ asyncio_mode = "auto"
95
+ asyncio_default_fixture_loop_scope = "function"
96
+ markers = ["integration: runs a real `100xprompt serve`"]