Content Generation API
Generate text and image content using AI personas with support for multiple social media platforms.
Text
Blog posts, social media copy, marketing content
Images
DALL-E 2/3 powered image generation
Video
Video content generation (coming soon)
Audio
Audio content generation (coming soon)
The Content Object
A content object represents generated content with metadata, status, and optional platform-specific variations.
Content Object Structure
{
"id": "clx1abc123xyz789",
"title": "Product Launch Announcement",
"type": "TEXT",
"content": "Exciting news! We're thrilled to announce...",
"prompt": "Write an engaging product launch announcement...",
"status": "GENERATED",
"metadata": {
"socialMedias": ["twitter", "linkedin"],
"generationMode": "individual",
"platformContents": {
"twitter": "Exciting news! We're launching...",
"linkedin": "We're thrilled to announce..."
}
},
"generationData": {
"model": "gpt-4o",
"tokensUsed": 450,
"finishReason": "stop"
},
"creator": {
"id": "user_123",
"name": "John Doe",
"email": "john@example.com"
},
"persona": {
"id": "persona_456",
"name": "Marketing Assistant",
"avatar": "https://..."
},
"platformContents": [
{
"id": "pc_1",
"platform": "TWITTER",
"content": "Exciting news! We're launching...",
"status": "GENERATED"
},
{
"id": "pc_2",
"platform": "LINKEDIN",
"content": "We're thrilled to announce...",
"status": "GENERATED"
}
],
"createdAt": "2024-01-15T10:30:00Z",
"updatedAt": "2024-01-15T10:30:00Z"
}Content Attributes
| Attribute | Type | Description |
|---|---|---|
| id | string | Unique identifier for the content |
| title | string | Title or name of the content |
| type | enum | TEXT, IMAGE, VIDEO, or AUDIO |
| content | string | The generated content (text or image URL) |
| prompt | string | The prompt used to generate the content |
| status | enum | DRAFT, GENERATED, PUBLISHED, or ARCHIVED |
| metadata | object | Additional metadata (platforms, generation settings) |
| personaId | string? | Optional persona used for generation context |
Content Types
AIPersona supports multiple content types for different use cases.
TEXT Text Content
Generate written content using your configured LLM provider. Best for:
- Social media posts (Twitter, LinkedIn, Facebook)
- Blog articles and marketing copy
- Email templates and newsletters
- Product descriptions
IMAGE Image Content
Generate images using DALL-E 2 or DALL-E 3. Best for:
- Social media graphics and banners
- Product visuals and mockups
- Marketing materials
- Illustrations and artwork
Generate Text Content
Create text content with optional persona context and platform-specific variations.
trpc.content.createGenerate new text content using AI.
1const response = await fetch('https://aipersona.dsethiopia.org/api/trpc/content.create', {
2 method: 'POST',
3 headers: {
4 'Content-Type': 'application/json',
5 'X-API-Key': 'your-api-key',
6 'X-Organization-ID': 'your-org-id'
7 },
8 body: JSON.stringify({
9 json: {
10 title: "Product Launch Announcement",
11 type: "TEXT",
12 prompt: "Write an engaging announcement for our new AI-powered productivity tool. Highlight key features: smart scheduling, automated reports, and team collaboration."
13 }
14 })
15});
16
17const result = await response.json();
18console.log(result.result.data.content);Text Generation Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| title | string | Yes | Title for the content |
| type | string | Yes | Must be "TEXT" |
| prompt | string | Yes | Generation prompt/instructions |
| personaId | string | No | Persona for voice/style context |
| metadata.socialMedias | string[] | No | Platforms: twitter, linkedin, facebook |
| metadata.generationMode | string | No | "individual" for platform-specific content |
Generate Image Content
Create images using DALL-E with customizable size and quality settings.
trpc.content.createGenerate new image content using DALL-E.
1const response = await fetch('https://aipersona.dsethiopia.org/api/trpc/content.create', {
2 method: 'POST',
3 headers: {
4 'Content-Type': 'application/json',
5 'X-API-Key': 'your-api-key',
6 'X-Organization-ID': 'your-org-id'
7 },
8 body: JSON.stringify({
9 json: {
10 title: "Product Banner",
11 type: "IMAGE",
12 prompt: "A modern, minimalist product banner featuring a sleek laptop on a clean desk with soft natural lighting, professional photography style",
13 metadata: {
14 model: "dall-e-3",
15 size: "1792x1024", // Landscape format
16 quality: "hd" // HD quality
17 }
18 }
19 })
20});
21
22const result = await response.json();
23const imageUrl = result.result.data.content; // URL to generated imageImage Generation Options
DALL-E 3 Sizes
1024x1024- Square1792x1024- Landscape1024x1792- Portrait
DALL-E 2 Sizes
256x256- Small512x512- Medium1024x1024- Large
Quality Options (DALL-E 3 only)
standard- Default qualityhd- Higher detail and quality
List Content
Retrieve all generated content with optional filtering by type and status.
trpc.content.listList content with pagination and filters.
1const response = await fetch('https://aipersona.dsethiopia.org/api/trpc/content.list?input=' +
2 encodeURIComponent(JSON.stringify({
3 json: {
4 type: "TEXT", // Optional: TEXT, IMAGE, VIDEO, AUDIO
5 status: "GENERATED", // Optional: DRAFT, GENERATED, PUBLISHED, ARCHIVED
6 limit: 20, // Items per page (max 100)
7 cursor: "cursor_xyz" // Optional: for pagination
8 }
9 })), {
10 headers: {
11 'X-API-Key': 'your-api-key',
12 'X-Organization-ID': 'your-org-id'
13 }
14});
15
16const result = await response.json();
17const { items, nextCursor } = result.result.data;
18
19// Use nextCursor for pagination
20if (nextCursor) {
21 // Fetch next page with cursor: nextCursor
22}Get Content
Retrieve a specific content item by ID.
trpc.content.getGet content details including platform-specific versions.
1const response = await fetch('https://aipersona.dsethiopia.org/api/trpc/content.get?input=' +
2 encodeURIComponent(JSON.stringify({
3 json: { id: "clx1abc123xyz789" }
4 })), {
5 headers: {
6 'X-API-Key': 'your-api-key',
7 'X-Organization-ID': 'your-org-id'
8 }
9});
10
11const content = await response.json();
12console.log(content.result.data);Update Content
Update content title, content text, status, or metadata.
trpc.content.updateUpdate an existing content item.
1const response = await fetch('https://aipersona.dsethiopia.org/api/trpc/content.update', {
2 method: 'POST',
3 headers: {
4 'Content-Type': 'application/json',
5 'X-API-Key': 'your-api-key',
6 'X-Organization-ID': 'your-org-id'
7 },
8 body: JSON.stringify({
9 json: {
10 id: "clx1abc123xyz789",
11 title: "Updated Title",
12 content: "Modified content text...",
13 status: "PUBLISHED",
14 metadata: {
15 publishedAt: new Date().toISOString()
16 }
17 }
18 })
19});Update Parameters
| Parameter | Type | Description |
|---|---|---|
| id | string | Content ID (required) |
| title | string? | New title |
| content | string? | Modified content |
| status | enum? | DRAFT, GENERATED, PUBLISHED, ARCHIVED |
| metadata | object? | Additional metadata |
Delete Content
Permanently delete a content item and its platform-specific versions.
trpc.content.deleteDelete content by ID.
1const response = await fetch('https://aipersona.dsethiopia.org/api/trpc/content.delete', {
2 method: 'POST',
3 headers: {
4 'Content-Type': 'application/json',
5 'X-API-Key': 'your-api-key',
6 'X-Organization-ID': 'your-org-id'
7 },
8 body: JSON.stringify({
9 json: { id: "clx1abc123xyz789" }
10 })
11});
12
13const result = await response.json();
14// result.result.data.success === truePlatform-Specific Content
AIPersona can generate content tailored for specific social media platforms.
- 280 character limit
- Hashtag optimization
- Thread support
- Engagement-focused
- Professional tone
- Longer format
- Industry keywords
- Thought leadership
- Conversational style
- Emoji support
- Story-driven
- Community focus
1// After generating with socialMedias in metadata
2const content = result.result.data;
3
4// Main content
5console.log(content.content);
6
7// Platform-specific versions
8content.platformContents.forEach(pc => {
9 console.log(`${pc.platform}: ${pc.content}`);
10});
11
12// Or access from metadata
13const { platformContents } = content.metadata;
14console.log(platformContents.twitter);
15console.log(platformContents.linkedin);
16console.log(platformContents.facebook);