API
Overview
PRISM API for agents is designed for developers and traditional web companies to integrate customizable, state-of-the-art machine learning models into their applications. It enables the creation and deployment of AI agents that interact with the blockchain, automate tasks, analyze data, and make decisions on behalf of users. Key features include agent creation and deployment, scalability and customizability, automated task execution and decision-making capabilities, and the integration of advanced machine-learning models.
Once your agent is deployed to PRISM, you should take note of three values:
agent_id
: The unique identifier for your deployed agentapi_key
: The authentication key required to access your agent's APIagent_url
: The URL endpoint for interacting with your agent
Authentication
Authentication for the PRISM API for agents is done using an API key. You must include this key in your requests X-API-Key
header. For a comprehensive guide on authenticating your requests, check out our authentication page. You'll find detailed instructions and examples to help you get started.
Example usage:
- Python
- TypeScript
import requests
def agent_api(message):
url = "https://api.prism.niv.ac"
payload = {
"input": {
"input": message,
"tools": [
# add more tools here
"airdrop_checker"
]
},
"config": {},
"kwargs": {}
}
headers = {
"Content-Type": "application/json",
"X-API-Key": "YOUR_API_KEY"
}
response = requests.post(url, json=payload, headers=headers)
return response.text
user_message = input("Enter your message: ")
result = agent_api(user_message)
print(result)
import axios from "axios";
async function agentApi(message: string): Promise<string> {
const url = "https://api.prism.niv.ac";
const payload = {
input: {
input: message,
tools: ["airdrop_checker"], // can add more tools here
},
config: {},
kwargs: {},
};
const headers = {
"Content-Type": "application/json",
"X-API-Key": "YOUR_API_KEY",
};
try {
const response = await axios.post(url, payload, { headers });
return response.data;
} catch (error) {
console.error("Error:", error);
throw error;
}
}
// usage
async function main() {
const userMessage = "Your message here";
if (userMessage) {
try {
const result = await agentApi(userMessage);
console.log(result);
} catch (error) {
console.error("Failed to get response:", error);
}
} else {
console.log("No message entered.");
}
}
main();
Rate Limiting
Requests to agents are capped at 10 per 10-second period. This rate limit helps ensure fair usage and maintains the performance of the service for all users. If you require a higher rate limit during the beta period, please contact the PRISM team directly in our Discord.