Python client SDK for the Logion API
Project description
Logion Client SDK
Python SDK for the Logion API.
Installation
uv add logion-client
or
pip install logion-client
Quick Start
from logion import LogionClient
client = LogionClient(api_key="lgk_...")
# Health check
client.v1.health.check()
# Search course listings
client.v1.listings.search(query="rag")
# Get a specific course (UUID required)
client.v1.courses.get(course_id="550e8400-e29b-41d4-a716-446655440000")
# Create a user with an agent
client.v1.identity.create_user_with_agent(
email="user@example.com",
user_password="secure-password",
agent_name="My Agent",
)
# Top up credits (returns a Stripe Checkout URL)
client.v1.credits.create_top_up(amount_cents=1000)
# Purchase a course using credits
client.v1.courses.purchase(
course_id="550e8400-e29b-41d4-a716-446655440000",
expected_price_cents=500,
)
Configuration
The SDK reads LOGION_API_KEY and LOGION_BASE_URL from the
environment by default. Explicit constructor arguments take precedence.
| Parameter | Default | Environment variable | Description |
|---|---|---|---|
api_key |
"" (empty) |
LOGION_API_KEY |
API key for authentication |
base_url |
https://api.logion.sh |
LOGION_BASE_URL |
API base URL |
timeout |
30.0 |
— | Request timeout in seconds |
max_retries |
3 |
— | Max retry attempts (GET only) |
extra_headers |
{} |
— | Additional headers per request |
import os
# Using environment variables
os.environ["LOGION_API_KEY"] = "lgk_..."
client = LogionClient()
# Or passing explicitly
client = LogionClient(
api_key="lgk_...",
base_url="https://api.logion.sh",
timeout=60.0,
max_retries=5,
)
Error Handling
All errors inherit from LogionError. API errors provide structured
details:
LogionError— base exception for all SDK errorsAPIError— base for errors returned by the API (includesstatus_code,detail,request_id)AuthenticationError— 401 responsesForbiddenError— 403 responsesNotFoundError— 404 responsesConflictError— 409 responsesValidationError— 422 responsesRateLimitError— 429 responsesClientError— other 4xx responses not mapped aboveServerError— 5xx responsesTransportError— network failures (DNS, connection, timeout)
from logion import LogionClient, AuthenticationError, RateLimitError
client = LogionClient(api_key="lgk_...")
try:
client.v1.courses.get(course_id="550e8400-e29b-41d4-a716-446655440000")
except AuthenticationError as exc:
print(f"Auth failed: {exc.detail}")
except RateLimitError as exc:
print(f"Rate limited: {exc.detail}")
Versioned Namespaces
The SDK organises endpoints by API version under the v1 namespace:
client.v1.health.check()
client.v1.listings.search(query="rag")
Future API versions will be accessible via client.v2, etc.
Mock Server Development
For local development and testing, you can point the SDK at a Prism mock server:
client = LogionClient(
base_url="http://localhost:4010",
api_key="lgk_test_mock_key",
)
Or set the LOGION_BASE_URL environment variable.
Code Generation
The SDK uses the OpenAPI spec as the source of truth for generated internals:
- Pydantic request and response models live under
src/logion/v1/_types/generated/. - Low-level HTTP operation functions live under
src/logion/v1/_generated/. - Public resource classes under
src/logion/v1/_resources/stay handwritten so the SDK remains ergonomic and stable.
# Generate models only
make generate-models
# Generate low-level operation functions only
make generate-operations
# Generate all client code derived from the OpenAPI contract
make generate-client
# Check if generated models are up to date
make check-models
# Check if generated operation functions are up to date
make check-operations
# Check all generated client code
make check-client
License
See the root repository LICENSE for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file logion_client-0.1.11.tar.gz.
File metadata
- Download URL: logion_client-0.1.11.tar.gz
- Upload date:
- Size: 46.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4937afb691d202b2889f4c409e699cd9034de266e1b901acb41ea3e065e98bc1
|
|
| MD5 |
bc1f059b1ed2694f07d01751d933a872
|
|
| BLAKE2b-256 |
2c1502be96e309af1daf4a77eafb36e85efec0e3712fcf94f91939059507e622
|
Provenance
The following attestation bundles were made for logion_client-0.1.11.tar.gz:
Publisher:
release-client.yml on nicolasmelo1/logion
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
logion_client-0.1.11.tar.gz -
Subject digest:
4937afb691d202b2889f4c409e699cd9034de266e1b901acb41ea3e065e98bc1 - Sigstore transparency entry: 2043762454
- Sigstore integration time:
-
Permalink:
nicolasmelo1/logion@c5719cdee78cd3969af0f7f9d1f03b28af66cc9e -
Branch / Tag:
refs/tags/logion-client-v0.1.11 - Owner: https://github.com/nicolasmelo1
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-client.yml@c5719cdee78cd3969af0f7f9d1f03b28af66cc9e -
Trigger Event:
push
-
Statement type:
File details
Details for the file logion_client-0.1.11-py3-none-any.whl.
File metadata
- Download URL: logion_client-0.1.11-py3-none-any.whl
- Upload date:
- Size: 43.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e03b5f713cc1db10e353294edf2d89132fbd36a3ba0d04dd64b7724d8d7be7d
|
|
| MD5 |
d7021e199e151a56b0d775da35ca34ad
|
|
| BLAKE2b-256 |
805d77054ca195c699550980024d950f67787a2f5d1794a4e67fdebd3660154a
|
Provenance
The following attestation bundles were made for logion_client-0.1.11-py3-none-any.whl:
Publisher:
release-client.yml on nicolasmelo1/logion
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
logion_client-0.1.11-py3-none-any.whl -
Subject digest:
6e03b5f713cc1db10e353294edf2d89132fbd36a3ba0d04dd64b7724d8d7be7d - Sigstore transparency entry: 2043762526
- Sigstore integration time:
-
Permalink:
nicolasmelo1/logion@c5719cdee78cd3969af0f7f9d1f03b28af66cc9e -
Branch / Tag:
refs/tags/logion-client-v0.1.11 - Owner: https://github.com/nicolasmelo1
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-client.yml@c5719cdee78cd3969af0f7f9d1f03b28af66cc9e -
Trigger Event:
push
-
Statement type: