logion-client 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.
Files changed (63) hide show
  1. logion_client-0.1.0/.gitignore +244 -0
  2. logion_client-0.1.0/LICENSE +21 -0
  3. logion_client-0.1.0/Makefile +65 -0
  4. logion_client-0.1.0/PKG-INFO +194 -0
  5. logion_client-0.1.0/README.md +168 -0
  6. logion_client-0.1.0/pyproject.toml +140 -0
  7. logion_client-0.1.0/scripts/generate_operations.py +412 -0
  8. logion_client-0.1.0/src/logion/__init__.py +32 -0
  9. logion_client-0.1.0/src/logion/_client.py +61 -0
  10. logion_client-0.1.0/src/logion/_config.py +56 -0
  11. logion_client-0.1.0/src/logion/_errors.py +74 -0
  12. logion_client-0.1.0/src/logion/_http.py +187 -0
  13. logion_client-0.1.0/src/logion/_types/__init__.py +2 -0
  14. logion_client-0.1.0/src/logion/_version.py +19 -0
  15. logion_client-0.1.0/src/logion/_versioning.py +22 -0
  16. logion_client-0.1.0/src/logion/py.typed +0 -0
  17. logion_client-0.1.0/src/logion/v1/__init__.py +36 -0
  18. logion_client-0.1.0/src/logion/v1/_generated/__init__.py +2 -0
  19. logion_client-0.1.0/src/logion/v1/_generated/operations.py +1085 -0
  20. logion_client-0.1.0/src/logion/v1/_operation_map.py +90 -0
  21. logion_client-0.1.0/src/logion/v1/_resources/__init__.py +2 -0
  22. logion_client-0.1.0/src/logion/v1/_resources/admin/__init__.py +24 -0
  23. logion_client-0.1.0/src/logion/v1/_resources/admin/courses.py +51 -0
  24. logion_client-0.1.0/src/logion/v1/_resources/admin/payments.py +2 -0
  25. logion_client-0.1.0/src/logion/v1/_resources/admin/reports.py +74 -0
  26. logion_client-0.1.0/src/logion/v1/_resources/admin/shared.py +12 -0
  27. logion_client-0.1.0/src/logion/v1/_resources/admin/users_agents.py +78 -0
  28. logion_client-0.1.0/src/logion/v1/_resources/bounties/__init__.py +19 -0
  29. logion_client-0.1.0/src/logion/v1/_resources/bounties/core.py +97 -0
  30. logion_client-0.1.0/src/logion/v1/_resources/bounties/shared.py +14 -0
  31. logion_client-0.1.0/src/logion/v1/_resources/bounties/submissions.py +108 -0
  32. logion_client-0.1.0/src/logion/v1/_resources/course_reviews.py +141 -0
  33. logion_client-0.1.0/src/logion/v1/_resources/courses/__init__.py +24 -0
  34. logion_client-0.1.0/src/logion/v1/_resources/courses/core.py +181 -0
  35. logion_client-0.1.0/src/logion/v1/_resources/courses/publication.py +40 -0
  36. logion_client-0.1.0/src/logion/v1/_resources/courses/reviews.py +99 -0
  37. logion_client-0.1.0/src/logion/v1/_resources/courses/shared.py +34 -0
  38. logion_client-0.1.0/src/logion/v1/_resources/credits.py +40 -0
  39. logion_client-0.1.0/src/logion/v1/_resources/health.py +24 -0
  40. logion_client-0.1.0/src/logion/v1/_resources/identity.py +113 -0
  41. logion_client-0.1.0/src/logion/v1/_resources/listings.py +77 -0
  42. logion_client-0.1.0/src/logion/v1/_resources/notifications.py +53 -0
  43. logion_client-0.1.0/src/logion/v1/_resources/payments.py +80 -0
  44. logion_client-0.1.0/src/logion/v1/_resources/referrals.py +38 -0
  45. logion_client-0.1.0/src/logion/v1/_resources/reports.py +72 -0
  46. logion_client-0.1.0/src/logion/v1/_types/__init__.py +6 -0
  47. logion_client-0.1.0/src/logion/v1/_types/generated/__init__.py +7 -0
  48. logion_client-0.1.0/src/logion/v1/_types/generated/v1.py +2026 -0
  49. logion_client-0.1.0/tests/conftest.py +25 -0
  50. logion_client-0.1.0/tests/test_client_init.py +92 -0
  51. logion_client-0.1.0/tests/test_config.py +115 -0
  52. logion_client-0.1.0/tests/test_errors.py +140 -0
  53. logion_client-0.1.0/tests/test_http.py +271 -0
  54. logion_client-0.1.0/tests/test_resource_architecture.py +60 -0
  55. logion_client-0.1.0/tests/test_v1_admin.py +277 -0
  56. logion_client-0.1.0/tests/test_v1_bounties.py +272 -0
  57. logion_client-0.1.0/tests/test_v1_course_reviews.py +113 -0
  58. logion_client-0.1.0/tests/test_v1_courses_extended.py +233 -0
  59. logion_client-0.1.0/tests/test_v1_health.py +39 -0
  60. logion_client-0.1.0/tests/test_v1_notifications.py +69 -0
  61. logion_client-0.1.0/tests/test_v1_operation_coverage.py +94 -0
  62. logion_client-0.1.0/tests/test_v1_reports.py +66 -0
  63. logion_client-0.1.0/tests/test_v1_resources.py +462 -0
