Skip to main content

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 errors
  • APIError — base for errors returned by the API (includes status_code, detail, request_id)
  • AuthenticationError — 401 responses
  • ForbiddenError — 403 responses
  • NotFoundError — 404 responses
  • ConflictError — 409 responses
  • ValidationError — 422 responses
  • RateLimitError — 429 responses
  • ClientError — other 4xx responses not mapped above
  • ServerError — 5xx responses
  • TransportError — 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

logion_client-0.1.2.tar.gz (46.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

logion_client-0.1.2-py3-none-any.whl (43.2 kB view details)

Uploaded Python 3

File details

Details for the file logion_client-0.1.2.tar.gz.

File metadata

  • Download URL: logion_client-0.1.2.tar.gz
  • Upload date:
  • Size: 46.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for logion_client-0.1.2.tar.gz
Algorithm Hash digest
SHA256 a4dc97f71613a735f9e9c3ddd0eab215d000ece2ac0de2309a28e7c0cce3d6fe
MD5 d6e477f4f1b7c7631b1fa96224277aa7
BLAKE2b-256 684baac6971e77eb3eda4ac2c4ca6cb9bb597325bfa1db8a1eaa22cafa439d75

See more details on using hashes here.

Provenance

The following attestation bundles were made for logion_client-0.1.2.tar.gz:

Publisher: release-client.yml on nicolasmelo1/logion

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file logion_client-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: logion_client-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 43.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for logion_client-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f6ed169560efba20d8ccc83e6da4bf7eb12d80832b805cd08395f3f20ffa35da
MD5 b2af7cd64f776d7e9dbc4015e31a6e53
BLAKE2b-256 d1eb75bd597ab60076f26fbd086223bb26cdf2e394b3da275cafd19c84b2c193

See more details on using hashes here.

Provenance

The following attestation bundles were made for logion_client-0.1.2-py3-none-any.whl:

Publisher: release-client.yml on nicolasmelo1/logion

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page