SDKs
Python SDK
NeuralGate's zero-dependency Python client. No pip install required — works with Python 3.7+ standard library only.
Download
curl -o neuralgate.py https://api.computeshare.servequake.com/hosters/client.py
Quickstart
from neuralgate import NeuralGate
ng = NeuralGate(
api_key="ngk_your_key",
base_url="https://api.computeshare.servequake.com"
)
# Chat
response = ng.chat("What is the capital of France?")
print(response.text)
# → "The capital of France is Paris."
print(f"Source: {response.source}, Tokens: {response.total_tokens}")
NeuralGate class
NeuralGate(
api_key: str, # Required: your API key
base_url: str = "https://api.computeshare.servequake.com",
timeout: int = 120 # Request timeout in seconds
)
Methods
chat(text, model, max_tokens) → ChatResponse
response = ng.chat(
text="Explain neural networks",
model="auto", # optional, default: "auto"
max_tokens=500 # optional
)
# Response fields:
response.source # "local" | "hoster" | "cloud" | "error"
response.text # The model's response
response.model # Model that served the request
response.input_tokens # Tokens in your prompt
response.output_tokens # Tokens in the response
response.total_tokens # input + output
response.reason # Why it was routed here (if escalated)
models() → list[dict]
models = ng.models()
for m in models:
print(m["id"], m["owned_by"])
usage() → UsageStats
stats = ng.usage()
print(f"Balance: ${stats.credit_balance_usd:.4f}")
print(f"Requests today: {stats.total_requests}")
print(f"Total tokens: {stats.total_input_tokens + stats.total_output_tokens}")
health() → bool
if ng.health():
print("NeuralGate is up")
CLI usage
NEURALGATE_API_KEY=ngk_your_key python neuralgate.py "What year did WW2 end?"
# → [LOCAL] 1945.
# Tokens: 8 in / 4 out
Error handling
from neuralgate import NeuralGate, NeuralGateError
ng = NeuralGate(api_key="ngk_your_key")
try:
response = ng.chat("Hello")
except NeuralGateError as e:
print(f"HTTP {e.status_code}: {e.detail}")