Streaming Responses

Stream the AI Query answer token by token for chat and typeahead UIs.

This path supports both GET with query parameters and POST with the AI Query JSON request body. Use POST when sending the full request in the body; the GET example below covers query parameters only.

#The streaming endpoint

GET https://api.vedika.io/api/v1/astrology/query/stream streams the answer token-by-token, server-sent style, instead of waiting for the full response. Use it anywhere people watch an answer arrive live — chat interfaces, typeahead, voice UIs.

FieldNotes
questionRequired. The natural-language question to answer.
birthDetailsBirth chart context — datetime, latitude, longitude, timezone — used to ground the answer.
languageResponse language.
speedDelivery tier: eco, standard or fast.
responseFormatResponse shape: text (default), markdown or json.

#Example

Open the stream and read tokens as they arrive:

curl -N -G "https://api.vedika.io/api/v1/astrology/query/stream" \
  -H "Authorization: Bearer $VEDIKA_KEY" \
  --data-urlencode "question=Which career field suits me best?" \
  --data-urlencode 'birthDetails={"datetime":"1990-05-15T10:30:00","latitude":28.6139,"longitude":77.2090,"timezone":"Asia/Kolkata"}' \
  --data-urlencode "speed=fast"
const params = new URLSearchParams({
  question: "Which career field suits me best?",
  birthDetails: JSON.stringify({
    datetime: "1990-05-15T10:30:00",
    latitude: 28.6139, longitude: 77.2090,
    timezone: "Asia/Kolkata",
  }),
  speed: "fast",
});

const res = await fetch(
  `https://api.vedika.io/api/v1/astrology/query/stream?${params}`,
  { headers: { "Authorization": `Bearer ${process.env.VEDIKA_KEY}` } },
);

const reader = res.body.getReader();
const decoder = new TextDecoder();
while (true) {
  const { done, value } = await reader.read();
  if (done) break;
  process.stdout.write(decoder.decode(value, { stream: true }));
}

#Tier availability

Streaming is available on all four delivery tiers All plans — Eco, Standard, Swift and Pro Ultra. On Vedika Swift (speed:"fast", Business plans and above) tokens arrive faster than on the other tiers.

Tip
Billing settles once, at the end of the stream — the same as a non-streaming call. A malformed request still returns 400 before any tokens are sent, so bad input never starts, or gets charged for, a stream.