Integration Guide
AIPersona can be accessed through the dashboard UI or integrated into your applications via HTTP API calls.
Dashboard
Full-featured web interface with no setup required
HTTP API
Direct HTTP calls work with any language
tRPC Client
Type-safe integration for Next.js apps
Dashboard (No Setup Required)
The easiest way to use AIPersona is through the web dashboard. Simply sign in and start creating personas.
Getting Started with the Dashboard
- Sign up or sign in to your account
- Create or join an organization
- Navigate to Settings → LLM Configuration to add your LLM provider API keys
- Go to Personas to create your first AI persona
- Use the Chat section to test your personas
HTTP API Integration
For external integrations, AIPersona provides a tRPC-based HTTP API. You can call it from any programming language using standard HTTP requests.
API Base URL
https://aipersona.dsethiopia.org/api/trpc/[procedure]
# For mutations (POST requests):
https://aipersona.dsethiopia.org/api/trpc/persona.create
https://aipersona.dsethiopia.org/api/trpc/chat.sendMessage
# For queries (GET requests):
https://aipersona.dsethiopia.org/api/trpc/persona.list?input={}Required Headers
Include these headers with every API request:
Content-Type: application/json
X-API-Key: your-api-key-here
X-Organization-ID: your-organization-idRequest Body Format
tRPC expects the request body wrapped in a json object:
{
"json": {
"name": "My Persona",
"description": "A helpful assistant",
"systemPrompt": "You are a helpful assistant...",
"model": "gpt-4o",
"llmProvider": "OPENAI"
}
}JavaScript/TypeScript Integration
// Helper function for AIPersona API calls
async function callAIPersona(procedure, data) {
const response = await fetch(`https://aipersona.dsethiopia.org/api/trpc/${procedure}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': process.env.AIPERSONA_API_KEY,
'X-Organization-ID': process.env.AIPERSONA_ORG_ID,
},
body: JSON.stringify({ json: data })
});
const result = await response.json();
if (result.error) throw new Error(result.error.message);
return result.result.data;
}
// Create a persona
const persona = await callAIPersona('persona.create', {
name: 'Customer Support Bot',
description: 'Handles customer inquiries',
systemPrompt: 'You are a helpful customer support agent...',
model: 'gpt-4o',
llmProvider: 'OPENAI',
temperature: 0.7,
maxTokens: 2000
});
// Create a chat session
const session = await callAIPersona('chat.createSession', {
personaId: persona.id,
title: 'Customer Inquiry',
platform: 'API'
});
// Send a message
const message = await callAIPersona('chat.sendMessage', {
chatSessionId: session.id,
content: 'Hello! I need help with my order.',
role: 'USER'
});
console.log('AI Response:', message.content);Python Integration
import os
import requests
class AIPersonaClient:
def __init__(self, api_key=None, org_id=None, base_url=None):
self.api_key = api_key or os.environ.get('AIPERSONA_API_KEY')
self.org_id = org_id or os.environ.get('AIPERSONA_ORG_ID')
self.base_url = base_url or 'https://aipersona.dsethiopia.org/api/trpc'
def _call(self, procedure, data):
response = requests.post(
f'{self.base_url}/{procedure}',
headers={
'Content-Type': 'application/json',
'X-API-Key': self.api_key,
'X-Organization-ID': self.org_id,
},
json={'json': data}
)
result = response.json()
if 'error' in result:
raise Exception(result['error']['message'])
return result['result']['data']
def create_persona(self, **kwargs):
return self._call('persona.create', kwargs)
def create_session(self, persona_id, title='', platform='API'):
return self._call('chat.createSession', {
'personaId': persona_id,
'title': title,
'platform': platform
})
def send_message(self, session_id, content, role='USER'):
return self._call('chat.sendMessage', {
'chatSessionId': session_id,
'content': content,
'role': role
})
# Usage
client = AIPersonaClient()
persona = client.create_persona(
name='Support Bot',
description='Handles support inquiries',
systemPrompt='You are a helpful support agent...',
model='gpt-4o',
llmProvider='OPENAI'
)
session = client.create_session(persona['id'], 'Support Request')
response = client.send_message(session['id'], 'Hello, I need help!')
print('AI Response:', response['content'])tRPC Client (Next.js Apps)
If you're building a Next.js application and want type-safe API access, you can set up a tRPC client that connects to the AIPersona API.
1. Install Dependencies
npm install @trpc/client @trpc/react-query @tanstack/react-query superjson2. Create tRPC Client
// lib/trpc.ts
import { createTRPCProxyClient, httpBatchLink } from '@trpc/client';
import superjson from 'superjson';
// Import the AppRouter type from AIPersona if available,
// or use 'any' for untyped access
type AppRouter = any;
export const trpc = createTRPCProxyClient<AppRouter>({
transformer: superjson,
links: [
httpBatchLink({
url: 'https://your-aipersona-domain.com/api/trpc',
headers() {
return {
'X-API-Key': process.env.NEXT_PUBLIC_AIPERSONA_API_KEY!,
'X-Organization-ID': process.env.NEXT_PUBLIC_AIPERSONA_ORG_ID!,
};
},
}),
],
});3. Use in Your Application
// In your component or API route
const personas = await trpc.persona.list.query();
const newPersona = await trpc.persona.create.mutate({
name: 'My Assistant',
description: 'A helpful assistant',
systemPrompt: 'You are helpful...',
model: 'gpt-4o',
llmProvider: 'OPENAI'
});
const session = await trpc.chat.createSession.mutate({
personaId: newPersona.id,
title: 'New Chat'
});
const response = await trpc.chat.sendMessage.mutate({
chatSessionId: session.id,
content: 'Hello!',
role: 'USER'
});cURL Examples
Test the API directly with cURL commands. These are great for debugging and quick scripts.
List All Personas
curl -X GET "https://aipersona.dsethiopia.org/api/trpc/persona.list?input=%7B%7D" \
-H "X-API-Key: your-api-key" \
-H "X-Organization-ID: your-org-id"Create a Persona
curl -X POST "https://aipersona.dsethiopia.org/api/trpc/persona.create" \
-H "Content-Type: application/json" \
-H "X-API-Key: your-api-key" \
-H "X-Organization-ID: your-org-id" \
-d '{
"json": {
"name": "Test Persona",
"description": "A test AI persona",
"systemPrompt": "You are a helpful test assistant.",
"model": "gpt-4o",
"llmProvider": "OPENAI",
"temperature": 0.7,
"maxTokens": 2000
}
}'Create a Chat Session
curl -X POST "https://aipersona.dsethiopia.org/api/trpc/chat.createSession" \
-H "Content-Type: application/json" \
-H "X-API-Key: your-api-key" \
-H "X-Organization-ID: your-org-id" \
-d '{
"json": {
"personaId": "clx1abc123xyz",
"title": "Test Chat",
"platform": "API"
}
}'Send a Message
curl -X POST "https://aipersona.dsethiopia.org/api/trpc/chat.sendMessage" \
-H "Content-Type: application/json" \
-H "X-API-Key: your-api-key" \
-H "X-Organization-ID: your-org-id" \
-d '{
"json": {
"chatSessionId": "session_xyz789",
"content": "Hello! Can you help me?",
"role": "USER"
}
}'Verify Connection
Test your setup with a simple API call to ensure everything is configured correctly.
# Test connection by listing personas
curl -X GET "https://aipersona.dsethiopia.org/api/trpc/persona.list?input=%7B%7D" \
-H "X-API-Key: your-api-key" \
-H "X-Organization-ID: your-org-id" \
-w "\nHTTP Status: %{http_code}\n"
# Expected: HTTP Status: 200
# Response: {"result":{"data":[...]}}200 status code, you're all set! A 401 error means your API key is invalid. A 403 error usually means the Organization ID is incorrect.Next Steps
Quick Start Tutorial
Follow our step-by-step guide to create your first persona and start chatting.
Start TutorialCreate Persona Guide
Learn about structured prompts, tools, and knowledge base configuration.
Read Guide