POST · AI

AI Chat (Text)

Base path POST https://starsapi.com/api/v3/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/v3/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. Single-chart: career_expert, health_expert, love_guru, love_guru_male, transit_expert, numeromitra, western_natal. Always send it — omitting it falls back to an internal default that is not part of the public contract and may change. The roster enabled for your account is shown in your dashboard.
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. Derived from year when omitted.
placestringNoBirth city name — display only. The chart is computed from latitude/longitude/timezone; this simply lets the astrologer say “born in Jaipur” instead of quoting coordinates. Aliases: city, birth_place, location.
preferred_languagestringNoLanguage of the greeting. Accepts hinglish (Hindi in Roman script) or any ISO 639-1 codeen, hi, ta, te, mr, bn, ne, es, fr, ja, ar and so on. Regional forms such as pt-br resolve to the base language. An unrecognised value silently falls back to English. 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/v3/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.
Turn numbering. The greeting is turn 1, so the first user message returns turn 2. preferred_language is not accepted here — from turn 2 onward the astrologer mirrors whatever language and script the user actually types, switching mid-conversation if they do.
Session errors. 404 SESSION_NOT_FOUND, 403 FORBIDDEN (the session belongs to a different API key) and 409 SESSION_CLOSED all mean the same thing for your UI: start a new session.

Start match session (two charts)

Endpoint POST /api/v3/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 two-chart persona: matchmaking, numeromitra_match or western_synastry. A single-chart key here will be priced and framed as a single-chart session — do not mix them.
preferred_languagestringNoSame values as /starthinglish or any ISO 639-1 code. 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.
person1.placestringNoBirth city name, display only.
person2 (same fields as person1)

Match-start example body

{
  "astrologer": "matchmaking",
  "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
statusintegerMirrors the HTTP status.
successbooleantrue on success.
data
session_idstring32-character lowercase hex session identifier. Pass to /message for subsequent turns.
turnintegerTurn count. 1 = greeting, 2+ = conversation turns.
pre_messagestringWaiting-state copy to show while a reply is pending (“Arjun is studying your chart…”). /start only — not returned by /match-start or /message.
match_summaryobject/match-start only. Compatibility headline. Switch on match_summary.system — see the callout below.
data.astrologer
keystringAstrologer identifier (e.g. career_expert).
namestringDisplay name.
avatar_emojistringEmoji for UI rendering.
astrology_systemstringPrimary system used (e.g. vedic).
data.new_messages
rolestringassistant.
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, up to 4. Frequently empty — render nothing when it is, do not reserve space for chips.
data.billing — see the billing callout; may be absent
cost_minorintegerTurn cost in minor units (paise for INR, cents for USD).
currencystringINR or USD.
wallet_balance_minorintegerBalance after this turn was debited. null on internal/test accounts.
wallet_balance_humanstringFormatted balance string. null on internal/test accounts.
meta — sibling of data, not inside it
endpointstringPath that served the request.
versionstringAPI version, 3.0.
response_time_msintegerServer-side processing time.
request_idstringQuote this when reporting an issue.
match_summary has three shapes. Read match_summary.system first, then the fields for that system. Vedic: total_points, max_points, percentage, verdict. Numerology: overall_score, max_score, score_label, verdict. Western: compatibility. Any individual value may be null if the underlying calculation did not produce it — render defensively.
Billing is per AI response, and the greeting counts. The session-start greeting is a full AI turn — chart computation plus generation — and is charged like any other turn. There are no free turns, and couple sessions cost more than single-chart ones. The billing block is not guaranteed: on /message it is absent for internal and test accounts, and absent if the wallet debit itself fails (you still get a normal 200 with the reply). Treat a missing billing key as “no charge information for this turn”, never as an error.
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 — and render nothing when the array is empty.
  4. Use pre_message for the waiting state on /start; handle its absence elsewhere.
  5. On user input → call /message with session_id + message. One request in flight per session.
  6. Check billing.wallet_balance_minor when present, and warn on a low balance. Never break the UI when the block is missing.
  7. Route 403 / 404 / 409 to “start a new session”.
  8. Handle errors: show error.message to the user for validation failures.

Errors

HTTPCodeEndpointCause
400INVALID_JSONallBody is not valid JSON.
400VALIDATION_ERRORallMissing or invalid field, unknown astrologer key, malformed session_id. The message names the offending field — surface it.
401AUTH_ERRORallBad or missing API key.
403FORBIDDEN/messageSession belongs to a different API key.
404SESSION_NOT_FOUND/messageNo session with that ID.
409SESSION_CLOSED/messageSession is no longer active.
402WALLET_INSUFFICIENTallWallet balance is below the cost of this turn. The message states the amount required and the amount available. Top up — the session survives.
403PLAN_FREE_TIERallAI chat is not available on the free plan.
403PLAN_NO_AI_CHATallYour plan does not include AI chat.
403PLAN_EXPIREDallSubscription has expired. The wallet balance is preserved.
403TRIAL_NO_AIallAI services are not available during the trial period.
403ACCOUNT_SUSPENDEDallAccount is not active.
500CALCULATION_ERROR/start, /match-startChart computation failed for the supplied birth data.
500CONFIG_ERROR/messageAstrologer config missing for a session already in progress.
500INTERNAL_ERRORallUnexpected server-side failure.
Account and wallet rejections happen before any AI work. A free-tier plan, an expired subscription, a plan without AI chat, or an insufficient balance all stop the request at the gate — nothing is generated and nothing is charged. These arrive as 402 or 403 with a specific code, so route them to an account or top-up screen rather than to a generic error state. Only WALLET_INSUFFICIENT is recoverable in place: top up and the same session continues.
Never retry automatically. AI replies take 4–12 seconds; set a 120 s client timeout and show a typing indicator. A request that timed out on your side may still have completed and been billed. Within one session a repeated turn is not charged twice, but a retried /start creates a new session and is charged again. Let the user choose to resend.

See also