Python SDK
The official Nascentist Python SDK provides convenient access to the REST API from any Python 3.9+ application.
Installation
1 lines
pip install nascentistQuick Start
19 lines
from nascentist import Nascentist
client = Nascentist(api_key="nsc_live_YOUR_KEY")
# Simple completion
response = client.complete(
prompt="def bubble_sort(arr):",
max_tokens=200
)
print(response.choices[0].text)
# Agent fix
fix = client.agent.fix(
code="def add(a, b): return a - b",
language="python",
max_iterations=5
)
if fix.status == "fixed":
print(fix.fixed_code)Project Memory
Store your tech stack and conventions once. They're automatically injected into every request.
21 lines
# Bulk setup your project memory
client.memory.bulk_create([
{
"key": "tech_stack",
"value": "Python 3.11, FastAPI, PostgreSQL",
"type": "stack"
},
{
"key": "formatting",
"value": "black, isort, flake8",
"type": "convention"
}
])
# All future requests automatically include this
response = client.complete(prompt="optimize this query")
# List memories
memories = client.memory.list()
for m in memories.memories:
print(f"{m.key}: {m.value}")Async Jobs
9 lines
# Automatically poll long jobs via Jobs API
job = client.jobs.wait(
"job_abc123",
poll_interval=2.0,
timeout=300.0,
on_progress=lambda j: print(f"Job is {j.status}")
)
if job.status == "completed":
print(job.result)Streaming
2 lines
for chunk in client.complete("Explain Python decorators", stream=True):
print(chunk, end="", flush=True)Async Client
12 lines
import asyncio
from nascentist import AsyncNascentist
async def main():
async with AsyncNascentist(api_key="nsc_live_YOUR_KEY") as client:
result = await client.agent.review(
code="x = 1",
language="python"
)
print(f"Score: {result.score}/100")
asyncio.run(main())Error Handling
14 lines
from nascentist.exceptions import (
NascentistError,
RateLimitError,
AuthenticationError
)
try:
response = client.complete(prompt="...")
except RateLimitError as e:
print(f"Rate limited. Retry after {e.retry_after}s")
except AuthenticationError:
print("Invalid API key")
except NascentistError as e:
print(f"API SDK error: {e.message}")