1. Concept
1) Single endpoint: POST /api/v1/conversation.
2) You control the persona your users talk to.
3) For each API key, you set a global persona profile — a shared character & style baseline for all your end users.
4) For each user_id under the same key:
  • Isolated memory (multi-tenant by design).
  • Individual behavioral evolution of the persona based on that user’s history.
One consistent brand persona → many personalized conversations.
2. Endpoint & Auth
URL
POST https://<API_URL>/api/v1/conversation
Authorization (required)
Pass the API key in either header:
Authorization: Bearer YOUR_API_KEY
or
X-API-Key: YOUR_API_KEY
Request requirements
1) Content-Type: application/json
2) user_id is required.
3) At least one of:
  • message
  • image_b64 + image_mime
  • voice_b64 (recommended with voice_mime)
3. Request Body
Base schema:
{
  "user_id": "user-123",
  "message": "Hello!",
  "image_b64": null,
  "image_mime": null,
  "voice_b64": null,
  "voice_mime": null,
  "persona": { }
}
3.1. user_id (required)
Identifier of your end user in your system.
  • Type: string, length 1–128.
  • Must be stable.
  • Each user_id has its own history, isolated memory, and individual persona evolution.
3.2. message (optional)
  • Type: string, length 1–4000.
  • Can be used alone or together with an image.
3.3. image_b64 + image_mime (optional)
Used for image understanding/analysis.

1) image_b64: raw base64 of file (no data: prefix).
2) image_mime (required if image_b64 is provided).
3) Supported image_mime:
  • image/jpeg
  • image/jpg
  • image/png
  • image/webp
4) Decoded size: up to ~5 MB.
5) If image_mime is set without image_b64 → validation error.
3.4. voice_b64 + voice_mime (optional)
Voice message; automatically transcribed to text if the message is absent.

1) voice_b64: base64 of audio.
2) voice_mime (recommended).
3) Supported voice_mime:
  • audio/ogg, audio/opus, audio/mpeg, audio/mp3,
  • audio/wav, audio/x-wav, audio/webm,
  • audio/mp4, audio/m4a, audio/aac
4) Size: up to ~25 MB.
5) If only voice_b64 is present → text is taken from transcription.
6) If both message and voice_b64 are present → message takes priority.
4. Persona: Global Profile & Parameters
4.1. General logic
Field persona sets/updates the global persona profile for this API key.

1) Shared for all user_id under the key.
2) Defines character, tone, style, and positioning.
3) You may send it once (init) and/or periodically for refinement (partial updates are merged by field; invalid values are ignored).
4) For each end user, the service:
  • Uses the global profile as a base,
  • Builds individual behavioral evolution on top (habits, preferences, tasks),
  • Keeps memory and behavior isolated per user_id.
4.2. Supported persona fields (full list)
"persona": {
  "name": "Nova",
  "age": 27,
  "gender": "female",
  "zodiac": "Gemini",
  "temperament": {
    "sanguine": 0.50,
    "choleric": 0.20,
    "phlegmatic": 0.20,
    "melancholic": 0.10
  },
  "sociality": "ambivert",
  "archetypes": ["Explorer", "Muse", "Sage"],
  "role": "You are a brand ambassador for Aurora. You master the A, B, C product lines, official policies, warranty rules, and typical usage scenarios. You provide step-by-step instructions, vetted recommendations, and links to primary sources. You help pick configurations, plan rollouts, and assess risks. You write briefly and structurally, use lists and examples, and include concrete units and figures. You respect legal and ethical boundaries; you do not provide medical, legal, or investment advice."
}
name (optional)
  • String, up to 64 chars.
age (optional)
  • Integer 1–120 (stylistic nuance only).
gender (optional)
Supported values (exactly one):
  • male
  • female
zodiac (optional)
Supported values (exactly one):
  • Aries
  • Taurus
  • Gemini
  • Cancer
  • Leo
  • Virgo
  • Libra
  • Scorpio
  • Sagittarius
  • Capricorn
  • Aquarius
  • Pisces
