AI captions and hashtags with the TypeScript SDK
The ai resource generates platform-tailored captions and hashtag suggestions. Generation runs on the AI key your workspace has configured (bring your own key). Check availability first.
How do I check whether AI is available?
typescript
const { available } = await socifyr.ai.status()Returns { available: boolean }.
How do I generate a caption for several platforms?
typescript
const result = await socifyr.ai.generateContent({
uploadType: 'video',
platforms: ['instagram', 'linkedin'],
title: 'Product launch video',
tone: 'professional',
brandVoice: 'Direct and practical. Short sentences.',
})
for (const [platform, caption] of Object.entries(result.content)) {
console.log(platform, caption)
}GenerateContentParams:
| Field | Type | Required | Notes |
|---|---|---|---|
uploadType | 'video' | 'photo' | 'text' | 'document' | yes | |
platforms | Platform[] | yes | Platform types, not connection slugs |
text | string | no | Source text |
title | string | no | |
description | string | no | |
tone | 'professional' | 'casual' | 'humorous' | 'inspirational' | 'informative' | no | |
brandVoice | string | no |
Returns { content: Record<string, string> }, a map from platform to caption.
How do I get hashtag suggestions?
typescript
const tags = await socifyr.ai.suggestHashtags({
text: 'Launching our new social media SDK',
platforms: ['instagram', 'x'],
count: 15,
})
// [{ platform: 'instagram', hashtags: [...] }, { platform: 'x', hashtags: [...] }]SuggestHashtagsParams: text (required), platforms (required), count?, existingHashtags?. Returns SuggestedHashtags[], each with platform and hashtags.
What errors can AI calls raise?
If the workspace has no AI key, the API answers 503 with No AI provider key set for this workspace. Add your own key in Settings → AI to use AI features. The SDK throws a plain SocifyrError (code: 'api_error', status: 503). Add a key in Settings first. See the dashboard overview.