Skip to main content

Neural LAB Python SDK

PROPRIETARY SOFTWARE - ALL RIGHTS RESERVED

Python SDK for Neural LAB AI Platform APIs.

Proprietary Notice

Copyright (c) 2026 Neural Thinker | AI Engineering LTDA
CNPJ: 62.155.930/0001-71
Author: Anderson Henrique da Silva
Location: Minas Gerais, Brasil

This software is proprietary and confidential.
Unauthorized copying, distribution, or use is strictly prohibited.

Installation

pip install ntlabs

Optional Dependencies

# Full installation with all features
pip install ntlabs[full]

# Specific features
pip install ntlabs[cache]        # Redis caching
pip install ntlabs[email]        # Email templates
pip install ntlabs[export]       # PDF/Excel export
pip install ntlabs[middleware]   # FastAPI middleware
pip install ntlabs[observability] # Sentry + OpenTelemetry

For Local Development

pip install -e /path/to/neural-lab/packages/python-sdk[dev]

Quick Start

from neural_lab import NeuralLabClient

# Initialize client
client = NeuralLabClient(api_key="nl_hipo_xxx")

# Or use environment variable NEURAL_LAB_API_KEY
client = NeuralLabClient()

Available Resources

Chat (LLM)

response = client.chat.complete(
    messages=[
        {"role": "system", "content": "Você é um assistente médico."},
        {"role": "user", "content": "O que é hipertensão?"}
    ],
    model="maritaca-sabia-4",
    max_tokens=1024,
)

Email

client.email.send(
    to=["paciente@email.com"],
    subject="Confirmação de Consulta",
    html="<h1>Sua consulta foi agendada</h1>",
)

Transcription

result = client.transcribe.audio("consulta.mp3", language="pt")
print(result.text)

Government APIs

# CNPJ lookup
empresa = client.gov.cnpj("12.345.678/0001-90")

# CEP lookup
endereco = client.gov.cep("01310-100")

# CPF validation
valido = client.gov.validate_cpf("123.456.789-00")

# Portal da Transparência
contratos = client.gov.transparencia("contratos", params={"uf": "MG"})

Banco do Brasil (OAuth + PIX)

from decimal import Decimal

# OAuth - Get authorization URL
auth = client.bb.get_authorize_url(redirect_uri="https://app.com/callback")
# Redirect user to auth.authorize_url

# OAuth - Exchange code for tokens
tokens = client.bb.exchange_code(code="abc", state="xyz", redirect_uri="...")

# Get user info (CPF verified by bank)
user = client.bb.get_userinfo(tokens.access_token)
print(f"CPF: {user.cpf}, Nome: {user.nome}")

# PIX - Create charge
charge = client.bb.create_pix_charge(
    amount=Decimal("99.90"),
    description="Consulta Médica",
)
print(f"QR Code: {charge.qr_code}")

# PIX - Check status
status = client.bb.get_pix_status(charge.txid)
if status.status == "CONCLUIDA":
    print(f"Pago em: {status.paid_at}")

Medical AI (Hipócrates)

# Transcribe consultation
transcription = client.saude.transcribe(audio_file)

# Generate SOAP note
soap = client.saude.generate_soap(
    transcription=transcription.text,
    paciente={"idade": 45, "sexo": "M"},
)

Notary AI (Mercurius)

# OCR certificate
result = client.cartorio.ocr(image_file, tipo="nascimento")

# Generate deed
minuta = client.cartorio.generate_escritura(dados)

Billing

usage = client.billing.get_usage()
print(f"Total: R$ {usage.total_cost}")

Authentication (OAuth v2 with PKCE)

# Initiate OAuth flow (returns URL for redirect)
oauth = client.auth.initiate_oauth_v2(
    provider="github",  # or "google"
    redirect_uri="https://myapp.com/auth/callback",
    product="hipocrates",
)
# Redirect user to: oauth["authorization_url"]

# After callback, claim the session (frontend receives sid + sig in URL)
session = client.auth.claim_session(
    session_id="sess_xxx",
    signature="hmac_xxx",
)
print(f"Token: {session['access_token']}")
print(f"User: {session['user']['email']}")

# Validate a session
validation = client.auth.validate_session(
    session_id="sess_xxx",
    product="hipocrates",
)
if validation["valid"]:
    print(f"User: {validation['user']['email']}")

# Check SSO (for cross-product auth)
sso = client.auth.check_sso(product="mercurius")
if sso["has_valid_session"]:
    print("User already authenticated via SSO")

# Refresh tokens (with rotation)
new_tokens = client.auth.refresh_v2(
    refresh_token="old_refresh_token",
    session_id="sess_xxx",
)

