Welcome to the haiblock documentation!
This Getting Started section will help you create your first haiblock and learn the core features you'll use in every project.
haiblock is a platform that optimizes and hosts content for AI model ingestion, enabling companies to improve their visibility when users interact with AI chatbots like OpenAI, Perplexity, and Anthropic.
Content Upload & Management: Upload and manage content for AI optimization
Content Transformation: Transform content specifically for AI model consumption
AI Model Integration: Submit content to major AI providers (Amazon Bedrock)
Analytics & Monitoring: Track performance and cost optimization
Authentication: Secure API access with AWS Cognito integration
On the computer terminal:
from haiblock import HaiBlockClient
# Initialize client
client = HaiBlockClient(
api_url="https://api.haiblock.com",
auth_token="your-auth-token"
)
# Upload content
content = client.upload_file("company-info.txt")
# Transform content for AI consumption
transformed = client.transform_content(content.id)
# Submit to AI providers
submission = client.submit_to_model(content.id, "bedrock")
# Get analytics
analytics = client.get_analytics()
import { HaiBlockClient } from 'haiblock';
// Initialize client
const client = new HaiBlockClient({
apiUrl: "https://api.haiblock.com",
authToken: "your-auth-token"
});
async function main() {
try {
// Upload content
const content = await client.uploadFile("company-info.txt");
// Transform content for AI consumption
const transformed = await client.transformContent(content.id);
// Submit to AI providers
const submission = await client.submitToModel(content.id, "bedrock");
// Get analytics
const analytics = await client.getAnalytics();
console.log("Process completed successfully");
} catch (error) {
console.error("Error:", error);
}
}
// Run the main function
main();
package main
import (
"fmt"
"log"
)
// HaiBlockClient represents the client for interacting with the HaiBlock API
type HaiBlockClient struct {
APIURL string
AuthToken string
}
// Content represents uploaded content metadata
type Content struct {
ID string
}
// Submission represents a model submission result
type Submission struct {
ID string
Status string
}
// Analytics represents analytics data
type Analytics struct {
TotalUploads int
TotalProcessed int
SuccessRate float64
}
// NewHaiBlockClient creates a new HaiBlock client
func NewHaiBlockClient(apiURL, authToken string) *HaiBlockClient {
return &HaiBlockClient{
APIURL: apiURL,
AuthToken: authToken,
}
}
// UploadFile uploads a file to the HaiBlock service
func (c *HaiBlockClient) UploadFile(filename string) (*Content, error) {
// In a real implementation, this would make an HTTP request
fmt.Printf("Uploading file: %s\n", filename)
return &Content{ID: "content-12345"}, nil
}
// TransformContent transforms content for AI consumption
func (c *HaiBlockClient) TransformContent(contentID string) (*Content, error) {
// In a real implementation, this would make an HTTP request
fmt.Printf("Transforming content: %s\n", contentID)
return &Content{ID: contentID}, nil
}
// SubmitToModel submits content to an AI model
func (c *HaiBlockClient) SubmitToModel(contentID, model string) (*Submission, error) {
// In a real implementation, this would make an HTTP request
fmt.Printf("Submitting content %s to model: %s\n", contentID, model)
return &Submission{
ID: "submission-67890",
Status: "pending",
}, nil
}
// GetAnalytics retrieves analytics data
func (c *HaiBlockClient) GetAnalytics() (*Analytics, error) {
// In a real implementation, this would make an HTTP request
return &Analytics{
TotalUploads: 42,
TotalProcessed: 38,
SuccessRate: 0.90,
}, nil
}
func main() {
// Initialize client
client := NewHaiBlockClient(
"https://api.haiblock.com",
"your-auth-token",
)
// Upload content
content, err := client.UploadFile("company-info.txt")
if err != nil {
log.Fatalf("Failed to upload file: %v", err)
}
// Transform content for AI consumption
transformed, err := client.TransformContent(content.ID)
if err != nil {
log.Fatalf("Failed to transform content: %v", err)
}
// Submit to AI providers
submission, err := client.SubmitToModel(transformed.ID, "bedrock")
if err != nil {
log.Fatalf("Failed to submit to model: %v", err)
}
// Get analytics
analytics, err := client.GetAnalytics()
if err != nil {
log.Fatalf("Failed to get analytics: %v", err)
}
// Print results
fmt.Printf("\n--- Results ---\n")
fmt.Printf("Content ID: %s\n", content.ID)
fmt.Printf("Submission ID: %s\n", submission.ID)
fmt.Printf("Submission Status: %s\n", submission.Status)
fmt.Printf("Analytics - Total Uploads: %d\n", analytics.TotalUploads)
fmt.Printf("Analytics - Total Processed: %d\n", analytics.TotalProcessed)
fmt.Printf("Analytics - Success Rate: %.2f%%\n", analytics.SuccessRate*100)
}