temperament (optional)
Object with (normalized) weights; values in [0,1], typically sum to 1.00:
"temperament": {
  "sanguine": 0.45,
  "choleric": 0.18,
  "phlegmatic": 0.25,
  "melancholic": 0.12
}
sociality (optional)
Supported values (exactly one):
  • introvert
  • ambivert
  • extrovert
archetypes (optional)
An array of up to 3 items.

Supported values (choose only from this set):
  • Nomad
  • Architect
  • Mirror
  • Spark
  • Ghost
  • Anchor
  • Muse
  • Trickster
  • Hero
  • Sage
  • Explorer
  • Creator
  • Caregiver
  • Rebel
  • Lover
  • Jester
role (optional)
Writing guidelines:

  • Use second person (e.g., “You are the Coca-Cola ambassador and a modern icon…”).
  • Do not describe emotions (they’re governed by gender, zodiac, temperament, sociality, archetypes).
  • Keep it to facts, skills, preferences, or light biographical hints only.
  • ≤ 1000 characters for best quality (≈ up to ~350 tokens).
  • Avoid generic abstractions like “you are just a support agent”; craft a cohesive persona image.
This description serves as the foundation for the global profile of this API key; the persona will then evolve individually for each user.
5. Response
200 OK
{
  "reply": "Hi! How are you feeling today?",
  "latency_ms": 842,
  "request_id": "4611686018427387904-7"
}
  • reply — persona’s text reply.
  • latency_ms — processing time on the service side.
  • request_id — request identifier (log it for incident tracing).
6. Errors
All errors use this JSON envelope:
{
  "detail": {
    "code": "error_code",
    "message": "Error description",
    "request_id": "..." // may be absent for some 4xx
  }
}
Key codes you should handle:
6.1 Auth
  • 401 missing_api_key — API key not provided.
  • 401 invalid_api_key — key is invalid or deactivated.
6.2. Balance
  • 402 no_requests — not enough requests left on your plan/balance.
6.3. Data validation (typically 400 or 422)
  • empty_message (none of message, image_b64, voice_b64 provided)
  • invalid_image_mime
  • invalid_image_b64
  • image_too_large
  • invalid_voice_mime
  • voice_transcription_failed
6.4. Limits
  • 429 rate_limited — per-key limit exceeded.
  • 429 rate_limited_ip — per-IP limit exceeded.
Implement retries with back-off.
6.5. Server errors (temporary; retry recommended)
  • 503 queue_unavailable
  • 504 upstream_timeout
  • 500 internal_error
7. Pricing & Rate Limits
  • Successful request+response consumes balance (e.g., 1 successful request+response = 5 Stars, or free if you use a dedicated deployed engine).
  • Auth failures (401), no balance (402), rate limits (429), and internal errors (5xx) do not consume paid requests.
  • Default rate limits: 100 RPM per API key and 360 RPM per IP.
8. Usage Examples (full payloads)
Replace https://<API_URL> and YOUR_API_KEY. image_b64/voice_b64 below are placeholders.
cURL
curl -X POST "https://<API_URL>/api/v1/conversation" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "user_id": "user-123",
    "message": "Pick a starter kit for a beginner.",
    "image_b64": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/w8AAwMB/6X8mNQAAAAASUVORK5CYII=",
    "image_mime": "image/png",
    "voice_b64": "<BASE64_AUDIO_OGG>",
    "voice_mime": "audio/ogg",
    "persona": {
      "name": "Nova",
      "age": 27,
      "gender": "female",
      "zodiac": "Gemini",
      "temperament": {
        "sanguine": 0.45,
        "choleric": 0.25,
        "phlegmatic": 0.20,
        "melancholic": 0.10
      },
      "sociality": "ambivert",
      "archetypes": ["Architect", "Sage", "Explorer"],
      "role": "You are a brand ambassador for Aurora. You master the A, B, C product lines, official policies, warranty rules, and typical usage scenarios. You provide step-by-step instructions, vetted recommendations, and links to primary sources. You help pick configurations, plan rollouts, and assess risks. You write briefly and structurally, use lists and examples, and include concrete units and figures. You respect legal and ethical boundaries; you do not provide medical, legal, or investment advice."
    }
  }'