# Logout (single session)
client.auth.revoke_session(session_id="sess_xxx")

# Global logout (all sessions)
client.auth.revoke_session(revoke_all=True)

SSO Cross-Product Navigation

# Create ticket for navigating to another product
ticket = client.auth.create_sso_ticket(target_product="mercurius")
# Redirect to: https://mercurius.app/auth?sso_ticket={ticket['ticket']}

# On target product: exchange ticket for session
session = client.auth.exchange_sso_ticket(
    ticket="ticket_xxx",
    target_product="mercurius",
)

Environment Variables

Variable Description
NEURAL_LAB_API_KEY API key (nl_hipo_xxx, nl_merc_xxx, nl_poli_xxx)
NEURAL_LAB_API_URL API URL (default: production)

Error Handling

from neural_lab import (
    NeuralLabClient,
    AuthenticationError,
    RateLimitError,
    InsufficientCreditsError,
    APIError,
)

try:
    response = client.chat.complete(messages=[...])
except AuthenticationError:
    print("Invalid API key")
except RateLimitError as e:
    print(f"Rate limited. Retry after {e.retry_after}s")
except InsufficientCreditsError:
    print("Add more credits")
except APIError as e:
    print(f"API error: {e}")

AI Agents

from ntlabs import NTLClient

client = NTLClient(api_key="ntl_xxx")

# List available agents
agents = client.agents.list()
for agent in agents:
    print(f"{agent.name}: {agent.description_pt}")

# Chat with an agent
response = client.agents.chat(
    agent="dedalo",  # dedalo, chiron, themis, hermes, athena
    messages=[{"role": "user", "content": "Olá!"}],
    session_id="session_123",
)
print(response.message)

# Streaming chat
for chunk in client.agents.chat_stream(
    agent="dedalo",
    messages=[{"role": "user", "content": "Conte-me sobre a Neural LAB"}],
):
    if chunk.type == "token":
        print(chunk.content, end="", flush=True)

Available Agents:

Agent Product Description Status
dedalo Neural LAB Sales & Lead Qualification Active
chiron Hipócrates Medical AI Assistant Beta
themis Argos Legal AI Assistant Coming Soon
hermes Mercúrius Notary AI Assistant Coming Soon
athena Pólis Public Health AI Assistant Coming Soon

Publishing to PyPI

Automatic (GitHub Actions)

Create a release with tag sdk-v{version}:

gh release create sdk-v1.4.0 \
  --repo NeuralThinkersLab/neural-lab \
  --title "ntlabs v1.4.0 - Release Title" \
  --notes "Release notes..."

Manual (when GitHub Actions billing is unavailable)

cd packages/python-sdk

# Build
python -m venv venv
./venv/bin/pip install build twine
./venv/bin/python -m build

# Publish (token from ~/.env)
source ~/.env
TWINE_USERNAME=__token__ TWINE_PASSWORD=$PYPI_TOKEN ./venv/bin/twine upload dist/ntlabs-{version}*

License

Proprietary Software

Copyright (c) 2026 Neural Thinker | AI Engineering LTDA

All rights reserved. This software and its documentation are proprietary and confidential. No part of this software may be reproduced, distributed, or transmitted in any form or by any means without the prior written permission of Neural Thinker | AI Engineering LTDA.

For licensing inquiries: contato@ntlabs.dev

Metadata

Release files for ntlabs 2.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ntlabs 2.1.2
File Size Uploaded Provenance Actions
ntlabs-2.1.2.tar.gz 334.9 kB With provenance Details for ntlabs-2.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ntlabs 2.1.2
File Interpreter ABI Platform Actions
ntlabs-2.1.2-py3-none-any.whl Python 3 none any Details for ntlabs-2.1.2-py3-none-any.whl

Total release size: 562.4 kB

Release files / ntlabs-2.1.2.tar.gz

Download URL ntlabs-2.1.2.tar.gz
Size 334.9 kB
Tags Source
SHA-256 checksum
How to use checksums
ff16046aae0640c6551e800a0a1d881a205da1fc56ebbac1e6b03c183e9e3b30
BLAKE2b-256 checksum
How to use checksums
566e47c2a66a58948a11f4d97a42379b9fd246e93fda01522a2c7f4339b0bfcb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log

Release files / ntlabs-2.1.2-py3-none-any.whl

Download URL ntlabs-2.1.2-py3-none-any.whl
Size 227.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7eeba66838e25cdd7271b6947890cde6cc777b14331c761a7511fc00c481164b
BLAKE2b-256 checksum
How to use checksums
973dce0afa93a92c352872d76f7211c256318db9d02e3a78b151fc31b268fb38
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log

Security for ntlabs 2.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ntlabs-2.1.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page