@@ -0,0 +1,244 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
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
+ !packages/npm-wrapper/src/lib/
19
+ !packages/npm-wrapper/src/lib/**
20
+ lib64/
21
+ parts/
22
+ sdist/
23
+ var/
24
+ wheels/
25
+ share/python-wheels/
26
+ *.egg-info/
27
+ .installed.cfg
28
+ *.egg
29
+ MANIFEST
30
+
31
+ # PyInstaller
32
+ # Usually these files are written by a python script from a template
33
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
34
+ *.manifest
35
+ *.spec
36
+
37
+ # Installer logs
38
+ pip-log.txt
39
+ pip-delete-this-directory.txt
40
+
41
+ # Unit test / coverage reports
42
+ htmlcov/
43
+ .tox/
44
+ .nox/
45
+ .coverage
46
+ .coverage.*
47
+ .cache
48
+ nosetests.xml
49
+ coverage.xml
50
+ *.cover
51
+ *.py.cover
52
+ .hypothesis/
53
+ .pytest_cache/
54
+ cover/
55
+
56
+ # Translations
57
+ *.mo
58
+ *.pot
59
+
60
+ # Django stuff:
61
+ *.log
62
+ local_settings.py
63
+ db.sqlite3
64
+ db.sqlite3-journal
65
+
66
+ # Flask stuff:
67
+ instance/
68
+ .webassets-cache
69
+
70
+ # Scrapy stuff:
71
+ .scrapy
72
+
73
+ # Sphinx documentation
74
+ docs/_build/
75
+
76
+ # PyBuilder
77
+ .pybuilder/
78
+ target/
79
+
80
+ # Jupyter Notebook
81
+ .ipynb_checkpoints
82
+
83
+ # IPython
84
+ profile_default/
85
+ ipython_config.py
86
+
87
+ # pyenv
88
+ # For a library or package, you might want to ignore these files since the code is
89
+ # intended to run in multiple environments; otherwise, check them in:
90
+ # .python-version
91
+
92
+ # pipenv
93
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
94
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
95
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
96
+ # install all needed dependencies.
97
+ # Pipfile.lock
98
+
99
+ # UV
100
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
101
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
102
+ # commonly ignored for libraries.
103
+ # uv.lock
104
+
105
+ # poetry
106
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
107
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
108
+ # commonly ignored for libraries.
109
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
110
+ # poetry.lock
111
+ # poetry.toml
112
+
113
+ # pdm
114
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
115
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
116
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
117
+ # pdm.lock
118
+ # pdm.toml
119
+ .pdm-python
120
+ .pdm-build/
121
+
122
+ # pixi
123
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
124
+ # pixi.lock
125
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
126
+ # in the .venv directory. It is recommended not to include this directory in version control.
127
+ .pixi
128
+
129
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
130
+ __pypackages__/
131
+
132
+ # Celery stuff
133
+ celerybeat-schedule
134
+ celerybeat.pid
135
+
136
+ # Redis
137
+ *.rdb
138
+ *.aof
139
+ *.pid
140
+
141
+ # RabbitMQ
142
+ mnesia/
143
+ rabbitmq/
144
+ rabbitmq-data/
145
+
146
+ # ActiveMQ
147
+ activemq-data/
148
+
149
+ # SageMath parsed files
150
+ *.sage.py
151
+
152
+ # Environments
153
+ .env
154
+ .envrc
155
+ .venv
156
+ env/
157
+ venv/
158
+ ENV/
159
+ env.bak/
160
+ venv.bak/
161
+
162
+ # Spyder project settings
163
+ .spyderproject
164
+ .spyproject
165
+
166
+ # Rope project settings
167
+ .ropeproject
168
+
169
+ # mkdocs documentation
170
+ /site
171
+
172
+ # mypy
173
+ .mypy_cache/
174
+ .dmypy.json
175
+ dmypy.json
176
+
177
+ # Pyre type checker
178
+ .pyre/
179
+
180
+ # pytype static type analyzer
181
+ .pytype/
182
+
183
+ # Cython debug symbols
184
+ cython_debug/
185
+
186
+ # PyCharm
187
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
188
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
189
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
190
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
191
+ # .idea/
192
+
193
+ # Abstra
194
+ # Abstra is an AI-powered process automation framework.
195
+ # Ignore directories containing user credentials, local state, and settings.
196
+ # Learn more at https://abstra.io/docs
197
+ .abstra/
198
+
199
+ # Visual Studio Code
200
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
201
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
202
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
203
+ # you could uncomment the following to ignore the entire vscode folder
204
+ # .vscode/
205
+ # Temporary file for partial code execution
206
+ tempCodeRunnerFile.py
207
+
208
+ # Ruff stuff:
209
+ .ruff_cache/
210
+
211
+ # PyPI configuration file
212
+ .pypirc
213
+
214
+ # Marimo
215
+ marimo/_static/
216
+ marimo/_lsp/
217
+ __marimo__/
218
+
219
+ # Streamlit
220
+ .streamlit/secrets.toml
221
+
222
+ # Mock server PID
223
+ .prism.pid
224
+
225
+ # Local GGUF model cache for llama.cpp evals
226
+ .models/
227
+ *.gguf
228
+
229
+ # DSPy optimizer generated candidates (keep .gitkeep only).
230
+ # Use `**` so the rule matches regardless of which workspace package
231
+ # the candidates land in.
232
+ **/evals/optimizers/dspy/generated_candidates/*.json
233
+ **/evals/optimizers/dspy/generated_candidates/*.program.json
234
+ **/evals/optimizers/dspy/generated_candidates/*.review.md
235
+
236
+ # Secrets and credentials (never commit these)
237
+ *.pem
238
+ *.key
239
+ .secrets.baseline.local
240
+
241
+ # generated by test_handler_manifest.py
242
+ packages/cli/.artifacts/
243
+
244
+ .DS_Store
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nicolas Leal
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,65 @@
1
+ SHELL := /bin/bash
2
+ ROOT := $(shell git rev-parse --show-toplevel 2>/dev/null || pwd)
3
+ SPEC := $(ROOT)/contracts/openapi/v1.json
4
+ GEN_DIR := src/logion/v1/_types/generated
5
+ GEN_FILE := $(GEN_DIR)/v1.py
6
+ OPS_FILE := src/logion/v1/_generated/operations.py
7
+
8
+ .PHONY: generate-models check-models generate-operations check-operations generate-client check-client lint test typecheck
9
+
10
+ generate-models:
11
+ uv run datamodel-codegen \
12
+ --input $(SPEC) \
13
+ --output $(GEN_FILE) \
14
+ --output-model-type pydantic_v2.BaseModel \
15
+ --field-constraints \
16
+ --use-schema-description \
17
+ --use-default-kwarg \
18
+ --snake-case-field \
19
+ --target-python-version 3.12 \
20
+ --use-annotated \
21
+ --enum-field-as-literal all \
22
+ --allow-extra-fields
23
+ uv run ruff format $(GEN_FILE)
24
+
25
+ check-models:
26
+ @set -e; \
27
+ tmpfile=$$(mktemp /tmp/logion-models-XXXXXX.py); \
28
+ trap 'rm -f "$$tmpfile" "$$tmpfile.clean"' EXIT; \
29
+ uv run datamodel-codegen \
30
+ --input $(SPEC) \
31
+ --output "$$tmpfile" \
32
+ --output-model-type pydantic_v2.BaseModel \
33
+ --field-constraints \
34
+ --use-schema-description \
35
+ --use-default-kwarg \
36
+ --snake-case-field \
37
+ --target-python-version 3.12 \
38
+ --use-annotated \
39
+ --enum-field-as-literal all \
40
+ --allow-extra-fields; \
41
+ uv run ruff format "$$tmpfile"; \
42
+ sed '1,3d' "$$tmpfile" > "$$tmpfile.clean"; \
43
+ diff "$$tmpfile.clean" <(sed '1,3d' $(GEN_FILE))
44
+
45
+ generate-operations:
46
+ uv run python scripts/generate_operations.py
47
+ uv run ruff format $(OPS_FILE)
48
+ uv run ruff check --fix $(OPS_FILE)
49
+
50
+ check-operations:
51
+ uv run python scripts/generate_operations.py --check
52
+
53
+ generate-client: generate-models generate-operations
54
+
55
+ check-client: check-models check-operations
56
+
57
+ lint:
58
+ uv run ruff check src/ tests/ scripts/
59
+ uv run ruff format --check src/ tests/ scripts/
60
+
61
+ test:
62
+ uv run pytest tests/ -v -m "not integration"
63
+
64
+ typecheck:
65
+ uv run mypy src/ --ignore-missing-imports
@@ -0,0 +1,194 @@
1
+ Metadata-Version: 2.4
2
+ Name: logion-client
3
+ Version: 0.1.0
4
+ Summary: Python client SDK for the Logion API
5
+ Project-URL: Homepage, https://github.com/nicolasmelo1/logion
6
+ Project-URL: Repository, https://github.com/nicolasmelo1/logion
7
+ Project-URL: Issues, https://github.com/nicolasmelo1/logion/issues
8
+ Project-URL: Documentation, https://github.com/nicolasmelo1/logion#readme
9
+ Project-URL: Changelog, https://github.com/nicolasmelo1/logion/releases
10
+ Author: Logion contributors
11
+ License-Expression: MIT
12
+ License-File: LICENSE
13
+ Keywords: agent,logion,marketplace,sdk
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Software Development :: Libraries
21
+ Requires-Python: >=3.12
22
+ Requires-Dist: email-validator<3.0.0,>=2.1
23
+ Requires-Dist: httpx<1.0.0,>=0.27
24
+ Requires-Dist: pydantic<3.0.0,>=2.7
25
+ Description-Content-Type: text/markdown
26
+
27
+ # Logion Client SDK
28
+
29
+ Python SDK for the Logion API.
30
+
31
+ ## Installation
32
+
33
+ ```bash
34
+ uv add logion-client
35
+ ```
36
+
37
+ or
38
+
39
+ ```bash
40
+ pip install logion-client
41
+ ```
42
+
43
+ ## Quick Start
44
+
45
+ ```python
46
+ from logion import LogionClient
47
+
48
+ client = LogionClient(api_key="lgk_...")
49
+
50
+ # Health check
51
+ client.v1.health.check()
52
+
53
+ # Search course listings
54
+ client.v1.listings.search(query="rag")
55
+
56
+ # Get a specific course (UUID required)
57
+ client.v1.courses.get(course_id="550e8400-e29b-41d4-a716-446655440000")
58
+
59
+ # Create a user with an agent
60
+ client.v1.identity.create_user_with_agent(
61
+ email="user@example.com",
62
+ user_password="secure-password",
63
+ agent_name="My Agent",
64
+ )
65
+
66
+ # Top up credits (returns a Stripe Checkout URL)
67
+ client.v1.credits.create_top_up(amount_cents=1000)
68
+
69
+ # Purchase a course using credits
70
+ client.v1.courses.purchase(
71
+ course_id="550e8400-e29b-41d4-a716-446655440000",
72
+ expected_price_cents=500,
73
+ )
74
+ ```
75
+
76
+ ## Configuration
77
+
78
+ The SDK reads ``LOGION_API_KEY`` and ``LOGION_BASE_URL`` from the
79
+ environment by default. Explicit constructor arguments take precedence.
80
+
81
+ | Parameter | Default | Environment variable | Description |
82
+ | --------------- | ------------------------ | -------------------- | -------------------------------------- |
83
+ | `api_key` | `""` (empty) | `LOGION_API_KEY` | API key for authentication |
84
+ | `base_url` | `https://api.logion.sh` | `LOGION_BASE_URL` | API base URL |
85
+ | `timeout` | `30.0` | — | Request timeout in seconds |
86
+ | `max_retries` | `3` | — | Max retry attempts (GET only) |
87
+ | `extra_headers` | `{}` | — | Additional headers per request |
88
+
89
+ ```python
90
+ import os
91
+
92
+ # Using environment variables
93
+ os.environ["LOGION_API_KEY"] = "lgk_..."
94
+ client = LogionClient()
95
+
96
+ # Or passing explicitly
97
+ client = LogionClient(
98
+ api_key="lgk_...",
99
+ base_url="https://api.logion.sh",
100
+ timeout=60.0,
101
+ max_retries=5,
102
+ )
103
+ ```
104
+
105
+ ## Error Handling
106
+
107
+ All errors inherit from `LogionError`. API errors provide structured
108
+ details:
109
+
110
+ - **`LogionError`** — base exception for all SDK errors
111
+ - **`APIError`** — base for errors returned by the API (includes `status_code`, `detail`, `request_id`)
112
+ - **`AuthenticationError`** — 401 responses
113
+ - **`ForbiddenError`** — 403 responses
114
+ - **`NotFoundError`** — 404 responses
115
+ - **`ConflictError`** — 409 responses
116
+ - **`ValidationError`** — 422 responses
117
+ - **`RateLimitError`** — 429 responses
118
+ - **`ClientError`** — other 4xx responses not mapped above
119
+ - **`ServerError`** — 5xx responses
120
+ - **`TransportError`** — network failures (DNS, connection, timeout)
121
+
122
+ ```python
123
+ from logion import LogionClient, AuthenticationError, RateLimitError
124
+
125
+ client = LogionClient(api_key="lgk_...")
126
+
127
+ try:
128
+ client.v1.courses.get(course_id="550e8400-e29b-41d4-a716-446655440000")
129
+ except AuthenticationError as exc:
130
+ print(f"Auth failed: {exc.detail}")
131
+ except RateLimitError as exc:
132
+ print(f"Rate limited: {exc.detail}")
133
+ ```
134
+
135
+ ## Versioned Namespaces
136
+
137
+ The SDK organises endpoints by API version under the `v1` namespace:
138
+
139
+ ```python
140
+ client.v1.health.check()
141
+ client.v1.listings.search(query="rag")
142
+ ```
143
+
144
+ Future API versions will be accessible via `client.v2`, etc.
145
+
146
+ ## Mock Server Development
147
+
148
+ For local development and testing, you can point the SDK at a Prism
149
+ mock server:
150
+
151
+ ```python
152
+ client = LogionClient(
153
+ base_url="http://localhost:4010",
154
+ api_key="lgk_test_mock_key",
155
+ )
156
+ ```
157
+
158
+ Or set the ``LOGION_BASE_URL`` environment variable.
159
+
160
+ ## Code Generation
161
+
162
+ The SDK uses the OpenAPI spec as the source of truth for generated
163
+ internals:
164
+
165
+ - Pydantic request and response models live under
166
+ `src/logion/v1/_types/generated/`.
167
+ - Low-level HTTP operation functions live under
168
+ `src/logion/v1/_generated/`.
169
+ - Public resource classes under `src/logion/v1/_resources/` stay
170
+ handwritten so the SDK remains ergonomic and stable.
171
+
172
+ ```bash
173
+ # Generate models only
174
+ make generate-models
175
+
176
+ # Generate low-level operation functions only
177
+ make generate-operations
178
+
179
+ # Generate all client code derived from the OpenAPI contract
180
+ make generate-client
181
+
182
+ # Check if generated models are up to date
183
+ make check-models
184
+
185
+ # Check if generated operation functions are up to date
186
+ make check-operations
187
+
188
+ # Check all generated client code
189
+ make check-client
190
+ ```
191
+
192
+ ## License
193
+
194
+ See the [root repository LICENSE](../../LICENSE) for details.
@@ -0,0 +1,168 @@
1
+ # Logion Client SDK
2
+
3
+ Python SDK for the Logion API.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ uv add logion-client
9
+ ```
10
+
11
+ or
12
+
13
+ ```bash
14
+ pip install logion-client
15
+ ```
16
+
17
+ ## Quick Start
18
+
19
+ ```python
20
+ from logion import LogionClient
21
+
22
+ client = LogionClient(api_key="lgk_...")
23
+
24
+ # Health check
25
+ client.v1.health.check()
26
+
27
+ # Search course listings
28
+ client.v1.listings.search(query="rag")
29
+
30
+ # Get a specific course (UUID required)
31
+ client.v1.courses.get(course_id="550e8400-e29b-41d4-a716-446655440000")
32
+
33
+ # Create a user with an agent
34
+ client.v1.identity.create_user_with_agent(
35
+ email="user@example.com",
36
+ user_password="secure-password",
37
+ agent_name="My Agent",
38
+ )
39
+
40
+ # Top up credits (returns a Stripe Checkout URL)
41
+ client.v1.credits.create_top_up(amount_cents=1000)
42
+
43
+ # Purchase a course using credits
44
+ client.v1.courses.purchase(
45
+ course_id="550e8400-e29b-41d4-a716-446655440000",
46
+ expected_price_cents=500,
47
+ )
48
+ ```
49
+
50
+ ## Configuration
51
+
52
+ The SDK reads ``LOGION_API_KEY`` and ``LOGION_BASE_URL`` from the
53
+ environment by default. Explicit constructor arguments take precedence.
54
+
55
+ | Parameter | Default | Environment variable | Description |
56
+ | --------------- | ------------------------ | -------------------- | -------------------------------------- |
57
+ | `api_key` | `""` (empty) | `LOGION_API_KEY` | API key for authentication |
58
+ | `base_url` | `https://api.logion.sh` | `LOGION_BASE_URL` | API base URL |
59
+ | `timeout` | `30.0` | — | Request timeout in seconds |
60
+ | `max_retries` | `3` | — | Max retry attempts (GET only) |
61
+ | `extra_headers` | `{}` | — | Additional headers per request |
62
+
63
+ ```python
64
+ import os
65
+
66
+ # Using environment variables
67
+ os.environ["LOGION_API_KEY"] = "lgk_..."
68
+ client = LogionClient()
69
+
70
+ # Or passing explicitly
71
+ client = LogionClient(
72
+ api_key="lgk_...",
73
+ base_url="https://api.logion.sh",
74
+ timeout=60.0,
75
+ max_retries=5,
76
+ )
77
+ ```
78
+
79
+ ## Error Handling
80
+
81
+ All errors inherit from `LogionError`. API errors provide structured
82
+ details:
83
+
84
+ - **`LogionError`** — base exception for all SDK errors
85
+ - **`APIError`** — base for errors returned by the API (includes `status_code`, `detail`, `request_id`)
86
+ - **`AuthenticationError`** — 401 responses
87
+ - **`ForbiddenError`** — 403 responses
88
+ - **`NotFoundError`** — 404 responses
89
+ - **`ConflictError`** — 409 responses
90
+ - **`ValidationError`** — 422 responses
91
+ - **`RateLimitError`** — 429 responses
92
+ - **`ClientError`** — other 4xx responses not mapped above
93
+ - **`ServerError`** — 5xx responses
94
+ - **`TransportError`** — network failures (DNS, connection, timeout)
95
+
96
+ ```python
97
+ from logion import LogionClient, AuthenticationError, RateLimitError
98
+
99
+ client = LogionClient(api_key="lgk_...")
100
+
101
+ try:
102
+ client.v1.courses.get(course_id="550e8400-e29b-41d4-a716-446655440000")
103
+ except AuthenticationError as exc:
104
+ print(f"Auth failed: {exc.detail}")
105
+ except RateLimitError as exc:
106
+ print(f"Rate limited: {exc.detail}")
107
+ ```
108
+
109
+ ## Versioned Namespaces
110
+
111
+ The SDK organises endpoints by API version under the `v1` namespace:
112
+
113
+ ```python
114
+ client.v1.health.check()
115
+ client.v1.listings.search(query="rag")
116
+ ```
117
+
118
+ Future API versions will be accessible via `client.v2`, etc.
119
+
120
+ ## Mock Server Development
121
+
122
+ For local development and testing, you can point the SDK at a Prism
123
+ mock server:
124
+
125
+ ```python
126
+ client = LogionClient(
127
+ base_url="http://localhost:4010",
128
+ api_key="lgk_test_mock_key",
129
+ )
130
+ ```
131
+
132
+ Or set the ``LOGION_BASE_URL`` environment variable.
133
+
134
+ ## Code Generation
135
+
136
+ The SDK uses the OpenAPI spec as the source of truth for generated
137
+ internals:
138
+
139
+ - Pydantic request and response models live under
140
+ `src/logion/v1/_types/generated/`.
141
+ - Low-level HTTP operation functions live under
142
+ `src/logion/v1/_generated/`.
143
+ - Public resource classes under `src/logion/v1/_resources/` stay
144
+ handwritten so the SDK remains ergonomic and stable.
145
+
146
+ ```bash
147
+ # Generate models only
148
+ make generate-models
149
+
150
+ # Generate low-level operation functions only
151
+ make generate-operations
152
+
153
+ # Generate all client code derived from the OpenAPI contract
154
+ make generate-client
155
+
156
+ # Check if generated models are up to date
157
+ make check-models
158
+
159
+ # Check if generated operation functions are up to date
160
+ make check-operations
161
+
162
+ # Check all generated client code
163
+ make check-client
164
+ ```
165
+
166
+ ## License
167
+
168
+ See the [root repository LICENSE](../../LICENSE) for details.