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)

Beta

Audio

Audio content generation (coming soon)

Beta

The Content Object

A content object represents generated content with metadata, status, and optional platform-specific variations.

Content Object Structure

JSON
{
  "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

AttributeTypeDescription
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.

POST
trpc.content.create

Generate new text content using AI.

Basic Text Generation
JavaScript
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

ParameterTypeRequiredDescription
title
string
YesTitle for the content
type
string
YesMust be "TEXT"
prompt
string
YesGeneration prompt/instructions
personaId
string
NoPersona for voice/style context
metadata.socialMedias
string[]
NoPlatforms: 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.

POST
trpc.content.create

Generate new image content using DALL-E.

DALL-E 3 Image Generation
JavaScript
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 image

Image Generation Options

DALL-E 3 Sizes
  • 1024x1024 - Square
  • 1792x1024 - Landscape
  • 1024x1792 - Portrait
DALL-E 2 Sizes
  • 256x256 - Small
  • 512x512 - Medium
  • 1024x1024 - Large
Quality Options (DALL-E 3 only)
  • standard - Default quality
  • hd - Higher detail and quality

List Content

Retrieve all generated content with optional filtering by type and status.

GET
trpc.content.list

List content with pagination and filters.

List Content with Filters
JavaScript
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.

GET
trpc.content.get

Get content details including platform-specific versions.

Get Content by ID
JavaScript
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.

POST
trpc.content.update

Update an existing content item.

Update Content
JavaScript
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

ParameterTypeDescription
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.

POST
trpc.content.delete

Delete content by ID.

Delete Content
JavaScript
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 === true
Warning
Deleting content is permanent and also removes all associated platform-specific content versions.

Platform-Specific Content

AIPersona can generate content tailored for specific social media platforms.

Twitter

  • 280 character limit
  • Hashtag optimization
  • Thread support
  • Engagement-focused

LinkedIn

  • Professional tone
  • Longer format
  • Industry keywords
  • Thought leadership

Facebook

  • Conversational style
  • Emoji support
  • Story-driven
  • Community focus
Accessing Platform Content
JavaScript
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);