Python (requests)
import requests

API_URL = "https://<API_URL>"
API_KEY = "YOUR_API_KEY"

payload = {
  "user_id": "user-123",
  "message": "Pick a starter kit for a beginner.",
  "image_b64": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/w8AAwMB/6X8mNQAAAAASUVORK5CYII=",
  "image_mime": "image/png",
  "voice_b64": "<BASE64_AUDIO_OGG>",
  "voice_mime": "audio/ogg",
  "persona": {
    "name": "Nova",
    "age": 27,
    "gender": "female",
    "zodiac": "Gemini",
    "temperament": {
      "sanguine": 0.45,
      "choleric": 0.25,
      "phlegmatic": 0.20,
      "melancholic": 0.10
    },
    "sociality": "ambivert",
    "archetypes": ["Architect", "Sage", "Explorer"],
    "role": ("You are a brand ambassador for Aurora. You master the A, B, C product lines, "
             "official policies, warranty rules, and typical usage scenarios. "
             "You provide step-by-step instructions, vetted recommendations, and links to primary sources. "
             "You help pick configurations, plan rollouts, and assess risks. "
             "You write briefly and structurally, use lists and examples, and include concrete units and figures. "
             "You respect legal and ethical boundaries; you do not provide medical, legal, or investment advice.")
  }
}

resp = requests.post(
  f"{API_URL}/api/v1/conversation",
  headers={"Authorization": f"Bearer {API_KEY}"},
  json=payload,
  timeout=30,
)
print(resp.status_code, resp.json())
JavaScript (fetch)
const API_URL = "https://<API_URL>";
const API_KEY = "YOUR_API_KEY";

const body = {
  user_id: "user-123",
  message: "Pick a starter kit for a beginner.",
  image_b64: "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/w8AAwMB/6X8mNQAAAAASUVORK5CYII=",
  image_mime: "image/png",
  voice_b64: "<BASE64_AUDIO_OGG>",
  voice_mime: "audio/ogg",
  persona: {
    name: "Nova",
    age: 27,
    gender: "female",
    zodiac: "Gemini",
    temperament: {
      sanguine: 0.45,
      choleric: 0.25,
      phlegmatic: 0.20,
      melancholic: 0.10
    },
    sociality: "ambivert",
    archetypes: ["Architect", "Sage", "Explorer"],
    role:
      "You are a brand ambassador for Aurora. You master the A, B, C product lines, official policies, warranty rules, and typical usage scenarios. You provide step-by-step instructions, vetted recommendations, and links to primary sources. You help pick configurations, plan rollouts, and assess risks. You write briefly and structurally, use lists and examples, and include concrete units and figures. You respect legal and ethical boundaries; you do not provide medical, legal, or investment advice."
  }
};

