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.5.1.tar.gz
(22.3 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.5.1-py3-none-any.whl
(11.2 kB
view details)
File details
Details for the file neonloops-0.5.1.tar.gz.
File metadata
- Download URL: neonloops-0.5.1.tar.gz
- Upload date:
- Size: 22.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0760c448a4ca87ff50f2e4932f3b6bc5d19c5cf8fcd02180784dd1c7db27c1b0
|
|
| MD5 |
ea212f9b134dfec17571e13cd9ea72ef
|
|
| BLAKE2b-256 |
7bcd0dc576574a3dd84ba74871702225a4d275f799e6026533e4de7ce5e6675b
|
File details
Details for the file neonloops-0.5.1-py3-none-any.whl.
File metadata
- Download URL: neonloops-0.5.1-py3-none-any.whl
- Upload date:
- Size: 11.2 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 |
f2062e49659dd216d2788190fb59e502433b6393a1c1b7c17ea1d2bc1b33ba30
|
|
| MD5 |
8d3e04efd91fce3c17315c4a70fa3ae9
|
|
| BLAKE2b-256 |
d4477a30abf76abbb93f5f3402681b64f4713c05dd3fa34cecfc95ae23a9f9ce
|