Python SDK for Neonloops — run AI workflows via API
Project description
neonloops
Python SDK for Neonloops — run AI workflows via API.
Installation
pip install neonloops
Quick Start
Async (recommended)
import asyncio
from neonloops import Runner, RunInput
runner = Runner(
api_key="nl_sk_...",
# base_url="https://neonloops.com", # optional, defaults to https://neonloops.com
)
async def main():
result = await runner.run(
workflow_id="wf_abc123",
input=[RunInput(role="user", content="Hello, run my workflow!")],
)
print(result.output)
print(result.metadata.tokens)
asyncio.run(main())
Sync
from neonloops import Runner, RunInput
runner = Runner(
api_key="nl_sk_...",
# base_url="https://neonloops.com", # optional, defaults to https://neonloops.com
)
result = runner.run_sync(
workflow_id="wf_abc123",
input=[RunInput(role="user", content="Hello!")],
)
print(result.output)
Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key |
str |
— | Required. Your Neonloops API key (nl_sk_...) |
base_url |
str |
https://neonloops.com |
Base URL of your Neonloops instance |
project_id |
str |
None |
Default project ID to scope requests |
timeout |
float |
120.0 |
Request timeout in seconds |
max_retries |
int |
2 |
Max retries for 429/5xx errors |
Multi-Turn Conversations
# Create a session
session = await runner.create_session("wf_abc123")
# First turn
r1 = await runner.run(
workflow_id="wf_abc123",
input=[RunInput(role="user", content="Hello!")],
session_id=session.id,
)
# Follow-up — server loads previous messages automatically
r2 = await runner.run(
workflow_id="wf_abc123",
input=[RunInput(role="user", content="Tell me more")],
session_id=session.id,
)
# Retrieve message history
messages = await runner.get_session_messages(session.id)
Error Handling
from neonloops import Runner, NeonloopsApiError, NeonloopsTimeoutError
try:
result = await runner.run(
workflow_id="wf_abc123",
input=[RunInput(role="user", content="Hello")],
)
except NeonloopsApiError as e:
print(f"API error {e.status}: {e}")
except NeonloopsTimeoutError as e:
print(f"Timeout: {e}")
License
MIT
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
neonloops-0.4.0.tar.gz
(21.2 kB
view details)
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
neonloops-0.4.0-py3-none-any.whl
(10.9 kB
view details)
File details
Details for the file neonloops-0.4.0.tar.gz.
File metadata
- Download URL: neonloops-0.4.0.tar.gz
- Upload date:
- Size: 21.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2584a4cbdd6ba68a1d7607503e740418a10b4ae30a40fd10a2cd49d9687b5adc
|
|
| MD5 |
02bfb909c3cdac7740f19c7b651d53dc
|
|
| BLAKE2b-256 |
46ba868290df8f67ece9ef3f34467b0f88f3c381e087e06566ec6b415ac2b8ac
|
File details
Details for the file neonloops-0.4.0-py3-none-any.whl.
File metadata
- Download URL: neonloops-0.4.0-py3-none-any.whl
- Upload date:
- Size: 10.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a97899743abbaccbf4e2b57dbb99de2c63354da0d495cdf7c16b0d8791c696c
|
|
| MD5 |
b13b7183eac2ddbf68cc9df0700f7d7a
|
|
| BLAKE2b-256 |
aa3b139085ad488322d2c697365a8ea87fd9b8f89b542aa70bfd11cccf66953a
|