POST · AI

AI Chat (Text)

Base path POST https://starsapi.com/api/v2/partner/ai/chat/

Text-based AI astrologer sessions. Open a session with birth details, get a greeting, then keep sending messages. Three endpoints: /start (single chart), /match-start (two charts), and /message (follow-up turns). All return the same response envelope.

Start session

Endpoint POST /api/v2/partner/ai/chat/start

Opens a new single-chart session. Computes the user’s Vedic chart, selects the astrologer, and returns the AI’s opening greeting in new_messages.

Request body

FieldTypeRequiredDescription
astrologerstringYesAstrologer key: guruji, love_guru, career_expert, health_expert, transit_expert.
yearintegerYesBirth year, 4-digit.
monthintegerYesBirth month, 112.
dayintegerYesDay of month, 131.
hourintegerYesHour in 24-hour local clock time, 023.
minuteintegerYesMinute, 059.
latitudenumberYesSigned decimal degrees, −90…90. Positive = North.
longitudenumberYesSigned decimal degrees, −180…180. Positive = East.
timezonestringYesIANA timezone identifier (e.g. Asia/Kolkata).
namestringNoUser’s name. Used to personalize the astrologer’s responses.
genderstringNomale or female.
ageintegerNoUser’s age.
preferred_languagestringNoResponse language code: en, hi, etc. Default: en.
Use the local clock time of birth. Pass the wall-clock time as recorded on the birth certificate together with the IANA timezone of the birth place. Do not pre-convert to UTC.

Send message

Endpoint POST /api/v2/partner/ai/chat/message

Send a follow-up message in an active session. The server loads the chart context and conversation history automatically from the session_id. Returns the astrologer’s reply in the same envelope as /start.

Request body

FieldTypeRequiredDescription
session_idstringYesThe 32-character session ID from the /start response.
messagestringYesThe user’s message text.

Start match session (two charts)

Endpoint POST /api/v2/partner/ai/chat/match-start

Opens a matchmaking session with two birth charts loaded simultaneously. Used for compatibility analysis — Ashtakoot, Mangal Dosha, synastry, relationship counsel. Both charts remain in scope for the entire conversation. Subsequent turns use the same /message endpoint.

Request body

Send two person objects. The preferred field names are person1 and person2. Legacy names boy / girl are also accepted.

FieldTypeRequiredDescription
astrologerstringYesUse a matching-capable astrologer, e.g. guruji or love_guru.
preferred_languagestringNoResponse language. Default: en.
person1 (object)
person1.namestringNoName of person 1.
person1.yearintegerYesBirth year.
person1.monthintegerYesBirth month.
person1.dayintegerYesBirth day.
person1.hourintegerYesBirth hour (24h).
person1.minuteintegerYesBirth minute.
person1.latitudenumberYesSigned decimal latitude.
person1.longitudenumberYesSigned decimal longitude.
person1.timezonestringYesIANA timezone.
person1.genderstringNomale or female.
person2 (same fields as person1)

Match-start example body

{
  "astrologer": "love_guru",
  "preferred_language": "en",
  "person1": {
    "name": "Ravi",
    "year": 1990, "month": 6, "day": 15,
    "hour": 14, "minute": 30,
    "timezone": "Asia/Kolkata",
    "latitude": 28.6139, "longitude": 77.2090,
    "gender": "male"
  },
  "person2": {
    "name": "Priya",
    "year": 1992, "month": 3, "day": 22,
    "hour": 9, "minute": 15,
    "timezone": "Asia/Kolkata",
    "latitude": 19.0760, "longitude": 72.8777,
    "gender": "female"
  }
}

Response shape

All three endpoints return the same envelope. The data object contains the session state, the astrologer’s reply, and billing.

FieldTypeDescription
successbooleantrue on success.
data
session_idstring32-character session identifier. Pass to /message for subsequent turns.
turnintegerTurn count. 1 = greeting, 2+ = conversation turns.
data.astrologer
keystringAstrologer identifier (e.g. guruji).
namestringDisplay name.
taglinestringShort description.
avatarstringEmoji or avatar identifier for UI rendering.
astrology_systemstringPrimary system used (e.g. vedic).
data.new_messages
rolestringastrologer.
messagearray of stringsReply text split into reading-sized chunks. Render each as a separate chat bubble.
data.suggested_followups
array of stringsAI-generated quick-reply prompts. Surface as tappable chips in your UI.
data.billing
cost_minorintegerTurn cost in minor units.
currencystringINR or USD.
wallet_balance_minorintegerRemaining balance after debit.
wallet_balance_humanstringFormatted balance string.
Message chunking. The message field is an array of strings, not a single string. Each element is one “bubble” — render them separately in your chat UI for a natural conversational feel. Optionally add a short delay between bubbles.

Integration checklist

  1. Call /start with birth details + astrologer key → save session_id.
  2. Render new_messages[0].message as separate chat bubbles.
  3. Show suggested_followups as tappable chips below the last bubble.
  4. On user input → call /message with session_id + message.
  5. Check billing.wallet_balance_minor and warn the user when balance is low.
  6. Handle errors: show error.message to the user for validation failures.

Errors

HTTPCodeCause
400VALIDATION_ERRORMissing/invalid fields or unknown astrologer key.
400MISSING_FIELDA required field is absent.
400INVALID_DATEDate values out of range.
400INVALID_TIMEHour/minute out of range.
400INVALID_TIMEZONENon-IANA timezone value.
400INVALID_COORDINATELatitude/longitude out of range.
400INVALID_SESSIONSession ID not found or expired.
401AUTH_MISSING_KEYNo API key in request.
402INSUFFICIENT_BALANCEWallet balance too low.
405METHOD_NOT_ALLOWEDNon-POST request.

See also