0.1.1 • Published 1 year ago
@hiero-ai/protocol-sdk v0.1.1
Hiero Protocol SDK
TypeScript/JavaScript SDK for interacting with the Hiero Protocol API.
Installation
yarn add @hiero/protocol-sdkUsage
import { HieroClient } from "@hiero/protocol-sdk";
// Initialize the client
const client = new HieroClient({
baseUrl: "https://api.hiero.xyz",
privateKey: "0x...", // Your wallet private key
});
// Example: Create an agent
const createAgent = async () => {
const response = await client.createAgent({
name: "My Agent",
description: "A helpful AI agent",
configuration: {
model: "gpt-4",
prompt: "You are a helpful assistant...",
},
});
if (response.error) {
console.error("Failed to create agent:", response.error);
return;
}
console.log("Agent created:", response.data);
};
// Example: Use agent inference
const useAgent = async (agentId: string) => {
const response = await client.inferAgent(
agentId,
"Hello, can you help me?",
"thread_123"
);
if (response.error) {
console.error("Inference failed:", response.error);
return;
}
console.log("Agent response:", response.data.result);
console.log("Usage metrics:", response.data.usage);
console.log("Metadata:", response.data.metadata);
};API Reference
Agents
createAgent(agent: CreateAgentT): Create a new agentgetAgent(agentId: string): Get agent detailsupdateAgent(agentId: string, update: Partial<CreateAgentT>): Update agentdeleteAgent(agentId: string): Delete agentlistMyAgents(params?: PaginationParams): List your agentsgenerateAgentConfig(specification: string): Generate agent configurationinferAgent(agentId: string, input: string, threadId: string): Use agent inference
Services
createService(service: CreateServiceT): Create a new servicegetService(serviceId: string): Get service detailsupdateService(serviceId: string, update: Partial<CreateServiceT>): Update servicesearchServices(params?: ServiceSearchParams): Search available servicesauthorizeService(serviceId: string, authorization: Authorization): Authorize service usage
Error Handling
All methods return an APIResponse<T> type which includes either a data or an error property:
interface APIResponse<T> {
data?: T;
error?: {
error: string;
details?: unknown;
};
}