API Reference
The PaiTIENT Secure Model Service provides comprehensive SDKs for both Python and JavaScript (Node.js), as well as a REST API for direct integration.
SDK Overview
Our SDKs are designed to provide a simple, consistent interface for interacting with the PaiTIENT Secure Model Service. They handle authentication, error handling, and provide a convenient abstraction over the underlying REST API.
Available SDKs
- Python SDK: For data scientists, ML engineers, and backend developers
- JavaScript SDK: For web developers and Node.js applications
Common Concepts
All SDKs share common concepts and structures:
Authentication
All requests to the PaiTIENT Secure Model Service require authentication using an API key and client ID. These credentials should be kept secure and never exposed publicly.
# Python example
from paitient_secure_model import SecureModelClient
client = SecureModelClient(
api_key="your-api-key",
client_id="your-client-id"
)// JavaScript example
const { SecureModelClient } = require('paitient-secure-model');
const client = new SecureModelClient({
apiKey: "your-api-key",
clientId: "your-client-id"
});Model Deployments
A deployment represents a specific model that has been deployed to your secure environment. Deployments can be created, updated, and deleted as needed.
# Python example - Create a deployment
deployment = client.deploy_model(
model_name="ZimaBlueAI/HuatuoGPT-o1-8B",
deployment_name="my-secure-model",
use_gpu=True
)
# Get deployment status
status = client.get_deployment_status(deployment_id=deployment.id)// JavaScript example - Create a deployment
const deployment = await client.deploy({
modelName: "ZimaBlueAI/HuatuoGPT-o1-8B",
deploymentName: "my-secure-model",
useGpu: true
});
// Get deployment status
const status = await client.getDeploymentStatus(deployment.id);Text Generation
Once a model is deployed, you can use it to generate text using a prompt.
# Python example
result = client.generate(
deployment_id="deployment-123",
prompt="Explain the importance of HIPAA compliance in healthcare AI",
max_tokens=500,
temperature=0.7
)
print(result.text)// JavaScript example
const result = await client.generate({
deploymentId: "deployment-123",
prompt: "Explain the importance of HIPAA compliance in healthcare AI",
maxTokens: 500,
temperature: 0.7
});
console.log(result.text);Subscription Management
You can check your subscription status, including usage limits and current usage.
# Python example
subscription = client.get_subscription()
print(f"Tier: {subscription.tier}")
print(f"Usage: {subscription.current_usage}/{subscription.usage_limit}")// JavaScript example
const subscription = await client.getSubscription();
console.log(`Tier: ${subscription.tier}`);
console.log(`Usage: ${subscription.currentUsage}/${subscription.usageLimit}`);Error Handling
All SDKs use a consistent error handling approach. Errors are categorized as:
- Authentication Errors: Invalid API key or client ID
- Validation Errors: Invalid input parameters
- Resource Errors: Problems with the requested resource
- Rate Limit Errors: Too many requests
- Service Errors: Internal server errors
Example error handling:
# Python example
from paitient_secure_model import SecureModelClient, AuthenticationError, ValidationError
try:
client = SecureModelClient(api_key="invalid-key", client_id="invalid-id")
client.deploy_model(model_name="ZimaBlueAI/HuatuoGPT-o1-8B")
except AuthenticationError as e:
print(f"Authentication error: {e}")
except ValidationError as e:
print(f"Validation error: {e}")
except Exception as e:
print(f"Other error: {e}")// JavaScript example
const { SecureModelClient, AuthenticationError, ValidationError } = require('paitient-secure-model');
try {
const client = new SecureModelClient({
apiKey: "invalid-key",
clientId: "invalid-id"
});
await client.deploy({ modelName: "ZimaBlueAI/HuatuoGPT-o1-8B" });
} catch (error) {
if (error instanceof AuthenticationError) {
console.error("Authentication error:", error.message);
} else if (error instanceof ValidationError) {
console.error("Validation error:", error.message);
} else {
console.error("Other error:", error.message);
}
}REST API
For direct integration without using our SDKs, you can use our REST API. All endpoints require authentication using an API key and client ID passed in the request headers.
Authorization: Bearer your-api-key
X-Client-ID: your-client-idThe base URL for all API requests is:
https://api.paitient.ai/v1See the REST API documentation for detailed information on all available endpoints.