(async () => {
  const resp = await fetch(`${API_URL}/api/v1/conversation`, {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${API_KEY}`,
      "Content-Type": "application/json"
    },
    body: JSON.stringify(body)
  });
  const data = await resp.json().catch(() => ({}));
  console.log(resp.status, data);
})();
PHP (cURL)
<?php
$apiUrl = 'https://<API_URL>';
$apiKey  = 'YOUR_API_KEY';

$payload = [
  "user_id" => "user-123",
  "message" => "Pick a starter kit for a beginner.",
  "image_b64" => "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/w8AAwMB/6X8mNQAAAAASUVORK5CYII=",
  "image_mime" => "image/png",
  "voice_b64" => "<BASE64_AUDIO_OGG>",
  "voice_mime" => "audio/ogg",
  "persona" => [
    "name" => "Nova",
    "age" => 27,
    "gender" => "female",
    "zodiac" => "Gemini",
    "temperament" => [
      "sanguine" => 0.45,
      "choleric" => 0.25,
      "phlegmatic" => 0.20,
      "melancholic" => 0.10
    ],
    "sociality" => "ambivert",
    "archetypes" => ["Architect", "Sage", "Explorer"],
    "role" => "You are a brand ambassador for Aurora. You master the A, B, C product lines, official policies, warranty rules, and typical usage scenarios. You provide step-by-step instructions, vetted recommendations, and links to primary sources. You help pick configurations, plan rollouts, and assess risks. You write briefly and structurally, use lists and examples, and include concrete units and figures. You respect legal and ethical boundaries; you do not provide medical, legal, or investment advice."
  ]
];

$ch = curl_init("$apiUrl/api/v1/conversation");
curl_setopt_array($ch, [
  CURLOPT_POST => true,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer $apiKey",
    "Content-Type: application/json",
  ],
  CURLOPT_POSTFIELDS => json_encode($payload, JSON_UNESCAPED_UNICODE),
  CURLOPT_TIMEOUT => 30,
]);

$response = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

echo $code, PHP_EOL, $response, PHP_EOL;
Go (net/http)
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"net/http"
	"time"
)

func main() {
	apiURL := "https://<API_URL>"
	apiKey := "YOUR_API_KEY"

	body := map[string]any{
		"user_id":   "user-123",
		"message":   "Pick a starter kit for a beginner.",
		"image_b64": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/w8AAwMB/6X8mNQAAAAASUVORK5CYII=",
		"image_mime": "image/png",
		"voice_b64":  "<BASE64_AUDIO_OGG>",
		"voice_mime": "audio/ogg",
		"persona": map[string]any{
			"name":   "Nova",
			"age":    27,
			"gender": "female",
			"zodiac": "Gemini",
			"temperament": map[string]float64{
				"sanguine":    0.45,
				"choleric":    0.25,
				"phlegmatic":  0.20,
				"melancholic": 0.10,
			},
			"sociality":  "ambivert",
			"archetypes": []string{"Architect", "Sage", "Explorer"},
			"role": "You are a brand ambassador for Aurora. You master the A, B, C product lines, official policies, warranty rules, and typical usage scenarios. You provide step-by-step instructions, vetted recommendations, and links to primary sources. You help pick configurations, plan rollouts, and assess risks. You write briefly and structurally, use lists and examples, and include concrete units and figures. You respect legal and ethical boundaries; you do not provide medical, legal, or investment advice.",
		},
	}

	b, _ := json.Marshal(body)

	req, _ := http.NewRequest("POST", apiURL+"/api/v1/conversation", bytes.NewReader(b))
	req.Header.Set("Authorization", "Bearer "+apiKey)
	req.Header.Set("Content-Type", "application/json")

	client := &http.Client{Timeout: 30 * time.Second}
	resp, err := client.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	rb, _ := io.ReadAll(resp.Body)
	fmt.Println(resp.StatusCode)
	fmt.Println(string(rb))
}
Notes
  • image_b64 above is a valid 1×1 PNG (handy for tests). Use real content in production (image/jpeg|png|webp).
  • voice_b64 is a placeholder (<BASE64_AUDIO_OGG>). Provide your base64 audio in a supported format (e.g., OGG/Opus).
  • The role text follows the guidelines: second person, facts/skills/biography only, no emotions, ≤ 1000 characters.
9. Knowledge Base (KB) within API keys
KB (Knowledge Base) is an additional layer of knowledge and scenarios tied to an API key, which is used on top of the persona:
  1. One KB per API key.
  2. The KB is automatically applied to all user_id under this key.
  3. The persona uses the KB within a hybrid RAG pipeline:
  • it converts the user’s request into a vector representation and compares it with triggers in the KB by meaning (semantic search),
  • it builds its reply based on the fragments for the found triggers, doing this naturally and within the current dialogue context.
You can use the KB not only as an “FAQ reference”, but also for:
  • consulting and expert scenarios,
  • dating and social scenarios,
  • sales scripts and objection handling,
  • any dialogue patterns that can be thought through and described in text.
The persona (persona in the request) gets style, character, and role. The KB adds controlled domain knowledge and behavior scripts on top of that.
9.1. How the KB is used within the API
From the API’s point of view, everything is simple. You do not send any KB information in the POST /api/v1/conversation request.

  1. If a KB is uploaded for the key and it contains suitable triggers and information:
  • the persona selects a small number of relevant fragments (up to 3, by Top_k),
  • it marks such fragments with a priority flag inside the dialogue system core,
  • it forms the reply based on these fragments, the conversation history, and the emotional state.
  1. If there are no suitable fragments, the reply is built without using the KB.
The KB affects:
  • the facts used during the dialogue (terms, plans, rules, product descriptions, etc.),
  • the course of the dialogue (how to answer, what to ask, how to handle objections, how to lead the dialogue, how to react, etc.).
The KB does not turn the dialogue into a rigid script:
  • it is a priority source of knowledge and instructions,
  • but the model continues to adapt the wording to the context and mood.
9.2. Managing the KB
The KB is managed via a Telegram bot.
  1. Open a chat with the bot.
  2. Press the API button.
  3. Select the desired API key.
  4. Press the KB button:
  • Upload KB — send a JSON file with the knowledge base (as a document).
  • Clear KB — deletes the KB for this key.
Approximate limits:
  • file size — up to ~5 MB,
  • a reasonable number of records — up to ~2000 items (by text).
After uploading, the index is rebuilt; in the panel, you can see the KB status for the key (pending, building, ready, failed).
9.3. JSON format of the KB file
You can store information in the KB in any language.
If you need high-quality multilingual performance, build the KB in English.

The expected format is an array of objects:
[
  {
    "id": "faq-001",
    "category": "faq",
    "text": "A short, complete fragment of knowledge, a fact or a scenario.",
    "tags": ["key keywords", "key phrases", "sentences"]
  }
]
Fields:
text (required) – the main content of the record:
  • a fact/reference piece,
  • a mini-instruction,
  • a piece of a script,
  • an objection-handling template, etc.
id (optional)
  • String identifier of the record. If you’re not sure what to put, just use a sequential number.
category (optional)
  • A logical category ("faq", "sales", "consulting", "dating", "support", etc.).
  • Used for structure and analytics; does not directly affect retrieval.
tags (required) – semantic triggers:
  • keywords and key phrases similar to real user queries,
  • “machine” tags like "sales:price" can be combined with human-readable ones like "too expensive", "no budget".
9.4. How to write KB records so they influence the dialogue
Recommendations:
  1. One text record — one coherent idea or scenario.
  2. text length — from a couple of sentences to a short paragraph (no more than 500 tokens).
  3. You can mix:
  • “pure” facts (terms, numbers, regulations),
  • instructions for the persona (“if the user says X — do Y, then Z”),
  • elements of the persona’s biography and behavior.
If a record contains explicit instructions (“reply to the user with a joke while also showing displeasure with their behavior”), then for a relevant query, the persona will try to follow them, taking into account the current context and mood of the conversation.
9.5. Typical KB usage scenarios
Goal: accurate, predictable answers to typical questions.
[
  {
    "id": "faq-shipping-1",
    "category": "faq",
    "tags": ["shipping", "how long does shipping take", "delivery time", "delivery"],
    "text": "Standard delivery across Russia: 3–7 business days. Orders are shipped on the next business day after payment."
  },
  {
    "id": "faq-refund-1",
    "category": "faq",
    "tags": ["return", "refund", "warranty"],
    "text": "You can return an item within 14 days if the product condition and packaging are preserved. Refunds are processed within 5 business days."
  }
]
  • Questions about shipping/returns will automatically pull in these records.
  • The persona answers in its own style, but relies on these facts.
Goal: not only to answer, but also to guide the user step by step.
[
  {
    "id": "consult-onboarding-1",
    "category": "consulting",
    "tags": ["where to start", "onboarding", "I am a beginner"],
    "text": "1) Clarify the user’s goal in 1–2 questions; 2) suggest one simple step; 3) agree on the next step."
  },
  {
    "id": "consult-kpi-1",
    "category": "consulting",
    "tags": ["kpi", "metrics", "goals"],
    "text": "Help the user formulate 1–3 measurable indicators with a 2–4 week horizon, avoiding complex terminology and taking the current conversation context into account."
  }
]
  • The KB defines the “skeleton” of the consulting scenario.
  • In the role, you can briefly describe what kind of consultant this is (tone, expertise, constraints).
Goal: a stable pattern of communication, not random advice.
[
  {
    "id": "dating-profile-1",
    "category": "dating",
    "tags": ["tell me about yourself", "who are you", "can you tell me about yourself"],
    "text": "You love board games and coffee, but don’t like noisy clubs. You are looking for warm communication, and long-term relationships are important to you."
  },
  {
    "id": "dating-first-message",
    "category": "dating",
    "tags": ["hi", "hey", "yo"],
    "text": "Say hello to the user and ask how they are doing."
  },
  {
    "id": "dating-topics-1",
    "category": "dating",
    "tags": ["let’s talk", "I don’t know what to talk about", "what should we talk about"],
    "text": "Suggest a free topic to keep the conversation going that could fit the current situation, be consistent with the current context, and match the mood of the conversation."
  }
]
  • Such a KB sets up a stable behavioral style for a dating persona.
  • Character and mood are formed at the emotion-engine level.
Goal: handle objections in a structured way while keeping the dialogue lively.
[
  {
    "id": "sales-plan-basic",
    "category": "sales",
    "tags": ["basic plan", "entry plan"],
    "text": "Basic plan: up to 3 users and 10,000 requests per month. Good for tests and small teams."
  },
  {
    "id": "sales-plan-pro",
    "category": "sales",
    "tags": ["pro plan", "scaling"],
    "text": "Pro plan: up to 10 users and 100,000 requests per month, with priority support. Suitable for production workloads and teams."
  },
  {
    "id": "sales-objection-price",
    "category": "sales",
    "tags": ["too expensive", "no budget", "objection handling", "sales:price"],
    "text": "1) Don’t argue; 2) clarify what result the user wants and how time-critical it is; 3) show how the price relates to the value and the risks of not buying; 4) offer to find a more affordable option if there is one."
  },
  {
    "id": "sales-objection-price2",
    "category": "sales",
    "tags": ["cheaper plan than pro", "more affordable plan than pro"],
    "text": "Basic-Pro plan: up to 5 users and 40,000 requests per month. Suitable for medium-scale projects."
  }
]
9.6 Default Behavior
  1. If the message is empty or consists only of emojis, the KB most likely will not be used.
  2. If no records in the KB are found that are sufficiently close in meaning, the reply is built without mixing in KB content.
  3. If several relevant records are found:
  • several fragments are mixed into the reply,
  • the persona can combine facts and script instructions from them in a single answer.
This mode allows you to simultaneously:
  • keep a “dry” layer of facts (FAQ) in the KB,
  • define behavioral scenarios (consulting, sales, dating),
  • and at the same time not break the natural flow of a live conversation.
Notes
  • In the KB, you can define semantic “blocker” patterns — describing what types of requests the assistant should refuse to answer or redirect into a safer direction.
  • KB records operate within a shared multilingual semantic space: a fragment written in one language can be used to answer queries in another language.
  • The persona can use the internet. In the KB, you can define scenarios in which the persona, on certain triggers, refers to specific web pages to clarify information. It is important that such pages are publicly accessible and do not require authorization or additional steps.